Even more miscellaneous gamepad buttons!

main
Sam Lantinga 2024-02-01 20:34:05 -08:00
parent cb70e972e3
commit d04fea8b87
6 changed files with 23 additions and 1 deletions

View File

@ -122,6 +122,8 @@ typedef enum
SDL_GAMEPAD_BUTTON_MISC2, /* Additional button */
SDL_GAMEPAD_BUTTON_MISC3, /* Additional button */
SDL_GAMEPAD_BUTTON_MISC4, /* Additional button */
SDL_GAMEPAD_BUTTON_MISC5, /* Additional button */
SDL_GAMEPAD_BUTTON_MISC6, /* Additional button */
SDL_GAMEPAD_BUTTON_MAX
} SDL_GamepadButton;

View File

@ -1088,7 +1088,9 @@ static const char *map_StringForGamepadButton[] = {
"touchpad",
"misc2",
"misc3",
"misc4"
"misc4",
"misc5",
"misc6"
};
SDL_COMPILE_TIME_ASSERT(map_StringForGamepadButton, SDL_arraysize(map_StringForGamepadButton) == SDL_GAMEPAD_BUTTON_MAX);
@ -1757,6 +1759,8 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *
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);
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc5", &raw_map->misc5);
SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "misc6", &raw_map->misc6);
/* 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);

View File

@ -215,6 +215,8 @@ typedef struct SDL_GamepadMapping
SDL_InputMapping misc2;
SDL_InputMapping misc3;
SDL_InputMapping misc4;
SDL_InputMapping misc5;
SDL_InputMapping misc6;
SDL_InputMapping right_paddle1;
SDL_InputMapping left_paddle1;
SDL_InputMapping right_paddle2;

View File

@ -702,6 +702,16 @@ static SDL_bool VIRTUAL_JoystickGetGamepadMapping(int device_index, SDL_GamepadM
out->misc4.target = current_button++;
}
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_MISC5))) {
out->misc5.kind = EMappingKind_Button;
out->misc5.target = current_button++;
}
if (current_button < hwdata->desc.nbuttons && (hwdata->desc.button_mask & (1 << SDL_GAMEPAD_BUTTON_MISC6))) {
out->misc6.kind = EMappingKind_Button;
out->misc6.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++;

View File

@ -652,6 +652,8 @@ static const char *gamepad_button_names[] = {
"Misc2",
"Misc3",
"Misc4",
"Misc5",
"Misc6",
};
SDL_COMPILE_TIME_ASSERT(gamepad_button_names, SDL_arraysize(gamepad_button_names) == SDL_GAMEPAD_BUTTON_MAX);

View File

@ -785,6 +785,8 @@ static const char *GetBindingInstruction(void)
case SDL_GAMEPAD_BUTTON_MISC2:
case SDL_GAMEPAD_BUTTON_MISC3:
case SDL_GAMEPAD_BUTTON_MISC4:
case SDL_GAMEPAD_BUTTON_MISC5:
case SDL_GAMEPAD_BUTTON_MISC6:
return "Press any additional button not already bound";
case SDL_GAMEPAD_ELEMENT_AXIS_LEFTX_NEGATIVE:
return "Move the left thumbstick to the left";