Skip to content

Commit ffe416d

Browse files
committed
Allow mapping pause, escape, previous weapon, and next weapon
* Sort of kill mouse customization for now since it was easier
1 parent 2a245e7 commit ffe416d

File tree

5 files changed

+91
-56
lines changed

5 files changed

+91
-56
lines changed

foreign.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
#define STR_COPEN "Open"
6464
#define STR_CFIRE "Fire"
6565
#define STR_CSTRAFE "Strafe"
66+
#define STR_CPREVWEP "Wep-"
67+
#define STR_CNEXTWEP "Wep+"
68+
#define STR_CPAUSE "Pause"
69+
#define STR_CESCAPE "Esc"
6670

6771
#define STR_LEFT "Left"
6872
#define STR_RIGHT "Right"

id_in.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,10 @@ IN_ReadControl(int player,ControlInfo *info)
542542
info->button6 = (buttons & (1 << 6)) != 0;
543543
info->button7 = (buttons & (1 << 7)) != 0;
544544
info->button8 = (buttons & (1 << 8)) != 0;
545-
info->button9 = (buttons & (1 << 9)) != 0;
545+
info->button9 = (buttons & (1 << 9)) != 0;
546+
info->button10 = (buttons & (1 << 10)) != 0;
547+
info->button11 = (buttons & (1 << 11)) != 0;
548+
info->button12 = (buttons & (1 << 12)) != 0;
546549
info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
547550
}
548551

id_in.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ typedef enum {
115115
dir_None
116116
} Direction;
117117
typedef struct {
118-
boolean button0,button1,button2,button3,button4,button5,button6,button7,button8,button9;
118+
boolean button0,button1,button2,button3,button4,button5,button6,button7,button8,button9,button10,button11,button12;
119119
short x,y;
120120
Motion xaxis,yaxis;
121121
Direction dir;

wl_menu.cpp

Lines changed: 78 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,10 +2203,9 @@ DrawCtlScreen (void)
22032203
// CUSTOMIZE CONTROLS
22042204
//
22052205
////////////////////////////////////////////////////////////////////
2206-
enum
2207-
{ FIRE, STRAFE, RUN, OPEN };
2208-
char mbarray[10][3] = { "A ", "B ", "X ", "Y ", "L1", "R1", "L2", "R2", "LS", "RS" };
2209-
int8_t order[4] = { RUN, OPEN, FIRE, STRAFE };
2206+
char mbarray[13][3] = { "A ", "B ", "X ", "Y ", "L1", "R1", "L2", "R2", "LS", "RS", "BK", "GD", "XB" };
2207+
int8_t order[4] = { bt_run, bt_use, bt_attack, bt_strafe };
2208+
int8_t order2[4] = { bt_pause, bt_esc, bt_prevweapon, bt_nextweapon };
22102209

22112210

22122211
int
@@ -2221,8 +2220,8 @@ CustomControls (int)
22212220
switch (which)
22222221
{
22232222
case 0:
2224-
DefineMouseBtns ();
2225-
DrawCustMouse (1);
2223+
DefineJoy2Btns ();
2224+
DrawCustJoy2 (1);
22262225
break;
22272226
case 3:
22282227
DefineJoyBtns ();
@@ -2250,10 +2249,10 @@ CustomControls (int)
22502249
// DEFINE THE MOUSE BUTTONS
22512250
//
22522251
void
2253-
DefineMouseBtns (void)
2252+
DefineJoy2Btns (void)
22542253
{
2255-
CustomCtrls mouseallowed = { 0, 1, 1, 1 };
2256-
EnterCtrlData (2, &mouseallowed, DrawCustMouse, PrintCustMouse, MOUSE);
2254+
CustomCtrls joyallowed = { 1, 1, 1, 1 };
2255+
EnterCtrlData (2, &joyallowed, DrawCustJoy2, PrintCustJoy2, JOYSTICK2);
22572256
}
22582257

22592258

@@ -2346,7 +2345,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
23462345
SDL_Delay(5);
23472346
ReadAnyControl (&ci);
23482347

2349-
if (type == MOUSE || type == JOYSTICK)
2348+
if (type == MOUSE || type == JOYSTICK || type == JOYSTICK2)
23502349
if (IN_KeyDown (sc_Enter) || IN_KeyDown (sc_Control) || IN_KeyDown (sc_Alt))
23512350
{
23522351
IN_ClearKeysDown ();
@@ -2355,7 +2354,7 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
23552354
//
23562355
// CHANGE BUTTON VALUE?
23572356
//
2358-
if (((type != KEYBOARDBTNS && type != KEYBOARDMOVE) && (ci.button0 || ci.button1 || ci.button2 || ci.button3 || ci.button4 || ci.button5 || ci.button6 || ci.button7 || ci.button8 || ci.button9)) ||
2357+
if (((type != KEYBOARDBTNS && type != KEYBOARDMOVE) && (ci.button0 || ci.button1 || ci.button2 || ci.button3 || ci.button4 || ci.button5 || ci.button6 || ci.button7 || ci.button8 || ci.button9 || ci.button10 || ci.button11 || ci.button12)) ||
23592358
((type == KEYBOARDBTNS || type == KEYBOARDMOVE) && LastScan == sc_Enter))
23602359
{
23612360
lastFlashTime = GetTimeCount();
@@ -2395,31 +2394,49 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
23952394
//
23962395
switch (type)
23972396
{
2398-
case MOUSE:
2399-
button = IN_MouseButtons();
2400-
switch (button)
2401-
{
2402-
case 1:
2403-
result = 1;
2404-
break;
2405-
case 2:
2406-
result = 2;
2407-
break;
2408-
case 4:
2409-
result = 3;
2410-
break;
2411-
}
2397+
case JOYSTICK2:
2398+
if (ci.button0)
2399+
result = 1;
2400+
else if (ci.button1)
2401+
result = 2;
2402+
else if (ci.button2)
2403+
result = 3;
2404+
else if (ci.button3)
2405+
result = 4;
2406+
else if (ci.button4)
2407+
result = 5;
2408+
else if (ci.button5)
2409+
result = 6;
2410+
else if (ci.button6)
2411+
result = 7;
2412+
else if (ci.button7)
2413+
result = 8;
2414+
else if (ci.button8)
2415+
result = 9;
2416+
else if (ci.button9)
2417+
result = 10;
2418+
else if (ci.button10)
2419+
result = 11;
2420+
else if (ci.button11)
2421+
result = 12;
2422+
else if (ci.button12)
2423+
result = 13;
24122424

24132425
if (result)
24142426
{
2415-
for (int z = 0; z < 4; z++)
2416-
if (order[which] == buttonmouse[z])
2427+
/*
2428+
// Allow the same action to be bound to multiple buttons
2429+
for (int z = 0; z < 10; z++)
2430+
{
2431+
if (order[which] == buttonjoy[z])
24172432
{
2418-
buttonmouse[z] = bt_nobutton;
2433+
buttonjoy[z] = bt_nobutton;
24192434
break;
24202435
}
2436+
}
2437+
*/
24212438

2422-
buttonmouse[result - 1] = order[which];
2439+
buttonjoy[result - 1] = order2[which];
24232440
picked = 1;
24242441
SD_PlaySound (SHOOTDOORSND);
24252442
}
@@ -2446,6 +2463,12 @@ EnterCtrlData (int index, CustomCtrls * cust, void (*DrawRtn) (int), void (*Prin
24462463
result = 9;
24472464
else if (ci.button9)
24482465
result = 10;
2466+
else if (ci.button10)
2467+
result = 11;
2468+
else if (ci.button11)
2469+
result = 12;
2470+
else if (ci.button12)
2471+
result = 13;
24492472

24502473
if (result)
24512474
{
@@ -2582,7 +2605,7 @@ FixupCustom (int w)
25822605
switch (w)
25832606
{
25842607
case 0:
2585-
DrawCustMouse (1);
2608+
DrawCustJoy2 (1);
25862609
break;
25872610
case 3:
25882611
DrawCustJoy (1);
@@ -2612,7 +2635,7 @@ FixupCustom (int w)
26122635
switch (lastwhich)
26132636
{
26142637
case 0:
2615-
DrawCustMouse (0);
2638+
DrawCustJoy2 (0);
26162639
break;
26172640
case 3:
26182641
DrawCustJoy (0);
@@ -2645,7 +2668,7 @@ DrawCustomScreen (void)
26452668

26462669
PrintX = CST_START;
26472670
PrintY = CST_Y + 26;
2648-
DrawCustMouse (0);
2671+
DrawCustJoy2 (0);
26492672

26502673
PrintX = CST_START;
26512674
US_Print ("\n\n\n");
@@ -2675,7 +2698,7 @@ DrawCustomScreen (void)
26752698

26762699
#ifndef SPEAR
26772700
PrintY = CST_Y;
2678-
US_CPrint ("Mouse\n");
2701+
US_CPrint ("Game Controller\n");
26792702
#else
26802703
PrintY = CST_Y + 13;
26812704
VWB_DrawPic (128, 48, C_MOUSEPIC);
@@ -2684,26 +2707,26 @@ DrawCustomScreen (void)
26842707
SETFONTCOLOR (TEXTCOLOR, BKGDCOLOR);
26852708
#ifdef SPANISH
26862709
PrintX = CST_START - 16;
2687-
US_Print (STR_CRUN);
2710+
US_Print (STR_CPAUSE);
26882711
PrintX = CST_START - 16 + CST_SPC * 1;
2689-
US_Print (STR_COPEN);
2712+
US_Print (STR_CESCAPE);
26902713
PrintX = CST_START - 16 + CST_SPC * 2;
2691-
US_Print (STR_CFIRE);
2714+
US_Print (STR_CPREVWEP);
26922715
PrintX = CST_START - 16 + CST_SPC * 3;
2693-
US_Print (STR_CSTRAFE "\n");
2716+
US_Print (STR_CNEXTWEP "\n");
26942717
#else
26952718
PrintX = CST_START;
2696-
US_Print (STR_CRUN);
2719+
US_Print (STR_CPAUSE);
26972720
PrintX = CST_START + CST_SPC * 1;
2698-
US_Print (STR_COPEN);
2721+
US_Print (STR_CESCAPE);
26992722
PrintX = CST_START + CST_SPC * 2;
2700-
US_Print (STR_CFIRE);
2723+
US_Print (STR_CPREVWEP);
27012724
PrintX = CST_START + CST_SPC * 3;
2702-
US_Print (STR_CSTRAFE "\n");
2725+
US_Print (STR_CNEXTWEP "\n");
27032726
#endif
27042727

27052728
DrawWindow (5, PrintY - 1, 310, 13, BKGDCOLOR);
2706-
DrawCustMouse (0);
2729+
DrawCustJoy2 (0);
27072730
US_Print ("\n");
27082731

27092732

@@ -2712,7 +2735,7 @@ DrawCustomScreen (void)
27122735
//
27132736
#ifndef SPEAR
27142737
SETFONTCOLOR (READCOLOR, BKGDCOLOR);
2715-
US_CPrint ("Joystick/Gravis GamePad\n");
2738+
US_CPrint ("\n");
27162739
#else
27172740
PrintY += 13;
27182741
VWB_DrawPic (40, 88, C_JOYSTICKPIC);
@@ -2825,21 +2848,23 @@ DrawCustomScreen (void)
28252848

28262849

28272850
void
2828-
PrintCustMouse (int i)
2851+
PrintCustJoy2 (int i)
28292852
{
28302853
int j;
28312854

2832-
for (j = 0; j < 4; j++)
2833-
if (order[i] == buttonmouse[j])
2855+
for (int j = 0; j < 13; j++)
2856+
{
2857+
if (order2[i] == buttonjoy[j])
28342858
{
28352859
PrintX = CST_START + CST_SPC * i;
28362860
US_Print (mbarray[j]);
28372861
break;
28382862
}
2863+
}
28392864
}
28402865

28412866
void
2842-
DrawCustMouse (int hilight)
2867+
DrawCustJoy2 (int hilight)
28432868
{
28442869
int i, color;
28452870

@@ -2849,7 +2874,7 @@ DrawCustMouse (int hilight)
28492874
color = HIGHLIGHT;
28502875
SETFONTCOLOR (color, BKGDCOLOR);
28512876

2852-
if (!mouseenabled)
2877+
if (!joystickenabled)
28532878
{
28542879
SETFONTCOLOR (DEACTIVE, BKGDCOLOR);
28552880
CusMenu[0].active = 0;
@@ -2859,7 +2884,7 @@ DrawCustMouse (int hilight)
28592884

28602885
PrintY = CST_Y + 13 * 2;
28612886
for (i = 0; i < 4; i++)
2862-
PrintCustMouse (i);
2887+
PrintCustJoy2 (i);
28632888
}
28642889

28652890
void
@@ -3732,7 +3757,7 @@ WaitKeyUp (void)
37323757
{
37333758
ControlInfo ci;
37343759
while (ReadAnyControl (&ci), ci.button0 |
3735-
ci.button1 | ci.button2 | ci.button3 | ci.button4 | ci.button5 | ci.button6 | ci.button7 | ci.button8 | ci.button9 |
3760+
ci.button1 | ci.button2 | ci.button3 | ci.button4 | ci.button5 | ci.button6 | ci.button7 | ci.button8 | ci.button9 | ci.button10 | ci.button11 | ci.button12 |
37363761
Keyboard[sc_Space] | Keyboard[sc_Enter] | Keyboard[sc_Escape])
37373762
{
37383763
IN_WaitAndProcessEvents();
@@ -3825,6 +3850,9 @@ ReadAnyControl (ControlInfo * ci)
38253850
ci->button7 = (jb & (1 << 7)) > 0;
38263851
ci->button8 = (jb & (1 << 8)) > 0;
38273852
ci->button9 = (jb & (1 << 9)) > 0;
3853+
ci->button10 = (jb & (1 << 10)) > 0;
3854+
ci->button11 = (jb & (1 << 11)) > 0;
3855+
ci->button12 = (jb & (1 << 12)) > 0;
38283856
}
38293857
}
38303858
}

wl_menu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void SetTextColor(CP_itemtype *items,int hlight);
155155
void DrawMenuGun(CP_iteminfo *iteminfo);
156156
void DrawStripes(int y);
157157

158-
void DefineMouseBtns(void);
158+
void DefineJoy2Btns(void);
159159
void DefineJoyBtns(void);
160160
void DefineKeyBtns(void);
161161
void DefineKeyMove(void);
@@ -171,11 +171,11 @@ void DrawMouseSens(void);
171171
void DrawCtlScreen(void);
172172
void DrawCustomScreen(void);
173173
void DrawLSAction(int which);
174-
void DrawCustMouse(int hilight);
174+
void DrawCustJoy2(int hilight);
175175
void DrawCustJoy(int hilight);
176176
void DrawCustKeybd(int hilight);
177177
void DrawCustKeys(int hilight);
178-
void PrintCustMouse(int i);
178+
void PrintCustJoy2(int i);
179179
void PrintCustJoy(int i);
180180
void PrintCustKeybd(int i);
181181
void PrintCustKeys(int i);
@@ -204,7 +204,7 @@ void CheckForEpisodes(void);
204204
void FreeMusic(void);
205205

206206

207-
enum {MOUSE,JOYSTICK,KEYBOARDBTNS,KEYBOARDMOVE}; // FOR INPUT TYPES
207+
enum {MOUSE,JOYSTICK,JOYSTICK2,KEYBOARDBTNS,KEYBOARDMOVE}; // FOR INPUT TYPES
208208

209209
enum menuitems
210210
{

0 commit comments

Comments
 (0)