Usermode/axwin3 - Fixed using stdout as stdin (causing read errors)
authorJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:47:38 +0000 (12:47 +0800)
committerJohn Hodge <[email protected]>
Sun, 15 Jul 2012 04:47:38 +0000 (12:47 +0800)
Usermode/Applications/axwin3_src/WM/input.c
Usermode/Applications/axwin3_src/WM/main.c
Usermode/Applications/axwin3_src/WM/video.c

index bd23c0b..352bdee 100644 (file)
@@ -21,7 +21,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 +57,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);
index 66fe14e..7aa5534 100644 (file)
@@ -30,6 +30,7 @@ const char    *gsMouseDevice = NULL;
  int   giScreenHeight = 480;
 
  int   giTerminalFD = -1;
+ int   giTerminalFD_Input = 0;
  int   giMouseFD = -1;
 
 #define __INSTALL_ROOT "/Acess/Apps/AxWin/3.0"
index 5b513de..3adb17d 100644 (file)
@@ -15,6 +15,9 @@
 #include <wm.h>
 #include <string.h>
 
+// === IMPORTS ===
+extern int     giTerminalFD_Input;
+
 // === PROTOTYPES ===
 void   Video_Setup(void);
 void   Video_SetCursorPos(short X, short Y);
@@ -43,6 +46,7 @@ void Video_Setup(void)
        }
        #else
        giTerminalFD = 1;
+       giTerminalFD_Input = 0;
        // Check that the console is a VT
        // - ioctl(..., 0, NULL) returns the type, which should be 2
        if( ioctl(1, 0, NULL) != 2 )

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