1 //==========================================================================
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
13 // eCos is free software; you can redistribute it and/or modify it under
14 // the terms of the GNU General Public License as published by the Free
15 // Software Foundation; either version 2 or (at your option) any later version.
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 // You should have received a copy of the GNU General Public License along
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 // As a special exception, if other files instantiate templates or use macros
27 // or inline functions from this file, or you compile this file and link it
28 // with other works to produce a work based on this file, this file does not
29 // by itself cause the resulting work to be covered by the GNU General Public
30 // License. However the source code for this file must still be made available
31 // in accordance with section (3) of the GNU General Public License.
33 // This exception does not invalidate any other reasons why a work based on
34 // this file might be covered by the GNU General Public License.
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37 // at http://sources.redhat.com/ecos/ecos-license/
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //==========================================================================
41 //#####DESCRIPTIONBEGIN####
43 // Author(s): Chris Garry <cgarry@sweeneydesign.co.uk>
47 // Description: Microwindows mouse driver for VNC server on eCos
49 //####DESCRIPTIONEND####
51 //========================================================================*/
60 #include <sys/ioctl.h>
61 #include <pkgconf/vnc_server.h> /* CYGDAT_VNC_SERVER_MOUSE_NAME */
64 static int vnc_Open(MOUSEDEVICE *pmd);
65 static void vnc_Close(void);
66 static int vnc_GetButtonInfo(void);
67 static void vnc_GetDefaultAccel(int *pscale,int *pthresh);
68 static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb);
70 static int mouse_fd = -1;
72 /* Hack extern to used when hiding the mouse cursor
73 * There needs to be a better way to do this
75 extern SCREENDEVICE scrdev;
77 MOUSEDEVICE mousedev = {
87 static int vnc_Open(MOUSEDEVICE *pmd)
89 mouse_fd = open(CYGDAT_VNC_SERVER_MOUSE_NAME, O_RDONLY | O_NONBLOCK);
92 EPRINTF("Error %d opening VNC mouse\n", errno);
96 // GdHideCursor(&scrdev);
100 static void vnc_Close(void)
102 /* Close the mouse device. */
111 static int vnc_GetButtonInfo(void)
113 /* Get mouse buttons supported */
114 return (MWBUTTON_L + MWBUTTON_R);
117 static void vnc_GetDefaultAccel(int *pscale,int *pthresh)
120 * Get default mouse acceleration settings
121 * Just return something inconspicuous for now.
123 // diag_printf("Mouse: vnc_GetDefaultAccel()\n");
128 static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb)
130 /* Read a mouse event */
134 bytes_read = read(mouse_fd, data, 8);
136 if (bytes_read != sizeof(data))
138 if (errno == EINTR || errno == EAGAIN)
143 * kernel driver bug: select returns read available,
144 * but read returns -1
145 * we return 0 here to avoid GsError above
152 *px = data[2]*256 + data[3];
153 *py = data[4]*256 + data[5];
171 return 1; /* Don't have button data */
175 return 2; /* Have full set of data */