]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_in.h
OH OH OH MY GOD OH OH OH!!
[16.git] / src / lib / 16_in.h
index b37a9d5bcf46b821a3b37bca0f1ab3bb5abb0a8d..cd3199fbf57991580708d4f6e85f8f58bb49ae02 100644 (file)
@@ -1,4 +1,4 @@
-/* Catacomb Armageddon Source Code\r
+/* Catacomb Apocalypse Source Code\r
  * Copyright (C) 1993-2014 Flat Rock Software\r
  *\r
  * This program is free software; you can redistribute it and/or modify\r
 //\r
 //     ID Engine\r
 //     ID_IN.h - Header file for Input Manager\r
-//     v1.0d1\r
-//     By Jason Blochowiak\r
+//     v1.0d1w\r
+//     By Jason Blochowiak
+//     Open Watcom port by sparky4\r
 //\r
 \r
 #ifndef        __16_IN__\r
 #define        __16_IN__\r
-\r
+
+#include <string.h>\r
 #include "src/lib/lib_head.h"\r
-//#include "src/lib/16_us.h"\r
 \r
 //++++#ifdef   __DEBUG__\r
 #define        __DEBUG_InputMgr__\r
 //++++#endif\r
 \r
-#define DOMO\r
+//#define TESTKEYIN
+#define TESTCONTROLNOISY\r
 \r
 #define        KeyInt  9       // The keyboard ISR number\r
 \r
@@ -44,7 +46,8 @@
 \r
 #define        MaxPlayers      4\r
 #define        MaxKbds         2\r
-#define        MaxJoys         2\r
+#define        MaxJoys         2
+#define        MaxPads         2\r
 #define        NumCodes        128\r
 \r
 typedef        byte            ScanCode;\r
@@ -130,6 +133,10 @@ typedef    byte            ScanCode;
 #define        key_BackSpace   0x08\r
 #define        key_Tab                 0x09\r
 #define        key_Delete              0x7f\r
+
+#define        key_LSuper                      0x5b
+#define        key_RSuper                      0x5c
+#define        key_Menu                        0x5d
 \r
 //     Stuff for the mouse\r
 #define        MReset          0\r
@@ -143,12 +150,14 @@ typedef   enum            {
                                        } Demo;\r
 #endif\r
 typedef        enum            {\r
-                                               ctrl_None,                              // MDM (GAMERS EDGE) - added\r
+                                               //ctrl_None,                            // MDM (GAMERS EDGE) - added\r
                                                ctrl_Keyboard,\r
                                                        ctrl_Keyboard1 = ctrl_Keyboard,ctrl_Keyboard2,\r
                                                ctrl_Joystick,\r
                                                        ctrl_Joystick1 = ctrl_Joystick,ctrl_Joystick2,\r
-                                               ctrl_Mouse\r
+                                               ctrl_Mouse,
+                                               ctrl_Joypad,
+                                                       ctrl_Joypad1 = ctrl_Joypad,ctrl_Joypad2\r
                                        } ControlType;\r
 typedef        enum            {\r
                                                motion_Left = -1,motion_Up = -1,\r
@@ -158,17 +167,16 @@ typedef   enum            {
 typedef        enum            {\r
                                                dir_North,//dir_NorthEast,\r
                                                dir_East,//dir_SouthEast,\r
-                                               dir_South,//dir_SouthWest,\r
-                                               dir_West,//dir_NorthWest,\r
+                                               dir_South,//dir_Soutinest,\r
+                                               dir_West,//dir_Nortinest,\r
                                                dir_None\r
                                        } Direction;\r
 typedef        struct          {\r
-                                               boolean         button0,button1;\r
+                                               boolean         button0,button1,button2,button3;\r
                                                int                     x,y;\r
                                                Motion          xaxis,yaxis;\r
                                                Direction       dir;\r
                                        } CursorInfo;\r
-typedef        CursorInfo      ControlInfo;\r
 \r
 typedef        struct          {\r
                                                ScanCode        button0,button1,\r
@@ -188,143 +196,89 @@ typedef  struct          {
                                                                        joyMaxX,joyMaxY,\r
                                                                        joyMultXL,joyMultYL,\r
                                                                        joyMultXH,joyMultYH;\r
-                                       } JoystickDef;\r
+                                       } JoystickDef;
+typedef        struct
+{
+       boolean w;\r
+} JoypadDef;
+
+typedef        struct
+{
+       CursorInfo      info;
+       ControlType     Controls;
+} player_t;
+
 /*\r
 =============================================================================\r
 \r
                                        GLOBAL VARIABLES\r
 \r
 =============================================================================\r
-*/\r
-\r
-//\r
-// configuration variables\r
-//\r
-static boolean                 MousePresent;\r
-static boolean                 JoysPresent[MaxJoys];\r
-static boolean                 JoyPadPresent;\r
-\r
-\r
-//     Global variables\r
-               static boolean JoystickCalibrated=false;                // MDM (GAMERS EDGE) - added\r
-               static ControlType ControlTypeUsed;                             // MDM (GAMERS EDGE) - added\r
-\r
-               static boolean          Keyboard[NumCodes];\r
-               static boolean          Paused;\r
-               static char             LastASCII;\r
-               static ScanCode LastScan;\r
-\r
-               static KeyboardDef      KbdDefs[] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               static JoystickDef      JoyDefs[MaxJoys];\r
-               static ControlType      Controls[MaxPlayers];\r
-\r
-               static dword    MouseDownCount;\r
-\r
+*/
+/*extern struct inconfig
+{
+       boolean                 MousePresent;\r
+       boolean                 JoysPresent[MaxJoys];\r
+       boolean                 JoyPadPresent[MaxPads];
+       boolean         Keyboard[NumCodes];\r
+       boolean         Paused;\r
+       char            LastASCII;\r
+       ScanCode        LastScan;
+
+       KeyboardDef     KbdDefs[MaxKbds];
+       JoystickDef     JoyDefs[MaxJoys];
+       JoypadDef       JoypadDefs[MaxPads];
+} inpu;*/
+
 #ifdef DEMO0\r
                static Demo             DemoMode = demo_Off;\r
                static byte /*_seg*/    *DemoBuffer;\r
                static word             DemoOffset,DemoSize;\r
 #endif\r
