Skip to content

Commit

Permalink
Presets, Gamepad: Fixed sdl_gamepad::copy_data to also include touch …
Browse files Browse the repository at this point in the history
…pad button (#422)

Iterate until `< SDL_CONTROLLER_BUTTON_MAX` instead of `< SDL_CONTROLLER_BUTTON_TOUCHPAD` so that the touchpad button is also copied.

- Improved DualSense Preset to support PSButton, TouchPad & MuteMic Button
- Cleaned up the json file with proper names for everything.
  • Loading branch information
meo9979 authored Oct 21, 2024
1 parent 32d19bb commit bcbb793
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 94 deletions.
234 changes: 141 additions & 93 deletions presets/dualsense/dualsense.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
0,
0
],
"id": "texture0",
"z_level": "0",
"id": "PS5 DualSense texture",
"z_level": 0,
"mapping": [
1,
1,
Expand All @@ -28,7 +28,7 @@
389,
517
],
"id": "analog stick1",
"id": "Left analog stick",
"z_level": 1,
"mapping": [
1359,
Expand All @@ -40,124 +40,145 @@
"side": 0
},
{
"type": 2,
"type": 5,
"pos": [
1047,
431
810,
516
],
"id": "gamepad button3",
"id": "Right analog stick",
"z_level": 1,
"mapping": [
0,
792,
99,
91
],
"code": 0
},
{
"type": 2,
"pos": [
946,
349
],
"id": "gamepad button4",
"z_level": "1",
"mapping": [
102,
793,
98,
90
1359,
1,
157,
156
],
"code": 2
"stick_radius": 30,
"side": 1
},
{
"type": 8,
"pos": [
136,
281
],
"id": "dpad5",
"z_level": "1",
"id": "D-Pad",
"z_level": 1,
"mapping": [
1,
1013,
229,
220
]
},
{
"type": 6,
"pos": [
990,
0
],
"id": "PS5 Left Trigger L2",
"z_level": 1,
"mapping": [
922,
792,
187,
104
],
"direction": 1,
"trigger_mode": false,
"side": 1
},
{
"type": 6,
"pos": [
167,
0
],
"id": "PS5 Right Trigger R2",
"z_level": 1,
"mapping": [
1112,
792,
187,
104
],
"direction": 1,
"trigger_mode": false,
"side": 0
},
{
"type": 2,
"pos": [
1050,
257
1047,
431
],
"id": "gamepad button6",
"z_level": "1",
"id": "Button PS5 X",
"z_level": 1,
"mapping": [
203,
0,
792,
99,
91
],
"code": 3
"code": 0
},
{
"type": 2,
"pos": [
1150,
345
],
"id": "gamepad button7",
"z_level": "1",
"id": "Button PS5 Circle",
"z_level": 1,
"mapping": [
305,
792,
98,
90
],
"code": 1
},
},
{
"type": 2,
"pos": [
146,
75
946,
349
],
"id": "gamepad button8",
"z_level": "1",
"id": "Button PS5 Square",
"z_level": 1,
"mapping": [
409,
792,
206,
108
102,
793,
98,
90
],
"code": 9
"code": 2
},
{
"type": 2,
"pos": [
992,
75
1050,
257
],
"id": "gamepad button9",
"z_level": "1",
"id": "Button PS5 Triangle",
"z_level": 1,
"mapping": [
618,
203,
792,
206,
108
99,
91
],
"code": 10
"code": 3
},
{
"type": 2,
"pos": [
332,
225
],
"id": "gamepad button10",
"z_level": "1",
"id": "Button PS5 Start",
"z_level": 1,
"mapping": [
874,
792,
Expand All @@ -166,14 +187,30 @@
],
"code": 4
},
{
"type": 2,
"pos": [
634,
507
],
"id": "Button PS5 PS Button",
"z_level": 1,
"mapping": [
1551,
16,
86,
54
],
"code": 5
},
{
"type": 2,
"pos": [
968,
225
],
"id": "gamepad button11",
"z_level": "1",
"id": "Button PS5 Select",
"z_level": 1,
"mapping": [
827,
792,
Expand All @@ -183,57 +220,68 @@
"code": 6
},
{
"type": 6,
"type": 2,
"pos": [
990,
0
650,
587
],
"id": "trigger12",
"id": "Button PS5 Mute",
"z_level": 1,
"mapping": [
922,
792,
187,
104
1661,
21,
54,
29
],
"direction": 1,
"trigger_mode": false,
"side": 1
"code": 15
},
{
"type": 6,
"type": 2,
"pos": [
167,
0
390,
138
],
"id": "trigger13",
"z_level": "1",
"id": "Button PS5 TouchPad",
"z_level": 1,
"mapping": [
1112,
1368,
329,
572,
313
],
"code": 20
},
{
"type": 2,
"pos": [
146,
75
],
"id": "PS5 Left Bumper L1",
"z_level": 1,
"mapping": [
409,
792,
187,
104
206,
108
],
"direction": 1,
"trigger_mode": false,
"side": 0
"code": 9
},
{
"type": 5,
"type": 2,
"pos": [
810,
516
992,
75
],
"id": "analog stick2",
"z_level": "5",
"id": "PS5 Right Bumper R1",
"z_level": 1,
"mapping": [
1359,
1,
157,
156
618,
792,
206,
108
],
"stick_radius": 30,
"side": 1
"code": 10
}
]
}
Binary file modified presets/dualsense/dualsense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified presets/dualsense/dualsenseblack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified presets/dualsense/dualsensewhite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/hook/sdl_gamepad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

void sdl_gamepad::copy_data(input_data *data, int index)
{
for (int i = 0; i < SDL_CONTROLLER_BUTTON_TOUCHPAD; ++i) {
for (int i = 0; i < SDL_CONTROLLER_BUTTON_MAX; ++i) {
data->gamepad_buttons[index][i] = SDL_GameControllerGetButton(m_controller, (SDL_GameControllerButton)i) ==
SDL_PRESSED;
}
Expand Down

0 comments on commit bcbb793

Please sign in to comment.