diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 310a741cc..accaeaf27 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1026,6 +1026,18 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_lookbackaxis2); CV_RegisterVar(&cv_lookbackaxis3); CV_RegisterVar(&cv_lookbackaxis4); + CV_RegisterVar(&cv_custom1axis); + CV_RegisterVar(&cv_custom1axis2); + CV_RegisterVar(&cv_custom1axis3); + CV_RegisterVar(&cv_custom1axis4); + CV_RegisterVar(&cv_custom2axis); + CV_RegisterVar(&cv_custom2axis2); + CV_RegisterVar(&cv_custom2axis3); + CV_RegisterVar(&cv_custom2axis4); + CV_RegisterVar(&cv_custom3axis); + CV_RegisterVar(&cv_custom3axis2); + CV_RegisterVar(&cv_custom3axis3); + CV_RegisterVar(&cv_custom3axis4); CV_RegisterVar(&cv_xdeadzone); CV_RegisterVar(&cv_ydeadzone); CV_RegisterVar(&cv_xdeadzone2); diff --git a/src/g_game.c b/src/g_game.c index 42cde4b0e..91bf3c781 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -449,6 +449,9 @@ consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, consvar_t cv_fireaxis = {"joyaxis_fire", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftaxis = {"joyaxis_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lookbackaxis = {"joyaxis_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom1axis = {"joyaxis_custom1", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom2axis = {"joyaxis_custom2", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom3axis = {"joyaxis_custom3", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_xdeadzone = {"joy_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ydeadzone = {"joy_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -460,6 +463,9 @@ consvar_t cv_lookaxis2 = {"joyaxis2_look", "None", CV_SAVE, joyaxis_cons_t, NULL consvar_t cv_fireaxis2 = {"joyaxis2_fire", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftaxis2 = {"joyaxis2_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lookbackaxis2 = {"joyaxis2_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom1axis2 = {"joyaxis2_custom1", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom2axis2 = {"joyaxis2_custom2", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom3axis2 = {"joyaxis2_custom3", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_xdeadzone2 = {"joy2_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ydeadzone2 = {"joy2_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -471,6 +477,9 @@ consvar_t cv_lookaxis3 = {"joyaxis3_look", "None", CV_SAVE, joyaxis_cons_t, NULL consvar_t cv_fireaxis3 = {"joyaxis3_fire", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftaxis3 = {"joyaxis3_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lookbackaxis3 = {"joyaxis3_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom1axis3 = {"joyaxis3_custom1", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom2axis3 = {"joyaxis3_custom2", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom3axis3 = {"joyaxis3_custom3", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_xdeadzone3 = {"joy3_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ydeadzone3 = {"joy3_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -482,6 +491,9 @@ consvar_t cv_lookaxis4 = {"joyaxis4_look", "None", CV_SAVE, joyaxis_cons_t, NULL consvar_t cv_fireaxis4 = {"joyaxis4_fire", "L Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftaxis4 = {"joyaxis4_drift", "R Trigger", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_lookbackaxis4 = {"joyaxis4_lookback", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom1axis4 = {"joyaxis4_custom1", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom2axis4 = {"joyaxis4_custom2", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_custom3axis4 = {"joyaxis4_custom3", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_xdeadzone4 = {"joy4_xdeadzone", "0.3", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ydeadzone4 = {"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -732,6 +744,15 @@ static INT32 Joy1Axis(axis_input_e axissel) case AXISLOOKBACK: axisval = cv_lookbackaxis.value; break; + case AXISCUSTOM1: + axisval = cv_custom1axis.value; + break; + case AXISCUSTOM2: + axisval = cv_custom2axis.value; + break; + case AXISCUSTOM3: + axisval = cv_custom3axis.value; + break; default: return 0; } @@ -816,6 +837,15 @@ static INT32 Joy2Axis(axis_input_e axissel) case AXISLOOKBACK: axisval = cv_lookbackaxis2.value; break; + case AXISCUSTOM1: + axisval = cv_custom1axis2.value; + break; + case AXISCUSTOM2: + axisval = cv_custom2axis2.value; + break; + case AXISCUSTOM3: + axisval = cv_custom3axis2.value; + break; default: return 0; } @@ -902,6 +932,15 @@ static INT32 Joy3Axis(axis_input_e axissel) case AXISLOOKBACK: axisval = cv_lookbackaxis3.value; break; + case AXISCUSTOM1: + axisval = cv_custom1axis3.value; + break; + case AXISCUSTOM2: + axisval = cv_custom2axis3.value; + break; + case AXISCUSTOM3: + axisval = cv_custom3axis3.value; + break; default: return 0; } @@ -988,6 +1027,15 @@ static INT32 Joy4Axis(axis_input_e axissel) case AXISLOOKBACK: axisval = cv_lookbackaxis4.value; break; + case AXISCUSTOM1: + axisval = cv_custom1axis4.value; + break; + case AXISCUSTOM2: + axisval = cv_custom2axis4.value; + break; + case AXISCUSTOM3: + axisval = cv_custom3axis4.value; + break; default: return 0; } @@ -1305,11 +1353,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->buttons |= BT_DRIFT; // Lua scriptable buttons - if (InputDown(gc_custom1, ssplayer)) + axis = JoyAxis(AXISCUSTOM1, ssplayer); + if (InputDown(gc_custom1, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_CUSTOM1; - if (InputDown(gc_custom2, ssplayer)) + axis = JoyAxis(AXISCUSTOM2, ssplayer); + if (InputDown(gc_custom2, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_CUSTOM2; - if (InputDown(gc_custom3, ssplayer)) + axis = JoyAxis(AXISCUSTOM3, ssplayer); + if (InputDown(gc_custom3, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_CUSTOM3; // Reset camera diff --git a/src/g_game.h b/src/g_game.h index a57468a2e..bfc158583 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -120,10 +120,10 @@ extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mouse extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; extern consvar_t cv_useranalog, cv_useranalog2, cv_useranalog3, cv_useranalog4; extern consvar_t cv_analog, cv_analog2, cv_analog3, cv_analog4; -extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_lookbackaxis,cv_xdeadzone,cv_ydeadzone; -extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_lookbackaxis2,cv_xdeadzone2,cv_ydeadzone2; -extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_lookbackaxis3,cv_xdeadzone3,cv_ydeadzone3; -extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_lookbackaxis4,cv_xdeadzone4,cv_ydeadzone4; +extern consvar_t cv_turnaxis,cv_moveaxis,cv_brakeaxis,cv_aimaxis,cv_lookaxis,cv_fireaxis,cv_driftaxis,cv_lookbackaxis,cv_custom1axis,cv_custom2axis,cv_custom3axis,cv_xdeadzone,cv_ydeadzone; +extern consvar_t cv_turnaxis2,cv_moveaxis2,cv_brakeaxis2,cv_aimaxis2,cv_lookaxis2,cv_fireaxis2,cv_driftaxis2,cv_lookbackaxis2,cv_custom1axis2,cv_custom2axis2,cv_custom3axis2,cv_xdeadzone2,cv_ydeadzone2; +extern consvar_t cv_turnaxis3,cv_moveaxis3,cv_brakeaxis3,cv_aimaxis3,cv_lookaxis3,cv_fireaxis3,cv_driftaxis3,cv_lookbackaxis3,cv_custom1axis3,cv_custom2axis3,cv_custom3axis3,cv_xdeadzone3,cv_ydeadzone3; +extern consvar_t cv_turnaxis4,cv_moveaxis4,cv_brakeaxis4,cv_aimaxis4,cv_lookaxis4,cv_fireaxis4,cv_driftaxis4,cv_lookbackaxis4,cv_custom1axis4,cv_custom2axis4,cv_custom3axis4,cv_xdeadzone4,cv_ydeadzone4; extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff; // Hud offsets @@ -188,6 +188,9 @@ typedef enum AXISFIRE, AXISDRIFT, AXISLOOKBACK, + AXISCUSTOM1, + AXISCUSTOM2, + AXISCUSTOM3 } axis_input_e; // mouseaiming (looking up/down with the mouse or keyboard) diff --git a/src/m_menu.c b/src/m_menu.c index 6c63db9e5..45b201af0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1186,8 +1186,11 @@ static menuitem_t OP_Joystick1Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis , 100}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 120}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis , 130}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone , 140}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone , 150}, }; static menuitem_t OP_Joystick2Menu[] = @@ -1201,8 +1204,11 @@ static menuitem_t OP_Joystick2Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis2 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis2 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis2 , 100}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 120}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis2 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis2 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis2 , 130}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone2 , 140}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone2 , 150}, }; static menuitem_t OP_Joystick3Menu[] = @@ -1216,8 +1222,11 @@ static menuitem_t OP_Joystick3Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis3 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis3 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis3 , 100}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 120}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 130}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis3 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis3 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis3 , 130}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone3 , 140}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone3 , 150}, }; static menuitem_t OP_Joystick4Menu[] = @@ -1231,8 +1240,11 @@ static menuitem_t OP_Joystick4Menu[] = {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis4 , 80}, {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis4 , 90}, {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis4 , 100}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 110}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis4 , 110}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis4 , 120}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis4 , 130}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone4 , 140}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone4 , 150}, }; static menuitem_t OP_JoystickSetMenu[] =