|
30 | 30 | #include "controller_type.h"
|
31 | 31 | #include "usb_ids.h"
|
32 | 32 | #include "hidapi/SDL_hidapi_nintendo.h"
|
| 33 | +#include "hidapi/SDL_hidapi_sinput.h" |
33 | 34 | #include "../events/SDL_events_c.h"
|
34 | 35 |
|
35 | 36 |
|
|
57 | 58 | static bool SDL_gamepads_initialized;
|
58 | 59 | static SDL_Gamepad *SDL_gamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
|
59 | 60 |
|
60 |
| -// The face button style of a gamepad |
61 |
| -typedef enum |
62 |
| -{ |
63 |
| - SDL_GAMEPAD_FACE_STYLE_UNKNOWN, |
64 |
| - SDL_GAMEPAD_FACE_STYLE_ABXY, |
65 |
| - SDL_GAMEPAD_FACE_STYLE_AXBY, |
66 |
| - SDL_GAMEPAD_FACE_STYLE_BAYX, |
67 |
| - SDL_GAMEPAD_FACE_STYLE_SONY, |
68 |
| -} SDL_GamepadFaceStyle; |
69 |
| - |
70 | 61 | // our hard coded list of mapping support
|
71 | 62 | typedef enum
|
72 | 63 | {
|
@@ -697,10 +688,11 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
697 | 688 | char mapping_string[1024];
|
698 | 689 | Uint16 vendor;
|
699 | 690 | Uint16 product;
|
| 691 | + Uint16 version; |
700 | 692 |
|
701 | 693 | SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));
|
702 | 694 |
|
703 |
| - SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); |
| 695 | + SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL); |
704 | 696 |
|
705 | 697 | if (SDL_IsJoystickWheel(vendor, product)) {
|
706 | 698 | // We don't want to pick up Logitech FFB wheels here
|
@@ -799,55 +791,42 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
|
799 | 791 | // This controller has no guide button
|
800 | 792 | SDL_strlcat(mapping_string, "a:b1,b:b0,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", sizeof(mapping_string));
|
801 | 793 | } else if (SDL_IsJoystickSInputController(vendor, product)) {
|
802 |
| - Uint8 face_style = (guid.data[15] & 0xE0) >> 5; |
803 |
| - Uint8 sub_type = guid.data[15] & 0x1F; |
| 794 | + struct SDL_SInputFeatures features; |
| 795 | + HIDAPI_DriverSInput_GetControllerType(vendor, product, version, guid.data[15], &features); |
804 | 796 |
|
805 |
| - // Apply face style according to gamepad response |
806 |
| - switch (face_style) { |
| 797 | + // Apply mapping profile for type |
| 798 | + switch (features.controller_type) { |
| 799 | + case k_eSInputControllerType_HHL_PROGCC: |
| 800 | + SDL_strlcat(mapping_string, "a:b1,b:b0,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b4,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b7,rightstick:b5,righttrigger:b9,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", sizeof(mapping_string)); |
| 801 | + break; |
| 802 | + case k_eSInputControllerType_HHL_GCCULT: |
| 803 | + SDL_strlcat(mapping_string, "a:b0,b:b2,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b4,lefttrigger:a4,leftx:a0,lefty:a1,misc1:b13,misc2:b14,rightshoulder:b7,rightstick:b5,righttrigger:a5,rightx:a2,righty:a3,start:b10,x:b1,y:b3,misc3:b8,misc4:b9,hint:!SDL_GAMECONTROLLER_USE_GAMECUBE_LABELS:=1,", sizeof(mapping_string)); |
| 804 | + break; |
807 | 805 | default:
|
| 806 | + case k_eSInputControllerType_Dynamic: |
| 807 | + // Default Fully Exposed Mapping |
| 808 | + // TODO... |
| 809 | + SDL_strlcat(mapping_string, "leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,b:b0,a:b1,y:b2,x:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b4,rightstick:b5,leftshoulder:b6,rightshoulder:b7,paddle1:b10,paddle2:b11,start:b12,back:b13,guide:b14,misc1:b15,paddle3:b16,paddle4:b17,touchpad:b18,misc2:b19,misc3:b20,misc4:b21,misc5:b22,misc6:b23", sizeof(mapping_string)); |
| 810 | + break; |
| 811 | + } |
| 812 | + |
| 813 | + // Apply face style |
| 814 | + switch (features.face_style) { |
| 815 | + case SDL_GAMEPAD_FACE_STYLE_ABXY: |
808 | 816 | SDL_strlcat(mapping_string, "face:abxy,", sizeof(mapping_string));
|
809 | 817 | break;
|
810 |
| - case 2: |
| 818 | + case SDL_GAMEPAD_FACE_STYLE_AXBY: |
811 | 819 | SDL_strlcat(mapping_string, "face:axby,", sizeof(mapping_string));
|
812 | 820 | break;
|
813 |
| - case 3: |
| 821 | + case SDL_GAMEPAD_FACE_STYLE_BAYX: |
814 | 822 | SDL_strlcat(mapping_string, "face:bayx,", sizeof(mapping_string));
|
815 | 823 | break;
|
816 |
| - case 4: |
| 824 | + case SDL_GAMEPAD_FACE_STYLE_SONY: |
817 | 825 | SDL_strlcat(mapping_string, "face:sony,", sizeof(mapping_string));
|
818 | 826 | break;
|
819 |
| - } |
820 |
| - |
821 |
| - switch (product) { |
822 |
| - case USB_PRODUCT_HANDHELDLEGEND_PROGCC: |
823 |
| - switch (sub_type) { |
824 |
| - default: |
825 |
| - // ProGCC Primary Mapping |
826 |
| - SDL_strlcat(mapping_string, "a:b1,b:b0,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b4,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b13,rightshoulder:b7,rightstick:b5,righttrigger:b9,rightx:a2,righty:a3,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", sizeof(mapping_string)); |
827 |
| - break; |
828 |
| - } |
829 |
| - break; |
830 |
| - case USB_PRODUCT_HANDHELDLEGEND_GCULTIMATE: |
831 |
| - switch (sub_type) { |
832 |
| - default: |
833 |
| - // GC Ultimate Primary Map |
834 |
| - SDL_strlcat(mapping_string, "a:b0,b:b2,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b4,lefttrigger:a4,leftx:a0,lefty:a1,misc1:b13,misc2:b14,rightshoulder:b7,rightstick:b5,righttrigger:a5,rightx:a2,righty:a3,start:b10,x:b1,y:b3,misc3:b8,misc4:b9,hint:!SDL_GAMECONTROLLER_USE_GAMECUBE_LABELS:=1,", sizeof(mapping_string)); |
835 |
| - break; |
836 |
| - } |
837 |
| - break; |
838 |
| - case USB_PRODUCT_HANDHELDLEGEND_SINPUT_GENERIC: |
839 |
| - switch (sub_type) { |
840 |
| - default: |
841 |
| - // Default Fully Exposed Mapping (Development Purposes) |
842 |
| - SDL_strlcat(mapping_string, "leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,b:b0,a:b1,y:b2,x:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftstick:b4,rightstick:b5,leftshoulder:b6,rightshoulder:b7,paddle1:b10,paddle2:b11,start:b12,back:b13,guide:b14,misc1:b15,paddle3:b16,paddle4:b17,touchpad:b18,misc2:b19,misc3:b20,misc4:b21,misc5:b22,misc6:b23", sizeof(mapping_string)); |
843 |
| - break; |
844 |
| - } |
845 |
| - break; |
846 |
| - |
847 |
| - case USB_PRODUCT_BONZIRICHANNEL_FIREBIRD: |
| 827 | + case SDL_GAMEPAD_FACE_STYLE_UNKNOWN: |
848 | 828 | default:
|
849 |
| - // Unmapped device |
850 |
| - return NULL; |
| 829 | + break; |
851 | 830 | }
|
852 | 831 | } else {
|
853 | 832 | // All other gamepads have the standard set of 19 buttons and 6 axes
|
|
0 commit comments