]> 4ch.mooo.com Git - 16.git/commitdiff
input fully ported!! it is a bit buggy but it works!!
authorsparky4 <sparky4@cock.li>
Mon, 29 Jun 2015 05:54:59 +0000 (00:54 -0500)
committersparky4 <sparky4@cock.li>
Mon, 29 Jun 2015 05:54:59 +0000 (00:54 -0500)
modified:   16.LIB
modified:   GFX.LIB
modified:   emmtest.exe
modified:   emsdump.exe
modified:   exmmtest.exe
modified:   fmemtest.exe
modified:   inputest.exe
modified:   palettec.exe
modified:   src/inputest.c
modified:   src/lib/16_in.c
modified:   src/lib/16_in.h

16.LIB
GFX.LIB
emmtest.exe
emsdump.exe
exmmtest.exe
fmemtest.exe
inputest.exe
palettec.exe
src/inputest.c
src/lib/16_in.c
src/lib/16_in.h

diff --git a/16.LIB b/16.LIB
index 45f43dea12a9473ab4d108992b6fd7885d20f8f9..4899d50af9a6051789d77e3befb67055b6d227f2 100644 (file)
Binary files a/16.LIB and b/16.LIB differ
diff --git a/GFX.LIB b/GFX.LIB
index 30582814bf73bc28f0cebb0d5d447ac30285f027..8eac230995b237105220429997f900b802b27acf 100644 (file)
Binary files a/GFX.LIB and b/GFX.LIB differ
index fb51561fba2318cd5e9c911d768dcabbfcce7c56..1afe9df7ab0f53fa981d5d4e8988f04372d9ba45 100644 (file)
Binary files a/emmtest.exe and b/emmtest.exe differ
index 9dac2237052d4c64943dd884961a976d3fd17ac3..e19947ac5a5e6184e767a84144a91290af1f0874 100644 (file)
Binary files a/emsdump.exe and b/emsdump.exe differ
index 355105363e3d0b7d0b8520120e7ef77e3c833ed3..d27e9afcd4a4ef46ce2fa5d6aae572ca4bb6a572 100644 (file)
Binary files a/exmmtest.exe and b/exmmtest.exe differ
index 951d244027f6f6ae31868851c8f7a59e8a254534..7904c7d68723ec8cab90dcb366ae7f50c3d64091 100644 (file)
Binary files a/fmemtest.exe and b/fmemtest.exe differ
index 2cd78ff59f8ef23c65efbab0af8c43c01ea5bac7..52f08c514095d2efa8bf13aeedead497773c618a 100644 (file)
Binary files a/inputest.exe and b/inputest.exe differ
index 7801de41b4c071690224e0ea45f39d85f1030dff..fa4b8c085d9823bbf0c721965c46bf95f076d9a8 100644 (file)
Binary files a/palettec.exe and b/palettec.exe differ
index 9693104657c8cae19a318d09d173bf53caf6db17..d4a3d44c50f6150bda75fbf381b1a3a2c0773787 100644 (file)
 \r
 void\r
 main(int argc, char *argv[])\r
-{\r
-//     CursorInfo control;
+{
        player_t player[MaxPlayers];
-       hwconfig hw;
-       player.KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};
+       inconfig in;
+       //word i=0;
 \r
-       extern boolean Keyboard[NumCodes];\r
-       IN_Startup();
-       IN_Default(0,&player,ctrl_Joystick);\r
-//     IN_Default(0,ctrl_Joystick);\r
-       while(!IN_qb(sc_Escape))\r
-       {\r
-               IN_ReadControl(0,&control);\r
-//             printf("%u\n", Keyboard[sc_Escape]);\r
+       in.KbdDefs[0].button0 = 0x1d;
+       in.KbdDefs[0].button1 = 0x38;
+       //in.KbdDefs[0].upleft = 0x47;
+       in.KbdDefs[0].up = 0x48;
+       //in.KbdDefs[0].upright = 0x49;
+       in.KbdDefs[0].left = 0x4b;
+       in.KbdDefs[0].right = 0x4d;
+       //in.KbdDefs[0].downleft = 0x4f;
+       in.KbdDefs[0].down = 0x50;
+       //in.KbdDefs[0].downright = 0x51;
 \r
-       }\r
-       IN_Shutdown();\r
+       if(IN_Startup(&in))
+       {
+               IN_Default(0,&player,ctrl_Joystick, &in);\r
+               while(!in.Keyboard[sc_Escape])\r
+               {
+                       IN_ReadControl(0,&player, &in);\r
+                       //printf("%u\n", in.Keyboard[sc_Escape]);
+                       //printf("i=%u\n", i);
+                       printf("");
+                       //i++;\r
+               }
+               IN_Shutdown(&in);
+       }
+       //printf("%u\n", in.Keyboard[sc_Escape]);\r
 }\r
