X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_in.c;h=bdd3d0fe47554db0db169cbe3b761b4f2fec9e96;hb=5af1604f7af6c1d1ab94299bfe6a4195b203a323;hp=98ecb70d117a330213f9fb00a974dda1463ecbbd;hpb=af2715fef8681d909afe82f7baaf5e13baabb76f;p=16.git diff --git a/src/lib/16_in.c b/src/lib/16_in.c index 98ecb70d..bdd3d0fe 100755 --- a/src/lib/16_in.c +++ b/src/lib/16_in.c @@ -78,15 +78,21 @@ static word far* clockw= (word far*) 0x046C; /* 18.2hz clock */ extern "C" { #endif -static struct instat { - boolean CapsLock; +/*static struct instat { + boolean CapsLock; ScanCode CurCode,LastCode; boolean Keyboard[NumCodes]; boolean Paused; char LastASCII; ScanCode LastScan; -} inst; +} inst;*/ + +//the def stuff is need fix warnings +#ifndef INSTDEFED +#define INSTDEFED +static inst_t inst; +#endif static byte far ASCIINames[] = // Unshifted ASCII for scan codes { @@ -163,6 +169,7 @@ static Direction DirTable[] = // Quick lookup for total direction static void (*INL_KeyHook)(void); static void interrupt (*OldKeyVect)(void); static char *ParmStringsIN[] = {"nojoys","nomouse",nil}; +static void INL_StartKbd(void); // Internal routines @@ -242,17 +249,6 @@ static boolean special; outportb(0x20,0x20); } -void INL_Mouse(int x) -{ - //union REGS CPURegs; - //x = CPURegs.x.ax; - __asm { - mov ax,x - int MouseInt - } - //int86(MouseInt,&CPURegs,&CPURegs); -} - /////////////////////////////////////////////////////////////////////////// // // INL_GetMouseDelta() - Gets the amount that the mouse has moved from the @@ -262,10 +258,9 @@ void INL_Mouse(int x) static void INL_GetMouseDelta(int *x,int *y) { - union REGS CPURegs; Mouse(MDelta); - *x = CPURegs.x.cx; - *y = CPURegs.x.dx; + *x = _CX; + *y = _DX; } /////////////////////////////////////////////////////////////////////////// @@ -277,11 +272,10 @@ INL_GetMouseDelta(int *x,int *y) static word INL_GetMouseButtons(void) { - union REGS CPURegs; word buttons; Mouse(MButtons); - buttons = CPURegs.x.bx; + buttons = _BX; return(buttons); } @@ -497,7 +491,7 @@ IN_GetJoyButtonsDB(word joy) // /////////////////////////////////////////////////////////////////////////// static void -INL_StartKbd(global_game_variables_t *gvar) +INL_StartKbd(void) { INL_KeyHook = NULL; // Clear key hook @@ -536,7 +530,7 @@ INL_StartMouse(void) return(true); } return(false); -#endif +#else byte far *vector; @@ -548,6 +542,7 @@ INL_StartMouse(void) Mouse(MReset); return true; +#endif } /////////////////////////////////////////////////////////////////////////// @@ -674,7 +669,7 @@ IN_Startup(global_game_variables_t *gvar) } } - INL_StartKbd(gvar); + INL_StartKbd(); gvar->in.MousePresent = checkmouse? INL_StartMouse() : false; for (i = 0;i < MaxJoys;i++) @@ -683,7 +678,6 @@ IN_Startup(global_game_variables_t *gvar) gvar->in.inst = &inst; gvar->in.IN_Started = true; - } /////////////////////////////////////////////////////////////////////////// @@ -872,8 +866,7 @@ register KeyboardDef *def; #endif switch (type = player->Controls) { - case ctrl_Keyboard1: - case ctrl_Keyboard2: + case ctrl_Keyboard: def = &(gvar->in.KbdDefs[type - ctrl_Keyboard]); /* if (Keyboard[def->upleft]) @@ -948,8 +941,8 @@ register KeyboardDef *def; } else { - dx = mx;// * 127; - dy = my;// * 127; + dx = mx * 127; + dy = my * 127; } player->info.x = dx; @@ -997,6 +990,22 @@ register KeyboardDef *def; } #endif #ifdef __DEBUG_InputMgr__ +if(dbg_joymousedelta) +{ + { +static int old_dx,old_dy; +static word old_buttons=0; + if(dx!=old_dx || dy!=old_dy) printf("dx,dy [%d,%d] %d,%d\n", dx, dy, mx, my); + if(dx!=old_dx) old_dx=dx; + if(dy!=old_dy) old_dy=dy; + if(old_buttons!=buttons) + { + printf(" buttons={%u,%u,%u,%u}\n", player->info.button0, player->info.button1, player->info.button2, player->info.button3); + old_buttons=buttons; + } + } +} + if(dbg_testcontrolnoisy > 0) if(player->info.dir!=2/*(inst.Keyboard[def->up] || inst.Keyboard[def->down] || inst.Keyboard[def->left] || inst.Keyboard[def->right])*/ || player->enti.q>1) { @@ -1177,8 +1186,13 @@ boolean IN_CheckAck (global_game_variables_t *gvar) // // see if something has been pressed // - if (inst.LastScan) - return true; + if(!gvar->in.IN_Started) + getch(); + else + { + if (inst.LastScan) + return true; + } buttons = IN_JoyButtons () << 4; if (gvar->in.MousePresent) @@ -1266,11 +1280,10 @@ boolean IN_UserInput(word delay, global_game_variables_t *gvar) byte IN_MouseButtons (global_game_variables_t *gvar) { - union REGS CPURegs; if (gvar->in.MousePresent) { Mouse(MButtons); - return CPURegs.x.bx; + return _BX; } else return 0; @@ -1299,8 +1312,8 @@ byte IN_JoyButtons (void) boolean IN_KeyDown(byte code) { #ifdef __DEBUG_InputMgr__ - if(inst.Keyboard[code]) - printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]); +// if(inst.Keyboard[code]) +// printf("IN_KeyDown(%c): %u\n", code, inst.Keyboard[code]); if(!dbg_nointest) #endif return inst.Keyboard[code];