Added miscellaneous gamepad buttons for additional macro buttons on some controllers
This commit is contained in:
@@ -790,14 +790,14 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||
SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickGoogleStadiaController(vendor, product)) {
|
||||
/* The Google Stadia controller has a share button and a Google Assistant button */
|
||||
SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string));
|
||||
SDL_strlcat(mapping_string, "misc1:b11,misc2:b12", sizeof(mapping_string));
|
||||
} else if (SDL_IsJoystickNVIDIASHIELDController(vendor, product)) {
|
||||
/* The NVIDIA SHIELD controller has a share button between back and start buttons */
|
||||
SDL_strlcat(mapping_string, "misc1:b11,", sizeof(mapping_string));
|
||||
|
||||
if (product == USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103) {
|
||||
/* The original SHIELD controller has a touchpad as well */
|
||||
SDL_strlcat(mapping_string, "touchpad:b12,", sizeof(mapping_string));
|
||||
/* The original SHIELD controller has a touchpad and plus/minus buttons as well */
|
||||
SDL_strlcat(mapping_string, "touchpad:b12,misc2:b13,misc3:b14", sizeof(mapping_string));
|
||||
}
|
||||
} else if (SDL_IsJoystickPS4(vendor, product)) {
|
||||
/* PS4 controllers have an additional touchpad button */
|
||||
@@ -805,7 +805,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
|
||||
} else if (SDL_IsJoystickPS5(vendor, product)) {
|
||||
/* PS5 controllers have a microphone button and an additional touchpad button */
|
||||
SDL_strlcat(mapping_string, "touchpad:b11,misc1:b12,", sizeof(mapping_string));
|
||||
/* DualSense Edge controllers have paddles */
|
||||
/* DualSense Edge controllers have paddles and a microphone button */
|
||||
if (SDL_IsJoystickDualSenseEdge(vendor, product)) {
|
||||
SDL_strlcat(mapping_string, "paddle1:b16,paddle2:b15,paddle3:b14,paddle4:b13,", sizeof(mapping_string));
|
||||
}
|
||||
@@ -1085,7 +1085,10 @@ static const char *map_StringForGamepadButton[] = {
|
||||
"paddle2",
|
||||
"paddle3",
|
||||
"paddle4",
|
||||
"touchpad"
|
||||
"touchpad",
|
||||
"misc2",
|
||||
"misc3",
|
||||
"misc4"
|
||||
};
|
||||
SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == SDL_GAMEPAD_BUTTON_MAX);
|
||||
|
||||
@@ -1518,7 +1521,7 @@ static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping)
|
||||
|
||||
/* Trim whitespace */
|
||||
length = SDL_strlen(result);
|
||||
while (SDL_isspace(result[length - 1])) {
|
||||
while (length > 0 && SDL_isspace(result[length - 1])) {
|
||||
--length;
|
||||
}
|
||||
result[length] = '\0';
|
||||
@@ -1751,6 +1754,9 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "dpleft", &raw_map->dpleft);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "dpright", &raw_map->dpright);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc1", &raw_map->misc1);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc2", &raw_map->misc2);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc3", &raw_map->misc3);
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc4", &raw_map->misc4);
|
||||
/* Keep using paddle1-4 in the generated mapping so that it can be
|
||||
* reused with SDL2 */
|
||||
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "paddle1", &raw_map->right_paddle1);
|
||||
|
||||
@@ -212,6 +212,9 @@ typedef struct SDL_GamepadMapping
|
||||
SDL_InputMapping dpleft;
|
||||
SDL_InputMapping dpright;
|
||||
SDL_InputMapping misc1;
|
||||
SDL_InputMapping misc2;
|
||||
SDL_InputMapping misc3;
|
||||
SDL_InputMapping misc4;
|
||||
SDL_InputMapping right_paddle1;
|
||||
SDL_InputMapping left_paddle1;
|
||||
SDL_InputMapping right_paddle2;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_STADIA_SHARE = 11,
|
||||
SDL_GAMEPAD_BUTTON_STADIA_CAPTURE = 11,
|
||||
SDL_GAMEPAD_BUTTON_STADIA_GOOGLE_ASSISTANT,
|
||||
SDL_GAMEPAD_NUM_STADIA_BUTTONS,
|
||||
};
|
||||
@@ -218,7 +218,7 @@ static void HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_GUIDE, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_START, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_STICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_STADIA_SHARE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_STADIA_CAPTURE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
|
||||
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_STADIA_GOOGLE_ASSISTANT, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED);
|
||||
}
|
||||
|
||||
|
||||
@@ -682,6 +682,26 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM
|
||||
out->left_paddle2.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_TOUCHPAD))) {
|
||||
out->touchpad.kind = EMappingKind_Button;
|
||||
out->touchpad.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_MISC2))) {
|
||||
out->misc2.kind = EMappingKind_Button;
|
||||
out->misc2.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_MISC3))) {
|
||||
out->misc3.kind = EMappingKind_Button;
|
||||
out->misc3.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_MISC4))) {
|
||||
out->misc4.kind = EMappingKind_Button;
|
||||
out->misc4.target = current_button++;
|
||||
}
|
||||
|
||||
if (current_axis < hwdata->desc.naxes && (hwdata->desc.axis_mask & (1 << SDL_GAMEPAD_AXIS_LEFTX))) {
|
||||
out->leftx.kind = EMappingKind_Axis;
|
||||
out->leftx.target = current_axis++;
|
||||
|
||||
Reference in New Issue
Block a user