]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - release/sysinstall/mouse.c
This commit was generated by cvs2svn to compensate for changes in r51415,
[FreeBSD/FreeBSD.git] / release / sysinstall / mouse.c
1 /*-
2  * Copyright (c) 1998 Kazutaka YOKOTA (yokota@zodiac.mech.utsunomiya-u.ac.jp)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. The name of the author may not be used to endorse or promote 
14  *    products derived from this software without specific prior written 
15  *    permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHRO AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHRO OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * $FreeBSD$
30  */
31
32 #include "sysinstall.h"
33 #include <string.h>
34
35 int
36 mousedTest(dialogMenuItem *self)
37 {
38         char *type;
39         char *port;
40         int ret;
41
42         type = variable_get(VAR_MOUSED_TYPE);
43         port = variable_get(VAR_MOUSED_PORT);
44         if ((type == NULL) || (port == NULL) 
45                 || (strlen(type) <= 0) || (strlen(port) <= 0)
46                 || (strcmp(type, "NO") == 0)) {
47                 msgConfirm("Please select a mouse protocol and a port first.");
48                 return DITEM_FAILURE;
49         }
50
51         msgNotify("Trying to start the mouse daemon...");
52         if (file_readable("/var/run/moused.pid"))
53             vsystem("kill `cat /var/run/moused.pid`");
54         systemExecute("vidcontrol -m on");
55         vsystem("moused -t %s -p %s", type, port);
56
57         ret = msgYesNo("Now move the mouse and see if it works.\n"
58               "(Note that buttons don't have any effect for now.)\n\n"
59               "         Is the mouse cursor moving?\n");
60         systemExecute("vidcontrol -m off");
61         if (ret) {
62                 if (file_readable("/var/run/moused.pid"))
63                     vsystem("kill `cat /var/run/moused.pid`");
64                 variable_set2(VAR_MOUSED, "NO", 1);
65         } else {
66                 variable_set2(VAR_MOUSED, "YES", 1);
67                 vsystem("ln -fs /dev/sysmouse /dev/mouse"); /* backwards compat */
68         }
69
70         return DITEM_SUCCESS;
71 }
72
73 int
74 mousedDisable(dialogMenuItem *self)
75 {
76         if (file_readable("/var/run/moused.pid"))
77             vsystem("kill `cat /var/run/moused.pid`");
78         variable_set2(VAR_MOUSED, "NO", 1);
79         variable_set2(VAR_MOUSED_TYPE, "NO", 1);
80         variable_unset(VAR_MOUSED_PORT);
81         msgConfirm("The mouse daemon is disabled.");
82         return DITEM_SUCCESS;
83 }