Major build system changes
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / input.c
index cb6a03c..aa7f3b3 100644 (file)
@@ -6,6 +6,27 @@
 #include <acess/sys.h>
 
 // === CODE ===
+int Input_Init(void)
+{
+       struct {
+                int    Num, Value;
+       }       num_value;
+
+       // Open mouse for RW
+       giMouseFD = open(gsMouseDevice, 3);
+
+       // Set mouse limits
+       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;
@@ -18,7 +39,13 @@ void Input_HandleSelect(fd_set *set)
 {
        if(FD_ISSET(giTerminalFD, set))
        {
-               // TODO:
+               uint32_t        codepoint;
+               if( read(giTerminalFD, &codepoint, sizeof(codepoint)) != sizeof(codepoint) )
+               {
+                       // oops, error
+               }
+               // TODO: pass on to message handler
+               _SysDebug("Keypress 0x%x", codepoint);
        }
 
        if(FD_ISSET(giMouseFD, set))
@@ -32,8 +59,11 @@ void Input_HandleSelect(fd_set *set)
                        }       Axies[2];
                        uint8_t Buttons[3];
                }       mouseinfo;
-               
-               if( read(giMouseFD, sizeof(mouseinfo), &mouseinfo) != sizeof(mouseinfo) )
+       
+               _SysDebug("Cursor event");
+
+               seek(giMouseFD, 0, SEEK_SET);   
+               if( read(giMouseFD, &mouseinfo, sizeof(mouseinfo)) != sizeof(mouseinfo) )
                {
                        // Not a 3 button mouse, oops
                        return ;
@@ -41,5 +71,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].CursorPos, mouseinfo.Axies[1].CursorPos);
        }
 }

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