Mercurial > repos > blastem
annotate controller_info.c @ 2276:709036ee222a
Don't set write pending flag for non-existent RF5C164 registers
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 02 Jan 2023 11:37:31 -0800 |
parents | dd9d43c67986 |
children | 7df357522c49 |
rev | line source |
---|---|
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include <string.h> |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
2 #include <stdlib.h> |
2215
a8af8d898a7c
Fix windows build for real
Michael Pavone <pavone@retrodev.com>
parents:
2018
diff
changeset
|
3 #include "render.h" |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
4 #ifndef USE_FBDEV |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 #include "render_sdl.h" |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
6 #endif |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include "controller_info.h" |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
8 #include "config.h" |
1604
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
9 #include "util.h" |
1852
a4cae960fd08
Allow config file to be saved with executable for "portable" setups
Michael Pavone <pavone@retrodev.com>
parents:
1779
diff
changeset
|
10 #include "blastem.h" |
1861
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
11 #include "bindings.h" |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 typedef struct { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 char const *name; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 controller_info info; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 } heuristic; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
18 static heuristic heuristics[] = { |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 //TODO: Add more heuristic rules |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 {"DualShock 4", {.type = TYPE_PSX, .subtype = SUBTYPE_PS4}}, |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
21 {"PS5", {.type = TYPE_PSX, .subtype = SUBTYPE_PS5}}, |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 {"PS4", {.type = TYPE_PSX, .subtype = SUBTYPE_PS4}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 {"PS3", {.type = TYPE_PSX, .subtype = SUBTYPE_PS3}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 {"X360", {.type = TYPE_XBOX, .subtype = SUBTYPE_X360}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 {"Xbox 360", {.type = TYPE_XBOX, .subtype = SUBTYPE_X360}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 {"X-box 360", {.type = TYPE_XBOX, .subtype = SUBTYPE_X360}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 {"Xbox One", {.type = TYPE_XBOX, .subtype = SUBTYPE_XBONE}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 {"X-box One", {.type = TYPE_XBOX, .subtype = SUBTYPE_XBONE}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 {"WiiU", {.type = TYPE_NINTENDO, .subtype = SUBTYPE_WIIU}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 {"Wii U", {.type = TYPE_NINTENDO, .subtype = SUBTYPE_WIIU}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 {"Nintendo Switch", {.type = TYPE_NINTENDO, .subtype = SUBTYPE_SWITCH}}, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 {"Saturn", {.type = TYPE_SEGA, .subtype = SUBTYPE_SATURN}} |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 const uint32_t num_heuristics = sizeof(heuristics)/sizeof(*heuristics); |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
36 static tern_node *info_config; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
37 static uint8_t loaded; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
38 static const char *subtype_names[] = { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
39 "unknown", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
40 "xbox", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
41 "xbox 360", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
42 "xbone", |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
43 "xbox elite", |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
44 "ps2", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
45 "ps3", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
46 "ps4", |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
47 "ps5", |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
48 "wiiu", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
49 "switch", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
50 "genesis", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
51 "saturn" |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
52 }; |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
53 static const char *subtype_human_names[] = { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
54 "unknown", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
55 "Xbos", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
56 "Xbox 360", |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
57 "Xbox One/Series", |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
58 "Xbox Elite", |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
59 "PS2", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
60 "PS3", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
61 "PS4", |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
62 "PS5", |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
63 "Wii-U", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
64 "Switch", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
65 "Genesis", |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
66 "Saturn" |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
67 }; |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
68 static const char *variant_names[] = { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
69 "normal", |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
70 "6b bumpers", |
2015
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
71 "6b right", |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
72 "3button", |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
73 "6button", |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
74 "8button" |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
75 }; |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
76 |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
77 static void load_ctype_config(void) |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 { |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
79 if (!loaded) { |
1852
a4cae960fd08
Allow config file to be saved with executable for "portable" setups
Michael Pavone <pavone@retrodev.com>
parents:
1779
diff
changeset
|
80 info_config = load_overrideable_config("controller_types.cfg", "controller_types.cfg", NULL); |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
81 loaded = 1; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
82 } |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
83 } |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
84 |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
85 controller_info get_controller_info(int joystick) |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
86 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
87 #ifndef USE_FBDEV |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
88 load_ctype_config(); |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
89 char guid_string[33]; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
90 SDL_Joystick *stick = render_get_joystick(joystick); |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 SDL_GameController *control = render_get_controller(joystick); |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
92 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(stick), guid_string, sizeof(guid_string)); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
93 tern_node *info = tern_find_node(info_config, guid_string); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
94 if (info) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
95 controller_info res; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
96 char *subtype = tern_find_ptr(info, "subtype"); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
97 res.subtype = SUBTYPE_UNKNOWN; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
98 if (subtype) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
99 for (int i = 0; i < SUBTYPE_NUM; i++) |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
100 { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
101 if (!strcmp(subtype_names[i], subtype)) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
102 res.subtype = i; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
103 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
104 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
105 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
106 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
107 switch (res.subtype) |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
108 { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
109 case SUBTYPE_XBOX: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
110 case SUBTYPE_X360: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
111 case SUBTYPE_XBONE: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
112 res.type = TYPE_XBOX; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
113 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
114 case SUBTYPE_PS2: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
115 case SUBTYPE_PS3: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
116 case SUBTYPE_PS4: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
117 res.type = TYPE_PSX; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
118 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
119 case SUBTYPE_WIIU: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
120 case SUBTYPE_SWITCH: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
121 res.type = TYPE_NINTENDO; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
122 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
123 case SUBTYPE_GENESIS: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
124 case SUBTYPE_SATURN: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
125 res.type = TYPE_SEGA; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
126 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
127 default: |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
128 res.type = TYPE_UNKNOWN; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
129 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
130 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
131 char *variant = tern_find_ptr(info, "variant"); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
132 res.variant = VARIANT_NORMAL; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
133 if (variant) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
134 for (int i = 0; i < VARIANT_NUM; i++) |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
135 { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
136 if (!strcmp(variant_names[i], variant)) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
137 res.variant = i; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
138 break; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
139 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
140 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
141 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
142 res.name = control ? SDL_GameControllerName(control) : SDL_JoystickName(stick); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
143 if (control) { |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
144 SDL_GameControllerClose(control); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
145 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
146 return res; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
147 } |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 if (!control) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 return (controller_info) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 .type = TYPE_UNKNOWN, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 .subtype = SUBTYPE_UNKNOWN, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 .variant = VARIANT_NORMAL, |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
153 .name = SDL_JoystickName(stick) |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 const char *name = SDL_GameControllerName(control); |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 SDL_GameControllerClose(control); |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 for (uint32_t i = 0; i < num_heuristics; i++) |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 if (strstr(name, heuristics[i].name)) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 controller_info res = heuristics[i].info; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 res.name = name; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 return res; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 } |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
166 #else |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
167 const char *name = "Unknown"; |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
168 #endif |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 //default to a 360 |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 return (controller_info){ |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 .type = TYPE_GENERIC_MAPPING, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 .subtype = SUBTYPE_UNKNOWN, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 .variant = VARIANT_NORMAL, |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 .name = name |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
178 static void mappings_iter(char *key, tern_val val, uint8_t valtype, void *data) |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
179 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
180 #ifndef USE_FBDEV |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
181 if (valtype != TVAL_NODE) { |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
182 return; |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
183 } |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
184 char *mapping = tern_find_ptr(val.ptrval, "mapping"); |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
185 if (mapping) { |
1604
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
186 const char *parts[] = {key, ",", mapping}; |
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
187 char * full = alloc_concat_m(3, parts); |
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
188 SDL_GameControllerAddMapping(full); |
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
189 free(full); |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
190 } |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
191 #endif |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
192 } |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
193 |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
194 void controller_add_mappings(void) |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
195 { |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
196 load_ctype_config(); |
1604
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
197 if (info_config) { |
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
198 tern_foreach(info_config, mappings_iter, NULL); |
68b05322d971
Don't redundantly store controller GUID when saving a mapping. Remove illegal chars from controller name
Michael Pavone <pavone@retrodev.com>
parents:
1603
diff
changeset
|
199 } |
1603
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
200 } |
c0727712d529
Read extral SDL2 mappings on startup from controller_types.cfg
Michael Pavone <pavone@retrodev.com>
parents:
1600
diff
changeset
|
201 |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
202 void save_controller_info(int joystick, controller_info *info) |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
203 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
204 #ifndef USE_FBDEV |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
205 char guid_string[33]; |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
206 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string)); |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
207 tern_node *existing = tern_find_node(info_config, guid_string); |
1859
52f136052ab0
Allow changing SDL2 mapping and controller type after initial configuration
Michael Pavone <pavone@retrodev.com>
parents:
1852
diff
changeset
|
208 existing = tern_insert_ptr(existing, "subtype", strdup(subtype_names[info->subtype])); |
52f136052ab0
Allow changing SDL2 mapping and controller type after initial configuration
Michael Pavone <pavone@retrodev.com>
parents:
1852
diff
changeset
|
209 existing = tern_insert_ptr(existing, "variant", strdup(variant_names[info->variant])); |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
210 info_config = tern_insert_node(info_config, guid_string, existing); |
1852
a4cae960fd08
Allow config file to be saved with executable for "portable" setups
Michael Pavone <pavone@retrodev.com>
parents:
1779
diff
changeset
|
211 persist_config_at(config, info_config, "controller_types.cfg"); |
1861
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
212 handle_joy_added(joystick); |
2215
a8af8d898a7c
Fix windows build for real
Michael Pavone <pavone@retrodev.com>
parents:
2018
diff
changeset
|
213 #endif |
1599
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
214 } |
1fc61c844ec5
Allow selecting controller type when controllers have an SDL 2 mapping, but heuristics fail to idenify details
Michael Pavone <pavone@retrodev.com>
parents:
1597
diff
changeset
|
215 |
1600
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
216 void save_controller_mapping(int joystick, char *mapping_string) |
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
217 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
218 #ifndef USE_FBDEV |
1600
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
219 char guid_string[33]; |
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
220 SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(render_get_joystick(joystick)), guid_string, sizeof(guid_string)); |
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
221 tern_node *existing = tern_find_node(info_config, guid_string); |
2218
58774a77f2e0
Fix crash when rebinding a controller
Michael Pavone <pavone@retrodev.com>
parents:
2215
diff
changeset
|
222 existing = tern_insert_ptr(existing, "mapping", strdup(mapping_string)); |
1600
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
223 info_config = tern_insert_node(info_config, guid_string, existing); |
1852
a4cae960fd08
Allow config file to be saved with executable for "portable" setups
Michael Pavone <pavone@retrodev.com>
parents:
1779
diff
changeset
|
224 persist_config_at(config, info_config, "controller_types.cfg"); |
1861
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
225 const char *parts[] = {guid_string, ",", mapping_string}; |
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
226 char * full = alloc_concat_m(3, parts); |
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
227 SDL_GameControllerAddMapping(full); |
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
228 free(full); |
fc05f49075c2
Reprocess bindings when SDL2 mappings, controller types or controller order change
Michael Pavone <pavone@retrodev.com>
parents:
1859
diff
changeset
|
229 handle_joy_added(joystick); |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
230 #endif |
1600
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
231 } |
7f39c40b4b25
WIP UI for creating an SDL2 mapping for controllers that don't have one
Michael Pavone <pavone@retrodev.com>
parents:
1599
diff
changeset
|
232 |
2018
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
233 void delete_controller_info(void) |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
234 { |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
235 delete_custom_config_at("controller_types.cfg"); |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
236 loaded = 0; |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
237 tern_free(info_config); |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
238 info_config = NULL; |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
239 render_reset_mappings(); |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
240 } |
193b804c9845
Add a UI button to reset config to defaults
Michael Pavone <pavone@retrodev.com>
parents:
2015
diff
changeset
|
241 |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
242 char const *labels_xbox[] = { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
243 "A", "B", "X", "Y", "Back", NULL, "Start", "Click", "Click", "White", "Black", "LT", "RT" |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
244 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
245 char const *labels_360[] = { |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
246 "A", "B", "X", "Y", "Back", "Xbox", "Start", "Click", "Click", "LB", "RB", "LT", "RT" |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
247 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
248 static char const *labels_xbone[] = { |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
249 "A", "B", "X", "Y", "View", "Xbox", "Menu", "Click", "Click", "LB", "RB", "LT", "RT" |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
250 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
251 static char const *labels_ps3[] = { |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
252 "cross", "circle", "square", "triangle", "Select", "PS", "Start", "L3", "R3", "L1", "R1", "L2", "R2" |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
253 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
254 static char const *labels_ps4[] = { |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
255 "cross", "circle", "square", "triangle", "Share", "PS", "Options", "L3", "R3", "L1", "R1", "L2", "R2" |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
256 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
257 static char const *labels_nintendo[] = { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
258 "B", "A", "Y", "X", "-", "Home", "+", "Click", "Click", "L", "R", "ZL", "ZR" |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
259 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
260 static char const *labels_genesis[] = { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
261 "A", "B", "X", "Y", NULL, NULL, "Start", NULL, NULL, "Z", "C", NULL, "Mode" |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
262 }; |
2015
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
263 static char const *labels_genesis_3button[] = { |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
264 "A", "B", NULL, NULL, NULL, NULL, "Start", NULL, NULL, NULL, "C", NULL, "Mode" |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
265 }; |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
266 static char const *labels_genesis_8button[] = { |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
267 "A", "B", "X", "Y", "Mode", NULL, "Start", NULL, NULL, "Z", "C", "L", "R" |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
268 }; |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
269 static char const *labels_saturn[] = { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
270 "A", "B", "X", "Y", NULL, NULL, "Start", NULL, NULL, "Z", "C", "LT", "RT" |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
271 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
272 |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
273 static const char** label_source(controller_info *info) |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
274 { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
275 if (info->type == TYPE_UNKNOWN || info->type == TYPE_GENERIC_MAPPING || info->subtype ==SUBTYPE_X360) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
276 return labels_360; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
277 } else if (info->type == TYPE_NINTENDO) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
278 return labels_nintendo; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
279 } else if (info->type == TYPE_PSX) { |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
280 if (info->subtype >= SUBTYPE_PS4) { |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
281 return labels_ps4; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
282 } else { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
283 return labels_ps3; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
284 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
285 } else if (info->type == TYPE_XBOX) { |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
286 if (info->subtype >= SUBTYPE_XBONE) { |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
287 return labels_xbone; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
288 } else { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
289 return labels_xbox; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
290 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
291 } else { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
292 if (info->subtype == SUBTYPE_GENESIS) { |
2015
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
293 if (info->variant == VARIANT_8BUTTON) { |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
294 return labels_genesis_8button; |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
295 } else if (info->variant == VARIANT_3BUTTON) { |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
296 return labels_genesis_3button; |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
297 } else { |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
298 return labels_genesis; |
8a64d86cc362
Use different variants for Genesis controllers to better represent what types are out there
Michael Pavone <pavone@retrodev.com>
parents:
1861
diff
changeset
|
299 } |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
300 } else { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
301 return labels_saturn; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
302 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
303 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
304 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
305 |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
306 const char *get_button_label(controller_info *info, int button) |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
307 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
308 #ifndef USE_FBDEV |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
309 #if SDL_VERSION_ATLEAST(2,0,12) |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
310 if (info->subtype == SUBTYPE_XBOX_ELITE && button >= SDL_CONTROLLER_BUTTON_PADDLE1 && button <= SDL_CONTROLLER_BUTTON_PADDLE4) { |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
311 static char const * names[] = {"Paddle 1", "Paddle 2", "Paddle 3", "Paddle 4"}; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
312 return names[button - SDL_CONTROLLER_BUTTON_PADDLE1]; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
313 } |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
314 if (button == SDL_CONTROLLER_BUTTON_TOUCHPAD && (info->subtype == SUBTYPE_PS4 || info->subtype == SUBTYPE_PS5)) { |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
315 return "Touchpad"; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
316 } |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
317 if (button == SDL_CONTROLLER_BUTTON_MISC1) { |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
318 switch (info->subtype) |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
319 { |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
320 case SUBTYPE_XBONE: |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
321 case SUBTYPE_XBOX_ELITE: |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
322 return "Share"; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
323 case SUBTYPE_PS5: |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
324 return "Microphone"; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
325 case SUBTYPE_SWITCH: |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
326 return "Capture"; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
327 } |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
328 } |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
329 #endif |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
330 if (button >= SDL_CONTROLLER_BUTTON_DPAD_UP) { |
2220
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
331 if (button <= SDL_CONTROLLER_BUTTON_DPAD_RIGHT) { |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
332 static char const * dirs[] = {"Up", "Down", "Left", "Right"}; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
333 return dirs[button - SDL_CONTROLLER_BUTTON_DPAD_UP]; |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
334 } |
dd9d43c67986
Add support for newer controller types. Fix crash caused by new controller button types introduced in 2.0.12 and support mapping them
Michael Pavone <pavone@retrodev.com>
parents:
2218
diff
changeset
|
335 return NULL; |
1597
75aa418d0227
Use better names for "Guide" button on PS and Xbox controllers, handle d-pad directions in get_button_label
Michael Pavone <pavone@retrodev.com>
parents:
1596
diff
changeset
|
336 } |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
337 #endif |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
338 return label_source(info)[button]; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
339 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
340 |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
341 static char const *axis_labels[] = { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
342 "Left X", "Left Y", "Right X", "Right Y" |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
343 }; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
344 const char *get_axis_label(controller_info *info, int axis) |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
345 { |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
346 #ifndef USE_FBDEV |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
347 if (axis < SDL_CONTROLLER_AXIS_TRIGGERLEFT) { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
348 return axis_labels[axis]; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
349 } else { |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
350 return label_source(info)[axis - SDL_CONTROLLER_AXIS_TRIGGERLEFT + SDL_CONTROLLER_BUTTON_RIGHTSHOULDER + 1]; |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
351 } |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
352 #else |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
353 return NULL; |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
354 #endif |
1596
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
355 } |
437e80a700aa
Initial heuristics for detecting controller types and showing different labels in UI. Modified controller settings view to first display a list of controllers, only showing mapping after selecting controller
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
356 |
1608
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
357 char *make_controller_type_key(controller_info *info) |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
358 { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
359 const char *subtype; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
360 if (info->subtype == SUBTYPE_UNKNOWN) { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
361 switch(info->type) |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
362 { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
363 case TYPE_XBOX: |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
364 subtype = subtype_names[SUBTYPE_X360]; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
365 break; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
366 case TYPE_PSX: |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
367 subtype = subtype_names[SUBTYPE_PS4]; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
368 break; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
369 case TYPE_NINTENDO: |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
370 subtype = subtype_names[SUBTYPE_SWITCH]; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
371 break; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
372 default: |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
373 subtype = "unknown"; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
374 } |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
375 } else { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
376 subtype = subtype_names[info->subtype]; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
377 } |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
378 const char *variant = variant_names[info->variant]; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
379 const char *parts[] = {subtype, "_", variant}; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
380 char *ret = alloc_concat_m(3, parts); |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
381 for (char *cur = ret; *cur; cur++) |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
382 { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
383 if (*cur == ' ') |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
384 { |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
385 *cur = '_'; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
386 } |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
387 } |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
388 return ret; |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
389 } |
419a0a133b5c
Allow a gamepad mapping to apply to all controllers, controllers of a particular type (i.e.e 6-button PS4 controllers) or specific controllers (based on SDL2 GUID) in addition to the controller in a certain slot
Michael Pavone <pavone@retrodev.com>
parents:
1604
diff
changeset
|
390 |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
391 char *make_human_readable_type_name(controller_info *info) |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
392 { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
393 const char *base = subtype_human_names[info->subtype]; |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
394 char *prefix; |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
395 if (info->variant == VARIANT_NORMAL) { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
396 prefix = "Normal "; |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
397 } else { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
398 static const char *parts[] = {"6 button (", NULL, "/", NULL, ") "}; |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
399 #ifdef USE_FBDEV |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
400 parts[1] = parts[3] = "??"; |
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
401 #else |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
402 if (info->variant == VARIANT_6B_BUMPERS) { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
403 parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_LEFTSHOULDER); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
404 parts[3] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
405 } else { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
406 parts[1] = get_button_label(info, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
407 parts[3] = get_axis_label(info, SDL_CONTROLLER_AXIS_TRIGGERRIGHT); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
408 } |
1779
3a8c4ee68568
Added raw fbdev/evdev/ALSA render backend
Michael Pavone <pavone@retrodev.com>
parents:
1645
diff
changeset
|
409 #endif |
1645
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
410 prefix = alloc_concat_m(5, parts); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
411 } |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
412 char *ret = alloc_concat(prefix, base); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
413 if (info->variant != VARIANT_NORMAL) { |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
414 free(prefix); |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
415 } |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
416 return ret; |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
417 } |
84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
Michael Pavone <pavone@retrodev.com>
parents:
1608
diff
changeset
|
418 |