From: John Hodge Date: Mon, 7 Nov 2011 08:51:48 +0000 (+0800) Subject: Usermode/AxWin3 - Working on input code X-Git-Tag: rel0.14~138 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=5b6ff5b0698142d4f17a693c0d340df10b375926;p=tpg%2Facess2.git Usermode/AxWin3 - Working on input code --- diff --git a/Usermode/Applications/axwin3_src/WM/Makefile b/Usermode/Applications/axwin3_src/WM/Makefile index 32e2f78c..60c3920d 100644 --- a/Usermode/Applications/axwin3_src/WM/Makefile +++ b/Usermode/Applications/axwin3_src/WM/Makefile @@ -7,7 +7,7 @@ CPPFLAGS += -I include/ -I ../include/ DIR := Apps/AxWin/3.0 BIN := AxWinWM OBJ := main.o input.o video.o ipc.o image.o -OBJ += wm.o wm_render.o wm_render_text.o +OBJ += wm.o wm_input.o wm_render.o wm_render_text.o OBJ += renderer_classes.o renderer_passthru.o renderer_background.o OBJ += renderer_widget.o renderer_widget_decorator.o diff --git a/Usermode/Applications/axwin3_src/WM/image.c b/Usermode/Applications/axwin3_src/WM/image.c index ef08150b..a0b86e9b 100644 --- a/Usermode/Applications/axwin3_src/WM/image.c +++ b/Usermode/Applications/axwin3_src/WM/image.c @@ -58,7 +58,6 @@ tImage *Image_Load(const char *URI) } tmp = fread(buf, 1, filesize, fp); - _SysDebug("Image_Load: fread() returned %i",tmp); fclose(fp); } else if( strcmp(uri->Proto, "base64") == 0 ) diff --git a/Usermode/Applications/axwin3_src/WM/input.c b/Usermode/Applications/axwin3_src/WM/input.c index d72d6b68..a35f913e 100644 --- a/Usermode/Applications/axwin3_src/WM/input.c +++ b/Usermode/Applications/axwin3_src/WM/input.c @@ -19,14 +19,17 @@ typedef struct // === IMPORTS === extern void Video_SetCursorPos(short X, short Y); -// TODO: Move out +extern void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY); +extern void WM_Input_MouseButton(int X, int Y, int Button, int Pressed); const char *gsMouseDevice; - int giTerminalFD; - int giScreenWidth; - int giScreenHeight; +extern int giTerminalFD; +extern int giScreenWidth; +extern int giScreenHeight; // === GLOBALS === int giMouseFD; + int giInput_MouseButtonState; + int giInput_MouseX, giInput_MouseY; // === CODE === int Input_Init(void) @@ -41,11 +44,13 @@ int Input_Init(void) num_value.Num = 0; num_value.Value = giScreenWidth; ioctl(giMouseFD, JOY_IOCTL_GETSETAXISLIMIT, &num_value); num_value.Value = giScreenWidth/2; + giInput_MouseX = giScreenWidth/2; ioctl(giMouseFD, JOY_IOCTL_GETSETAXISPOSITION, &num_value); num_value.Num = 1; num_value.Value = giScreenHeight; ioctl(giMouseFD, JOY_IOCTL_GETSETAXISLIMIT, &num_value); num_value.Value = giScreenHeight/2; + giInput_MouseY = giScreenHeight/2; ioctl(giMouseFD, JOY_IOCTL_GETSETAXISPOSITION, &num_value); return 0; @@ -74,6 +79,7 @@ void Input_HandleSelect(fd_set *set) if(FD_ISSET(giMouseFD, set)) { + int i; struct sMouseInfo { uint16_t NAxies; uint16_t NButtons; @@ -95,8 +101,25 @@ void Input_HandleSelect(fd_set *set) // Handle movement Video_SetCursorPos( mouseinfo.Axies[0].CursorPos, mouseinfo.Axies[1].CursorPos ); - - // TODO: Handle button presses + WM_Input_MouseMoved( + giInput_MouseX, giInput_MouseY, + mouseinfo.Axies[0].CursorPos, mouseinfo.Axies[1].CursorPos + ); + giInput_MouseX = mouseinfo.Axies[0].CursorPos; + giInput_MouseY = mouseinfo.Axies[1].CursorPos; + + for( i = 0; i < mouseinfo.NButtons; i ++ ) + { + int bit = 1 << i; + int cur = mouseinfo.Buttons[i] > 128; + + if( !!(giInput_MouseButtonState & bit) != cur ) + { + WM_Input_MouseButton(giInput_MouseX, giInput_MouseY, i, cur); + // Flip button state + giInput_MouseButtonState ^= bit; + } + } } } diff --git a/Usermode/Applications/axwin3_src/WM/wm.c b/Usermode/Applications/axwin3_src/WM/wm.c index 464901e4..e1602296 100644 --- a/Usermode/Applications/axwin3_src/WM/wm.c +++ b/Usermode/Applications/axwin3_src/WM/wm.c @@ -54,7 +54,7 @@ tWindow *WM_CreateWindow(tWindow *Parent, int RendererArg, const char *RendererN ret = renderer->CreateWindow(RendererArg); ret->Parent = Parent; ret->Renderer = renderer; - ret->Flags = WINFLAG_CLEAN; // Note, not acutally clean, but it makes invaidate work + ret->Flags = WINFLAG_CLEAN; // Needed to stop invaildate early exiting // Append to parent if(Parent) diff --git a/Usermode/Applications/axwin3_src/WM/wm_input.c b/Usermode/Applications/axwin3_src/WM/wm_input.c new file mode 100644 index 00000000..c2ebb9e6 --- /dev/null +++ b/Usermode/Applications/axwin3_src/WM/wm_input.c @@ -0,0 +1,49 @@ +/* + * Acess2 Window Manager v3 + * - By John Hodge (thePowersGang) + * + * wm.c + * - Window manager core + */ +#include +#include + +// === IMPORTS === +extern tWindow *gpWM_RootWindow; + +// === CODE === +tWindow *WM_int_GetWindowAtPos(int X, int Y) +{ + tWindow *win, *next_win, *ret; + + next_win = gpWM_RootWindow; + + while(next_win) + { + ret = next_win; + next_win = NULL; + for(win = ret->FirstChild; win; win = win->NextSibling) + { + if( !(win->Flags & WINFLAG_SHOW) ) continue ; + if( X < win->X || X >= win->X + win->W ) continue; + if( Y < win->Y || Y >= win->Y + win->H ) continue; + next_win = win; // Overwrite as we want the final rendered window + } + } + + return ret; +} + +void WM_Input_MouseMoved(int OldX, int OldY, int NewX, int NewY) +{ + // TODO: Mouse motion events + // TODO: Send mouseup to match mousedown if the cursor moves out of a window? +} + +void WM_Input_MouseButton(int X, int Y, int ButtonIndex, int Pressed) +{ +// tWindow *win = WM_int_GetWindowAtPos(X, Y); + + // Send Press/Release message +} +