Working on AxWin2
authorJohn Hodge <[email protected]>
Mon, 30 May 2011 12:27:27 +0000 (20:27 +0800)
committerJohn Hodge <[email protected]>
Mon, 30 May 2011 12:28:28 +0000 (20:28 +0800)
- 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
Usermode/Applications/axwin2_src/Shell_src/main.c
Usermode/Applications/axwin2_src/WM/input.c
Usermode/Libraries/libaxwin2.so_src/common.h
Usermode/Libraries/libaxwin2.so_src/main.c

index 888d4ac..06cdb23 100644 (file)
@@ -113,16 +113,23 @@ struct sJoystick_FileHeader
  * \brief Axis Definition in file data\r
  *\r
  * Describes the current state of an axis on the joystick.\r
- * \a MinValue and \a MaxValue describe the valid range for \a CurValue\r
- * While \a CurState is between zero and the current limit set by the\r
- * JOY_IOCTL_GETSETAXISLIMIT IOCtl.\r
+ * \a CursorPos is between zero and the current limit set by the\r
+ * JOY_IOCTL_GETSETAXISLIMIT IOCtl, while \a CurValue indicates the\r
+ * current position of the joystick axis. This is defined to be between\r
+ * \a MinValue and \a MaxValue.\r
  */\r
 struct sJoystick_Axis\r
 {\r
        Sint16  MinValue;       //!< Minumum value for \a CurValue\r
        Sint16  MaxValue;       //!< Maximum value for \a CurValue\r
        Sint16  CurValue;       //!< Current value (joystick position)\r
-       Uint16  CurState;       //!< Current state (cursor position)\r
+       Uint16  CursorPos;      //!< Current state (cursor position)\r
 };\r
 \r
+#define JOY_INFOSTRUCT(_naxies, _nbuttons) struct { \\r
+       Uint16  NAxies, NButtons;\\r
+       tJoystick_Axis  Axies[_naxies];\\r
+       Uint16  Buttons[_nbuttons];\\r
+       }\r
+\r
 #endif\r
index fbc6348..43b37fd 100644 (file)
@@ -4,18 +4,36 @@
  */
 #include <axwin2/axwin.h>
 
+// === 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;
 }
index f69e056..cb6a03c 100644 (file)
@@ -3,6 +3,7 @@
  * By John Hodge (thePowersGang)
  */
 #include "common.h"
+#include <acess/sys.h>
 
 // === 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] );
        }
 }
index f0a7ea1..4e80c7f 100644 (file)
@@ -11,7 +11,7 @@
 
 // === Includes ===
 #include <acess/sys.h>
-#include <axwin/axwin.h>
+#include <axwin2/axwin.h>
 #include <stdlib.h>
 
 // === Constants ===
index 1dfcf9b..c25c4e7 100644 (file)
@@ -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;
 }

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