Usermode/axwin2 - Commenting changes
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / input.c
index f69e056..85c649d 100644 (file)
@@ -3,8 +3,30 @@
  * By John Hodge (thePowersGang)
  */
 #include "common.h"
+#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;
@@ -17,6 +39,38 @@ void Input_HandleSelect(fd_set *set)
 {
        if(FD_ISSET(giTerminalFD, set))
        {
+               uint32_t        codepoint;
+               if( read(giTerminalFD, sizeof(codepoint), &codepoint) != sizeof(codepoint) )
+               {
+                       // oops, error
+               }
+               // TODO: pass on to message handler
+               _SysDebug("Keypress 0x%x", codepoint);
+       }
+
+       if(FD_ISSET(giMouseFD, set))
+       {
+               struct sMouseInfo {
+                       uint16_t        NAxies, NButtons;
+                       struct sMouseAxis {
+                                int16_t        MinValue, MaxValue;
+                                int16_t        CurValue;
+                               uint16_t        CursorPos;
+                       }       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
+                       return ;
+               }
                
+               // Handle movement
+//             Video_SetCursorPos( mouseinfo.Axies[0], mouseinfo.Axies[1] );
+               _SysDebug("Cursor to %i,%i\n", mouseinfo.Axies[0], mouseinfo.Axies[1]);
        }
 }

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