Renamed functions to get information from device IDs
Fixes https://github.com/libsdl-org/SDL/issues/10237
This commit is contained in:
1 parent
933f2fc239
commit
e90060d07f
20 files changed
+235
-229
No files matched your search
@@ -61,7 +61,7 @@ static int TestVirtualJoystick(void *arg)
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
gamepad = SDL_OpenGamepad(SDL_GetJoystickInstanceID(joystick));
|
||||
gamepad = SDL_OpenGamepad(SDL_GetJoystickID(joystick));
|
||||
SDLTest_AssertCheck(gamepad != NULL, "SDL_OpenGamepad() succeeded");
|
||||
if (gamepad) {
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), desc.name) == 0, "SDL_GetGamepadName()");
|
||||
@@ -69,7 +69,7 @@ static int TestVirtualJoystick(void *arg)
|
||||
SDLTest_AssertCheck(SDL_GetGamepadProduct(gamepad) == desc.product_id, "SDL_GetGamepadProduct()");
|
||||
|
||||
/* Set an explicit mapping with a different name */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual Gamepad,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,");
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickID(joystick), "ff0013db5669727475616c2043007601,Virtual Gamepad,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual Gamepad") == 0, "SDL_GetGamepadName() == Virtual Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A");
|
||||
|
||||
@@ -83,7 +83,7 @@ static int TestVirtualJoystick(void *arg)
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
/* Set an explicit mapping with legacy Nintendo style buttons */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual Nintendo Gamepad,a:b1,b:b0,x:b3,y:b2,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,");
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickID(joystick), "ff0013db5669727475616c2043007601,Virtual Nintendo Gamepad,a:b1,b:b0,x:b3,y:b2,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual Nintendo Gamepad") == 0, "SDL_GetGamepadName() == Virtual Nintendo Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B");
|
||||
|
||||
@@ -97,7 +97,7 @@ static int TestVirtualJoystick(void *arg)
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
/* Set an explicit mapping with PS4 style buttons */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual PS4 Gamepad,type:ps4,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,");
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickID(joystick), "ff0013db5669727475616c2043007601,Virtual PS4 Gamepad,type:ps4,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual PS4 Gamepad") == 0, "SDL_GetGamepadName() == Virtual PS4 Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS");
|
||||
|
||||
|
||||
@@ -1371,7 +1371,7 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
||||
}
|
||||
|
||||
if (controller->joystick) {
|
||||
SDL_snprintf(text, sizeof(text), "(%" SDL_PRIu32 ")", SDL_GetJoystickInstanceID(controller->joystick));
|
||||
SDL_snprintf(text, sizeof(text), "(%" SDL_PRIu32 ")", SDL_GetJoystickID(controller->joystick));
|
||||
x = SCREEN_WIDTH - (FONT_CHARACTER_SIZE * SDL_strlen(text)) - 8.0f;
|
||||
y = 8.0f;
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
|
||||
+2
-2
@@ -86,7 +86,7 @@ int main(int argc, char **argv)
|
||||
haptics = SDL_GetHaptics(&num_haptics);
|
||||
SDL_Log("%d Haptic devices detected.\n", num_haptics);
|
||||
for (i = 0; i < num_haptics; ++i) {
|
||||
SDL_Log(" %s\n", SDL_GetHapticInstanceName(haptics[i]));
|
||||
SDL_Log(" %s\n", SDL_GetHapticNameFromID(haptics[i]));
|
||||
}
|
||||
if (haptics) {
|
||||
if (num_haptics == 0) {
|
||||
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
|
||||
/* Try to find matching device */
|
||||
else {
|
||||
for (i = 0; i < num_haptics; i++) {
|
||||
if (SDL_strstr(SDL_GetHapticInstanceName(haptics[i]), name) != NULL) {
|
||||
if (SDL_strstr(SDL_GetHapticNameFromID(haptics[i]), name) != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
|
||||
/* Try to find matching device */
|
||||
else {
|
||||
for (i = 0; i < num_haptics; i++) {
|
||||
if (SDL_strstr(SDL_GetHapticInstanceName(haptics[i]), name) != NULL) {
|
||||
if (SDL_strstr(SDL_GetHapticNameFromID(haptics[i]), name) != NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -91,11 +91,11 @@ int main(int argc, char **argv)
|
||||
for (i = 0; i < num_sensors; ++i) {
|
||||
SDL_Log("Sensor %" SDL_PRIu32 ": %s, type %s, platform type %d\n",
|
||||
sensors[i],
|
||||
SDL_GetSensorInstanceName(sensors[i]),
|
||||
GetSensorTypeString(SDL_GetSensorInstanceType(sensors[i])),
|
||||
SDL_GetSensorInstanceNonPortableType(sensors[i]));
|
||||
SDL_GetSensorNameFromID(sensors[i]),
|
||||
GetSensorTypeString(SDL_GetSensorTypeFromID(sensors[i])),
|
||||
SDL_GetSensorNonPortableTypeFromID(sensors[i]));
|
||||
|
||||
if (SDL_GetSensorInstanceType(sensors[i]) != SDL_SENSOR_UNKNOWN) {
|
||||
if (SDL_GetSensorTypeFromID(sensors[i]) != SDL_SENSOR_UNKNOWN) {
|
||||
SDL_Sensor *sensor = SDL_OpenSensor(sensors[i]);
|
||||
if (!sensor) {
|
||||
SDL_Log("Couldn't open sensor %" SDL_PRIu32 ": %s\n", sensors[i], SDL_GetError());
|
||||
|
||||
Reference in new issue
Block a user