Usermode/AxWin3 - Changed to use SysSpawn and detect crap server PIDs
[tpg/acess2.git] / Usermode / Applications / axwin3_src / WM / input.c
index 9fe73ff..469c08e 100644 (file)
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <acess/sys.h>
 #include <wm_input.h>
+#include <stddef.h>
 
 // TODO: Move out to a common header
 typedef struct
@@ -21,7 +22,7 @@ typedef struct
 // === IMPORTS ===
 extern void    Video_SetCursorPos(short X, short Y);
 const char     *gsMouseDevice;
-extern int     giTerminalFD;
+extern int     giTerminalFD_Input;
 extern int     giScreenWidth;
 extern int     giScreenHeight;
 
@@ -57,24 +58,25 @@ int Input_Init(void)
 
 void Input_FillSelect(int *nfds, fd_set *set)
 {
-       if(*nfds < giTerminalFD)        *nfds = giTerminalFD;
+       if(*nfds < giTerminalFD_Input)  *nfds = giTerminalFD_Input;
        if(*nfds < giMouseFD)   *nfds = giMouseFD;
-       FD_SET(giTerminalFD, set);
+       FD_SET(giTerminalFD_Input, set);
        FD_SET(giMouseFD, set);
 }
 
 void Input_HandleSelect(fd_set *set)
 {
-       if(FD_ISSET(giTerminalFD, set))
+       if(FD_ISSET(giTerminalFD_Input, set))
        {
                uint32_t        codepoint;
                static uint32_t scancode;
                #define KEY_CODEPOINT_MASK      0x3FFFFFFF
                
-               if( read(giTerminalFD, &codepoint, sizeof(codepoint)) != sizeof(codepoint) )
+               size_t readlen = read(giTerminalFD_Input, &codepoint, sizeof(codepoint));
+               if( readlen != sizeof(codepoint) )
                {
                        // oops, error
-                       _SysDebug("Terminal read failed?");
+                       _SysDebug("Terminal read failed? (%i != %i)", readlen, sizeof(codepoint));
                }
        
 //             _SysDebug("Keypress 0x%x", codepoint);
@@ -125,8 +127,7 @@ void Input_HandleSelect(fd_set *set)
                        return ;
                }
                if( mouseinfo->NAxies > c_n_axies || mouseinfo->NButtons > c_n_buttons ) {
-                       _SysDebug(
-                               "%i axies, %i buttons above prealloc counts (%i, %i)",
+                       _SysDebug("%i axies, %i buttons above prealloc counts (%i, %i)",
                                mouseinfo->NAxies, mouseinfo->NButtons, c_n_axies, c_n_buttons
                                );
                        return ;

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