-\r
+
 extern dword far* clockdw;\r
 \r
-/*\r
-=============================================================================\r
-\r
-                                       LOCAL VARIABLES\r
-\r
-=============================================================================\r
-*/\r
-static byte        far ASCIINames[] =          // Unshifted ASCII for scan codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,27 ,'1','2','3','4','5','6','7','8','9','0','-','=',8  ,9  ,        // 0\r
-       'q','w','e','r','t','y','u','i','o','p','[',']',13 ,0  ,'a','s',        // 1\r
-       'd','f','g','h','j','k','l',';',39 ,'`',0  ,92 ,'z','x','c','v',        // 2\r
-       'b','n','m',',','.','/',0  ,'*',0  ,' ',0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,'7','8','9','-','4','5','6','+','1',        // 4\r
-       '2','3','0',127,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       },\r
-                                       far ShiftNames[] =              // Shifted ASCII for scan codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,27 ,'!','@','#','$','%','^','&','*','(',')','_','+',8  ,9  ,        // 0\r
-       'Q','W','E','R','T','Y','U','I','O','P','{','}',13 ,0  ,'A','S',        // 1\r
-       'D','F','G','H','J','K','L',':',34 ,'~',0  ,'|','Z','X','C','V',        // 2\r
-       'B','N','M','<','>','?',0  ,'*',0  ,' ',0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,'7','8','9','-','4','5','6','+','1',        // 4\r
-       '2','3','0',127,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       },\r
-                                       far SpecialNames[] =    // ASCII for 0xe0 prefixed codes\r
-                                       {\r
-//      0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 0\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,13 ,0  ,0  ,0  ,        // 1\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 2\r
-       0  ,0  ,0  ,0  ,0  ,'/',0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 3\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 4\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 5\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,        // 6\r
-       0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ,0           // 7\r
-                                       };\r
-\r
-\r
-static boolean         IN_Started;\r
-static boolean         CapsLock;\r
-static ScanCode        CurCode,LastCode;\r
-\r
-static Direction       DirTable[] =            // Quick lookup for total direction\r
-                                       {\r
-                                               //dir_NorthWest,\r
-                                               dir_North,\r
-                                               //dir_NorthEast,\r
-                                               dir_West,               dir_None,       dir_East,\r
-                                               //dir_SouthWest,\r
-                                               dir_South//,dir_SouthEast\r
-                                       };\r
-\r
-static void                    (*INL_KeyHook)(void);\r
-static void interrupt  (*OldKeyVect)(void);\r
-\r
-static char                    *ParmStrings[] = {"nojoys","nomouse",nil};\r
-\r
-// Function prototypes\r
-#define        IN_KeyDown(code)        (Keyboard[(code)])\r
-#define        IN_ClearKey(code)       {Keyboard[code] = false;\\r
-                                                       if (code == LastScan) LastScan = sc_None;}\r
-\r
-// DEBUG - put names in prototypes\r
-extern void            IN_Startup(void),IN_Shutdown(void),\r
-                                       IN_Default(boolean gotit,ControlType in),\r
-                                       IN_SetKeyHook(void (*)()),\r
-                                       IN_ClearKeysDown(void),\r
-                                       IN_ReadCursor(CursorInfo *),\r
-                                       IN_ReadControl(int,ControlInfo *),\r
-                                       IN_SetControlType(int,ControlType),\r
-                                       IN_GetJoyAbs(word joy,word *xp,word *yp),\r
-                                       IN_SetupJoy(word joy,word minx,word maxx,\r
-                                                               word miny,word maxy),\r
-                                       Mouse(int x),\r
-#ifdef DEMO0\r
-                                       IN_StartDemoPlayback(byte __segment *buffer,word bufsize),\r
-                                       IN_StopDemo(void),IN_FreeDemoBuffer(void),\r
-#endif\r
-                                       IN_Ack(void),IN_AckBack(void);\r
-extern boolean         IN_UserInput(dword delay,boolean clear),\r
-                                       IN_IsUserInput(void)\r
-#ifdef DEMO0\r
-                                       , IN_StartDemoRecord(word bufsize)\r
-#endif\r
-;\r
-extern byte            *IN_GetScanName(ScanCode);\r
-extern char            IN_WaitForASCII(void);\r
-extern ScanCode        IN_WaitForKey(void);\r
-extern word            IN_GetJoyButtonsDB(word joy);\r
-\r
+//     Internal routines
+extern void interrupt INL_KeyService();
+extern void Mouse(int x);
+//static void INL_GetMouseDelta(int *x,int *y);
+//static word INL_GetMouseButtons(void);
+extern void IN_GetJoyAbs(word joy,word *xp,word *yp);
+//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive);
+//static word INL_GetJoyButtons(word joy);
+extern word IN_GetJoyButtonsDB(word joy);
+//static void INL_StartKbd(void);
+//static void INL_ShutKbd(void);
+//static boolean INL_StartMouse(void);
+//static void INL_ShutMouse(void);
+//static void INL_SetJoyScale(word joy);
+extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
+//static boolean INL_StartJoy(word joy);
+//static void INL_ShutJoy(word joy);
+extern void IN_Startup();
+extern void IN_Default(boolean gotit,player_t *player,ControlType nt);
+extern void IN_Shutdown();
+extern void IN_SetKeyHook(void (*hook)());
+extern void IN_ClearKeysDown();
+//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
+extern void IN_ReadCursor(CursorInfo *info);
+extern void IN_ReadControl(int playnum,player_t *player);
+extern void IN_SetControlType(word playnum,player_t *player,ControlType type);
+#if DEMO0
+extern boolean IN_StartDemoRecord(word bufsize);
+extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
+extern void IN_StopDemo(void);
+extern void IN_FreeDemoBuffer(void);
+#endif
+extern byte *IN_GetScanName(ScanCode scan);
+extern ScanCode IN_WaitForKey();
+extern char IN_WaitForASCII();
+extern void IN_AckBack();
+extern void IN_Ack();
+extern boolean IN_IsUserInput();
+extern boolean IN_UserInput(dword delay,boolean clear);
+extern boolean IN_KeyDown(byte code);
+extern void IN_ClearKey(byte code);
+extern boolean IN_qb(byte kee);
 \r
-//static void interrupt INL_KeyService(void);\r
 #endif\r