diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 6eeae3e58..e3d7d29d0 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -1654,14 +1654,15 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) if ((osdflags & OSD_INITIALIZED) == 0) OSD_Init(); - if (!name) + if (!name || !name[0]) { - OSD_Printf("OSD_RegisterFunction(): may not register a function with a null name\n"); + OSD_Printf("OSD_RegisterFunction(): can't register function with null name\n"); return -1; } - if (!name[0]) + + if (!func) { - OSD_Printf("OSD_RegisterFunction(): may not register a function with no name\n"); + OSD_Printf("OSD_RegisterFunction(): can't register null function\n"); return -1; } @@ -1684,13 +1685,9 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) } if (!help) help = "(no description for this function)"; - if (!func) - { - OSD_Printf("OSD_RegisterFunction(): may not register a null function\n"); - return -1; - } symb = findexactsymbol(name); + if (symb) // allow this now for reusing an alias name { if (symb->func != OSD_ALIAS && symb->func != OSD_UNALIASED) @@ -1705,6 +1702,7 @@ int32_t OSD_RegisterFunction(const char *name, const char *help, int32_t (*func) } symb = addnewsymbol(name); + if (!symb) { OSD_Printf("OSD_RegisterFunction(): Failed registering function \"%s\"\n", name); diff --git a/polymer/eduke32/build/src/rawinput.c b/polymer/eduke32/build/src/rawinput.c index fdad1bbda..55dcb5daf 100644 --- a/polymer/eduke32/build/src/rawinput.c +++ b/polymer/eduke32/build/src/rawinput.c @@ -6,7 +6,7 @@ #include "scancodes.h" #include "build.h" -static BOOL init_done = 0; +static BOOL rawinput_started = 0; static uint8_t KeyboardState[256] = {0}; // VKeys static int8_t MWheel = 0; @@ -80,6 +80,7 @@ static inline void RI_ProcessMouse(const RAWMOUSE* rmouse) static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) { uint8_t key = rkbd->MakeCode, VKey = rkbd->VKey; + uint8_t buf[2], i; // for some reason rkbd->MakeCode is wrong for these // even though rkbd->VKey is right... @@ -122,18 +123,36 @@ static inline void RI_ProcessKeyboard(const RAWKEYBOARD* rkbd) key = sc_PgDn; break; case VK_RETURN: if (rkbd->Flags & RI_KEY_E0) key = sc_kpad_Enter; break; - } + case VK_PAUSE: + KeyboardState[VKey] = 1 - (rkbd->Flags & RI_KEY_BREAK); + if (rkbd->Flags & RI_KEY_BREAK) return; - KeyboardState[VKey] &= 0xfe; - KeyboardState[VKey] |= 1 - (rkbd->Flags & RI_KEY_BREAK); - - if (OSD_HandleScanCode(key, (rkbd->Flags & RI_KEY_BREAK) == 0)) - { - SetKey(key, (rkbd->Flags & RI_KEY_BREAK) == 0); + SetKey(sc_Pause, 1); if (keypresscallback) - keypresscallback(key, (rkbd->Flags & RI_KEY_BREAK) == 0); + keypresscallback(sc_Pause, 1); + return; } + + KeyboardState[VKey] = 1 - (rkbd->Flags & RI_KEY_BREAK); + + if (OSD_HandleScanCode(key, KeyboardState[VKey] != 0)) + { + SetKey(key, KeyboardState[VKey] != 0); + + if (keypresscallback) + keypresscallback(key, KeyboardState[VKey] != 0); + } + + if (rkbd->Flags & RI_KEY_BREAK) return; + if (((keyasciififoend+1)&(KEYFIFOSIZ-1)) == keyasciififoplc) return; + if ((keyasciififoend - keyasciififoplc) > 0) return; + if (ToAscii(VKey, key, &KeyboardState[0], (LPWORD)&buf[0], 0) != 1) return; + if ((OSD_OSDKey() < 128) && (Btolower(scantoasc[OSD_OSDKey()]) == Btolower(buf[0]))) return; + if (OSD_HandleChar(buf[0]) == 0) return; + + keyasciififo[keyasciififoend] = buf[0]; + keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); } // keyboard is always captured regardless of what we tell this function @@ -148,8 +167,8 @@ int32_t RI_CaptureInput(int32_t grab, HWND target) raw[1].usUsagePage = 0x01; raw[1].usUsage = 0x06; - raw[1].dwFlags = 0; - raw[1].hwndTarget = NULL; + raw[1].dwFlags = RIDEV_NOLEGACY; + raw[1].hwndTarget = target; mousegrab = grab; @@ -161,16 +180,16 @@ void RI_PollDevices() int32_t i; MSG msg; - if (!init_done) + if (!rawinput_started) { if (RI_CaptureInput(1, (HWND)win_gethwnd())) return; - - init_done = 1; + rawinput_started = 1; } + // snapshot the whole keyboard state so we can translate key presses into ascii later for (i = 0; i < 256; i++) - KeyboardState[i] = (KeyboardState[i] << 1) | (1 & KeyboardState[i]); + KeyboardState[i] = GetAsyncKeyState(i) >> 8; MWheel = 0; diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 184a7b4be..402965c67 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -86,7 +86,7 @@ static BOOL InitDirectInput(void); static void UninitDirectInput(void); static void GetKeyNames(void); static void AcquireInputDevices(char acquire, int8_t device); -static inline void DI_ProcessDevices(void); +static inline void DI_PollJoysticks(void); static int32_t SetupDirectDraw(int32_t width, int32_t height); static void UninitDIB(void); static int32_t SetupDIB(int32_t width, int32_t height); @@ -97,6 +97,8 @@ static BOOL RegisterWindowClass(void); static BOOL CreateAppWindow(int32_t modenum); static void DestroyAppWindow(void); +static BOOL bDInputInited = FALSE; + // video static int32_t desktopxdim=0,desktopydim=0,desktopbpp=0,modesetusing=-1; int32_t xres=-1, yres=-1, fullscreen=0, bpp=0, bytesperline=0, imageSize=0; @@ -663,7 +665,9 @@ int32_t handleevents(void) //if (frameplace && fullscreen) printf("Offscreen buffer is locked!\n"); RI_PollDevices(); - DI_ProcessDevices(); + + if (bDInputInited) + DI_PollJoysticks(); while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { @@ -693,7 +697,6 @@ int32_t handleevents(void) static HMODULE hDInputDLL = NULL; static LPDIRECTINPUT7A lpDI = NULL; static LPDIRECTINPUTDEVICE7A lpDID[NUM_INPUTS] = { NULL }; -static BOOL bDInputInited = FALSE; #define INPUT_BUFFER_SIZE 32 static GUID guidDevs[NUM_INPUTS]; @@ -1341,7 +1344,7 @@ static void AcquireInputDevices(char acquire, int8_t device) // // ProcessInputDevices() -- processes the input devices // -static inline void DI_ProcessDevices(void) +static inline void DI_PollJoysticks(void) { DWORD i, dwElements = INPUT_BUFFER_SIZE, ev = 0; HRESULT result; @@ -1355,6 +1358,7 @@ static inline void DI_ProcessDevices(void) if (*devicedef[t].did) { result = IDirectInputDevice7_Poll(*devicedef[t].did); + if (result == DIERR_INPUTLOST || result == DIERR_NOTACQUIRED) { if (SUCCEEDED(IDirectInputDevice7_Acquire(*devicedef[t].did))) @@ -1362,10 +1366,7 @@ static inline void DI_ProcessDevices(void) devacquired[t] = 1; IDirectInputDevice7_Poll(*devicedef[t].did); } - else - { - devacquired[t] = 0; - } + else devacquired[t] = 0; } if (devacquired[t]) @@ -1383,52 +1384,53 @@ static inline void DI_ProcessDevices(void) // to be read and input events processed ev = MsgWaitForMultipleObjects(numdevs, waithnds, FALSE, 0, 0); - if ((ev >= WAIT_OBJECT_0) && (ev < (WAIT_OBJECT_0+numdevs))) + if (ev < WAIT_OBJECT_0 || ev > WAIT_OBJECT_0+numdevs) + return; + + switch (idevnums[ev - WAIT_OBJECT_0]) { - switch (idevnums[ev - WAIT_OBJECT_0]) + case JOYSTICK: + if (!lpDID[JOYSTICK]) break; + + result = IDirectInputDevice7_GetDeviceData(lpDID[JOYSTICK], sizeof(DIDEVICEOBJECTDATA), + (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); + + if (result != DI_OK || !dwElements) break; + + for (i=dwElements-1; i>=0; i--) { - case JOYSTICK: // joystick - if (!lpDID[JOYSTICK]) break; - result = IDirectInputDevice7_GetDeviceData(lpDID[JOYSTICK], sizeof(DIDEVICEOBJECTDATA), - (LPDIDEVICEOBJECTDATA)&didod, &dwElements, 0); - if (result == DI_OK) + int32_t j; + + // check axes + for (j=0; j 0) return 0; - if ((OSD_OSDKey() < 128) && (Btolower(scantoasc[OSD_OSDKey()]) == Btolower((uint8_t)wParam))) return 0; - if (!OSD_HandleChar((uint8_t)wParam)) return 0; - keyasciififo[keyasciififoend] = (uint8_t)wParam; - keyasciififoend = ((keyasciififoend+1)&(KEYFIFOSIZ-1)); - //OSD_Printf("WM_CHAR %d, %d-%d\n",wParam,keyasciififoplc,keyasciififoend); - return 0; - - case WM_HOTKEY: - return 0; - case WM_ENTERMENULOOP: case WM_ENTERSIZEMOVE: AcquireInputDevices(0,-1); diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index 89f5870b7..dcd5ce642 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -237,7 +237,6 @@ void G_PlayAnim(const char *fn,char t) ANIM_LoadAnim(animbuf); numframes = ANIM_NumFrames(); - animpal = ANIM_GetPalette(); //setpalette(0L,256L,tempbuf); @@ -251,28 +250,35 @@ void G_PlayAnim(const char *fn,char t) ototalclock = totalclock + 10; - frametime = totalclock; - for (i=1; i 4) && (totalclock > frametime + 60)) + if (i > 4 && totalclock > frametime + 60) { OSD_Printf("WARNING: slowdown in %s, skipping playback\n",fn); goto ENDOFANIMLOOP; } + frametime = totalclock; + + waloff[TILE_ANIM] = (intptr_t)ANIM_DrawFrame(i); + invalidatetile(TILE_ANIM, 0, 1<<4); // JBF 20031228 + while (totalclock < ototalclock) { - if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) - goto ENDOFANIMLOOP; handleevents(); Net_GetPackets(); + + if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) + goto ENDOFANIMLOOP; + if (g_restorePalette == 1) { P_SetGamePalette(g_player[myconnectindex].ps,animpal,0); g_restorePalette = 0; } - idle(); + + rotatesprite(0<<16,0<<16,65536L,512,TILE_ANIM,0,0,2+4+8+16+64, 0,0,xdim-1,ydim-1); + nextpage(); } if (t == 10) ototalclock += 14; @@ -285,11 +291,6 @@ void G_PlayAnim(const char *fn,char t) else if (ud.volume_number == 1) ototalclock += 18; else ototalclock += 10; - waloff[TILE_ANIM] = (intptr_t)ANIM_DrawFrame(i); - invalidatetile(TILE_ANIM, 0, 1<<4); // JBF 20031228 - rotatesprite(0<<16,0<<16,65536L,512,TILE_ANIM,0,0,2+4+8+16+64, 0,0,xdim-1,ydim-1); - nextpage(); - if (t == 8) endanimvol41(i); else if (t == 10) endanimvol42(i); else if (t == 11) endanimvol43(i); @@ -301,7 +302,6 @@ void G_PlayAnim(const char *fn,char t) } ENDOFANIMLOOP: - #if defined(POLYMOST) && defined(USE_OPENGL) gltexfiltermode = ogltexfiltermode; gltexapplyprops(); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 19ed880af..3733e85dd 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -1026,6 +1026,8 @@ void CONFIG_WriteBinds(void) // save binds and aliases to _settings.cfg fprintf(fp,"// these settings take precedence over your main cfg file\n"); fprintf(fp,"// do not modify if you lack common sense\n"); + fprintf(fp,"unbindall\n"); + for (i=0; i 1) && ud.playerai) - TRAVERSE_CONNECT(i) - if (i != myconnectindex) - { - //clearbufbyte(&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t),0L); - computergetinput(i,&inputfifo[0][i]); - } - } } extern int32_t cacnum; @@ -2701,22 +2674,22 @@ static void G_DrawInventory(DukePlayer_t *p) { switch (n&(1<gm&MODE_MENU) - if ((g_currentMenu >= 400 && g_currentMenu <= 405)) - return; -*/ - if (getrendermode() >= 3) pus = NUMPAGES; // JBF 20040101: always redraw in GL if ((g_netServer || (g_netServer || ud.multimode > 1)) && (GametypeFlags[ud.coop] & GAMETYPE_FRAGBAR)) @@ -8929,7 +8896,7 @@ GAME_STATIC void G_HandleLocalKeys(void) int32_t i,ch; int32_t j; - CONTROL_ProcessBinds(); +// CONTROL_ProcessBinds(); if (ud.recstat == 2) { @@ -10489,7 +10456,7 @@ static void G_DisplayLogo(void) flushperms(); nextpage(); - Bsprintf(tempbuf,"%s - " APPNAME,g_gameNamePtr); + Bsprintf(tempbuf, "%s - " APPNAME, g_gameNamePtr); wm_setapptitle(tempbuf); S_StopMusic(); @@ -10532,8 +10499,9 @@ static void G_DisplayLogo(void) nextpage(); fadepaltile(0,0,0, 63,0,-7,DREALMS); totalclock = 0; - while (totalclock < (120*7) && !KB_KeyWaiting() && !MOUSE_GetButtons()&LEFT_MOUSE) + while (totalclock < (120*7) && !KB_KeyWaiting() && !MOUSE_GetButtons()&LEFT_MOUSE && !BUTTON(gamefunc_Fire) && !BUTTON(gamefunc_Open)) { + rotatesprite(0,0,65536L,0,DREALMS,0,0,2+8+16+64, 0,0,xdim-1,ydim-1); handleevents(); Net_GetPackets(); if (g_restorePalette) @@ -10541,6 +10509,7 @@ static void G_DisplayLogo(void) P_SetGamePalette(g_player[myconnectindex].ps,g_player[myconnectindex].ps->palette,0); g_restorePalette = 0; } + nextpage(); } fadepaltile(0,0,0, 0,64,7,DREALMS); } @@ -10579,6 +10548,7 @@ static void G_DisplayLogo(void) rotatesprite(160<<16,(104)<<16,60<<10,0,DUKENUKEM,0,0,2+8,0,0,xdim-1,ydim-1); } else soundanm = 1; + if (logoflags & LOGO_THREEDEE) { if (totalclock > 220 && totalclock < (220+30)) @@ -10596,6 +10566,7 @@ static void G_DisplayLogo(void) rotatesprite(160<<16,(129)<<16,30<<11,0,THREEDEE,0,0,2+8,0,0,xdim-1,ydim-1); } else soundanm = 2; + if (PLUTOPAK && (logoflags & LOGO_PLUTOPAKSPRITE)) { // JBF 20030804 @@ -10618,6 +10589,7 @@ static void G_DisplayLogo(void) rotatesprite(160<<16,(151)<<16,30<<11,0,PLUTOPAKSPRITE+1,0,0,2+8,0,0,xdim-1,ydim-1); } } + VM_OnEvent(EVENT_LOGO, -1, screenpeek, -1); handleevents(); Net_GetPackets(); @@ -11058,7 +11030,7 @@ void G_BackToMenu(void) g_player[myconnectindex].ps->gm = MODE_MENU; ChangeToMenu(0); KB_FlushKeyboardQueue(); - Bsprintf(tempbuf,APPNAME " - %s",g_gameNamePtr); + Bsprintf(tempbuf, "%s - " APPNAME, g_gameNamePtr); wm_setapptitle(tempbuf); } @@ -11586,7 +11558,7 @@ CLEAN_DIRECTORY: // gotta set the proper title after we compile the CONs if this is the full version - Bsprintf(tempbuf,"%s - " APPNAME,g_gameNamePtr); + Bsprintf(tempbuf, "%s - " APPNAME, g_gameNamePtr); wm_setapptitle(tempbuf); if (g_scriptDebug) @@ -11839,22 +11811,41 @@ MAIN_LOOP_RESTART: static uint32_t nextrender = 0, next = 0; uint32_t j; + if (handleevents() && quitevent) + { + KB_KeyDown[sc_Escape] = 1; + quitevent = 0; + } + // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo bindsenabled = g_player[myconnectindex].ps->gm & (MODE_GAME|MODE_DEMO); - // menus now call handleevents() from probe_() - while (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && ready2send && totalclock >= ototalclock+TICSPERFRAME) - { - if (handleevents() && quitevent) - { - // JBF - KB_KeyDown[sc_Escape] = 1; - quitevent = 0; - } + CONTROL_ProcessBinds(); + OSD_DispatchQueued(); - OSD_DispatchQueued(); - G_HandleLocalKeys(); + if (!(g_player[myconnectindex].ps->gm & (MODE_MENU|MODE_DEMO)) && totalclock >= ototalclock+TICSPERFRAME) + { faketimerhandler(); + getinput(myconnectindex); + G_HandleLocalKeys(); + + avg.fvel += loc.fvel; + avg.svel += loc.svel; + avg.avel += loc.avel; + avg.horz += loc.horz; + avg.bits |= loc.bits; + avg.extbits |= loc.extbits; + + Bmemcpy(&inputfifo[0][myconnectindex], &avg, sizeof(input_t)); + Bmemset(&avg, 0, sizeof(input_t)); + + if ((g_netServer || ud.multimode > 1) && ud.playerai) + TRAVERSE_CONNECT(i) + if (i != myconnectindex) + { + //clearbufbyte(&inputfifo[g_player[i].movefifoend&(MOVEFIFOSIZ-1)][i],sizeof(input_t),0L); + computergetinput(i,&inputfifo[0][i]); + } } if (((ud.show_help == 0 && (g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && @@ -11871,8 +11862,7 @@ MAIN_LOOP_RESTART: case 2: goto MAIN_LOOP_RESTART; } } - - if (g_netClient && g_multiMapState) + else if (g_netClient && g_multiMapState) { for (i=g_gameVarCount-1; i>=0; i--) { @@ -11887,13 +11877,12 @@ MAIN_LOOP_RESTART: if (next) { + next--; if (ud.statusbarmode == 1 && (ud.statusbarscale == 100 || !getrendermode())) { ud.statusbarmode = 0; G_UpdateScreenArea(); } - - next--; nextpage(); } @@ -11906,7 +11895,8 @@ MAIN_LOOP_RESTART: nextrender += g_frameDelay; - if ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm&MODE_MENU)) || (g_netServer || ud.multimode > 1) || ud.recstat == 2) + if ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && !(g_player[myconnectindex].ps->gm&MODE_MENU)) || + (g_netServer || ud.multimode > 1) || ud.recstat == 2) i = min(max((totalclock-ototalclock)*(65536L/TICSPERFRAME),0),65536); else i = 65536; @@ -12836,7 +12826,7 @@ void G_BonusScreen(int32_t bonusonly) 350, 380,VICTORY1+8,86,59 }; - Bsprintf(tempbuf,"%s - " APPNAME,g_gameNamePtr); + Bsprintf(tempbuf, "%s - " APPNAME, g_gameNamePtr); wm_setapptitle(tempbuf); if (ud.volume_number == 0 && ud.last_level == 8 && boardfilename[0]) diff --git a/polymer/eduke32/source/gamedefs.h b/polymer/eduke32/source/gamedefs.h index f818e2e87..a5cc1193d 100644 --- a/polymer/eduke32/source/gamedefs.h +++ b/polymer/eduke32/source/gamedefs.h @@ -117,13 +117,9 @@ extern "C" { #define BASECONTROLSCALEVALUE (1<<16) -// MAX mouse sensitivity scale - -#define MAXMOUSESENSITIVITY (1<<17) - // DEFAULT mouse sensitivity scale -#define DEFAULTMOUSESENSITIVITY 18 +#define DEFAULTMOUSESENSITIVITY 7 enum { diff --git a/polymer/eduke32/source/grpscan.c b/polymer/eduke32/source/grpscan.c index ea7ca4cdf..fe066891d 100644 --- a/polymer/eduke32/source/grpscan.c +++ b/polymer/eduke32/source/grpscan.c @@ -15,7 +15,6 @@ struct grpfile grpfiles[numgrpfiles] = { "Duke Nukem 3D: Atomic Edition", 0xFD3DCFF1, 44356548, GAMEDUKE, NULL }, { "Duke Nukem 3D Shareware", 0x983AD923, 11035779, GAMEDUKE, NULL }, { "Duke Nukem 3D Mac Shareware", 0xC5F71561, 10444391, GAMEDUKE, NULL }, -// { "Duke Nukem 3D Mac", 0x00000000, 0, GAMEDUKE, NULL }, { "NAM", 0x75C1F07B, 43448927, GAMENAM, NULL }, { "Napalm", 0x3DE1589A, 44365728, GAMENAM, NULL }, { "WW2GI", 0x907B82BF, 77939508, GAMEWW2, NULL }, diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c index aab1f4990..7dffdb4fc 100644 --- a/polymer/eduke32/source/jmact/control.c +++ b/polymer/eduke32/source/jmact/control.c @@ -754,93 +754,7 @@ void CONTROL_ButtonFunctionState(int32_t *p1) while (i--); } } -/* -void CONTROL_GetUserInput( UserInput *info ) -{ - ControlInfo ci; - CONTROL_PollDevices( &ci ); - - info->dir = dir_None; - - // checks if CONTROL_UserInputDelay is too far in the future due to clock skew? - if (GetTime() + ((ticrate * USERINPUTDELAY) / 1000) < CONTROL_UserInputDelay) - CONTROL_UserInputDelay = -1; - - if (GetTime() >= CONTROL_UserInputDelay) { - if (CONTROL_MouseAxes[1].digital == -1) - info->dir = dir_North; - else if (CONTROL_MouseAxes[1].digital == 1) - info->dir = dir_South; - else if (CONTROL_MouseAxes[0].digital == -1) - info->dir = dir_West; - else if (CONTROL_MouseAxes[0].digital == 1) - info->dir = dir_East; - - if (CONTROL_JoyAxes[1].digital == -1) - info->dir = dir_North; - else if (CONTROL_JoyAxes[1].digital == 1) - info->dir = dir_South; - else if (CONTROL_JoyAxes[0].digital == -1) - info->dir = dir_West; - else if (CONTROL_JoyAxes[0].digital == 1) - info->dir = dir_East; - } - - info->button0 = CONTROL_MouseButtonState[0] | CONTROL_JoyButtonState[0]; - info->button1 = CONTROL_MouseButtonState[1] | CONTROL_JoyButtonState[1]; - - if (KB_KeyDown[sc_kpad_8] || KB_KeyDown[sc_UpArrow]) - info->dir = dir_North; - else if (KB_KeyDown[sc_kpad_2] || KB_KeyDown[sc_DownArrow]) - info->dir = dir_South; - else if (KB_KeyDown[sc_kpad_4] || KB_KeyDown[sc_LeftArrow]) - info->dir = dir_West; - else if (KB_KeyDown[sc_kpad_6] || KB_KeyDown[sc_RightArrow]) - info->dir = dir_East; - - if (KB_KeyDown[BUTTON0_SCAN_1] || KB_KeyDown[BUTTON0_SCAN_2] || KB_KeyDown[BUTTON0_SCAN_3]) - info->button0 = 1; - if (KB_KeyDown[BUTTON1_SCAN]) - info->button1 = 1; - - if (CONTROL_UserInputCleared[1]) { - if (!info->button0) - CONTROL_UserInputCleared[1] = false; - else - info->button0 = false; - } - if (CONTROL_UserInputCleared[2]) { - if (!info->button1) - CONTROL_UserInputCleared[2] = false; - else - info->button1 = false; - } -} - -void CONTROL_ClearUserInput( UserInput *info ) -{ - switch (info->dir) { - case dir_North: - case dir_South: - case dir_East: - case dir_West: - CONTROL_UserInputCleared[0] = true; - CONTROL_UserInputDelay = GetTime() + ((ticrate * USERINPUTDELAY) / 1000); - switch (info->dir) { - case dir_North: KB_KeyDown[sc_UpArrow] = KB_KeyDown[sc_kpad_8] = 0; break; - case dir_South: KB_KeyDown[sc_DownArrow] = KB_KeyDown[sc_kpad_2] = 0; break; - case dir_East: KB_KeyDown[sc_LeftArrow] = KB_KeyDown[sc_kpad_4] = 0; break; - case dir_West: KB_KeyDown[sc_RightArrow] = KB_KeyDown[sc_kpad_6] = 0; break; - default: break; - } - break; - default: break; - } - if (info->button0) CONTROL_UserInputCleared[1] = true; - if (info->button1) CONTROL_UserInputCleared[2] = true; -} -*/ void CONTROL_ClearButton(int32_t whichbutton) { if (CONTROL_CheckRange(whichbutton)) return; @@ -848,38 +762,32 @@ void CONTROL_ClearButton(int32_t whichbutton) CONTROL_Flags[whichbutton].cleared = TRUE; } -inline void CONTROL_ProcessBinds(void) +void CONTROL_ProcessBinds(void) { + int32_t i=MAXBOUNDKEYS-1; + if (!bindsenabled) return; + do { - int32_t i=MAXBOUNDKEYS-1; - - do + if (KeyBindings[i].cmd[0]) { - if (KeyBindings[i].cmd[0] && KB_KeyPressed(i)) + if (KB_KeyPressed(i) && (KeyBindings[i].repeat || (KeyBindings[i].laststate == 0))) { - if (KeyBindings[i].repeat || (KeyBindings[i].laststate == 0)) - OSD_Dispatch(KeyBindings[i].cmd); + OSD_Dispatch(KeyBindings[i].cmd); + KeyBindings[i].laststate = KB_KeyPressed(i); } - KeyBindings[i].laststate = KB_KeyPressed(i); + else KeyBindings[i].laststate = KB_KeyPressed(i); } - while (--i); } - - if (KeyBindings[0].cmd[0] && KB_KeyPressed(0)) - { - if (KeyBindings[0].repeat || (KeyBindings[0].laststate == 0)) - OSD_Dispatch(KeyBindings[0].cmd); - } - KeyBindings[0].laststate = KB_KeyPressed(0); + while (i--); } - void CONTROL_GetInput(ControlInfo *info) { int32_t periphs[CONTROL_NUM_FLAGS]; + int32_t i = CONTROL_NUM_FLAGS-1; CONTROL_PollDevices(info); @@ -890,36 +798,18 @@ void CONTROL_GetInput(ControlInfo *info) CONTROL_ButtonHeldState = CONTROL_ButtonState; CONTROL_ButtonState = 0; - CONTROL_ProcessBinds(); - + do { - int32_t i = CONTROL_NUM_FLAGS-1; + CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i] | extinput[i]); - do - { - CONTROL_SetFlag(i, CONTROL_KeyboardFunctionPressed(i) | periphs[i] | extinput[i]); - - if (CONTROL_Flags[i].cleared == FALSE) BUTTONSET(i, CONTROL_Flags[i].active); - else if (CONTROL_Flags[i].active == FALSE) CONTROL_Flags[i].cleared = 0; - } - while (--i); - - CONTROL_SetFlag(0, CONTROL_KeyboardFunctionPressed(0) | periphs[0] | extinput[0]); - if (CONTROL_Flags[0].cleared == FALSE) BUTTONSET(0, CONTROL_Flags[0].active); - else if (CONTROL_Flags[0].active == FALSE) CONTROL_Flags[0].cleared = 0; + if (CONTROL_Flags[i].cleared == FALSE) BUTTONSET(i, CONTROL_Flags[i].active); + else if (CONTROL_Flags[i].active == FALSE) CONTROL_Flags[i].cleared = 0; } + while (i--); memset(extinput, 0, sizeof(extinput)); } -void CONTROL_WaitRelease(void) -{ -} - -void CONTROL_Ack(void) -{ -} - int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ticspersecond) { int32_t i; diff --git a/polymer/eduke32/source/jmact/control.h b/polymer/eduke32/source/jmact/control.h index 2641ea275..3a3d2132c 100644 --- a/polymer/eduke32/source/jmact/control.h +++ b/polymer/eduke32/source/jmact/control.h @@ -153,17 +153,13 @@ void CONTROL_MapButton int32_t whichfunction, int32_t whichbutton, int32_t doubleclicked, - controldevice device + controldevice device ); void CONTROL_DefineFlag( int32_t which, int32_t toggle ); int32_t CONTROL_FlagActive( int32_t which ); void CONTROL_ClearAssignments( void ); -void CONTROL_GetUserInput( UserInput *info ); void CONTROL_GetInput( ControlInfo *info ); void CONTROL_ClearButton( int32_t whichbutton ); -void CONTROL_ClearUserInput( UserInput *info ); -void CONTROL_WaitRelease( void ); -void CONTROL_Ack( void ); float CONTROL_MouseSensitivity; int32_t CONTROL_Startup ( diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index 248434fb6..41029d0cc 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -109,8 +109,6 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n) { int16_t centre; - handleevents(); - CONTROL_GetInput(&minfo); mi += (minfo.dpitch+minfo.dz); mii += minfo.dyaw; @@ -3678,9 +3676,9 @@ cheat_for_port_credits: mgametextpal(40,118+9+9+9+9,"Advanced mouse setup",MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2+2+2),10); { - int32_t sense = (int32_t)(CONTROL_MouseSensitivity * 2.0f); + int32_t sense = (int32_t)(CONTROL_MouseSensitivity * 4.0f); barsm(248,126,&sense,2,x==(MAXMOUSEBUTTONS-2)*2+2,MENUHIGHLIGHT((MAXMOUSEBUTTONS-2)*2+2),PHX(-7)); - CONTROL_MouseSensitivity = sense / 2.0f; + CONTROL_MouseSensitivity = sense / 4.0f; } if (!ud.mouseaiming) modval(0,1,(int32_t *)&g_myAimMode,1,probey == (MAXMOUSEBUTTONS-2)*2+2+1); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index 60d8395a5..90b552ab1 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -1038,7 +1038,18 @@ static int32_t osdcmd_bind(const osdfuncparm_t *parm) KeyBindings[ConsoleKeys[i].id].key=ConsoleKeys[i].name; - CONTROL_MapKey(CONFIG_FunctionNameToNum(tempbuf), ConsoleKeys[i].id, 0); + // populate the keyboard config menu based on the bind + if (!Bstrncasecmp(tempbuf, "gamefunc_", 9)) + { + j = CONFIG_FunctionNameToNum(tempbuf+9); + + if (j != -1) + { + ud.config.KeyboardKeys[j][1] = ud.config.KeyboardKeys[j][0]; + ud.config.KeyboardKeys[j][0] = ConsoleKeys[i].id; + CONTROL_MapKey(j, ConsoleKeys[i].id, ud.config.KeyboardKeys[j][0]); + } + } if (!OSD_ParsingScript()) OSD_Printf("%s\n",parm->raw); @@ -1055,10 +1066,20 @@ static int32_t osdcmd_unbindall(const osdfuncparm_t *parm) for (i=0; inumparms < 1) return OSDCMD_SHOWHELP; + for (i=0; ConsoleKeys[i].name; i++) if (!Bstrcasecmp(parm->parms[0],ConsoleKeys[i].name)) break; + if (!ConsoleKeys[i].name) { for (i=0; iparms[0],ConsoleButtons[i])) break; + if (i >= MAXMOUSEBUTTONS) return OSDCMD_SHOWHELP; + MouseBindings[i].repeat = 0; MouseBindings[i].cmd[0] = 0; + OSD_Printf("unbound %s\n",ConsoleButtons[i]); + return OSDCMD_OK; } + KeyBindings[ConsoleKeys[i].id].repeat = 0; KeyBindings[ConsoleKeys[i].id].cmd[0] = 0; + OSD_Printf("unbound key %s\n",ConsoleKeys[i].name); + return OSDCMD_OK; } @@ -1131,7 +1161,6 @@ static int32_t osdcmd_restorestate(const osdfuncparm_t *parm) G_RestoreMapState(MapInfo[ud.volume_number*MAXLEVELS+ud.level_number].savedstate); return OSDCMD_OK; } -*/ static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) { @@ -1153,6 +1182,7 @@ static int32_t osdcmd_inittimer(const osdfuncparm_t *parm) OSD_Printf("%s\n",parm->raw); return OSDCMD_OK; } +*/ static int32_t osdcmd_disconnect(const osdfuncparm_t *parm) { @@ -1273,6 +1303,8 @@ static int32_t osdcmd_kickban(const osdfuncparm_t *parm) continue; sscanf(parm->parms[0],"%" PRIxPTR "", &hexaddr); + + // TODO: implement banning logic if (currentPeer->address.host == hexaddr) { @@ -1303,72 +1335,69 @@ static int32_t osdcmd_cvar_set_game(const osdfuncparm_t *parm) { int32_t r = osdcmd_cvar_set(parm); -#ifdef USE_OPENGL - if (r == OSDCMD_OK) + if (r != OSDCMD_OK) return r; + + if (!Bstrcasecmp(parm->name, "r_maxfps")) { - if (!Bstrcasecmp(parm->name, "r_maxfps")) - { - if (r_maxfps) g_frameDelay = (1000/r_maxfps); - else g_frameDelay = 0; + if (r_maxfps) g_frameDelay = (1000/r_maxfps); + else g_frameDelay = 0; + return r; + } + else if (!Bstrcasecmp(parm->name, "r_ambientlight")) + { + r_ambientlightrecip = 1.f/r_ambientlight; + + return r; + } + else if (!Bstrcasecmp(parm->name, "in_mouse")) + { + CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent); + + return r; + } + else if (!Bstrcasecmp(parm->name, "in_joystick")) + { + CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent); + + return r; + } + else if (!Bstrcasecmp(parm->name, "vid_gamma")) + { + ud.brightness = (int32_t)(min(max((float)((vid_gamma-1.0)*10.0),0),15)); + ud.brightness <<= 2; + setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); + + return r; + } + else if (!Bstrcasecmp(parm->name, "vid_brightness")) + { + setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); + + return r; + } + else if (!Bstrcasecmp(parm->name, "vid_contrast")) + { + setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); + + return r; + } + else if (!Bstrcasecmp(parm->name, "hud_scale")) + { + G_UpdateScreenArea(); + + return r; + } + else if (!Bstrcasecmp(parm->name, "skill")) + { + if (numplayers > 1) return r; - } - else if (!Bstrcasecmp(parm->name, "r_ambientlight")) - { - r_ambientlightrecip = 1.f/r_ambientlight; - return r; - } - else if (!Bstrcasecmp(parm->name, "in_mouse")) - { - CONTROL_MouseEnabled = (ud.config.UseMouse && CONTROL_MousePresent); + ud.m_player_skill = ud.player_skill; - return r; - } - else if (!Bstrcasecmp(parm->name, "in_joystick")) - { - CONTROL_JoystickEnabled = (ud.config.UseJoystick && CONTROL_JoyPresent); - - return r; - } - else if (!Bstrcasecmp(parm->name, "vid_gamma")) - { - ud.brightness = (int32_t)(min(max((float)((vid_gamma-1.0)*10.0),0),15)); - ud.brightness <<= 2; - setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - - return r; - } - else if (!Bstrcasecmp(parm->name, "vid_brightness")) - { - setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - - return r; - } - else if (!Bstrcasecmp(parm->name, "vid_contrast")) - { - setbrightness(ud.brightness>>2,&g_player[myconnectindex].ps->palette[0],0); - - return r; - } - else if (!Bstrcasecmp(parm->name, "hud_scale")) - { - G_UpdateScreenArea(); - - return r; - } - else if (!Bstrcasecmp(parm->name, "skill")) - { - if (numplayers > 1) - return r; - - ud.m_player_skill = ud.player_skill; - - return r; - } + return r; } -#endif return r; } @@ -1523,7 +1552,7 @@ int32_t registerosdcommands(void) OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god); OSD_RegisterFunction("initgroupfile","initgroupfile : adds a grp file into the game filesystem", osdcmd_initgroupfile); - OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer); +// OSD_RegisterFunction("inittimer","debug", osdcmd_inittimer); OSD_RegisterFunction("kick","kick : kicks a multiplayer client. See listplayers.", osdcmd_kick); OSD_RegisterFunction("kickban","kickban : kicks a multiplayer client and prevents them from reconnecting. See listplayers.", osdcmd_kickban); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 79d1bc149..5c99f0d59 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2939,7 +2939,6 @@ void P_DisplayWeapon(int32_t snum) } } P_DisplaySpit(snum); - } #define TURBOTURNTIME (TICRATE/8) // 7 @@ -2966,7 +2965,7 @@ void getinput(int32_t snum) int32_t momx = 0,momy = 0; DukePlayer_t *p = g_player[snum].ps; - if ((p->gm&MODE_MENU) || (p->gm&MODE_TYPE) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) + if ((p->gm & (MODE_MENU|MODE_TYPE)) || (ud.pause_on && !KB_KeyPressed(sc_Pause))) { if (!(p->gm&MODE_MENU)) CONTROL_GetInput(&info[0]);