diff --git a/polymer/eduke32/Makefile b/polymer/eduke32/Makefile index 0a0a3ee36..a77030542 100644 --- a/polymer/eduke32/Makefile +++ b/polymer/eduke32/Makefile @@ -95,6 +95,7 @@ JMACTOBJ=$(OBJ)/file_lib.$o \ $(OBJ)/control.$o \ $(OBJ)/keyboard.$o \ $(OBJ)/mouse.$o \ + $(OBJ)/joystick.$o \ $(OBJ)/mathutil.$o \ $(OBJ)/scriplib.$o \ $(OBJ)/animlib.$o @@ -109,6 +110,7 @@ GAMEOBJS=$(OBJ)/game.$o \ $(OBJ)/gameexec.$o \ $(OBJ)/gamevars.$o \ $(OBJ)/global.$o \ + $(OBJ)/input.$o \ $(OBJ)/menus.$o \ $(OBJ)/namesdyn.$o \ $(OBJ)/net.$o \ diff --git a/polymer/eduke32/Makefile.deps b/polymer/eduke32/Makefile.deps index 451812b4d..ccd1cd16a 100644 --- a/polymer/eduke32/Makefile.deps +++ b/polymer/eduke32/Makefile.deps @@ -8,6 +8,8 @@ duke3d_h=\ $(EINC)/cache1d.h \ $(SRC)/jmact/file_lib.h \ $(SRC)/jmact/keyboard.h \ + $(SRC)/jmact/mouse.h \ + $(SRC)/jmact/joystick.h \ $(SRC)/jmact/control.h \ $(SRC)/jmact/mathutil.h \ $(SRC)/macros.h \ @@ -29,23 +31,24 @@ duke3d_h=\ gamedef_h=$(SRC)/gamedef.h $(SRC)/gameexec.h $(SRC)/gamevars.h -$(OBJ)/game.$o: $(SRC)/game.c $(SRC)/jmact/scriplib.h $(duke3d_h) $(INC)/osdfuncs.h $(INC)/osdcmds.h $(INC)/grpscan.h $(INC)/demo.h $(EINC)/hightile.h +$(OBJ)/game.$o: $(SRC)/game.c $(SRC)/jmact/scriplib.h $(duke3d_h) $(SRC)/input.h $(INC)/osdfuncs.h $(INC)/osdcmds.h $(INC)/grpscan.h $(INC)/demo.h $(EINC)/hightile.h $(OBJ)/actors.$o: $(SRC)/actors.c $(duke3d_h) -$(OBJ)/anim.$o: $(SRC)/anim.c $(duke3d_h) $(SRC)/jmact/animlib.h $(SRC)/animvpx.h -$(OBJ)/demo.$o: $(SRC)/demo.c $(duke3d_h) +$(OBJ)/anim.$o: $(SRC)/anim.c $(duke3d_h) $(SRC)/input.h $(SRC)/jmact/animlib.h $(SRC)/animvpx.h +$(OBJ)/demo.$o: $(SRC)/demo.c $(duke3d_h) $(SRC)/input.h $(OBJ)/gamedef.$o: $(SRC)/gamedef.c $(duke3d_h) $(gamedef_h) $(SRC)/savegame.h $(OBJ)/gameexec.$o: $(SRC)/gameexec.c $(SRC)/gamestructures.c $(duke3d_h) $(gamedef_h) $(OBJ)/gamestructures.$o: $(SRC)/gamestructures.c $(duke3d_h) $(gamedef_h) $(OBJ)/gamevars.$o: $(SRC)/gamevars.c $(SRC)/gamestructures.c $(duke3d_h) $(gamedef_h) $(SRC)/savegame.h $(OBJ)/global.$o: $(SRC)/*.c $(SRC)/global.c $(duke3d_h) +$(OBJ)/input.$o: $(SRC)/input.c $(duke3d_h) $(SRC)/input.h $(OBJ)/mdump.$o: $(SRC)/mdump.cpp $(SRC)/mdump.h -$(OBJ)/menus.$o: $(SRC)/menus.c $(duke3d_h) $(SRC)/jmact/mouse.h +$(OBJ)/menus.$o: $(SRC)/menus.c $(duke3d_h) $(SRC)/input.h $(SRC)/jmact/mouse.h $(OBJ)/namesdyn.$o: $(SRC)/namesdyn.c $(duke3d_h) $(OBJ)/net.$o: $(SRC)/net.c $(duke3d_h) $(OBJ)/player.$o: $(SRC)/player.c $(duke3d_h) $(OBJ)/premap.$o: $(SRC)/premap.c $(duke3d_h) $(EINC)/osd.h $(OBJ)/savegame.$o: $(SRC)/savegame.c $(duke3d_h) $(SRC)/savegame.h -$(OBJ)/sector.$o: $(SRC)/sector.c $(duke3d_h) +$(OBJ)/sector.$o: $(SRC)/sector.c $(duke3d_h) $(SRC)/input.h $(OBJ)/sounds.$o: $(SRC)/sounds.c $(duke3d_h) $(OBJ)/rts.$o: $(SRC)/rts.c $(duke3d_h) $(OBJ)/config.$o: $(SRC)/config.c $(duke3d_h) $(SRC)/jmact/scriplib.h $(INC)/_functio.h @@ -106,9 +109,10 @@ $(OBJ)/startgtk.game.$o: $(SRC)/startgtk.game.c $(duke3d_h) $(EINC)/dynamicgtk.h # jMACT objects $(OBJ)/animlib.$o: $(SRC)/jmact/animlib.c $(SRC)/jmact/animlib.h $(EINC)/compat.h $(OBJ)/file_lib.$o: $(SRC)/jmact/file_lib.c $(SRC)/jmact/file_lib.h -$(OBJ)/control.$o: $(SRC)/jmact/control.c $(SRC)/jmact/control.h $(SRC)/jmact/keyboard.h $(SRC)/jmact/mouse.h $(EINC)/baselayer.h +$(OBJ)/control.$o: $(SRC)/jmact/control.c $(SRC)/jmact/control.h $(SRC)/jmact/keyboard.h $(SRC)/jmact/mouse.h $(SRC)/jmact/joystick.h $(EINC)/baselayer.h $(OBJ)/keyboard.$o: $(SRC)/jmact/keyboard.c $(SRC)/jmact/keyboard.h $(EINC)/compat.h $(EINC)/baselayer.h $(OBJ)/mouse.$o: $(SRC)/jmact/mouse.c $(SRC)/jmact/mouse.h $(EINC)/baselayer.h +$(OBJ)/joystick.$o: $(SRC)/jmact/joystick.c $(SRC)/jmact/joystick.h $(EINC)/baselayer.h $(OBJ)/mathutil.$o: $(SRC)/jmact/mathutil.c $(EINC)/compat.h $(EINC)/pragmas.h $(OBJ)/scriplib.$o: $(SRC)/jmact/scriplib.c $(SRC)/jmact/scriplib.h $(SRC)/jmact/_scrplib.h $(EINC)/compat.h diff --git a/polymer/eduke32/Makefile.msvc b/polymer/eduke32/Makefile.msvc index a198ff5ba..3aa4c8617 100644 --- a/polymer/eduke32/Makefile.msvc +++ b/polymer/eduke32/Makefile.msvc @@ -64,6 +64,7 @@ JMACTOBJ=$(OBJ)\file_lib.$o \ $(OBJ)\control.$o \ $(OBJ)\keyboard.$o \ $(OBJ)\mouse.$o \ + $(OBJ)\joystick.$o \ $(OBJ)\mathutil.$o \ $(OBJ)\scriplib.$o @@ -78,6 +79,7 @@ GAMEOBJS=$(OBJ)\game.$o \ $(OBJ)\gameexec.$o \ $(OBJ)\gamevars.$o \ $(OBJ)\global.$o \ + $(OBJ)\input.$o \ $(OBJ)\menus.$o \ $(OBJ)\namesdyn.$o \ $(OBJ)\net.$o \ diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index ba6aaa098..f908814a0 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -133,6 +133,7 @@ void grabmouse(char a); void readmousexy(int32_t *x, int32_t *y); void readmouseabsxy(int32_t *x, int32_t *y); void readmousebstatus(int32_t *b); +void readjoybstatus(int32_t *b); void setjoydeadzone(int32_t axis, uint16_t dead, uint16_t satur); void getjoydeadzone(int32_t axis, uint16_t *dead, uint16_t *satur); diff --git a/polymer/eduke32/build/src/baselayer.c b/polymer/eduke32/build/src/baselayer.c index 326383bdc..1d579c42c 100644 --- a/polymer/eduke32/build/src/baselayer.c +++ b/polymer/eduke32/build/src/baselayer.c @@ -122,6 +122,12 @@ void readmousebstatus(int32_t *b) *b = mouseb; } +void readjoybstatus(int32_t *b) +{ + if (!appactive) { *b = 0; return; } + *b = joyb; +} + #ifdef USE_OPENGL struct glinfo_t glinfo = { diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index baaf4122d..e55d46fba 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -580,11 +580,17 @@ static const char *joynames[3][15] = "Left Stick Y", "Right Stick X", "Right Stick Y", - "wtf4", - "wtf5", - "wtf6", - "wtf7", - "wtf9", + "Axis 5", + "Axis 6", + "Axis 7", + "Axis 8", + "Axis 9", + "Axis 10", + "Axis 11", + "Axis 12", + "Axis 13", + "Axis 14", + "Axis 15", }, { "Button A", @@ -593,21 +599,32 @@ static const char *joynames[3][15] = "Button 2", "Button -", "Button +", - "Button NULL", + "Button HOME", "Button Z", "Button C", "Button X", "Button Y", "Trigger L", "Trigger R", - "Trigger zL", - "Trigger zR", + "Trigger ZL", + "Trigger ZR", }, { - "D-PAD Up", - "D-PAD Right", - "D-PAD Down", - "D-PAD Left", + "D-Pad Up", + "D-Pad Right", + "D-Pad Down", + "D-Pad Left", + "Hat 5", + "Hat 6", + "Hat 7", + "Hat 8", + "Hat 9", + "Hat 10", + "Hat 11", + "Hat 12", + "Hat 13", + "Hat 14", + "Hat 15", } }; const char *getjoyname(int32_t what, int32_t num) diff --git a/polymer/eduke32/source/_functio.h b/polymer/eduke32/source/_functio.h index 097fe3de9..091ad84a0 100644 --- a/polymer/eduke32/source/_functio.h +++ b/polymer/eduke32/source/_functio.h @@ -211,7 +211,7 @@ const char oldkeydefaults[NUMGAMEFUNCTIONS*3][MAXGAMEFUNCLEN] = "Quick_Kick", "`", "", "Next_Weapon", "'", "", "Previous_Weapon", ";", "", - "Show_Console", "`", "", + "Show_Console", "C", "", "Show_DukeMatch_Scores", "", "", "Dpad_Select", "", "", "Dpad_Aiming", "", "", @@ -247,6 +247,145 @@ static char * mouseclickeddefaults[] = }; +static char * mouseanalogdefaults[] = + { + "analog_turning", + "analog_moving", + }; + + +static char * mousedigitaldefaults[] = + { + "", + "", + "", + "", + }; + +#if defined(GEKKO) +static char * joystickdefaults[] = + { + "Open", // A + "Fire", // B + "Run", // 1 + "Map", // 2 + "Previous_Weapon", // - + "Next_Weapon", // + + "", // Home + "Jump", // Z + "Crouch", // C + "Map", // X + "Run", // Y + "Jump", // L + "Fire", // R + "Crouch", // ZL + "Inventory", // ZR + "Quick_Kick", // D-Pad Up + "Inventory_Right", // D-Pad Right + "Inventory", // D-Pad Down + "Inventory_Left", // D-Pad Left + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; + + +static char * joystickclickeddefaults[] = + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; + + +static char * joystickanalogdefaults[] = + { + "analog_strafing", + "analog_moving", + "analog_turning", + "analog_lookingupanddown", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; + + +static char * joystickdigitaldefaults[] = + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + }; +#else static char * joystickdefaults[] = { "Fire", @@ -329,22 +468,6 @@ static char * joystickclickeddefaults[] = }; -static char * mouseanalogdefaults[] = - { - "analog_turning", - "analog_moving", - }; - - -static char * mousedigitaldefaults[] = - { - "", - "", - "", - "", - }; - - static char * joystickanalogdefaults[] = { "analog_turning", @@ -378,6 +501,8 @@ static char * joystickdigitaldefaults[] = "", }; #endif + +#endif #ifdef __cplusplus }; #endif diff --git a/polymer/eduke32/source/anim.c b/polymer/eduke32/source/anim.c index 1adb71dfc..d1ec7b319 100644 --- a/polymer/eduke32/source/anim.c +++ b/polymer/eduke32/source/anim.c @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "animlib.h" #include "mouse.h" #include "compat.h" +#include "input.h" #include "anim.h" @@ -231,9 +232,9 @@ void G_PlayAnim(const char *fn,char t) // 11: vol4e3 if (t != 7 && t != 9 && t != 10 && t != 11) - KB_FlushKeyboardQueue(); + I_ClearAllInput(); - if (KB_KeyWaiting()) + if (I_CheckAllInput()) { FX_StopAllSounds(); goto ENDOFANIMLOOP; @@ -327,12 +328,14 @@ void G_PlayAnim(const char *fn,char t) palfadedelta = 0; showframe(0); + I_ClearAllInput(); + do { handleevents(); Net_GetPackets(); - if (KB_KeyWaiting() || (MOUSE_GetButtons()&LEFT_MOUSE)) + if (I_CheckAllInput()) { running = 0; break; @@ -346,7 +349,7 @@ void G_PlayAnim(const char *fn,char t) animvpx_restore_glstate(); animvpx_uninit_codec(&codec); - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearAllInput(); return; // done with playing VP8! } #endif @@ -395,12 +398,14 @@ void G_PlayAnim(const char *fn,char t) waloff[TILE_ANIM] = (intptr_t)ANIM_DrawFrame(i); invalidatetile(TILE_ANIM, 0, 1<<4); // JBF 20031228 + I_ClearAllInput(); + while (totalclock < ototalclock) { handleevents(); Net_GetPackets(); - if (KB_KeyWaiting() || MOUSE_GetButtons()&LEFT_MOUSE) + if (I_CheckAllInput()) goto ENDOFANIMLOOP; if (g_restorePalette == 1) @@ -441,7 +446,7 @@ ENDOFANIMLOOP: gltexfiltermode = ogltexfiltermode; gltexapplyprops(); #endif - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearAllInput(); ANIM_FreeAnim(); walock[TILE_ANIM] = 1; } diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index e96662175..279735a7d 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -299,7 +299,7 @@ void CONFIG_SetDefaults(void) memset(ud.config.MouseDigitalFunctions, -1, sizeof(ud.config.MouseDigitalFunctions)); for (i=0; i 1) + if (foundemo == 0 || in_menu || I_CheckAllInput() || numplayers > 1) { FX_StopAllSounds(); S_ClearSoundLocks(); @@ -391,7 +392,7 @@ RECHECK: ready2send = 0; bigi = 0; - KB_FlushKeyboardQueue(); + I_ClearAllInput(); // OSD_Printf("ticcnt=%d, total=%d\n", g_demo_cnt, g_demo_totalCnt); while (g_demo_cnt < g_demo_totalCnt || foundemo==0) @@ -637,9 +638,9 @@ nextdemo: if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) goto RECHECK; - if (KB_KeyPressed(sc_Escape) && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && (g_player[myconnectindex].ps->gm&MODE_TYPE) == 0) + if (I_EscapeTrigger() && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0 && (g_player[myconnectindex].ps->gm&MODE_TYPE) == 0) { - KB_ClearKeyDown(sc_Escape); + I_EscapeTriggerClear(); FX_StopAllSounds(); S_ClearSoundLocks(); g_player[myconnectindex].ps->gm |= MODE_MENU; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 6fc92607c..8beb08830 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gamedefs.h" #include "keyboard.h" #include "mouse.h" // JBF 20030809 +#include "joystick.h" #include "function.h" #include "control.h" #include "fx_man.h" @@ -53,6 +54,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "demo.h" #include "common.h" #include "common_game.h" +#include "input.h" #ifdef LUNATIC # include "lunatic.h" @@ -274,7 +276,7 @@ static int32_t sbarsc(int32_t sc) return scale(sc,ud.statusbarscale,100); } -static int32_t textsc(int32_t sc) +int32_t textsc(int32_t sc) { // prevent ridiculousness to a degree if (xdim <= 320) return sc; @@ -1929,11 +1931,6 @@ void P_DoQuote(int32_t q, DukePlayer_t *p) ////////// OFTEN-USED FEW-LINERS ////////// -static int32_t check_input_waiting(void) -{ - return KB_KeyWaiting() || (MOUSE_GetButtons()&LEFT_MOUSE) || BUTTON(gamefunc_Fire) || BUTTON(gamefunc_Open); -} - static void G_HandleAsync(void) { handleevents(); @@ -1942,18 +1939,26 @@ static void G_HandleAsync(void) static void handle_events_while_no_input(void) { - while (!check_input_waiting()) + I_ClearInputWaiting(); + + while (!I_CheckInputWaiting()) G_HandleAsync(); + + I_ClearInputWaiting(); } static int32_t play_sound_while_no_input(int32_t soundnum) { S_PlaySound(soundnum); + I_ClearInputWaiting(); while (S_CheckSoundPlaying(-1, soundnum)) { G_HandleAsync(); - if (check_input_waiting()) + if (I_CheckInputWaiting()) + { + I_ClearInputWaiting(); return 1; + } } return 0; @@ -2041,17 +2046,17 @@ static void G_DisplayExtraScreens(void) //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0 /*1*/); // JBF 20040308 fadepal(0,0,0, 0,63,7); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); rotatesprite_fs(0,0,65536L,0,3291,0,0,2+8+16+64+(ud.bgstretch?1024:0)); fadepaltile(0,0,0, 63,0,-7, 3291); - while (!KB_KeyWaiting()) + while (!I_CheckAllInput()) G_HandleAsync(); fadepaltile(0,0,0, 0,63,7, 3291); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); rotatesprite_fs(0,0,65536L,0,3290,0,0,2+8+16+64+(ud.bgstretch?1024:0)); fadepaltile(0,0,0, 63,0,-7,3290); - while (!KB_KeyWaiting()) + while (!I_CheckAllInput()) G_HandleAsync(); } @@ -2062,11 +2067,14 @@ static void G_DisplayExtraScreens(void) //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0 /*1*/); // JBF 20040308 fadepal(0,0,0, 0,63,7); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); rotatesprite_fs(0,0,65536L,0,TENSCREEN,0,0,2+8+16+64+(ud.bgstretch?1024:0)); fadepaltile(0,0,0, 63,0,-7,TENSCREEN); - while (!KB_KeyWaiting() && totalclock < 2400) + while (!I_CheckAllInput() && totalclock < 2400) G_HandleAsync(); + + fadepaltile(0,0,0, 0,63,7, TENSCREEN); + I_ClearAllInput(); } } @@ -2117,85 +2125,6 @@ void G_GameExit(const char *msg) exit(0); } -char inputloc = 0; - -int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c) -{ - char ch; - int32_t i; - - while ((ch = KB_Getch()) != 0 || (g_player[myconnectindex].ps->gm&MODE_MENU && MOUSE_GetButtons()&RIGHT_MOUSE)) - { - if (ch == asc_BackSpace) - { - if (inputloc > 0) - { - inputloc--; - *(t+inputloc) = 0; - } - } - else - { - if (ch == asc_Enter) - { - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - return (1); - } - else if (ch == asc_Escape || (g_player[myconnectindex].ps->gm&MODE_MENU && MOUSE_GetButtons()&RIGHT_MOUSE)) - { - KB_ClearKeyDown(sc_Escape); - MOUSE_ClearButton(RIGHT_MOUSE); - return (-1); - } - else if (ch >= 32 && inputloc < dalen && ch < 127) - { - ch = Btoupper(ch); - if (c != 997 || (ch >= '0' && ch <= '9')) - { - // JBF 20040508: so we can have numeric only if we want - *(t+inputloc) = ch; - *(t+inputloc+1) = 0; - inputloc++; - } - } - } - } - - if (c == 999) return(0); - if (c == 998) - { - char b[91],ii; - for (ii=0; iigm&MODE_TYPE) - x = mpgametext(y,b,c,2+8+16); - else x = gametext(x,y,b,c,2+8+16); - } - else - { - if (g_player[myconnectindex].ps->gm&MODE_TYPE) - x = mpgametext(y,t,c,2+8+16); - else x = gametext(x,y,t,c,2+8+16); - } - c = 4-(sintable[(totalclock<<4)&2047]>>11); - - i = G_GameTextLen(USERQUOTE_LEFTOFFSET,OSD_StripColors(tempbuf,t)); - while (i > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) - { - i -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET); - if (small&1) - y += textsc(6); - y += 8; - } - - if (small&1) - rotatesprite_fs(textsc(x)<<16,(y<<16),32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,(small&1)?(8|16):2+8); - else rotatesprite_fs((x+((small&1)?4:8))<<16,((y+((small&1)?0:4))<<16),32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,(small&1)?(8|16):2+8); - return (0); -} - static inline void G_MoveClouds(void) { @@ -2737,10 +2666,9 @@ void G_DisplayRest(int32_t smoothratio) break; } - if (KB_KeyPressed(sc_Escape) || MOUSE_GetButtons()&RIGHT_MOUSE) + if (I_ReturnTrigger()) { - KB_ClearKeyDown(sc_Escape); - MOUSE_ClearButton(RIGHT_MOUSE); + I_ReturnTriggerClear(); ud.show_help = 0; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { @@ -2864,13 +2792,14 @@ void G_DisplayRest(int32_t smoothratio) } } - if (KB_KeyPressed(sc_Escape) && ud.overhead_on == 0 + if (I_EscapeTrigger() && ud.overhead_on == 0 && ud.show_help == 0 && g_player[myconnectindex].ps->newowner == -1) { if ((g_player[myconnectindex].ps->gm&MODE_MENU) == MODE_MENU && g_currentMenu < 51) { - KB_ClearKeyDown(sc_Escape); + I_EscapeTriggerClear(); + S_PlaySound(EXITMENUSOUND); g_player[myconnectindex].ps->gm &= ~MODE_MENU; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { @@ -2886,7 +2815,7 @@ void G_DisplayRest(int32_t smoothratio) g_player[myconnectindex].ps->newowner == -1 && (g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE) { - KB_ClearKeyDown(sc_Escape); + I_EscapeTriggerClear(); FX_StopAllSounds(); S_ClearSoundLocks(); @@ -7817,7 +7746,7 @@ void G_HandleLocalKeys(void) inputloc = 0; } - if (KB_UnBoundKeyPressed(sc_F1)/* || (ud.show_help && (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || MOUSE_GetButtons()&LEFT_MOUSE))*/) + if (KB_UnBoundKeyPressed(sc_F1)/* || (ud.show_help && I_AdvanceTrigger())*/) { KB_ClearKeyDown(sc_F1); ChangeToMenu(400); @@ -7834,10 +7763,7 @@ void G_HandleLocalKeys(void) } /* - KB_ClearKeyDown(sc_Space); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_Enter); - MOUSE_ClearButton(LEFT_MOUSE); + I_AdvanceTriggerClear(); ud.show_help ++; if (ud.show_help > 2) @@ -8064,9 +7990,9 @@ FAKE_F3: } } - if (KB_KeyPressed(sc_Escape) && ud.overhead_on && g_player[myconnectindex].ps->newowner == -1) + if (I_EscapeTrigger() && ud.overhead_on && g_player[myconnectindex].ps->newowner == -1) { - KB_ClearKeyDown(sc_Escape); + I_EscapeTriggerClear(); ud.last_overhead = ud.overhead_on; ud.overhead_on = 0; ud.scrollmode = 0; @@ -9222,8 +9148,7 @@ static void G_DisplayLogo(void) ready2send = 0; - KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); // JBF + I_ClearAllInput(); setview(0,0,xdim-1,ydim-1); clearview(0L); @@ -9243,13 +9168,12 @@ static void G_DisplayLogo(void) if (VOLUMEALL && (logoflags & LOGO_PLAYANIM)) { - if (!KB_KeyWaiting() && g_noLogoAnim == 0) + if (!I_CheckAllInput() && g_noLogoAnim == 0) { Net_GetPackets(); G_PlayAnim("logo.anm",5); G_FadePalette(0,0,0,63); - KB_FlushKeyboardQueue(); - KB_ClearKeysDown(); // JBF + I_ClearAllInput(); } clearview(0L); @@ -9278,7 +9202,7 @@ static void G_DisplayLogo(void) nextpage(); fadepaltile(0,0,0, 63,0,-7,DREALMS); totalclock = 0; - while (totalclock < (120*7) && !check_input_waiting()) + while (totalclock < (120*7) && !I_CheckInputWaiting()) { if (getrendermode() >= 3) clearview(0); @@ -9296,8 +9220,7 @@ static void G_DisplayLogo(void) } fadepaltile(0,0,0, 0,63,7,DREALMS); } - KB_ClearKeysDown(); // JBF - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearInputWaiting(); } clearview(0L); @@ -9316,7 +9239,7 @@ static void G_DisplayLogo(void) fadepaltile(0,0,0, 63,0,-7,BETASCREEN); totalclock = 0; - while (totalclock < (860+120) && !KB_KeyWaiting() && !(MOUSE_GetButtons()&LEFT_MOUSE) && !BUTTON(gamefunc_Fire) && !BUTTON(gamefunc_Open)) + while (totalclock < (860+120) && !I_CheckInputWaiting()) { if (getrendermode() >= 3) clearview(0); @@ -9391,8 +9314,7 @@ static void G_DisplayLogo(void) nextpage(); } } - KB_ClearKeysDown(); // JBF - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearInputWaiting(); } flushperms(); @@ -10977,12 +10899,14 @@ static void G_DoOrderScreen(void) for (i=0; i<4; i++) { fadepal(0,0,0, 0,63,7); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); rotatesprite_fs(0,0,65536L,0,ORDERING+i,0,0,2+8+16+64+(ud.bgstretch?1024:0)); fadepal(0,0,0, 63,0,-7); - while (!KB_KeyWaiting()) + while (!I_CheckAllInput()) G_HandleAsync(); } + + I_ClearAllInput(); } @@ -11061,7 +10985,7 @@ void G_BonusScreen(int32_t bonusonly) //g_player[myconnectindex].ps->palette = endingpal; fadepal(0,0,0, 63,0,-1); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); totalclock = 0; // tinc = 0; while (1) @@ -11110,13 +11034,14 @@ void G_BonusScreen(int32_t bonusonly) G_HandleAsync(); nextpage(); - if (KB_KeyWaiting()) break; + if (I_CheckAllInput()) break; } } fadepal(0,0,0, 0,63,1); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); + I_ClearInputWaiting(); //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2/*+1*/); // JBF 20040308 @@ -11137,7 +11062,7 @@ void G_BonusScreen(int32_t bonusonly) if (ud.lockout == 0) { G_PlayAnim("cineov2.anm",1); - KB_FlushKeyBoardQueue(); + I_ClearInputWaiting(); clearview(0L); nextpage(); } @@ -11146,7 +11071,7 @@ void G_BonusScreen(int32_t bonusonly) fadepal(0,0,0, 0,63,1); setview(0,0,xdim-1,ydim-1); - KB_FlushKeyboardQueue(); + I_ClearInputWaiting(); //g_player[myconnectindex].ps->palette = palette; P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 8+2/*+1*/); // JBF 20040308 rotatesprite_fs(0,0,65536L,0,3293,0,0,2+8+16+64+(ud.bgstretch?1024:0)); @@ -11165,7 +11090,7 @@ void G_BonusScreen(int32_t bonusonly) if (ud.lockout == 0) { - KB_FlushKeyboardQueue(); + I_ClearInputWaiting(); G_PlayAnim("vol4e1.anm",8); clearview(0L); nextpage(); @@ -11180,7 +11105,7 @@ void G_BonusScreen(int32_t bonusonly) FX_StopAllSounds(); S_ClearSoundLocks(); S_PlaySound(ENDSEQVOL3SND4); - KB_FlushKeyBoardQueue(); + I_ClearInputWaiting(); //g_player[myconnectindex].ps->palette = palette; G_FadePalette(0,0,0,0); @@ -11196,17 +11121,16 @@ void G_BonusScreen(int32_t bonusonly) fadepal(0,0,0, 63,0,-3); nextpage(); - KB_FlushKeyboardQueue(); + I_ClearInputWaiting(); handle_events_while_no_input(); fadepal(0,0,0, 0,63,3); clearview(0L); nextpage(); - MOUSE_ClearButton(LEFT_MOUSE); G_PlayAnim("DUKETEAM.ANM",4); - KB_FlushKeyBoardQueue(); + I_ClearInputWaiting(); handle_events_while_no_input(); clearview(0L); @@ -11215,8 +11139,7 @@ void G_BonusScreen(int32_t bonusonly) FX_StopAllSounds(); S_ClearSoundLocks(); - KB_FlushKeyBoardQueue(); - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearInputWaiting(); break; @@ -11228,7 +11151,7 @@ void G_BonusScreen(int32_t bonusonly) { fadepal(0,0,0, 63,0,-1); G_PlayAnim("cineov3.anm",2); - KB_FlushKeyBoardQueue(); + I_ClearInputWaiting(); ototalclock = totalclock+200; while (totalclock < ototalclock) G_HandleAsync(); @@ -11241,7 +11164,7 @@ void G_BonusScreen(int32_t bonusonly) G_PlayAnim("RADLOGO.ANM",3); - if (ud.lockout == 0 && !check_input_waiting()) + if (ud.lockout == 0 && !I_CheckInputWaiting()) { if (play_sound_while_no_input(ENDSEQVOL3SND5)) goto ENDANM; if (play_sound_while_no_input(ENDSEQVOL3SND6)) goto ENDANM; @@ -11250,13 +11173,15 @@ void G_BonusScreen(int32_t bonusonly) if (play_sound_while_no_input(ENDSEQVOL3SND9)) goto ENDANM; } - MOUSE_ClearButton(LEFT_MOUSE); - KB_FlushKeyBoardQueue(); + I_ClearInputWaiting(); + totalclock = 0; if (PLUTOPAK) { - while (totalclock < 120 && !check_input_waiting()) + while (totalclock < 120 && !I_CheckInputWaiting()) G_HandleAsync(); + + I_ClearInputWaiting(); } else { @@ -11275,8 +11200,7 @@ ENDANM: G_PlayAnim("DUKETEAM.ANM",4); - KB_FlushKeyBoardQueue(); - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearInputWaiting(); handle_events_while_no_input(); clearview(0L); @@ -11284,12 +11208,10 @@ ENDANM: G_FadePalette(0,0,0,63); } - MOUSE_ClearButton(LEFT_MOUSE); + I_ClearInputWaiting(); FX_StopAllSounds(); S_ClearSoundLocks(); - KB_FlushKeyBoardQueue(); - clearview(0L); break; @@ -11378,11 +11300,11 @@ FRAGBONUS: fadepal(0,0,0, 63,0,-7); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); { int32_t tc = totalclock; - while (KB_KeyWaiting()==0) + while (I_CheckAllInput()==0) { // continue after 10 seconds... if (totalclock > tc + (120*10)) break; @@ -11419,7 +11341,7 @@ FRAGBONUS: S_PlaySound(BONUSMUSIC); nextpage(); - KB_FlushKeyboardQueue(); + I_ClearAllInput(); fadepal(0,0,0, 63,0,-1); bonuscnt = 0; totalclock = 0; @@ -11670,9 +11592,9 @@ FRAGBONUS: if (totalclock > 10240 && totalclock < 10240+10240) totalclock = 1024; - if (((MOUSE_GetButtons()&7) || KB_KeyWaiting() || BUTTON(gamefunc_Fire) || BUTTON(gamefunc_Open)) && totalclock > (60*2)) // JBF 20030809 + if (I_CheckAllInput() && totalclock > (60*2)) // JBF 20030809 { - MOUSE_ClearButton(7); + I_ClearAllInput(); if (totalclock < (60*13)) { KB_FlushKeyboardQueue(); diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index 24b2c7de0..3c3239bac 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -251,7 +251,6 @@ int32_t G_DoMoveThings(void); int32_t G_GameTextLen(int32_t x,const char *t); int32_t G_PrintGameText(int32_t f,int32_t tile,int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t o,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z); int32_t GetTime(void); -int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c); int32_t kopen4loadfrommod(const char *filename,char searchfirst); int32_t minitext_(int32_t x,int32_t y,const char *t,int32_t s,int32_t p,int32_t sb); int32_t mpgametext(int32_t y,const char *t,int32_t s,int32_t dabits); @@ -299,6 +298,7 @@ void G_Shutdown(void); void G_UpdatePlayerFromMenu(void); void M32RunScript(const char *s); void P_DoQuote(int32_t q,DukePlayer_t *p); +extern int32_t textsc(int32_t sc); void P_SetGamePalette(DukePlayer_t *player,uint8_t palid,int32_t set); int32_t app_main(int32_t argc,const char **argv); void computergetinput(int32_t snum,input_t *syn); diff --git a/polymer/eduke32/source/gamedefs.h b/polymer/eduke32/source/gamedefs.h index 2e0a5c04c..209d7f4a2 100644 --- a/polymer/eduke32/source/gamedefs.h +++ b/polymer/eduke32/source/gamedefs.h @@ -117,7 +117,20 @@ extern "C" { // DEFAULT mouse sensitivity scale -#define DEFAULTMOUSESENSITIVITY 7 +#define DEFAULTMOUSESENSITIVITY 7 +#define DEFAULTMOUSEANALOGUESCALE 65536 + +// DEFAULT joystick settings + +#if defined(GEKKO) +#define DEFAULTJOYSTICKANALOGUESCALE 16384 +#define DEFAULTJOYSTICKANALOGUEDEAD 1000 +#define DEFAULTJOYSTICKANALOGUESATURATE 9500 +#else +#define DEFAULTJOYSTICKANALOGUESCALE 65536 +#define DEFAULTJOYSTICKANALOGUEDEAD 1000 +#define DEFAULTJOYSTICKANALOGUESATURATE 9500 +#endif enum { diff --git a/polymer/eduke32/source/input.c b/polymer/eduke32/source/input.c new file mode 100644 index 000000000..b440c6549 --- /dev/null +++ b/polymer/eduke32/source/input.c @@ -0,0 +1,332 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010 EDuke32 developers and contributors + +This file is part of EDuke32. + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +//------------------------------------------------------------------------- + +#include "global.h" +#include "game.h" +#include "function.h" +#include "keyboard.h" +#include "mouse.h" +#include "joystick.h" +#include "control.h" +#include "input.h" + +int32_t I_CheckAllInput(void) +{ + return ( + KB_KeyWaiting() || + MOUSE_GetButtons() || + JOYSTICK_GetButtons() + ); +} +void I_ClearAllInput(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeysDown(); + MOUSE_ClearAllButtons(); + JOYSTICK_ClearAllButtons(); +} + +int32_t I_CheckInputWaiting(void) +{ + return ( + KB_KeyWaiting() || + (MOUSE_GetButtons()&LEFT_MOUSE) || + I_JoystickAdvanceTrigger() + ); +} +int32_t I_ClearInputWaiting(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeysDown(); // JBF + I_JoystickAdvanceTriggerClear(); + return ( + MOUSE_ClearButton(LEFT_MOUSE) + ); +} + +int32_t I_JoystickAdvanceTrigger(void) +{ + return ( + BUTTON(gamefunc_Jump) || +#if defined(GEKKO) + (JOYSTICK_GetButtons()&WII_A) +#else + BUTTON(gamefunc_Open) || + BUTTON(gamefunc_Fire) +#endif + ); +} +int32_t I_JoystickAdvanceTriggerClear(void) +{ + CONTROL_ClearButton(gamefunc_Jump); +#if defined(GEKKO) + return JOYSTICK_ClearButton(WII_A); +#else + CONTROL_ClearButton(gamefunc_Open); + CONTROL_ClearButton(gamefunc_Fire); + return 0; +#endif +} +int32_t I_JoystickReturnTrigger(void) +{ + return ( + BUTTON(gamefunc_Crouch) +#if defined(GEKKO) + || (JOYSTICK_GetButtons()&(WII_B|WII_HOME)) +#endif + ); +} +int32_t I_JoystickReturnTriggerClear(void) +{ + CONTROL_ClearButton(gamefunc_Crouch); + return ( +#if defined(GEKKO) + JOYSTICK_ClearButton(WII_B) || + JOYSTICK_ClearButton(WII_HOME) +#else + 0 +#endif + ); +} +int32_t I_JoystickEscapeTrigger(void) +{ + return ( +#if defined(GEKKO) + (JOYSTICK_GetButtons()&WII_HOME) +#else + 0 +#endif + ); +} +int32_t I_JoystickEscapeTriggerClear(void) +{ + return ( +#if defined(GEKKO) + JOYSTICK_ClearButton(WII_HOME) +#else + 0 +#endif + ); +} + +int32_t I_AdvanceTrigger(void) +{ + return ( + KB_KeyPressed(sc_Space) || + KB_KeyPressed(sc_kpad_Enter) || + KB_KeyPressed(sc_Enter) || + (MOUSE_GetButtons()&LEFT_MOUSE) || + I_JoystickAdvanceTrigger() + ); +} +int32_t I_AdvanceTriggerClear(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeyDown(sc_Space); + KB_ClearKeyDown(sc_kpad_Enter); + KB_ClearKeyDown(sc_Enter); + I_JoystickAdvanceTriggerClear(); + return ( + MOUSE_ClearButton(LEFT_MOUSE) + ); +} +int32_t I_ReturnTrigger(void) +{ + return ( + KB_KeyPressed(sc_Escape) || + (MOUSE_GetButtons()&RIGHT_MOUSE) || + I_JoystickReturnTrigger() + ); +} +int32_t I_ReturnTriggerClear(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeyDown(sc_Escape); + return ( + MOUSE_ClearButton(RIGHT_MOUSE) || + I_JoystickReturnTriggerClear() + ); +} +int32_t I_EscapeTrigger(void) +{ + return ( + KB_KeyPressed(sc_Escape) || + I_JoystickEscapeTrigger() + ); +} +int32_t I_EscapeTriggerClear(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeyDown(sc_Escape); + return ( + I_JoystickEscapeTriggerClear() + ); +} + + + +int32_t I_PanelUp(void) +{ + return ( + KB_KeyPressed(sc_LeftArrow) || + KB_KeyPressed(sc_kpad_4) || + KB_KeyPressed(sc_UpArrow) || + KB_KeyPressed(sc_kpad_8) || + KB_KeyPressed(sc_PgUp) || + (MOUSE_GetButtons()&WHEELUP_MOUSE) || + BUTTON(gamefunc_Move_Forward) || + BUTTON(gamefunc_Turn_Left) || + BUTTON(gamefunc_Strafe_Left) || + (JOYSTICK_GetHat(0)&HAT_UP) + ); +} +int32_t I_PanelUpClear(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeyDown(sc_LeftArrow); + KB_ClearKeyDown(sc_kpad_4); + KB_ClearKeyDown(sc_UpArrow); + KB_ClearKeyDown(sc_kpad_8); + KB_ClearKeyDown(sc_PgUp); + CONTROL_ClearButton(gamefunc_Move_Forward); + CONTROL_ClearButton(gamefunc_Turn_Left); + CONTROL_ClearButton(gamefunc_Strafe_Left); + JOYSTICK_ClearHat(0); + return ( + MOUSE_ClearButton(WHEELUP_MOUSE) + ); +} + +int32_t I_PanelDown(void) +{ + return ( + KB_KeyPressed(sc_RightArrow) || + KB_KeyPressed(sc_kpad_6) || + KB_KeyPressed(sc_DownArrow) || + KB_KeyPressed(sc_kpad_2) || + KB_KeyPressed(sc_PgDn) || + (MOUSE_GetButtons()&WHEELDOWN_MOUSE) || + BUTTON(gamefunc_Move_Backward) || + BUTTON(gamefunc_Turn_Right) || + BUTTON(gamefunc_Strafe_Right) || + (JOYSTICK_GetHat(0)&HAT_DOWN) || + I_AdvanceTrigger() + ); +} +int32_t I_PanelDownClear(void) +{ + KB_FlushKeyBoardQueue(); + KB_ClearKeyDown(sc_RightArrow); + KB_ClearKeyDown(sc_kpad_6); + KB_ClearKeyDown(sc_DownArrow); + KB_ClearKeyDown(sc_kpad_2); + KB_ClearKeyDown(sc_PgDn); + CONTROL_ClearButton(gamefunc_Move_Backward); + CONTROL_ClearButton(gamefunc_Turn_Right); + CONTROL_ClearButton(gamefunc_Strafe_Right); + JOYSTICK_ClearHat(0); + return ( + MOUSE_ClearButton(WHEELDOWN_MOUSE) || + I_AdvanceTriggerClear() + ); +} + + + + + +char inputloc = 0; + +int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c) +{ + char ch; + int32_t i; + + while ((ch = KB_Getch()) != 0) + { + if (ch == asc_BackSpace) + { + if (inputloc > 0) + { + inputloc--; + *(t+inputloc) = 0; + } + } + else + { + if (ch == asc_Enter) + { + I_AdvanceTriggerClear(); + return (1); + } + else if (ch == asc_Escape) + { + I_ReturnTriggerClear(); + return (-1); + } + else if (ch >= 32 && inputloc < dalen && ch < 127) + { + ch = Btoupper(ch); + if (c != 997 || (ch >= '0' && ch <= '9')) + { + // JBF 20040508: so we can have numeric only if we want + *(t+inputloc) = ch; + *(t+inputloc+1) = 0; + inputloc++; + } + } + } + } + + if (c == 999) return(0); + if (c == 998) + { + char b[91],ii; + for (ii=0; iigm&MODE_TYPE) + x = mpgametext(y,b,c,2+8+16); + else x = gametext(x,y,b,c,2+8+16); + } + else + { + if (g_player[myconnectindex].ps->gm&MODE_TYPE) + x = mpgametext(y,t,c,2+8+16); + else x = gametext(x,y,t,c,2+8+16); + } + c = 4-(sintable[(totalclock<<4)&2047]>>11); + + i = G_GameTextLen(USERQUOTE_LEFTOFFSET,OSD_StripColors(tempbuf,t)); + while (i > (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET)) + { + i -= (ud.config.ScreenWidth - USERQUOTE_RIGHTOFFSET); + if (small&1) + y += textsc(6); + y += 8; + } + + if (small&1) + rotatesprite_fs(textsc(x)<<16,(y<<16),32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,(small&1)?(8|16):2+8); + else rotatesprite_fs((x+((small&1)?4:8))<<16,((y+((small&1)?0:4))<<16),32768,0,SPINNINGNUKEICON+((totalclock>>3)%7),c,0,(small&1)?(8|16):2+8); + return (0); +} diff --git a/polymer/eduke32/source/input.h b/polymer/eduke32/source/input.h new file mode 100644 index 000000000..7d0c4d5ad --- /dev/null +++ b/polymer/eduke32/source/input.h @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010 EDuke32 developers and contributors + +This file is part of EDuke32. + +EDuke32 is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +//------------------------------------------------------------------------- + +#ifndef __input_h__ +#define __input_h__ + +extern int32_t I_CheckAllInput(void); +extern void I_ClearAllInput(void); + +extern int32_t I_CheckInputWaiting(void); +extern int32_t I_ClearInputWaiting(void); + +// Advance = Selecting a menu option || Saying "Yes" || Going forward in Help/Credits +// Return = Closing a sub-menu || Saying "No" +// Escape = Opening the menu in-game (should not be any gamefuncs) + +// Joysticks have separate functions to avoid spamming duplicated "ifdef GEKKO" everywhere. +extern int32_t I_JoystickAdvanceTrigger(void); +extern int32_t I_JoystickAdvanceTriggerClear(void); +extern int32_t I_JoystickReturnTrigger(void); +extern int32_t I_JoystickReturnTriggerClear(void); +extern int32_t I_JoystickEscapeTrigger(void); +extern int32_t I_JoystickEscapeTriggerClear(void); + +extern int32_t I_AdvanceTrigger(void); +extern int32_t I_AdvanceTriggerClear(void); +extern int32_t I_ReturnTrigger(void); +extern int32_t I_ReturnTriggerClear(void); +extern int32_t I_EscapeTrigger(void); +extern int32_t I_EscapeTriggerClear(void); + +extern int32_t I_PanelUp(void); +extern int32_t I_PanelUpClear(void); + +extern int32_t I_PanelDown(void); +extern int32_t I_PanelDownClear(void); + +extern char inputloc; +extern int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32_t c); + +#endif diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c index 42b3516ec..ce64db460 100644 --- a/polymer/eduke32/source/jmact/control.c +++ b/polymer/eduke32/source/jmact/control.c @@ -10,6 +10,7 @@ #include "keyboard.h" #include "mouse.h" +#include "joystick.h" #include "control.h" #include "_control.h" @@ -490,11 +491,7 @@ void CONTROL_GetDeviceButtons(void) if (CONTROL_MouseEnabled) { DoGetDeviceButtons( -#ifdef GEKKO - MOUSE_GetButtons()&0x3F, t, -#else MOUSE_GetButtons(), t, -#endif CONTROL_NumMouseButtons, CONTROL_MouseButtonState, CONTROL_MouseButtonClickedTime, @@ -506,15 +503,12 @@ void CONTROL_GetDeviceButtons(void) if (CONTROL_JoystickEnabled) { - int32_t buttons = joyb; - if (joynumhats > 0 && joyhat[0] != -1) + int32_t buttons = JOYSTICK_GetButtons(); + if (joynumhats > 0) { - static int32_t hatstate[] = { 1, 1|2, 2, 2|4, 4, 4|8, 8, 8|1 }; - int32_t val; - - // thanks SDL for this much more sensible method - val = ((joyhat[0] + 4500 / 2) % 36000) / 4500; - if (val < 8) buttons |= hatstate[val] << min(MAXJOYBUTTONS,joynumbuttons); + int32_t hat = JOYSTICK_GetHat(0); + if (hat != 0) + buttons |= hat << min(MAXJOYBUTTONS,joynumbuttons); } DoGetDeviceButtons( @@ -775,13 +769,11 @@ void CONTROL_ProcessBinds(void) while (i--); } -void CONTROL_GetInput(ControlInfo *info) +void CONTROL_GetFunctionInput(void) { int32_t periphs[CONTROL_NUM_FLAGS]; int32_t i = CONTROL_NUM_FLAGS-1; - CONTROL_PollDevices(info); - memset(periphs, 0, sizeof(periphs)); CONTROL_ButtonFunctionState(periphs); CONTROL_AxisFunctionState(periphs); @@ -801,6 +793,13 @@ void CONTROL_GetInput(ControlInfo *info) memset(extinput, 0, sizeof(extinput)); } +void CONTROL_GetInput(ControlInfo *info) +{ + CONTROL_PollDevices(info); + + CONTROL_GetFunctionInput(); +} + 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 554ffbb9b..487595f43 100644 --- a/polymer/eduke32/source/jmact/control.h +++ b/polymer/eduke32/source/jmact/control.h @@ -158,6 +158,7 @@ void CONTROL_MapButton void CONTROL_DefineFlag( int32_t which, int32_t toggle ); int32_t CONTROL_FlagActive( int32_t which ); void CONTROL_ClearAssignments( void ); +void CONTROL_GetFunctionInput( void ); void CONTROL_GetInput( ControlInfo *info ); void CONTROL_ClearButton( int32_t whichbutton ); extern float CONTROL_MouseSensitivity; diff --git a/polymer/eduke32/source/jmact/joystick.c b/polymer/eduke32/source/jmact/joystick.c new file mode 100644 index 000000000..c7e6f602f --- /dev/null +++ b/polymer/eduke32/source/jmact/joystick.c @@ -0,0 +1,102 @@ +/* + * joystick.c + * MACT library -to- Build Port Joystick Glue + * + * by Hendricks266 + * + * We needed raw joystick access for the Wii port. + * We only had raw mouse and keyboard access. + * I made raw joystick access. + * + */ +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +//------------------------------------------------------------------------- + +#include "compat.h" + +#include "joystick.h" +#include "baselayer.h" + +int32_t JOYSTICK_GetButtons(void) +{ + int32_t buttons; + + readjoybstatus(&buttons); + + return buttons; +} +int32_t JOYSTICK_ClearButton(int32_t b) +{ + return (joyb &= ~b); +} +void JOYSTICK_ClearAllButtons(void) +{ + joyb = 0; +} + +int32_t JOYSTICK_GetHat(int32_t h) +{ + if (h>=0 && h=0 && h=0 && a=0 && a extern char inputloc; int16_t g_skillSoundID=-1; -int32_t probey=0; +int32_t probey=0; // the row number on which the menu cursor is positioned static int32_t lastsavehead=0,last_menu_pos=0,last_menu,sh,onbar,buttonstat; static int32_t last_zero,last_fifty,last_onehundred,last_twoohtwo,last_threehundred = 0; +// ugly hack to get around inadequacies of calling CONTROL_GetInput() in M_Probe() and still have gamefuncs function throughout menus +// A previous solution was to add CONTROL_GetInput(&minfo); in M_DisplayMenus but that hurt mouse aiming +#define AdvanceTrigger 0x01 +#define ReturnTrigger 0x02 +#define EscapeTrigger 0x04 +#define ProbeTriggers(x) (menutriggers&x) +#define ProbeTriggersClear(x) (menutriggers&=~x) +static int32_t menutriggers=0; + static char menunamecnt; static fnlist_t fnlist; @@ -115,10 +126,10 @@ void savetemp(char *fn,int32_t daptr,int32_t dasiz) } #endif -#define LMB (buttonstat&(1|256)) -#define RMB (buttonstat&(2|512)) -#define WHEELUP (buttonstat&(16|4096)) -#define WHEELDOWN (buttonstat&(32|8192)) +#define LMB (buttonstat&LEFT_MOUSE) +#define RMB (buttonstat&RIGHT_MOUSE) +#define WHEELUP (buttonstat&WHEELUP_MOUSE) +#define WHEELDOWN (buttonstat&WHEELDOWN_MOUSE) static ControlInfo minfo; @@ -132,18 +143,22 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n) mi += (minfo.dpitch+minfo.dz); mii += minfo.dyaw; + menutriggers = 0; + if (x == (320>>1)) centre = 320>>2; else centre = 0; - if (!buttonstat || buttonstat == 16 || buttonstat == 32 || buttonstat == 4096 || buttonstat == 8192) + if (!buttonstat || buttonstat == WHEELUP_MOUSE || buttonstat == WHEELDOWN_MOUSE) { - if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || mi < -8192 || WHEELUP) + if (KB_KeyPressed(sc_UpArrow) || KB_KeyPressed(sc_kpad_8) || mi < -8192 || WHEELUP || BUTTON(gamefunc_Move_Forward) || (JOYSTICK_GetHat(0)&HAT_UP)) { mi = mii = 0; KB_ClearKeyDown(sc_UpArrow); KB_ClearKeyDown(sc_kpad_8); MOUSE_ClearButton(WHEELUP_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Forward); + JOYSTICK_ClearHat(0); S_PlaySound(KICK_HIT); @@ -173,13 +188,15 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n) probey = 0; } - if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || mi > 8192 || WHEELDOWN) + if (KB_KeyPressed(sc_DownArrow) || KB_KeyPressed(sc_kpad_2) || mi > 8192 || WHEELDOWN || BUTTON(gamefunc_Move_Backward) || (JOYSTICK_GetHat(0)&HAT_DOWN)) { mi = mii = 0; KB_ClearKeyDown(sc_DownArrow); KB_ClearKeyDown(sc_kpad_2); KB_ClearKeyDown(sc_PgDn); MOUSE_ClearButton(WHEELDOWN_MOUSE); + CONTROL_ClearButton(gamefunc_Move_Backward); + JOYSTICK_ClearHat(0); S_PlaySound(KICK_HIT); @@ -228,31 +245,38 @@ static int32_t probe_(int32_t type,int32_t x,int32_t y,int32_t i,int32_t n) rotatesprite_fs((x<<16)-((tilesizx[BIGFNTCURSOR]-4)<<(16-type)),(y+(probey*i)-(4>>type))<<16,65536L>>type,0,SPINNINGNUKEICON+(((totalclock>>3))%7),sh,0,10); } - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Enter) || (LMB && !onbar)) + if (I_AdvanceTrigger() && !onbar) { if (g_currentMenu != 110) S_PlaySound(PISTOL_BODYHIT); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_Space); - KB_ClearKeyDown(sc_kpad_Enter); - MOUSE_ClearButton(LEFT_MOUSE); + + menutriggers |= AdvanceTrigger; + + I_AdvanceTriggerClear(); + return(probey); } - else if (KB_KeyPressed(sc_Escape) || (RMB)) + else if (I_ReturnTrigger()) { - onbar = 0; - KB_ClearKeyDown(sc_Escape); S_PlaySound(EXITMENUSOUND); - MOUSE_ClearButton(RIGHT_MOUSE); + + menutriggers |= ReturnTrigger; + + I_ReturnTriggerClear(); + + onbar = 0; return(-1); } else { - if (onbar == 0) return(-probey-2); - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256))) + if (onbar == 0) + return(-probey-2); + + if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256)) || BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) return(probey); - else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256))) + else if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256)) || BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) return(probey); + return(-probey-2); } } @@ -266,6 +290,30 @@ static inline int32_t probesm(int32_t x,int32_t y,int32_t i,int32_t n) return probe_(1,x,y,i,n); } +// see menutriggers for why this is a sorry hack +// calling CONTROL_GetFunctionInput(); from input.c also would not work +// and probe_() must remain static +static int32_t Menu_EnterText(int32_t x,int32_t y,char *t,int32_t dalen,int32_t c) +{ + int32_t probeysave = probey; + int32_t probeoutputx = M_Probe(0,0,0,1); + probey = probeysave; + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger()) + { + I_AdvanceTriggerClear(); + return (1); + } + + if (probeoutputx == -1) + { + I_ReturnTriggerClear(); + return (-1); + } + + return G_EnterText(x, y, t, dalen, c); +} + int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char *t,int32_t bits) { int16_t i, ac, centre; @@ -407,11 +455,14 @@ static void sliderbar(int32_t type, int32_t x,int32_t y,int32_t *p,int32_t dainc if (damodify) { - if (*p >= min && *p <= max && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256)))) // && onbar) ) + if (*p >= min && *p <= max && (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && (WHEELUP || mii < -256)) || BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT))) // && onbar) ) { KB_ClearKeyDown(sc_LeftArrow); KB_ClearKeyDown(sc_kpad_4); MOUSE_ClearButton(WHEELUP_MOUSE); + CONTROL_ClearButton(gamefunc_Turn_Left); + CONTROL_ClearButton(gamefunc_Strafe_Left); + JOYSTICK_ClearHat(0); mii = 0; if (!rev) *p -= dainc; @@ -422,11 +473,14 @@ static void sliderbar(int32_t type, int32_t x,int32_t y,int32_t *p,int32_t dainc *p = max; S_PlaySound(KICK_HIT); } - if (*p <= max && *p >= min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256)))) //&& onbar) ) + if (*p <= max && *p >= min && (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && (WHEELDOWN || mii > 256)) || BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT))) //&& onbar) ) { KB_ClearKeyDown(sc_RightArrow); KB_ClearKeyDown(sc_kpad_6); MOUSE_ClearButton(WHEELDOWN_MOUSE); + CONTROL_ClearButton(gamefunc_Turn_Right); + CONTROL_ClearButton(gamefunc_Strafe_Right); + JOYSTICK_ClearHat(0); mii = 0; if (!rev) *p += dainc; @@ -465,10 +519,13 @@ static void modval(int32_t min, int32_t max,int32_t *p,int32_t dainc,int32_t dam { if (rev == 0) { - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256)) // && onbar) ) + if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256) || BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) // && onbar) ) { KB_ClearKeyDown(sc_LeftArrow); KB_ClearKeyDown(sc_kpad_4); + CONTROL_ClearButton(gamefunc_Turn_Left); + CONTROL_ClearButton(gamefunc_Strafe_Left); + JOYSTICK_ClearHat(0); *p -= dainc; if (*p < min) @@ -479,10 +536,13 @@ static void modval(int32_t min, int32_t max,int32_t *p,int32_t dainc,int32_t dam } S_PlaySound(PISTOL_BODYHIT); } - if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256)) //&& onbar) ) + if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256) || BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) //&& onbar) ) { KB_ClearKeyDown(sc_RightArrow); KB_ClearKeyDown(sc_kpad_6); + CONTROL_ClearButton(gamefunc_Turn_Right); + CONTROL_ClearButton(gamefunc_Strafe_Right); + JOYSTICK_ClearHat(0); *p += dainc; if (*p > max) @@ -496,10 +556,13 @@ static void modval(int32_t min, int32_t max,int32_t *p,int32_t dainc,int32_t dam } else { - if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256)) //&& onbar )) + if (KB_KeyPressed(sc_RightArrow) || KB_KeyPressed(sc_kpad_6) || (LMB && minfo.dyaw > 256) || BUTTON(gamefunc_Turn_Right) || BUTTON(gamefunc_Strafe_Right) || (JOYSTICK_GetHat(0)&HAT_RIGHT)) //&& onbar )) { KB_ClearKeyDown(sc_RightArrow); KB_ClearKeyDown(sc_kpad_6); + CONTROL_ClearButton(gamefunc_Turn_Right); + CONTROL_ClearButton(gamefunc_Strafe_Right); + JOYSTICK_ClearHat(0); *p -= dainc; if (*p < min) @@ -510,10 +573,13 @@ static void modval(int32_t min, int32_t max,int32_t *p,int32_t dainc,int32_t dam } S_PlaySound(PISTOL_BODYHIT); } - if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256)) // && onbar) ) + if (KB_KeyPressed(sc_LeftArrow) || KB_KeyPressed(sc_kpad_4) || (LMB && minfo.dyaw < -256) || BUTTON(gamefunc_Turn_Left) || BUTTON(gamefunc_Strafe_Left) || (JOYSTICK_GetHat(0)&HAT_LEFT)) // && onbar) ) { KB_ClearKeyDown(sc_LeftArrow); KB_ClearKeyDown(sc_kpad_4); + CONTROL_ClearButton(gamefunc_Turn_Left); + CONTROL_ClearButton(gamefunc_Strafe_Left); + JOYSTICK_ClearHat(0); *p += dainc; if (*p > max) @@ -838,9 +904,7 @@ void M_DisplayMenus(void) inputloc = strlen(buf); g_currentMenu = 20003; - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); } break; @@ -931,9 +995,9 @@ void M_DisplayMenus(void) } else { - // because OSD_StripColors needs a valid target and tempbuf is used in G_EnterText() + // because OSD_StripColors needs a valid target and tempbuf is used in _EnterText() char dummybuf[64]; - x = G_EnterText(d-50,37,buf,30,0); + x = Menu_EnterText(d-50,37,buf,30,0); while (Bstrlen(OSD_StripColors(dummybuf,buf)) > 10) { @@ -952,9 +1016,7 @@ void M_DisplayMenus(void) } // send name update } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); g_currentMenu = 20002; } @@ -1044,23 +1106,19 @@ void M_DisplayMenus(void) inputloc = strlen(buf); last_menu_pos = probey; g_currentMenu = 20005; - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); } } else { - x = G_EnterText(26,40+(8*probey),buf,34,0); + x = Menu_EnterText(26,40+(8*probey),buf,34,0); if (x) { if (x == 1) { Bstrcpy(ud.ridecule[last_menu_pos],buf); } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); g_currentMenu = 20004; } } @@ -1289,13 +1347,11 @@ void M_DisplayMenus(void) } else if (x == 2) {} - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); } else if (g_currentMenu == 20021) { - x = G_EnterText(40+100,50-9,buf,31,0); + x = Menu_EnterText(40+100,50-9,buf,31,0); if (x) { if (x == 1) @@ -1303,16 +1359,14 @@ void M_DisplayMenus(void) //strcpy(szPlayerName,buf); } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); g_currentMenu = 20020; } } else if (g_currentMenu == 20022) { - x = G_EnterText(40+100,50+20-9,buf,5,997); + x = Menu_EnterText(40+100,50+20-9,buf,5,997); if (x) { if (x == 1) @@ -1320,9 +1374,7 @@ void M_DisplayMenus(void) //strcpy(szPlayerName,buf); } - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); g_currentMenu = 20020; } @@ -1356,7 +1408,9 @@ void M_DisplayMenus(void) mgametext(160,99+9,"(Y/N)",0,2+8+16); - if (KB_KeyPressed(sc_Escape) || KB_KeyPressed(sc_N) || RMB) + x = M_Probe(186,124+9,0,0); + + if (x == -1 || KB_KeyPressed(sc_N)) { if (sprite[g_player[myconnectindex].ps->i].extra <= 0) { @@ -1365,7 +1419,6 @@ void M_DisplayMenus(void) } KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); g_player[myconnectindex].ps->gm &= ~MODE_MENU; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) @@ -1375,8 +1428,12 @@ void M_DisplayMenus(void) } } - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); + KB_FlushKeyboardQueue(); KB_ClearKeysDown(); FX_StopAllSounds(); @@ -1397,8 +1454,6 @@ void M_DisplayMenus(void) } } - M_Probe(186,124+9,0,0); - break; case 10000: @@ -1424,7 +1479,7 @@ void M_DisplayMenus(void) if (g_currentMenu == 10001) { mgametext(160,50+16+16+16+16-12,"Enter Password",0,2+8+16); - x = G_EnterText((320>>1),50+16+16+16+16,buf,19, 998); + x = Menu_EnterText((320>>1),50+16+16+16+16,buf,19, 998); if (x) { @@ -1444,9 +1499,7 @@ void M_DisplayMenus(void) #endif } g_currentMenu = 10000; - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_kpad_Enter); - KB_FlushKeyboardQueue(); + I_AdvanceTriggerClear(); } } else @@ -1536,8 +1589,14 @@ void M_DisplayMenus(void) mgametext(160,99,tempbuf,0,2+8+16); mgametext(160,99+9,"(Y/N)",0,2+8+16); - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + x = M_Probe(186,124+9,0,0); + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); + g_lastSaveSlot = g_currentMenu-1000; KB_FlushKeyboardQueue(); @@ -1555,13 +1614,9 @@ void M_DisplayMenus(void) break; } - M_Probe(186,124+9,0,0); - - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + if (x == -1 || KB_KeyPressed(sc_N)) { KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); - S_PlaySound(EXITMENUSOUND); if (g_player[myconnectindex].ps->gm&MODE_GAME) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; @@ -1582,25 +1637,27 @@ void M_DisplayMenus(void) case 1500: - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + x = M_Probe(186,124,0,0); + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); KB_FlushKeyboardQueue(); ChangeToMenu(100); } - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + if (x == -1 || KB_KeyPressed(sc_N)) { KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) { ready2send = 1; totalclock = ototalclock; } g_player[myconnectindex].ps->gm &= ~MODE_MENU; - S_PlaySound(EXITMENUSOUND); break; } - M_Probe(186,124,0,0); mgametext(160,90,"ABORT this game?",0,2+8+16); mgametext(160,90+9,"(Y/N)",0,2+8+16); @@ -1636,8 +1693,14 @@ void M_DisplayMenus(void) mgametext(160,90,"OVERWRITE previous SAVED game?",0,2+8+16); mgametext(160,90+9,"(Y/N)",0,2+8+16); - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + x = M_Probe(186,124,0,0); + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); + inputloc = strlen(&ud.savegame[g_currentMenu-2000][0]); ChangeToMenu(g_currentMenu-2000+360); @@ -1645,16 +1708,12 @@ void M_DisplayMenus(void) KB_FlushKeyboardQueue(); break; } - if (KB_KeyPressed(sc_N) || KB_KeyPressed(sc_Escape) || RMB) + if (x == -1 || KB_KeyPressed(sc_N)) { KB_ClearKeyDown(sc_N); - KB_ClearKeyDown(sc_Escape); ChangeToMenu(351); - S_PlaySound(EXITMENUSOUND); } - M_Probe(186,124,0,0); - break; case 990: @@ -1680,44 +1739,18 @@ void M_DisplayMenus(void) l = 3; } - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8) || - WHEELUP) + if (I_PanelUp()) { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); + I_PanelUpClear(); S_PlaySound(KICK_HIT); g_currentMenu--; if (g_currentMenu < 990) g_currentMenu = 990+l; } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_kpad_6) || - LMB || WHEELDOWN) + else if (I_PanelDown()) { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); + I_PanelDownClear(); + S_PlaySound(KICK_HIT); g_currentMenu++; if (g_currentMenu > 990+l) g_currentMenu = 990; @@ -4775,7 +4808,7 @@ cheat_for_port_credits: if (ud.volume_number == 0 && ud.level_number == 7) mgametext(160,180,currentboardfilename,0,2+8+16); - x = G_EnterText((320>>1),184,&ud.savegame[g_currentMenu-360][0],20, 999); + x = Menu_EnterText((320>>1),184,&ud.savegame[g_currentMenu-360][0],20, 999); if (x == -1) { @@ -4813,8 +4846,6 @@ cheat_for_port_credits: ready2send = 1; totalclock = ototalclock; } - KB_ClearKeyDown(sc_Escape); - S_PlaySound(EXITMENUSOUND); crc = 0; } @@ -4930,48 +4961,26 @@ DISPLAYNAMES: c = 320>>1; - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8)) + if (I_PanelUp()) { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); + I_PanelUpClear(); S_PlaySound(KICK_HIT); g_currentMenu--; if (g_currentMenu < 400) g_currentMenu = 403; } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_6)) + else if (I_PanelDown()) { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); + I_PanelDownClear(); + S_PlaySound(KICK_HIT); g_currentMenu++; if (g_currentMenu > 403) g_currentMenu = 400; } - if (KB_KeyPressed(sc_Escape)) + x = M_Probe(0,0,0,1); + + if (x == -1) { if (g_player[myconnectindex].ps->gm&MODE_GAME) ChangeToMenu(50); @@ -4987,43 +4996,18 @@ VOLUME_ALL_40x: c = 320>>1; - if (KB_KeyPressed(sc_LeftArrow) || - KB_KeyPressed(sc_kpad_4) || - KB_KeyPressed(sc_UpArrow) || - KB_KeyPressed(sc_PgUp) || - KB_KeyPressed(sc_kpad_8) || - WHEELDOWN) + if (I_PanelUp()) { - KB_ClearKeyDown(sc_LeftArrow); - KB_ClearKeyDown(sc_kpad_4); - KB_ClearKeyDown(sc_UpArrow); - KB_ClearKeyDown(sc_PgUp); - KB_ClearKeyDown(sc_kpad_8); + I_PanelUpClear(); + S_PlaySound(KICK_HIT); g_currentMenu--; if (g_currentMenu < 400) g_currentMenu = 401; } - else if ( - KB_KeyPressed(sc_PgDn) || - KB_KeyPressed(sc_Enter) || - KB_KeyPressed(sc_kpad_Enter) || - KB_KeyPressed(sc_RightArrow) || - KB_KeyPressed(sc_DownArrow) || - KB_KeyPressed(sc_kpad_2) || - KB_KeyPressed(sc_kpad_9) || - KB_KeyPressed(sc_Space) || - KB_KeyPressed(sc_kpad_6) || - LMB || WHEELUP) + else if (I_PanelDown()) { - KB_ClearKeyDown(sc_PgDn); - KB_ClearKeyDown(sc_Enter); - KB_ClearKeyDown(sc_RightArrow); - KB_ClearKeyDown(sc_kpad_Enter); - KB_ClearKeyDown(sc_kpad_6); - KB_ClearKeyDown(sc_kpad_9); - KB_ClearKeyDown(sc_kpad_2); - KB_ClearKeyDown(sc_DownArrow); - KB_ClearKeyDown(sc_Space); + I_PanelDownClear(); + S_PlaySound(KICK_HIT); g_currentMenu++; if (g_currentMenu > 401) g_currentMenu = 400; @@ -5075,15 +5059,18 @@ VOLUME_ALL_40x: mgametext(c,90,"Are you sure you want to quit?",0,2+8+16); mgametext(c,99,"(Y/N)",0,2+8+16); - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + x = M_Probe(186,124,0,1); + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); KB_FlushKeyboardQueue(); G_GameQuit(); } - - x = M_Probe(186,124,0,1); - if (x == -1 || KB_KeyPressed(sc_N) || RMB) + if (x == -1 || KB_KeyPressed(sc_N)) { KB_ClearKeyDown(sc_N); g_quitDeadline = 0; @@ -5113,8 +5100,14 @@ VOLUME_ALL_40x: mgametext(c,90,"Quit to Title?",0,2+8+16); mgametext(c,99,"(Y/N)",0,2+8+16); - if (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || KB_KeyPressed(sc_Y) || LMB) + x = M_Probe(186,124,0,0); + + if (ProbeTriggers(AdvanceTrigger) || I_AdvanceTrigger() || KB_KeyPressed(sc_Y)) { + I_AdvanceTriggerClear(); + ProbeTriggersClear(AdvanceTrigger); + KB_ClearKeyDown(sc_Y); + KB_FlushKeyboardQueue(); g_player[myconnectindex].ps->gm = MODE_DEMO; if (ud.recstat == 1) @@ -5122,9 +5115,7 @@ VOLUME_ALL_40x: ChangeToMenu(0); } - x = M_Probe(186,124,0,0); - - if (x == -1 || KB_KeyPressed(sc_N) || RMB) + if (x == -1 || KB_KeyPressed(sc_N)) { g_player[myconnectindex].ps->gm &= ~MODE_MENU; if ((!g_netServer && ud.multimode < 2) && ud.recstat != 2) @@ -5145,9 +5136,9 @@ VOLUME_ALL_40x: mgametext(160,50,tempbuf,0,2+8+16); mgametext(160,59,"to select level",0,2+8+16); - if (KB_KeyPressed(sc_Escape)) + if (I_EscapeTrigger()) { - KB_ClearKeyDown(sc_Escape); + I_EscapeTriggerClear(); S_PlaySound(EXITMENUSOUND); ChangeToMenu(0); } @@ -5483,6 +5474,9 @@ VOLUME_ALL_40x: if (apScriptGameEvent[EVENT_DISPLAYMENUREST]) VM_OnEvent(EVENT_DISPLAYMENUREST, g_player[myconnectindex].ps->i, myconnectindex, -1, 0); + if (I_EscapeTrigger()) + I_EscapeTriggerClear(); + if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { G_UpdateScreenArea(); diff --git a/polymer/eduke32/source/net.c b/polymer/eduke32/source/net.c index bc0444677..498f14d5e 100644 --- a/polymer/eduke32/source/net.c +++ b/polymer/eduke32/source/net.c @@ -26,6 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "net.h" #include "premap.h" #include "savegame.h" +#include "input.h" #include "enet/enet.h" #include "quicklz.h" diff --git a/polymer/eduke32/source/sector.c b/polymer/eduke32/source/sector.c index 87fd8f2bc..1110cfdaf 100644 --- a/polymer/eduke32/source/sector.c +++ b/polymer/eduke32/source/sector.c @@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "gameexec.h" #include "premap.h" #include "osd.h" +#include "common_game.h" +#include "input.h" // PRIMITIVE @@ -3319,8 +3321,8 @@ CLEARCAMERAS: else if (p->newowner >= 0) p->newowner = -1; - if (KB_KeyPressed(sc_Escape)) - KB_ClearKeyDown(sc_Escape); + if (I_EscapeTrigger()) + I_EscapeTriggerClear(); return; } diff --git a/polymer/eduke32/wiibuild.bat b/polymer/eduke32/wiibuild.bat index 926553a1a..962093044 100644 --- a/polymer/eduke32/wiibuild.bat +++ b/polymer/eduke32/wiibuild.bat @@ -21,6 +21,8 @@ set buildparameters=PLATFORM=WII %* make veryclean %buildparameters% make OPTLEVEL=2 LTO=0 %buildparameters% +if not exist "eduke32.elf" goto end + :: Package data: xcopy /e /q /y Wii\apps apps\ for %%G in (eduke32) do for %%H in (.elf) do if exist "%%~G%%~H" move /y "%%~G%%~H" "apps\%%~G\boot%%~H" @@ -29,6 +31,8 @@ for %%G in (eduke32) do for %%H in (.elf.map) do if exist "%%~G%%~H" del /f /q " if exist "*.txt" copy /y "*.txt" "apps\eduke32\" "ls.exe" -l -R apps +:end + :: Clean up revision number: if "%vc%"=="svn" svn revert source\rev.h if "%vc%"=="git" git checkout source\rev.h