mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-16 11:06:49 +01:00
Fixed whitespace and added code to support older game controller GUIDs
This commit is contained in:
parent
b6542ab237
commit
160e719449
@ -396,11 +396,11 @@ void SDL_PrivateGameControllerParseButton(const char *szGameButton, const char *
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
||||||
pMapping->axes[ axis ] = iSDLButton;
|
pMapping->axes[axis] = iSDLButton;
|
||||||
pMapping->raxes[ iSDLButton ] = axis;
|
pMapping->raxes[iSDLButton] = axis;
|
||||||
} else if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
} else if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||||
pMapping->axesasbutton[ button ] = iSDLButton;
|
pMapping->axesasbutton[button] = iSDLButton;
|
||||||
pMapping->raxesasbutton[ iSDLButton ] = button;
|
pMapping->raxesasbutton[iSDLButton] = button;
|
||||||
} else {
|
} else {
|
||||||
SDL_assert(!"How did we get here?");
|
SDL_assert(!"How did we get here?");
|
||||||
}
|
}
|
||||||
@ -411,11 +411,11 @@ void SDL_PrivateGameControllerParseButton(const char *szGameButton, const char *
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||||
pMapping->buttons[ button ] = iSDLButton;
|
pMapping->buttons[button] = iSDLButton;
|
||||||
pMapping->rbuttons[ iSDLButton ] = button;
|
pMapping->rbuttons[iSDLButton] = button;
|
||||||
} else if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
} else if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
||||||
pMapping->buttonasaxis[ axis ] = iSDLButton;
|
pMapping->buttonasaxis[axis] = iSDLButton;
|
||||||
pMapping->rbuttonasaxis[ iSDLButton ] = axis;
|
pMapping->rbuttonasaxis[iSDLButton] = axis;
|
||||||
} else {
|
} else {
|
||||||
SDL_assert(!"How did we get here?");
|
SDL_assert(!"How did we get here?");
|
||||||
}
|
}
|
||||||
@ -428,10 +428,10 @@ void SDL_PrivateGameControllerParseButton(const char *szGameButton, const char *
|
|||||||
|
|
||||||
if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
if (button != SDL_CONTROLLER_BUTTON_INVALID) {
|
||||||
int ridx;
|
int ridx;
|
||||||
pMapping->hatasbutton[ button ].hat = hat;
|
pMapping->hatasbutton[button].hat = hat;
|
||||||
pMapping->hatasbutton[ button ].mask = mask;
|
pMapping->hatasbutton[button].mask = mask;
|
||||||
ridx = (hat << 4) | mask;
|
ridx = (hat << 4) | mask;
|
||||||
pMapping->rhatasbutton[ ridx ] = button;
|
pMapping->rhatasbutton[ridx] = button;
|
||||||
} else if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
} else if (axis != SDL_CONTROLLER_AXIS_INVALID) {
|
||||||
SDL_assert(!"Support hat as axis");
|
SDL_assert(!"Support hat as axis");
|
||||||
} else {
|
} else {
|
||||||
@ -540,7 +540,26 @@ char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_memcpy(pchGUID, pMapping, pFirstComma - pMapping);
|
SDL_memcpy(pchGUID, pMapping, pFirstComma - pMapping);
|
||||||
pchGUID[ pFirstComma - pMapping ] = 0;
|
pchGUID[pFirstComma - pMapping] = '\0';
|
||||||
|
|
||||||
|
/* Convert old style GUIDs to the new style in 2.0.5 */
|
||||||
|
#if __WIN32__
|
||||||
|
if (SDL_strlen(pchGUID) == 32 &&
|
||||||
|
SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) {
|
||||||
|
SDL_memcpy(&pchGUID[20], "000000000000", 12);
|
||||||
|
SDL_memcpy(&pchGUID[16], &pchGUID[4], 4);
|
||||||
|
SDL_memcpy(&pchGUID[8], &pchGUID[0], 4);
|
||||||
|
SDL_memcpy(&pchGUID[0], "03000000", 8);
|
||||||
|
}
|
||||||
|
#elif __MACOSX__
|
||||||
|
if (SDL_strlen(pchGUID) == 32 &&
|
||||||
|
SDL_memcmp(&pchGUID[4], "000000000000", 12) == 0 &&
|
||||||
|
SDL_memcmp(&pchGUID[20], "000000000000", 12) == 0) {
|
||||||
|
SDL_memcpy(&pchGUID[20], "000000000000", 12);
|
||||||
|
SDL_memcpy(&pchGUID[8], &pchGUID[0], 4);
|
||||||
|
SDL_memcpy(&pchGUID[0], "03000000", 8);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return pchGUID;
|
return pchGUID;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -569,7 +588,7 @@ char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
SDL_memcpy(pchName, pFirstComma + 1, pSecondComma - pFirstComma);
|
SDL_memcpy(pchName, pFirstComma + 1, pSecondComma - pFirstComma);
|
||||||
pchName[ pSecondComma - pFirstComma - 1 ] = 0;
|
pchName[pSecondComma - pFirstComma - 1] = 0;
|
||||||
return pchName;
|
return pchName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user