index 176144abf3d842c247d1730e9db0fb752ea69c18..48e62c5237984cbbcf65103e40a6f9c55cf4e240 100644 (file)
 /*\r
 =============================================================================\r
 \r
-                                       GLOBAL VARIABLES\r
+                                       LOCAL VARIABLES\r
 \r
 =============================================================================\r
-*/\r
-//     Global variables
-//             boolean JoystickCalibrated=false;               // MDM (GAMERS EDGE) - added\r
-//             ControlType ControlTypeUsed;                            // MDM (GAMERS EDGE) - added\r
-               //boolean               Keyboard[NumCodes];\r
-               //boolean               Paused;\r
-               //char          LastASCII;\r
-               //ScanCode      LastScan;\r
+*/
+#ifdef __cplusplus             /* Function must be declared C style */
+extern "C" {
+#endif\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
+                                       *ScanNames[] =          // Scan code names with single chars\r
+                                       {\r
+       "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",\r
+       "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S",\r
+       "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V",\r
+       "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?",\r
+       "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?",\r
+       "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
+       "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
+       "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"\r
+                                       },      // DEBUG - consolidate these\r
+                                       far ExtScanCodes[] =    // Scan codes with >1 char names\r
+                                       {\r
+       1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,\r
+       0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,\r
+       0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,\r
+       0x50,0x4b,0x4d,0x00\r
+                                       },\r
+                                       *ExtScanNames[] =       // Names corresponding to ExtScanCodes\r
+                                       {\r
+       "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4",\r
+       "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft",\r
+       "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up",\r
+       "Down","Left","Right",""\r
+                                       };
 \r
-               //KeyboardDef   KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               //JoystickDef   JoyDefs[MaxJoys];\r
-               //ControlType   Controls[MaxPlayers];\r
+static Direction       DirTable[] =            // Quick lookup for total direction\r
+                                       {\r
+                                               //dir_Nortinest,\r
+                                               dir_North,\r
+                                               //dir_NorthEast,\r
+                                               dir_West,               dir_None,       dir_East,\r
+                                               //dir_Soutinest,\r
+                                               dir_South//,dir_SouthEast\r
+                                       };\r
+
+static boolean         IN_Started;\r
+static boolean         CapsLock;\r
+static ScanCode        CurCode,LastCode;
 \r
-               //dword MouseDownCount;
+static void                    (*INL_KeyHook)(void);
+static void interrupt  (*OldKeyVect)(void);
+static char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};
+#ifdef __cplusplus
+}
+#endif
 
 //     Internal routines
 ///////////////////////////////////////////////////////////////////////////
