Added default mapping for WGI game controllers
This commit is contained in:
parent
3d74707830
commit
2dfc92ca1e
2 changed files with 23 additions and 0 deletions
|
@ -657,6 +657,25 @@ static ControllerMapping_t *SDL_CreateMappingForRAWINPUTController(SDL_JoystickG
|
|||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to guess at a mapping for WGI controllers
|
||||
*/
|
||||
static ControllerMapping_t *SDL_CreateMappingForWGIController(SDL_JoystickGUID guid)
|
||||
{
|
||||
SDL_bool existing;
|
||||
char mapping_string[1024];
|
||||
|
||||
if (guid.data[15] != SDL_JOYSTICK_TYPE_GAMECONTROLLER) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));
|
||||
SDL_strlcat(mapping_string, "a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:b10,dpdown:b12,dpleft:b13,dpright:b11,leftx:a1,lefty:a0~,rightx:a3,righty:a2~,lefttrigger:a4,righttrigger:a5,", sizeof(mapping_string));
|
||||
|
||||
return SDL_PrivateAddMappingForGUID(guid, mapping_string,
|
||||
&existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to scan the mappings database for a controller with the specified GUID
|
||||
*/
|
||||
|
@ -689,6 +708,9 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
|
|||
if (!mapping && SDL_IsJoystickRAWINPUT(guid)) {
|
||||
mapping = SDL_CreateMappingForRAWINPUTController(guid);
|
||||
}
|
||||
if (!mapping && SDL_IsJoystickWGI(guid)) {
|
||||
mapping = SDL_CreateMappingForWGIController(guid);
|
||||
}
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue