SDL API renaming: SDL_joystick.h
Fixes https://github.com/libsdl-org/SDL/issues/6881
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
/**
|
||||
* @brief Check virtual joystick creation
|
||||
*
|
||||
* @sa SDL_JoystickAttachVirtualEx
|
||||
* @sa SDL_AttachVirtualJoystickEx
|
||||
*/
|
||||
static int
|
||||
TestVirtualJoystick(void *arg)
|
||||
@@ -32,36 +32,36 @@ TestVirtualJoystick(void *arg)
|
||||
desc.vendor_id = USB_VENDOR_NVIDIA;
|
||||
desc.product_id = USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104;
|
||||
desc.name = "Virtual NVIDIA SHIELD Controller";
|
||||
device_index = SDL_JoystickAttachVirtualEx(&desc);
|
||||
SDLTest_AssertCheck(device_index >= 0, "SDL_JoystickAttachVirtualEx()");
|
||||
SDLTest_AssertCheck(SDL_JoystickIsVirtual(device_index), "SDL_JoystickIsVirtual()");
|
||||
device_index = SDL_AttachVirtualJoystickEx(&desc);
|
||||
SDLTest_AssertCheck(device_index >= 0, "SDL_AttachVirtualJoystickEx()");
|
||||
SDLTest_AssertCheck(SDL_IsJoystickVirtual(device_index), "SDL_IsJoystickVirtual()");
|
||||
if (device_index >= 0) {
|
||||
joystick = SDL_JoystickOpen(device_index);
|
||||
SDLTest_AssertCheck(joystick != NULL, "SDL_JoystickOpen()");
|
||||
joystick = SDL_OpenJoystick(device_index);
|
||||
SDLTest_AssertCheck(joystick != NULL, "SDL_OpenJoystick()");
|
||||
if (joystick) {
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_JoystickName(joystick), desc.name) == 0, "SDL_JoystickName()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetVendor(joystick) == desc.vendor_id, "SDL_JoystickGetVendor()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetProduct(joystick) == desc.product_id, "SDL_JoystickGetProduct()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetProductVersion(joystick) == 0, "SDL_JoystickGetProductVersion()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetFirmwareVersion(joystick) == 0, "SDL_JoystickGetFirmwareVersion()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetSerial(joystick) == NULL, "SDL_JoystickGetSerial()");
|
||||
SDLTest_AssertCheck(SDL_JoystickGetType(joystick) == desc.type, "SDL_JoystickGetType()");
|
||||
SDLTest_AssertCheck(SDL_JoystickNumAxes(joystick) == desc.naxes, "SDL_JoystickNumAxes()");
|
||||
SDLTest_AssertCheck(SDL_JoystickNumHats(joystick) == desc.nhats, "SDL_JoystickNumHats()");
|
||||
SDLTest_AssertCheck(SDL_JoystickNumButtons(joystick) == desc.nbuttons, "SDL_JoystickNumButtons()");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetJoystickName(joystick), desc.name) == 0, "SDL_GetJoystickName()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickVendor(joystick) == desc.vendor_id, "SDL_GetJoystickVendor()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickProduct(joystick) == desc.product_id, "SDL_GetJoystickProduct()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickProductVersion(joystick) == 0, "SDL_GetJoystickProductVersion()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickFirmwareVersion(joystick) == 0, "SDL_GetJoystickFirmwareVersion()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickSerial(joystick) == NULL, "SDL_GetJoystickSerial()");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickType(joystick) == desc.type, "SDL_GetJoystickType()");
|
||||
SDLTest_AssertCheck(SDL_GetNumJoystickAxes(joystick) == desc.naxes, "SDL_GetNumJoystickAxes()");
|
||||
SDLTest_AssertCheck(SDL_GetNumJoystickHats(joystick) == desc.nhats, "SDL_GetNumJoystickHats()");
|
||||
SDLTest_AssertCheck(SDL_GetNumJoystickButtons(joystick) == desc.nbuttons, "SDL_GetNumJoystickButtons()");
|
||||
|
||||
SDLTest_AssertCheck(SDL_JoystickSetVirtualButton(joystick, SDL_CONTROLLER_BUTTON_A, SDL_PRESSED) == 0, "SDL_JoystickSetVirtualButton(SDL_CONTROLLER_BUTTON_A, SDL_PRESSED)");
|
||||
SDL_JoystickUpdate();
|
||||
SDLTest_AssertCheck(SDL_JoystickGetButton(joystick, SDL_CONTROLLER_BUTTON_A) == SDL_PRESSED, "SDL_JoystickGetButton(SDL_CONTROLLER_BUTTON_A) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_JoystickSetVirtualButton(joystick, SDL_CONTROLLER_BUTTON_A, SDL_RELEASED) == 0, "SDL_JoystickSetVirtualButton(SDL_CONTROLLER_BUTTON_A, SDL_RELEASED)");
|
||||
SDL_JoystickUpdate();
|
||||
SDLTest_AssertCheck(SDL_JoystickGetButton(joystick, SDL_CONTROLLER_BUTTON_A) == SDL_RELEASED, "SDL_JoystickGetButton(SDL_CONTROLLER_BUTTON_A) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_CONTROLLER_BUTTON_A, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_CONTROLLER_BUTTON_A, SDL_PRESSED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A) == SDL_PRESSED, "SDL_GetJoystickButton(SDL_CONTROLLER_BUTTON_A) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_CONTROLLER_BUTTON_A, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_CONTROLLER_BUTTON_A, SDL_RELEASED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_CONTROLLER_BUTTON_A) == SDL_RELEASED");
|
||||
|
||||
SDL_JoystickClose(joystick);
|
||||
SDL_CloseJoystick(joystick);
|
||||
}
|
||||
SDLTest_AssertCheck(SDL_JoystickDetachVirtual(device_index) == 0, "SDL_JoystickDetachVirtual()");
|
||||
SDLTest_AssertCheck(SDL_DetachVirtualJoystick(device_index) == 0, "SDL_DetachVirtualJoystick()");
|
||||
}
|
||||
SDLTest_AssertCheck(!SDL_JoystickIsVirtual(device_index), "!SDL_JoystickIsVirtual()");
|
||||
SDLTest_AssertCheck(!SDL_IsJoystickVirtual(device_index), "!SDL_IsJoystickVirtual()");
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user