AxWin2 - Added mouse support (well, it now reads the mouse state)
authorJohn Hodge <[email protected]>
Wed, 6 Jul 2011 15:09:25 +0000 (23:09 +0800)
committerJohn Hodge <[email protected]>
Wed, 6 Jul 2011 15:09:25 +0000 (23:09 +0800)
- TODO: Implement the cursor (probably as a HW cursor in the video driver)

Usermode/Applications/axwin2_src/WM/input.c
Usermode/Applications/axwin2_src/WM/main.c

index c75e0a0..0517993 100644 (file)
@@ -6,6 +6,24 @@
 #include <acess/sys.h>
 
 // === CODE ===
+int Input_Init(void)
+{
+       struct {
+                int    Num, Value;
+       }       num_value;
+       giMouseFD = open(gsMouseDevice, 3);
+
+       num_value.Num = 0;
+       num_value.Value = giScreenWidth;
+       ioctl(giMouseFD, 6, &num_value);
+
+       num_value.Num = 1;
+       num_value.Value = giScreenHeight;
+       ioctl(giMouseFD, 6, &num_value);
+
+       return 0;
+}
+
 void Input_FillSelect(int *nfds, fd_set *set)
 {
        if(*nfds < giTerminalFD)        *nfds = giTerminalFD;
@@ -24,6 +42,7 @@ void Input_HandleSelect(fd_set *set)
                        // oops, error
                }
                // TODO: pass on to message handler
+               _SysDebug("Keypress 0x%x", codepoint);
        }
 
        if(FD_ISSET(giMouseFD, set))
@@ -37,7 +56,10 @@ void Input_HandleSelect(fd_set *set)
                        }       Axies[2];
                        uint8_t Buttons[3];
                }       mouseinfo;
-               
+       
+               _SysDebug("Cursor event");
+
+               seek(giMouseFD, 0, SEEK_SET);   
                if( read(giMouseFD, sizeof(mouseinfo), &mouseinfo) != sizeof(mouseinfo) )
                {
                        // Not a 3 button mouse, oops
@@ -46,5 +68,6 @@ void Input_HandleSelect(fd_set *set)
                
                // Handle movement
 //             Video_SetCursorPos( mouseinfo.Axies[0], mouseinfo.Axies[1] );
+               _SysDebug("Cursor to %i,%i\n", mouseinfo.Axies[0], mouseinfo.Axies[1]);
        }
 }
index 781194a..48e47ff 100644 (file)
@@ -7,6 +7,7 @@
 
 // === IMPORTS ===
 extern void    WM_Update(void);
+extern int     Input_Init(void);
 
 // === GLOBALS ===
 const char     *gsTerminalDevice = NULL;
@@ -38,6 +39,7 @@ int main(int argc, char *argv[])
        Video_Setup();
        Interface_Init();
        IPC_Init();
+       Input_Init();
        
        WM_Update();
        

UCC git Repository :: git.ucc.asn.au