From 0c35f45b89f715d4a62e4a1063b806d82b538872 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 15 Jul 2012 12:47:38 +0800 Subject: [PATCH] Usermode/axwin3 - Fixed using stdout as stdin (causing read errors) --- Usermode/Applications/axwin3_src/WM/input.c | 13 +++++++------ Usermode/Applications/axwin3_src/WM/main.c | 1 + Usermode/Applications/axwin3_src/WM/video.c | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Usermode/Applications/axwin3_src/WM/input.c b/Usermode/Applications/axwin3_src/WM/input.c index bd23c0b2..352bdee4 100644 --- a/Usermode/Applications/axwin3_src/WM/input.c +++ b/Usermode/Applications/axwin3_src/WM/input.c @@ -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); diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index 66fe14e7..7aa5534a 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -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" diff --git a/Usermode/Applications/axwin3_src/WM/video.c b/Usermode/Applications/axwin3_src/WM/video.c index 5b513dec..3adb17d4 100644 --- a/Usermode/Applications/axwin3_src/WM/video.c +++ b/Usermode/Applications/axwin3_src/WM/video.c @@ -15,6 +15,9 @@ #include #include +// === 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 ) -- 2.20.1