@@ -94,8 +166,8 @@ static       boolean special;
                }
                else                    // Make code
                {
-                       in->LastCode = in->CurCode;
-                       in->CurCode = in->LastScan = k;
+                       LastCode = CurCode;
+                       CurCode = in->LastScan = k;
                        in->Keyboard[k] = true;
 
                        if (special)
@@ -104,20 +176,20 @@ static    boolean special;
                        {
                                if (k == sc_CapsLock)
                                {
-                                       in->CapsLock ^= true;
+                                       CapsLock ^= true;
                                        // DEBUG - make caps lock light work
                                }
 
                                if (in->Keyboard[sc_LShift] || in->Keyboard[sc_RShift]) // If shifted
                                {
                                        c = ShiftNames[k];
-                                       if ((c >= 'A') && (c <= 'Z') && in->CapsLock)
+                                       if ((c >= 'A') && (c <= 'Z') && CapsLock)
                                                c += 'a' - 'A';
                                }
                                else
                                {
                                        c = ASCIINames[k];
-                                       if ((c >= 'a') && (c <= 'z') && in->CapsLock)
+                                       if ((c >= 'a') && (c <= 'z') && CapsLock)
                                                c -= 'a' - 'A';
                                }
                        }
@@ -522,14 +594,16 @@ INL_ShutJoy(word joy, inconfig *in)
 //     IN_Startup() - Starts up the Input Mgr
 //
 ///////////////////////////////////////////////////////////////////////////
-void
+boolean
 IN_Startup(inconfig *in)
 {
        boolean checkjoys,checkmouse;
        word    i;
 
-       if (in->IN_Started)
-               return;
+       if (IN_Started)
+       {
+               return false;
+       }
 
        checkjoys = true;
        checkmouse = true;
@@ -552,7 +626,8 @@ IN_Startup(inconfig *in)
        for (i = 0;i < MaxJoys;i++)
                in->JoysPresent[i] = checkjoys? INL_StartJoy(i, in) : false;
 
-       in->IN_Started = true;
+       IN_Started = true;
+       return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -581,20 +656,23 @@ IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in)
 //     IN_Shutdown() - Shuts down the Input Mgr
 //
 ///////////////////////////////////////////////////////////////////////////
-void
+boolean
 IN_Shutdown(inconfig *in)
 {
        word    i;
 
-       if (!in->IN_Started)
-               return;
+       if (!IN_Started)
+       {
+               return false;
+       }
 
        INL_ShutMouse();
        for (i = 0;i < MaxJoys;i++)
                INL_ShutJoy(i, in);
        INL_ShutKbd();
 
-       in->IN_Started = false;
+       IN_Started = false;
+       return true;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -648,7 +726,7 @@ INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_ReadCursor(CursorInfo *info)
+IN_ReadCursor(CursorInfo *info, inconfig *in)
 {
        word    i,
                        buttons;
@@ -657,7 +735,7 @@ IN_ReadCursor(CursorInfo *info)
        info->x = info->y = 0;
        info->button0 = info->button1 = false;
 
-       if (MousePresent)
+       if (in->MousePresent)
        {
                buttons = INL_GetMouseButtons();
                INL_GetMouseDelta(&dx,&dy);
@@ -666,11 +744,11 @@ IN_ReadCursor(CursorInfo *info)
 
        for (i = 0;i < MaxJoys;i++)
        {
-               if (!JoysPresent[i])
+               if (!in->JoysPresent[i])
                        continue;
 
                buttons = INL_GetJoyButtons(i);
-               INL_GetJoyDelta(i,&dx,&dy,true);
+               INL_GetJoyDelta(i,&dx,&dy,true, in);
                dx /= 64;
                dy /= 64;
                INL_AdjustCursor(info,buttons,dx,dy);
@@ -684,7 +762,7 @@ IN_ReadCursor(CursorInfo *info)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_ReadControl(int playnum,player_t *player)
+IN_ReadControl(int playnum,player_t *player, inconfig *in)
 {
                        boolean         realdelta;
                        byte            dbyte;
@@ -720,11 +798,11 @@ register  KeyboardDef     *def;
        else
        {
 #endif
-               switch (type = player[playnum]->Controls)
+               switch (type = player[playnum].Controls)
                {
                case ctrl_Keyboard1:
                case ctrl_Keyboard2:
-                       def = player[playnum]->KbdDefs[type - ctrl_Keyboard];
+                       def = &(in->KbdDefs[type - ctrl_Keyboard]);
 
 /*                     if (Keyboard[def->upleft])
                                mx = motion_Left,my = motion_Up;
@@ -735,25 +813,25 @@ register  KeyboardDef     *def;
                        else if (Keyboard[def->downright])
                                mx = motion_Right,my = motion_Down;*/
 
-                       if (Keyboard[def->up])
+                       if (in->Keyboard[def->up])
                                my = motion_Up;
-                       else if (Keyboard[def->down])
+                       else if (in->Keyboard[def->down])
                                my = motion_Down;
 
-                       if (Keyboard[def->left])
+                       if (in->Keyboard[def->left])
                                mx = motion_Left;
-                       else if (Keyboard[def->right])
+                       else if (in->Keyboard[def->right])
                                mx = motion_Right;
 
-                       if (Keyboard[def->button0])
+                       if (in->Keyboard[def->button0])
                                buttons += 1 << 0;
-                       if (Keyboard[def->button1])
+                       if (in->Keyboard[def->button1])
                                buttons += 1 << 1;
                        realdelta = false;
                        break;
                case ctrl_Joystick1:
                case ctrl_Joystick2:
-                       INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false);
+                       INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false, in);
                        buttons = INL_GetJoyButtons(type - ctrl_Joystick);
                        realdelta = true;
                        break;
@@ -782,15 +860,15 @@ register  KeyboardDef     *def;
                dy = my * 127;
        }
 
-       player[playnum]->info.x = dx;
-       player[playnum]->info.xaxis = mx;
-       player[playnum]->info.y = dy;
-       player[playnum]->info.yaxis = my;
-       player[playnum]->info.button0 = buttons & (1 << 0);
-       player[playnum]->info.button1 = buttons & (1 << 1);
-       player[playnum]->info.button2 = buttons & (1 << 2);
-       player[playnum]->info.button3 = buttons & (1 << 3);
-       player[playnum]->info.dir = DirTable[((my + 1) * 3) + (mx + 1)];
+       player[playnum].info.x = dx;
+       player[playnum].info.xaxis = mx;
+       player[playnum].info.y = dy;
+       player[playnum].info.yaxis = my;
+       player[playnum].info.button0 = buttons & (1 << 0);
+       player[playnum].info.button1 = buttons & (1 << 1);
+       player[playnum].info.button2 = buttons & (1 << 2);
+       player[playnum].info.button3 = buttons & (1 << 3);
+       player[playnum].info.dir = DirTable[((my + 1) * 3) + (mx + 1)];
 
 #if DEMO0
        if (DemoMode == demo_Record)
@@ -829,7 +907,7 @@ void
 IN_SetControlType(word playnum,player_t *player,ControlType type)
 {
        // DEBUG - check that requested type is present?
-       player[playnum]->Controls = type;
+       player[playnum].Controls = type;
 }
 
 #if DEMO0
@@ -922,13 +1000,13 @@ IN_GetScanName(ScanCode scan)
 //
 ///////////////////////////////////////////////////////////////////////////
 ScanCode
-IN_WaitForKey(void)
+IN_WaitForKey(inconfig *in)
 {
        ScanCode        result;
 
-       while (!(result = LastScan))
+       while (!(result = in->LastScan))
                ;
-       LastScan = 0;
+       in->LastScan = 0;
        return(result);
 }
 
@@ -939,13 +1017,13 @@ IN_WaitForKey(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 char
-IN_WaitForASCII(void)
+IN_WaitForASCII(inconfig *in)
 {
        char            result;
 
-       while (!(result = LastASCII))
+       while (!(result = in->LastASCII))
                ;
-       LastASCII = '\0';
+       in->LastASCII = '\0';
        return(result);
 }
 
@@ -955,13 +1033,13 @@ IN_WaitForASCII(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_AckBack(void)
+IN_AckBack(inconfig *in)
 {
        word    i;
 
-       while (!LastScan)
+       while (!in->LastScan)
        {
-               if (MousePresent)
+               if (in->MousePresent)
                {
                        if (INL_GetMouseButtons())
                        {
@@ -973,7 +1051,7 @@ IN_AckBack(void)
 
                for (i = 0;i < MaxJoys;i++)
                {
-                       if (JoysPresent[i])
+                       if (in->JoysPresent[i])
                        {
                                if (IN_GetJoyButtonsDB(i))
                                {
@@ -985,8 +1063,8 @@ IN_AckBack(void)
                }
        }
 
-       IN_ClearKey(LastScan);
-       LastScan = sc_None;
+       IN_ClearKey(in->LastScan, in);
+       in->LastScan = sc_None;
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -995,22 +1073,22 @@ IN_AckBack(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 void
-IN_Ack(void)
+IN_Ack(inconfig *in)
 {
        word    i;
 
-       IN_ClearKey(LastScan);
-       LastScan = sc_None;
+       IN_ClearKey(in->LastScan, in);
+       in->LastScan = sc_None;
 
-       if (MousePresent)
+       if (in->MousePresent)
                while (INL_GetMouseButtons())
                                        ;
        for (i = 0;i < MaxJoys;i++)
-               if (JoysPresent[i])
+               if (in->JoysPresent[i])
                        while (IN_GetJoyButtonsDB(i))
                                ;
 
-       IN_AckBack();
+       IN_AckBack(in);
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -1020,19 +1098,19 @@ IN_Ack(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 boolean
-IN_IsUserInput(void)
+IN_IsUserInput(inconfig *in)
 {
        boolean result;
        word    i;
 
-       result = LastScan;
+       result = in->LastScan;
 
-       if (MousePresent)
+       if (in->MousePresent)
                if (INL_GetMouseButtons())
                        result = true;
 
        for (i = 0;i < MaxJoys;i++)
-               if (JoysPresent[i])
+               if (in->JoysPresent[i])
                        if (INL_GetJoyButtons(i))
                                result = true;
 
@@ -1048,7 +1126,7 @@ IN_IsUserInput(void)
 //
 ///////////////////////////////////////////////////////////////////////////
 boolean
-IN_UserInput(dword delay,boolean clear)
+IN_UserInput(dword delay,boolean clear, inconfig *in)
 {
        dword TimeCount = *clockdw;
        dword   lasttime;
@@ -1056,18 +1134,24 @@ IN_UserInput(dword delay,boolean clear)
        lasttime = TimeCount;
        do
        {
-               if (IN_IsUserInput())
+               if (IN_IsUserInput(in))
                {
                        if (clear)
-                               IN_AckBack();
+                               IN_AckBack(in);
                        return(true);
                }
        } while (TimeCount - lasttime < delay);
        return(false);
 }
 
-boolean IN_qb(byte kee)
+boolean IN_KeyDown(byte code, inconfig *in)
 {
-       if(Keyboard[kee]==true) return 1;
-       else return 0;
+       return in->Keyboard[(code)];
 }
+\r
+void IN_ClearKey(byte code, inconfig *in)
+{
+       in->Keyboard[code] = false;
+       if(code == in->LastScan)
+               in->LastScan = sc_None;
+       }
index 2d15828ee4b98045bdbc5cb7467148403c30bd92..f14e8178027bf40b2e1187b03081ae940046ec63 100644 (file)
@@ -218,46 +218,11 @@ typedef   struct
        char            LastASCII;\r
        ScanCode        LastScan;
 
-       boolean         IN_Started;\r
-       boolean         CapsLock;\r
-       ScanCode        CurCode,LastCode;
-
        KeyboardDef     KbdDefs[MaxKbds];
        JoystickDef     JoyDefs[MaxJoys];
        JoypadDef       JoypadDefs[MaxPads];
 } inconfig;
-\r
-/*\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[MaxPads];\r
-\r
-//     Global variables\r
-//             extern boolean JoystickCalibrated;              // MDM (GAMERS EDGE) - added\r
-//             extern ControlType ControlTypeUsed;                             // MDM (GAMERS EDGE) - added\r
-\r
-               //extern boolean                Keyboard[NumCodes];\r
-               //extern boolean                Paused;\r
-               //extern char           LastASCII;\r
-               //extern ScanCode       LastScan;\r
-\r
-               //extern KeyboardDef    KbdDefs[];
-               //static KeyboardDef    KbdDefs[MaxKbds] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
-               //extern JoystickDef    JoyDefs[MaxJoys];\r
-               //extern ControlType    Controls[MaxPlayers];\r
-\r
-               //extern dword  MouseDownCount;\r
-\r
+
 #ifdef DEMO0\r
                static Demo             DemoMode = demo_Off;\r
                static byte /*_seg*/    *DemoBuffer;\r
@@ -266,94 +231,6 @@ typedef    struct
 \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
-                                       *ScanNames[] =          // Scan code names with single chars\r
-                                       {\r
-       "?","?","1","2","3","4","5","6","7","8","9","0","-","+","?","?",\r
-       "Q","W","E","R","T","Y","U","I","O","P","[","]","|","?","A","S",\r
-       "D","F","G","H","J","K","L",";","\"","?","?","?","Z","X","C","V",\r
-       "B","N","M",",",".","/","?","?","?","?","?","?","?","?","?","?",\r
-       "?","?","?","?","?","?","?","?","\xf","?","-","\x15","5","\x11","+","?",\r
-       "\x13","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
-       "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?",\r
-       "?","?","?","?","?","?","?","?","?","?","?","?","?","?","?","?"\r
-                                       },      // DEBUG - consolidate these\r
-                                       far ExtScanCodes[] =    // Scan codes with >1 char names\r
-                                       {\r
-       1,0xe,0xf,0x1d,0x2a,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,\r
-       0x3f,0x40,0x41,0x42,0x43,0x44,0x57,0x59,0x46,0x1c,0x36,\r
-       0x37,0x38,0x47,0x49,0x4f,0x51,0x52,0x53,0x45,0x48,\r
-       0x50,0x4b,0x4d,0x00\r
-                                       },\r
-                                       *ExtScanNames[] =       // Names corresponding to ExtScanCodes\r
-                                       {\r
-       "Esc","BkSp","Tab","Ctrl","LShft","Space","CapsLk","F1","F2","F3","F4",\r
-       "F5","F6","F7","F8","F9","F10","F11","F12","ScrlLk","Enter","RShft",\r
-       "PrtSc","Alt","Home","PgUp","End","PgDn","Ins","Del","NumLk","Up",\r
-       "Down","Left","Right",""\r
-                                       };
-\r
-static Direction       DirTable[] =            // Quick lookup for total direction\r
-                                       {\r
-                                               //dir_Nortinest,\r
-                                               dir_North,\r
-                                               //dir_NorthEast,\r
-                                               dir_West,               dir_None,       dir_East,\r
-                                               //dir_Soutinest,\r
-                                               dir_South//,dir_SouthEast\r
-                                       };\r
-\r
-static void                    (*INL_KeyHook)(void);\r
-static void interrupt  (*OldKeyVect)(void);\r
-\r
-static char                    *ParmStringsIN[] = {"nojoys","nomouse",nil};\r
-\r
-// Function prototypes\r
-#define        IN_KeyDown(code)        (Keyboard[(code)])\r
-#define        IN_ClearKey(code)       {Keyboard[code] = false; if (code == LastScan) LastScan = sc_None;}\r
-
 //     Internal routines
 void interrupt INL_KeyService(inconfig *in);
 void Mouse(int x);
@@ -371,14 +248,14 @@ word IN_GetJoyButtonsDB(word joy);
 void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, inconfig *in);
 //static boolean INL_StartJoy(word joy);
 //static void INL_ShutJoy(word joy);
-void IN_Startup(inconfig *in);
+boolean IN_Startup(inconfig *in);
 void IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in);
-void IN_Shutdown(inconfig *in);
+boolean IN_Shutdown(inconfig *in);
 void IN_SetKeyHook(void (*hook)());
 void IN_ClearKeysDown(inconfig *in);
 //static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
-void IN_ReadCursor(CursorInfo *info);
-void IN_ReadControl(int playnum,player_t *player);
+void IN_ReadCursor(CursorInfo *info, inconfig *in);
+void IN_ReadControl(int playnum,player_t *player, inconfig *in);
 void IN_SetControlType(word playnum,player_t *player,ControlType type);
 #if DEMO0
 boolean IN_StartDemoRecord(word bufsize);
@@ -387,39 +264,13 @@ void IN_StopDemo(void);
 void IN_FreeDemoBuffer(void);
 #endif
 byte *IN_GetScanName(ScanCode scan);
-ScanCode IN_WaitForKey(void);
-char IN_WaitForASCII(void);
-void IN_AckBack(void);
-void IN_Ack(void);
-boolean IN_IsUserInput(void);
-boolean IN_UserInput(dword delay,boolean clear);
-\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
+ScanCode IN_WaitForKey(inconfig *in);
+char IN_WaitForASCII(inconfig *in);
+void IN_AckBack(inconfig *in);
+void IN_Ack(inconfig *in);
+boolean IN_IsUserInput(inconfig *in);
+boolean IN_UserInput(dword delay,boolean clear, inconfig *in);
+boolean IN_KeyDown(byte code, inconfig *in);
+void IN_ClearKey(byte code, inconfig *in);
 \r
-boolean IN_qb(byte kee);\r
 #endif\r