From 15fe58771e11393f0945f6807af77f6966a3a2db Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 30 May 2011 20:27:27 +0800 Subject: [PATCH] Working on AxWin2 - Implementing mouse movement > Changed the naming of the joystick fields to be less confusing - Working on the shell, moving to new structure > Required fixes to libaxwin2 --- Kernel/include/tpl_drv_joystick.h | 15 +++- .../Applications/axwin2_src/Shell_src/main.c | 33 +++++++-- Usermode/Applications/axwin2_src/WM/input.c | 23 ++++++ Usermode/Libraries/libaxwin2.so_src/common.h | 2 +- Usermode/Libraries/libaxwin2.so_src/main.c | 74 ++++++++++--------- 5 files changed, 103 insertions(+), 44 deletions(-) diff --git a/Kernel/include/tpl_drv_joystick.h b/Kernel/include/tpl_drv_joystick.h index 888d4ac1..06cdb23c 100644 --- a/Kernel/include/tpl_drv_joystick.h +++ b/Kernel/include/tpl_drv_joystick.h @@ -113,16 +113,23 @@ struct sJoystick_FileHeader * \brief Axis Definition in file data * * Describes the current state of an axis on the joystick. - * \a MinValue and \a MaxValue describe the valid range for \a CurValue - * While \a CurState is between zero and the current limit set by the - * JOY_IOCTL_GETSETAXISLIMIT IOCtl. + * \a CursorPos is between zero and the current limit set by the + * JOY_IOCTL_GETSETAXISLIMIT IOCtl, while \a CurValue indicates the + * current position of the joystick axis. This is defined to be between + * \a MinValue and \a MaxValue. */ struct sJoystick_Axis { Sint16 MinValue; //!< Minumum value for \a CurValue Sint16 MaxValue; //!< Maximum value for \a CurValue Sint16 CurValue; //!< Current value (joystick position) - Uint16 CurState; //!< Current state (cursor position) + Uint16 CursorPos; //!< Current state (cursor position) }; +#define JOY_INFOSTRUCT(_naxies, _nbuttons) struct { \ + Uint16 NAxies, NButtons;\ + tJoystick_Axis Axies[_naxies];\ + Uint16 Buttons[_nbuttons];\ + } + #endif diff --git a/Usermode/Applications/axwin2_src/Shell_src/main.c b/Usermode/Applications/axwin2_src/Shell_src/main.c index fbc63484..43b37fd3 100644 --- a/Usermode/Applications/axwin2_src/Shell_src/main.c +++ b/Usermode/Applications/axwin2_src/Shell_src/main.c @@ -4,18 +4,36 @@ */ #include +// === CONSTANTS === +enum eTerminal_Events +{ + EVENT_NULL, + EVENT_NEW_TAB, + EVENT_CLOSE_TAB, + EVENT_EXIT +}; + // === PROTOTYPES === int main(int argc, char *argv[]); - int Menubar_HandleMessage(tAxWin_Message *Message); + int Global_HandleMessage(tAxWin_Message *Message); + int Shell_HandleMessage(tAxWin_Message *Message); // === GLOBALS === -tAxWin_Element geConsole; +tAxWin_Element *geConsole; // === CODE === int main(int argc, char *argv[]) { - AxWin_Register("Terminal"); - + tAxWin_Element *menu, *tab; + AxWin_Register("Terminal", Global_HandleMessage); + + menu = AxWin_AddMenuItem(NULL, "File", 0); + AxWin_AddMenuItem(menu, "&New Tab\tCtrl-Shift-N", EVENT_NEW_TAB); + AxWin_AddMenuItem(menu, NULL, 0); + AxWin_AddMenuItem(menu, "&Close Tab\tCtrl-Shift-W", EVENT_CLOSE_TAB); + AxWin_AddMenuItem(menu, "E&xit\tAlt-F4", EVENT_EXIT); + + tab = AxWin_CreateTab("root@acess: ~"); //geConsole = AxWin_CreateElement(); AxWin_MessageLoop(); @@ -25,7 +43,12 @@ int main(int argc, char *argv[]) /** */ -int Menubar_HandleMessage(tAxWin_Message *Message) +int Global_HandleMessage(tAxWin_Message *Message) +{ + return 0; +} + +int Shell_HandleMessage(tAxWin_Message *Message) { return 0; } diff --git a/Usermode/Applications/axwin2_src/WM/input.c b/Usermode/Applications/axwin2_src/WM/input.c index f69e0562..cb6a03ce 100644 --- a/Usermode/Applications/axwin2_src/WM/input.c +++ b/Usermode/Applications/axwin2_src/WM/input.c @@ -3,6 +3,7 @@ * By John Hodge (thePowersGang) */ #include "common.h" +#include // === CODE === void Input_FillSelect(int *nfds, fd_set *set) @@ -17,6 +18,28 @@ void Input_HandleSelect(fd_set *set) { if(FD_ISSET(giTerminalFD, set)) { + // TODO: + } + + 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; + + 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] ); } } diff --git a/Usermode/Libraries/libaxwin2.so_src/common.h b/Usermode/Libraries/libaxwin2.so_src/common.h index f0a7ea15..4e80c7f4 100644 --- a/Usermode/Libraries/libaxwin2.so_src/common.h +++ b/Usermode/Libraries/libaxwin2.so_src/common.h @@ -11,7 +11,7 @@ // === Includes === #include -#include +#include #include // === Constants === diff --git a/Usermode/Libraries/libaxwin2.so_src/main.c b/Usermode/Libraries/libaxwin2.so_src/main.c index 1dfcf9b2..c25c4e72 100644 --- a/Usermode/Libraries/libaxwin2.so_src/main.c +++ b/Usermode/Libraries/libaxwin2.so_src/main.c @@ -12,6 +12,7 @@ // === GLOBALS === int giAxWin_Mode = 0; int giAxWin_PID = 0; +tAxWin_MessageCallback *gAxWin_DefaultCallback; // === CODE === int SoMain() @@ -19,62 +20,67 @@ int SoMain() return 0; } -int AxWin_Register(const char *Name) +tAxWin_Message *AxWin_int_SendAndWait(int RetID, tAxWin_Message *Message) { - tAxWin_Message req; tAxWin_Message *msg; - tAxWin_RetMsg *ret; - int len = strlen(Name); - - req.ID = MSG_SREQ_REGISTER; - req.Size = 1 + (len+1)/4; - strcpy(req.Data, Name); - - AxWin_SendMessage(&req); + tAxWin_RetMsg *rmsg; + + AxWin_SendMessage(Message); for(;;) { msg = AxWin_WaitForMessage(); - if(msg->ID == MSG_SREQ_ADDTAB) - { - ret = (void*) &msg->Data[0]; - if( ret->ReqID == MSG_SREQ_REGISTER ) - break; - } + rmsg = (void*)msg->Data; + if(msg->ID == MSG_SRSP_RETURN && rmsg->ReqID == Message->ID ) + break; AxWin_HandleMessage(msg); free(msg); } - return !!ret->Bool; + return msg; +} + +int AxWin_Register(const char *Name, tAxWin_MessageCallback *DefaultCallback) +{ + tAxWin_Message req; + tAxWin_Message *msg; + int ret; + int len = strlen(Name); + + req.ID = MSG_SREQ_REGISTER; + req.Size = 1 + (len+1)/4; + strcpy(req.Data, Name); + + msg = AxWin_int_SendAndWait(MSG_SREQ_ADDTAB, &req); + ret = ((tAxWin_RetMsg*)msg->Data)->Bool; + free(msg); + + gAxWin_DefaultCallback = DefaultCallback; + + return !!ret; } -tAxWin_Handle AxWin_AddTab(const char *Title) +tAxWin_Element *AxWin_CreateTab(const char *Title) { tAxWin_Message req; tAxWin_Message *msg; - tAxWin_RetMsg *ret; + tAxWin_Element *ret; int len = strlen(Title); req.ID = MSG_SREQ_ADDTAB; req.Size = 1 + (len+1)/4; strcpy(req.Data, Title); - for(;;) - { - msg = AxWin_WaitForMessage(); - - if(msg->ID == MSG_SRSP_RETURN) - { - ret = (void*) &msg->Data[0]; - if( ret->ReqID == MSG_SREQ_ADDTAB ) - break; - } - - AxWin_HandleMessage(msg); - free(msg); - } + msg = AxWin_int_SendAndWait(MSG_SRSP_RETURN, &req); + ret = (tAxWin_Element*) ((tAxWin_RetMsg*)msg->Data)->Handle; + free(msg); - return (tAxWin_Handle) ret->Handle; + return ret; +} + +tAxWin_Element *AxWin_AddMenuItem(tAxWin_Element *Parent, const char *Label, int Message) +{ + return NULL; } -- 2.20.1