mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-15 17:11:24 +00:00
- Added support for up to 4 DirectInput joysticks at the same time for fake splitscreen. But with more than 32 buttons per device they will overlap as before and you'll get wrong labels.
This commit is contained in:
parent
275ecb2623
commit
45abf1a5c9
4 changed files with 186 additions and 34 deletions
|
@ -111,30 +111,30 @@ const char *KeyNames[NUM_KEYS] =
|
|||
"Joy21", "Joy22", "Joy23", "Joy24",
|
||||
"Joy25", "Joy26", "Joy27", "Joy28",
|
||||
"Joy29", "Joy30", "Joy31", "Joy32",
|
||||
"Joy33", "Joy34", "Joy35", "Joy36",
|
||||
"Joy37", "Joy38", "Joy39", "Joy40",
|
||||
"Joy41", "Joy42", "Joy43", "Joy44",
|
||||
"Joy45", "Joy46", "Joy47", "Joy48",
|
||||
"Joy49", "Joy50", "Joy51", "Joy52",
|
||||
"Joy53", "Joy54", "Joy55", "Joy56",
|
||||
"Joy57", "Joy58", "Joy59", "Joy60",
|
||||
"Joy61", "Joy62", "Joy63", "Joy64",
|
||||
"Joy65", "Joy66", "Joy67", "Joy68",
|
||||
"Joy69", "Joy70", "Joy71", "Joy72",
|
||||
"Joy73", "Joy74", "Joy75", "Joy76",
|
||||
"Joy77", "Joy78", "Joy79", "Joy80",
|
||||
"Joy81", "Joy82", "Joy83", "Joy84",
|
||||
"Joy85", "Joy86", "Joy87", "Joy88",
|
||||
"Joy89", "Joy90", "Joy91", "Joy92",
|
||||
"Joy93", "Joy94", "Joy95", "Joy96",
|
||||
"Joy97", "Joy98", "Joy99", "Joy100",
|
||||
"Joy101", "Joy102", "Joy103", "Joy104",
|
||||
"Joy105", "Joy106", "Joy107", "Joy108",
|
||||
"Joy109", "Joy110", "Joy111", "Joy112",
|
||||
"Joy113", "Joy114", "Joy115", "Joy116",
|
||||
"Joy117", "Joy118", "Joy119", "Joy120",
|
||||
"Joy121", "Joy122", "Joy123", "Joy124",
|
||||
"Joy125", "Joy126", "Joy127", "Joy128",
|
||||
"Joy2_1", "Joy2_2", "Joy2_3", "Joy2_4",
|
||||
"Joy2_5", "Joy2_6", "Joy2_7", "Joy2_8",
|
||||
"Joy2_9", "Joy2_10", "Joy2_11", "Joy2_12",
|
||||
"Joy2_13", "Joy2_14", "Joy2_15", "Joy2_16",
|
||||
"Joy2_17", "Joy2_18", "Joy2_19", "Joy2_20",
|
||||
"Joy2_21", "Joy2_22", "Joy2_23", "Joy2_24",
|
||||
"Joy2_25", "Joy2_26", "Joy2_27", "Joy2_28",
|
||||
"Joy2_29", "Joy2_30", "Joy2_31", "Joy2_32",
|
||||
"Joy3_1", "Joy3_2", "Joy3_3", "Joy3_4",
|
||||
"Joy3_5", "Joy3_6", "Joy3_7", "Joy3_8",
|
||||
"Joy3_9", "Joy3_10", "Joy3_11", "Joy3_12",
|
||||
"Joy3_13", "Joy3_14", "Joy3_15", "Joy3_16",
|
||||
"Joy3_17", "Joy3_18", "Joy3_19", "Joy3_20",
|
||||
"Joy3_21", "Joy3_22", "Joy3_23", "Joy3_24",
|
||||
"Joy3_25", "Joy3_26", "Joy3_27", "Joy3_28",
|
||||
"Joy3_29", "Joy3_30", "Joy3_31", "Joy3_32",
|
||||
"Joy4_1", "Joy4_2", "Joy4_3", "Joy4_4",
|
||||
"Joy4_5", "Joy4_6", "Joy4_7", "Joy4_8",
|
||||
"Joy4_9", "Joy4_10", "Joy4_11", "Joy4_12",
|
||||
"Joy4_13", "Joy4_14", "Joy4_15", "Joy4_16",
|
||||
"Joy4_17", "Joy4_18", "Joy4_19", "Joy4_20",
|
||||
"Joy4_21", "Joy4_22", "Joy4_23", "Joy4_24",
|
||||
"Joy4_25", "Joy4_26", "Joy4_27", "Joy4_28",
|
||||
"Joy4_29", "Joy4_30", "Joy4_31", "Joy4_32",
|
||||
|
||||
"POV1Up", "POV1Right","POV1Down", "POV1Left", // First POV hat
|
||||
"POV2Up", "POV2Right","POV2Down", "POV2Left", // Second POV hat
|
||||
|
@ -155,7 +155,37 @@ const char *KeyNames[NUM_KEYS] =
|
|||
"DPadUp","DPadDown","DPadLeft","DPadRight", // Gamepad buttons
|
||||
"Pad_Start","Pad_Back","LThumb","RThumb",
|
||||
"LShoulder","RShoulder","LTrigger","RTrigger",
|
||||
"Pad_A", "Pad_B", "Pad_X", "Pad_Y"
|
||||
"Pad_A", "Pad_B", "Pad_X", "Pad_Y",
|
||||
|
||||
"POV21Up", "POV21Right","POV21Down", "POV21Left", // First POV hat
|
||||
"POV22Up", "POV22Right","POV22Down", "POV22Left", // Second POV hat
|
||||
"POV23Up", "POV23Right","POV23Down", "POV23Left", // Third POV hat
|
||||
"POV24Up", "POV24Right","POV24Down", "POV24Left", // Fourth POV hat
|
||||
|
||||
"POV31Up", "POV31Right","POV31Down", "POV31Left", // First POV hat
|
||||
"POV32Up", "POV32Right","POV32Down", "POV32Left", // Second POV hat
|
||||
"POV33Up", "POV33Right","POV33Down", "POV33Left", // Third POV hat
|
||||
"POV34Up", "POV34Right","POV34Down", "POV34Left", // Fourth POV hat
|
||||
|
||||
"POV41Up", "POV41Right","POV41Down", "POV41Left", // First POV hat
|
||||
"POV42Up", "POV42Right","POV42Down", "POV42Left", // Second POV hat
|
||||
"POV43Up", "POV43Right","POV43Down", "POV43Left", // Third POV hat
|
||||
"POV44Up", "POV44Right","POV44Down", "POV44Left", // Fourth POV hat
|
||||
|
||||
"Axis21Plus","Axis21Minus","Axis22Plus","Axis22Minus", // joystick axes as buttons
|
||||
"Axis23Plus","Axis23Minus","Axis24Plus","Axis24Minus",
|
||||
"Axis25Plus","Axis25Minus","Axis26Plus","Axis26Minus",
|
||||
"Axis27Plus","Axis27Minus","Axis28Plus","Axis28Minus",
|
||||
|
||||
"Axis31Plus","Axis31Minus","Axis32Plus","Axis32Minus", // joystick axes as buttons
|
||||
"Axis33Plus","Axis33Minus","Axis34Plus","Axis34Minus",
|
||||
"Axis35Plus","Axis35Minus","Axis36Plus","Axis36Minus",
|
||||
"Axis37Plus","Axis37Minus","Axis38Plus","Axis38Minus",
|
||||
|
||||
"Axis41Plus","Axis41Minus","Axis42Plus","Axis42Minus", // joystick axes as buttons
|
||||
"Axis43Plus","Axis43Minus","Axis44Plus","Axis44Minus",
|
||||
"Axis45Plus","Axis45Minus","Axis46Plus","Axis46Minus",
|
||||
"Axis47Plus","Axis47Minus","Axis48Plus","Axis48Minus"
|
||||
};
|
||||
|
||||
FKeyBindings Bindings;
|
||||
|
|
|
@ -173,6 +173,9 @@ enum ESkillLevels
|
|||
#define KEY_MOUSE8 0x107
|
||||
|
||||
#define KEY_FIRSTJOYBUTTON 0x108
|
||||
#define KEY_FIRSTJOY2BUTTON 0x128
|
||||
#define KEY_FIRSTJOY3BUTTON 0x148
|
||||
#define KEY_FIRSTJOY4BUTTON 0x168
|
||||
#define KEY_JOY1 (KEY_FIRSTJOYBUTTON+0)
|
||||
#define KEY_JOY2 (KEY_FIRSTJOYBUTTON+1)
|
||||
#define KEY_JOY3 (KEY_FIRSTJOYBUTTON+2)
|
||||
|
@ -240,7 +243,69 @@ enum ESkillLevels
|
|||
#define KEY_PAD_X 0x1C2
|
||||
#define KEY_PAD_Y 0x1C3
|
||||
|
||||
#define NUM_KEYS 0x1C4
|
||||
#define KEY_JOY2POV1_UP 0x1C4
|
||||
#define KEY_JOY2POV2_UP 0x1C8
|
||||
#define KEY_JOY2POV3_UP 0x1CC
|
||||
#define KEY_JOY2POV4_UP 0x1D0
|
||||
#define KEY_JOY3POV1_UP 0x1D4
|
||||
#define KEY_JOY3POV2_UP 0x1D8
|
||||
#define KEY_JOY3POV3_UP 0x1DC
|
||||
#define KEY_JOY3POV4_UP 0x1E0
|
||||
#define KEY_JOY4POV1_UP 0x1E4
|
||||
#define KEY_JOY4POV2_UP 0x1E8
|
||||
#define KEY_JOY4POV3_UP 0x1EC
|
||||
#define KEY_JOY4POV4_UP 0x1F0
|
||||
|
||||
#define KEY_JOY2AXIS1PLUS 0x1F4
|
||||
#define KEY_JOY2AXIS1MINUS 0x1F5
|
||||
#define KEY_JOY2AXIS2PLUS 0x1F6
|
||||
#define KEY_JOY2AXIS2MINUS 0x1F7
|
||||
#define KEY_JOY2AXIS3PLUS 0x1F8
|
||||
#define KEY_JOY2AXIS3MINUS 0x1F9
|
||||
#define KEY_JOY2AXIS4PLUS 0x1FA
|
||||
#define KEY_JOY2AXIS4MINUS 0x1FB
|
||||
#define KEY_JOY2AXIS5PLUS 0x1FC
|
||||
#define KEY_JOY2AXIS5MINUS 0x1FD
|
||||
#define KEY_JOY2AXIS6PLUS 0x1FE
|
||||
#define KEY_JOY2AXIS6MINUS 0x1FF
|
||||
#define KEY_JOY2AXIS7PLUS 0x200
|
||||
#define KEY_JOY2AXIS7MINUS 0x201
|
||||
#define KEY_JOY2AXIS8PLUS 0x202
|
||||
#define KEY_JOY2AXIS8MINUS 0x203
|
||||
#define KEY_JOY3AXIS1PLUS 0x204
|
||||
#define KEY_JOY3AXIS1MINUS 0x205
|
||||
#define KEY_JOY3AXIS2PLUS 0x206
|
||||
#define KEY_JOY3AXIS2MINUS 0x207
|
||||
#define KEY_JOY3AXIS3PLUS 0x208
|
||||
#define KEY_JOY3AXIS3MINUS 0x209
|
||||
#define KEY_JOY3AXIS4PLUS 0x20A
|
||||
#define KEY_JOY3AXIS4MINUS 0x20B
|
||||
#define KEY_JOY3AXIS5PLUS 0x20C
|
||||
#define KEY_JOY3AXIS5MINUS 0x20D
|
||||
#define KEY_JOY3AXIS6PLUS 0x20E
|
||||
#define KEY_JOY3AXIS6MINUS 0x20F
|
||||
#define KEY_JOY3AXIS7PLUS 0x210
|
||||
#define KEY_JOY3AXIS7MINUS 0x211
|
||||
#define KEY_JOY3AXIS8PLUS 0x212
|
||||
#define KEY_JOY3AXIS8MINUS 0x213
|
||||
#define KEY_JOY4AXIS1PLUS 0x214
|
||||
#define KEY_JOY4AXIS1MINUS 0x215
|
||||
#define KEY_JOY4AXIS2PLUS 0x216
|
||||
#define KEY_JOY4AXIS2MINUS 0x217
|
||||
#define KEY_JOY4AXIS3PLUS 0x218
|
||||
#define KEY_JOY4AXIS3MINUS 0x219
|
||||
#define KEY_JOY4AXIS4PLUS 0x21A
|
||||
#define KEY_JOY4AXIS4MINUS 0x21B
|
||||
#define KEY_JOY4AXIS5PLUS 0x21C
|
||||
#define KEY_JOY4AXIS5MINUS 0x21D
|
||||
#define KEY_JOY4AXIS6PLUS 0x21E
|
||||
#define KEY_JOY4AXIS6MINUS 0x21F
|
||||
#define KEY_JOY4AXIS7PLUS 0x220
|
||||
#define KEY_JOY4AXIS7MINUS 0x221
|
||||
#define KEY_JOY4AXIS8PLUS 0x222
|
||||
#define KEY_JOY4AXIS8MINUS 0x223
|
||||
|
||||
#define NUM_KEYS 0x224
|
||||
|
||||
// [RH] dmflags bits (based on Q2's)
|
||||
enum
|
||||
|
|
|
@ -163,7 +163,7 @@ public:
|
|||
~FDInputJoystick();
|
||||
|
||||
bool GetDevice();
|
||||
void ProcessInput();
|
||||
void ProcessInput(unsigned int joynum);
|
||||
void AddAxes(float axes[NUM_JOYAXIS]);
|
||||
|
||||
// IJoystickConfig interface
|
||||
|
@ -422,7 +422,7 @@ bool FDInputJoystick::GetDevice()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void FDInputJoystick::ProcessInput()
|
||||
void FDInputJoystick::ProcessInput(unsigned int joynum)
|
||||
{
|
||||
HRESULT hr;
|
||||
uint8_t *state;
|
||||
|
@ -473,16 +473,36 @@ void FDInputJoystick::ProcessInput()
|
|||
// Cancel out dead zone
|
||||
axisval = Joy_RemoveDeadZone(axisval, info->DeadZone, &buttonstate);
|
||||
info->Value = float(axisval);
|
||||
|
||||
int keyjoynaxis1plus;
|
||||
switch (joynum)
|
||||
{
|
||||
case 0:
|
||||
keyjoynaxis1plus = KEY_JOYAXIS1PLUS;
|
||||
break;
|
||||
case 1:
|
||||
keyjoynaxis1plus = KEY_JOY2AXIS1PLUS;
|
||||
break;
|
||||
case 2:
|
||||
keyjoynaxis1plus = KEY_JOY3AXIS1PLUS;
|
||||
break;
|
||||
case 3:
|
||||
keyjoynaxis1plus = KEY_JOY4AXIS1PLUS;
|
||||
break;
|
||||
default:
|
||||
keyjoynaxis1plus = KEY_JOYAXIS1PLUS;
|
||||
break;
|
||||
}
|
||||
if (i < NUM_JOYAXISBUTTONS && (i > 2 || Axes.Size() == 1))
|
||||
{
|
||||
Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 2, KEY_JOYAXIS1PLUS + i*2);
|
||||
Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 2, keyjoynaxis1plus + i*2);
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
// Since we sorted the axes, we know that the first two are definitely X and Y.
|
||||
// They are probably a single stick, so use angular position to determine buttons.
|
||||
buttonstate = Joy_XYAxesToButtons(axisval, Axes[0].Value);
|
||||
Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 4, KEY_JOYAXIS1PLUS);
|
||||
Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 4, keyjoynaxis1plus);
|
||||
}
|
||||
info->ButtonValue = buttonstate;
|
||||
}
|
||||
|
@ -496,7 +516,24 @@ void FDInputJoystick::ProcessInput()
|
|||
if (newstate != info->Value)
|
||||
{
|
||||
info->Value = newstate;
|
||||
ev.data1 = KEY_FIRSTJOYBUTTON + i;
|
||||
switch (joynum)
|
||||
{
|
||||
case 0:
|
||||
ev.data1 = KEY_FIRSTJOYBUTTON + i;
|
||||
break;
|
||||
case 1:
|
||||
ev.data1 = KEY_FIRSTJOY2BUTTON + i;
|
||||
break;
|
||||
case 2:
|
||||
ev.data1 = KEY_FIRSTJOY3BUTTON + i;
|
||||
break;
|
||||
case 3:
|
||||
ev.data1 = KEY_FIRSTJOY4BUTTON + i;
|
||||
break;
|
||||
default:
|
||||
ev.data1 = KEY_FIRSTJOYBUTTON + i;
|
||||
break;
|
||||
}
|
||||
ev.type = (newstate != 0) ? EV_KeyDown : EV_KeyUp;
|
||||
D_PostEvent(&ev);
|
||||
}
|
||||
|
@ -517,7 +554,24 @@ void FDInputJoystick::ProcessInput()
|
|||
pov = POVButtons[pov];
|
||||
|
||||
// Send events for POV "buttons" that have changed.
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOYPOV1_UP + i*4);
|
||||
switch (joynum)
|
||||
{
|
||||
case 0:
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOYPOV1_UP + i*4);
|
||||
break;
|
||||
case 1:
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOY2POV1_UP + i*4);
|
||||
break;
|
||||
case 2:
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOY3POV1_UP + i*4);
|
||||
break;
|
||||
case 3:
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOY4POV1_UP + i*4);
|
||||
break;
|
||||
default:
|
||||
Joy_GenerateButtonEvents(info->Value, pov, 4, KEY_JOYPOV1_UP + i*4);
|
||||
break;
|
||||
}
|
||||
info->Value = pov;
|
||||
}
|
||||
}
|
||||
|
@ -563,7 +617,7 @@ BOOL CALLBACK FDInputJoystick::EnumObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpd
|
|||
// joystick buttons. This is what DIJOYSTATE2 offers, so we
|
||||
// probably don't need to worry about any devices with more than
|
||||
// that.
|
||||
if (joy->Buttons.Size() < 128)
|
||||
if (joy->Buttons.Size() < 128) // with more than 32 they will overlap as before
|
||||
{
|
||||
joy->Buttons.Push(info);
|
||||
}
|
||||
|
@ -1082,7 +1136,7 @@ void FDInputJoystickManager::ProcessInput()
|
|||
{
|
||||
if (Devices[i] != NULL)
|
||||
{
|
||||
Devices[i]->ProcessInput();
|
||||
Devices[i]->ProcessInput(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -200,6 +200,9 @@ struct InputEvent native play version("2.4")
|
|||
Key_Mouse8 = 0x107,
|
||||
|
||||
Key_FirstJoyButton = 0x108,
|
||||
Key_FirstJoy2Button = 0x128,
|
||||
Key_FirstJoy3Button = 0x148,
|
||||
Key_FirstJoy4Button = 0x168,
|
||||
Key_Joy1 = (Key_FirstJoyButton+0),
|
||||
Key_Joy2 = (Key_FirstJoyButton+1),
|
||||
Key_Joy3 = (Key_FirstJoyButton+2),
|
||||
|
|
Loading…
Reference in a new issue