2 * Acess2 GUI (AxWin) Version 3
3 * - By John Hodge (thePowersGang)
11 // TODO: Move out to a common header
17 #define JOY_IOCTL_GETSETAXISLIMIT 6
18 #define JOY_IOCTL_GETSETAXISPOSITION 7
21 extern void Video_SetCursorPos(short X, short Y);
22 extern void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY);
23 extern void WM_Input_MouseButton(int X, int Y, int Button, int Pressed);
24 const char *gsMouseDevice;
25 extern int giTerminalFD;
26 extern int giScreenWidth;
27 extern int giScreenHeight;
31 int giInput_MouseButtonState;
32 int giInput_MouseX, giInput_MouseY;
40 giMouseFD = open(gsMouseDevice, 3);
43 // TODO: Update these if the screen resolution changes
44 num_value.Num = 0; num_value.Value = giScreenWidth;
45 ioctl(giMouseFD, JOY_IOCTL_GETSETAXISLIMIT, &num_value);
46 num_value.Value = giScreenWidth/2;
47 giInput_MouseX = giScreenWidth/2;
48 ioctl(giMouseFD, JOY_IOCTL_GETSETAXISPOSITION, &num_value);
50 num_value.Num = 1; num_value.Value = giScreenHeight;
51 ioctl(giMouseFD, JOY_IOCTL_GETSETAXISLIMIT, &num_value);
52 num_value.Value = giScreenHeight/2;
53 giInput_MouseY = giScreenHeight/2;
54 ioctl(giMouseFD, JOY_IOCTL_GETSETAXISPOSITION, &num_value);
59 void Input_FillSelect(int *nfds, fd_set *set)
61 if(*nfds < giTerminalFD) *nfds = giTerminalFD;
62 if(*nfds < giMouseFD) *nfds = giMouseFD;
63 FD_SET(giTerminalFD, set);
64 FD_SET(giMouseFD, set);
67 void Input_HandleSelect(fd_set *set)
69 if(FD_ISSET(giTerminalFD, set))
72 if( read(giTerminalFD, &codepoint, sizeof(codepoint)) != sizeof(codepoint) )
76 // TODO: pass on to message handler
77 _SysDebug("Keypress 0x%x", codepoint);
80 if(FD_ISSET(giMouseFD, set))
95 seek(giMouseFD, 0, SEEK_SET);
96 if( read(giMouseFD, &mouseinfo, sizeof(mouseinfo)) != sizeof(mouseinfo) )
98 // Not a 3 button mouse, oops
103 Video_SetCursorPos( mouseinfo.Axies[0].CursorPos, mouseinfo.Axies[1].CursorPos );
106 giInput_MouseX, giInput_MouseY,
107 mouseinfo.Axies[0].CursorPos, mouseinfo.Axies[1].CursorPos
109 giInput_MouseX = mouseinfo.Axies[0].CursorPos;
110 giInput_MouseY = mouseinfo.Axies[1].CursorPos;
112 for( i = 0; i < mouseinfo.NButtons; i ++ )
115 int cur = mouseinfo.Buttons[i] > 128;
117 if( !!(giInput_MouseButtonState & bit) != cur )
119 WM_Input_MouseButton(giInput_MouseX, giInput_MouseY, i, cur);
121 giInput_MouseButtonState ^= bit;