mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-04 13:04:41 +00:00
Use SDL_bool where appropriate in SDL events
This involved changing button state from Uint8 to SDL_bool, and made SDL_PRESSED and SDL_RELEASED unnecessary. Fixes https://github.com/libsdl-org/SDL/issues/10069
This commit is contained in:
@@ -198,7 +198,7 @@ static void PrintKey(SDL_KeyboardEvent *event)
|
||||
if (event->key) {
|
||||
print_string(&spot, &left,
|
||||
"Key %s: raw 0x%.2x, scancode %d = %s, keycode 0x%08X = %s ",
|
||||
event->state ? "pressed " : "released",
|
||||
event->down ? "pressed " : "released",
|
||||
event->raw,
|
||||
event->scancode,
|
||||
event->scancode == SDL_SCANCODE_UNKNOWN ? "UNKNOWN" : SDL_GetScancodeName(event->scancode),
|
||||
@@ -209,7 +209,7 @@ static void PrintKey(SDL_KeyboardEvent *event)
|
||||
event->raw,
|
||||
event->scancode,
|
||||
event->scancode == SDL_SCANCODE_UNKNOWN ? "UNKNOWN" : SDL_GetScancodeName(event->scancode),
|
||||
event->state ? "pressed " : "released");
|
||||
event->down ? "pressed " : "released");
|
||||
}
|
||||
print_modifiers(&spot, &left, event->mod);
|
||||
if (event->repeat) {
|
||||
@@ -234,7 +234,7 @@ static void PrintText(const char *eventtype, const char *text)
|
||||
static void CountKeysDown(void)
|
||||
{
|
||||
int i, count = 0, max_keys = 0;
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(&max_keys);
|
||||
const SDL_bool *keystate = SDL_GetKeyboardState(&max_keys);
|
||||
|
||||
for (i = 0; i < max_keys; ++i) {
|
||||
if (keystate[i]) {
|
||||
|
||||
@@ -81,7 +81,7 @@ static SDL_FRect touchpad_area = {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Uint8 state;
|
||||
SDL_bool down;
|
||||
float x;
|
||||
float y;
|
||||
float pressure;
|
||||
@@ -428,11 +428,7 @@ void UpdateGamepadImageFromGamepad(GamepadImage *ctx, SDL_Gamepad *gamepad)
|
||||
for (i = 0; i < SDL_GAMEPAD_BUTTON_TOUCHPAD; ++i) {
|
||||
const SDL_GamepadButton button = (SDL_GamepadButton)i;
|
||||
|
||||
if (SDL_GetGamepadButton(gamepad, button) == SDL_PRESSED) {
|
||||
SetGamepadImageElement(ctx, button, SDL_TRUE);
|
||||
} else {
|
||||
SetGamepadImageElement(ctx, button, SDL_FALSE);
|
||||
}
|
||||
SetGamepadImageElement(ctx, button, SDL_GetGamepadButton(gamepad, button));
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_GAMEPAD_AXIS_MAX; ++i) {
|
||||
@@ -483,7 +479,7 @@ void UpdateGamepadImageFromGamepad(GamepadImage *ctx, SDL_Gamepad *gamepad)
|
||||
for (i = 0; i < num_fingers; ++i) {
|
||||
GamepadTouchpadFinger *finger = &ctx->fingers[i];
|
||||
|
||||
SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &finger->state, &finger->x, &finger->y, &finger->pressure);
|
||||
SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &finger->down, &finger->x, &finger->y, &finger->pressure);
|
||||
}
|
||||
ctx->showing_touchpad = SDL_TRUE;
|
||||
} else {
|
||||
@@ -614,7 +610,7 @@ void RenderGamepadImage(GamepadImage *ctx)
|
||||
for (i = 0; i < ctx->num_fingers; ++i) {
|
||||
GamepadTouchpadFinger *finger = &ctx->fingers[i];
|
||||
|
||||
if (finger->state) {
|
||||
if (finger->down) {
|
||||
dst.x = ctx->x + (ctx->gamepad_width - ctx->touchpad_width) / 2;
|
||||
dst.x += touchpad_area.x + finger->x * touchpad_area.w;
|
||||
dst.x -= ctx->button_width / 2;
|
||||
@@ -1220,17 +1216,17 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
|
||||
if (SDL_GetNumGamepadTouchpads(gamepad) > 0) {
|
||||
int num_fingers = SDL_GetNumGamepadTouchpadFingers(gamepad, 0);
|
||||
for (i = 0; i < num_fingers; ++i) {
|
||||
Uint8 state;
|
||||
SDL_bool down;
|
||||
float finger_x, finger_y, finger_pressure;
|
||||
|
||||
if (!SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &state, &finger_x, &finger_y, &finger_pressure)) {
|
||||
if (!SDL_GetGamepadTouchpadFinger(gamepad, 0, i, &down, &finger_x, &finger_y, &finger_pressure)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "Touch finger %d:", i);
|
||||
SDLTest_DrawString(ctx->renderer, x + center - SDL_strlen(text) * FONT_CHARACTER_SIZE, y, text);
|
||||
|
||||
if (state) {
|
||||
if (down) {
|
||||
SDL_SetTextureColorMod(ctx->button_texture, 10, 255, 21);
|
||||
} else {
|
||||
SDL_SetTextureColorMod(ctx->button_texture, 255, 255, 255);
|
||||
@@ -1242,7 +1238,7 @@ void RenderGamepadDisplay(GamepadDisplay *ctx, SDL_Gamepad *gamepad)
|
||||
dst.h = ctx->button_height;
|
||||
SDL_RenderTexture(ctx->renderer, ctx->button_texture, NULL, &dst);
|
||||
|
||||
if (state) {
|
||||
if (down) {
|
||||
SDL_snprintf(text, sizeof(text), "(%.2f,%.2f)", finger_x, finger_y);
|
||||
SDLTest_DrawString(ctx->renderer, x + center + ctx->button_width + 4.0f, y, text);
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ static int SDLCALL TestVirtualJoystick(void *arg)
|
||||
SDLTest_AssertCheck(nbuttons == desc.nbuttons, "SDL_GetNumJoystickButtons() -> %d (expected %d)", nbuttons, desc.nbuttons);
|
||||
}
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE");
|
||||
|
||||
gamepad = SDL_OpenGamepad(SDL_GetJoystickID(joystick));
|
||||
SDLTest_AssertCheck(gamepad != NULL, "SDL_OpenGamepad() succeeded");
|
||||
@@ -124,13 +124,13 @@ static int SDLCALL TestVirtualJoystick(void *arg)
|
||||
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");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE");
|
||||
|
||||
/* Set an explicit mapping with legacy Nintendo style buttons */
|
||||
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,");
|
||||
@@ -141,13 +141,13 @@ static int SDLCALL TestVirtualJoystick(void *arg)
|
||||
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");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE");
|
||||
|
||||
/* Set an explicit mapping with PS4 style buttons */
|
||||
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,");
|
||||
@@ -158,13 +158,13 @@ static int SDLCALL TestVirtualJoystick(void *arg)
|
||||
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");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_TRUE");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE), "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_FALSE)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_FALSE");
|
||||
|
||||
SDL_CloseGamepad(gamepad);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
static int SDLCALL keyboard_getKeyboardState(void *arg)
|
||||
{
|
||||
int numkeys;
|
||||
const Uint8 *state;
|
||||
const SDL_bool *state;
|
||||
|
||||
/* Case where numkeys pointer is NULL */
|
||||
state = SDL_GetKeyboardState(NULL);
|
||||
|
||||
@@ -1113,7 +1113,7 @@ static SDL_bool ShowingFront(void)
|
||||
|
||||
/* Show the back of the gamepad if the paddles are being held or bound */
|
||||
for (i = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1; i <= SDL_GAMEPAD_BUTTON_LEFT_PADDLE2; ++i) {
|
||||
if (SDL_GetGamepadButton(controller->gamepad, (SDL_GamepadButton)i) == SDL_PRESSED ||
|
||||
if (SDL_GetGamepadButton(controller->gamepad, (SDL_GamepadButton)i) ||
|
||||
binding_element == i) {
|
||||
showing_front = SDL_FALSE;
|
||||
break;
|
||||
@@ -1210,7 +1210,7 @@ static void VirtualGamepadMouseMotion(float x, float y)
|
||||
const float MOVING_DISTANCE = 2.0f;
|
||||
if (SDL_fabs(x - virtual_axis_start_x) >= MOVING_DISTANCE ||
|
||||
SDL_fabs(y - virtual_axis_start_y) >= MOVING_DISTANCE) {
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_RELEASED);
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_FALSE);
|
||||
virtual_button_active = SDL_GAMEPAD_BUTTON_INVALID;
|
||||
}
|
||||
}
|
||||
@@ -1248,7 +1248,7 @@ static void VirtualGamepadMouseMotion(float x, float y)
|
||||
GetGamepadTouchpadArea(image, &touchpad);
|
||||
virtual_touchpad_x = (x - touchpad.x) / touchpad.w;
|
||||
virtual_touchpad_y = (y - touchpad.y) / touchpad.h;
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_PRESSED, virtual_touchpad_x, virtual_touchpad_y, 1.0f);
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_TRUE, virtual_touchpad_x, virtual_touchpad_y, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1264,14 +1264,14 @@ static void VirtualGamepadMouseDown(float x, float y)
|
||||
virtual_touchpad_active = SDL_TRUE;
|
||||
virtual_touchpad_x = (x - touchpad.x) / touchpad.w;
|
||||
virtual_touchpad_y = (y - touchpad.y) / touchpad.h;
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_PRESSED, virtual_touchpad_x, virtual_touchpad_y, 1.0f);
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_TRUE, virtual_touchpad_x, virtual_touchpad_y, 1.0f);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (element < SDL_GAMEPAD_BUTTON_MAX) {
|
||||
virtual_button_active = (SDL_GamepadButton)element;
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_PRESSED);
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_TRUE);
|
||||
} else {
|
||||
switch (element) {
|
||||
case SDL_GAMEPAD_ELEMENT_AXIS_LEFTX_NEGATIVE:
|
||||
@@ -1301,7 +1301,7 @@ static void VirtualGamepadMouseDown(float x, float y)
|
||||
static void VirtualGamepadMouseUp(float x, float y)
|
||||
{
|
||||
if (virtual_button_active != SDL_GAMEPAD_BUTTON_INVALID) {
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_RELEASED);
|
||||
SDL_SetJoystickVirtualButton(virtual_joystick, virtual_button_active, SDL_FALSE);
|
||||
virtual_button_active = SDL_GAMEPAD_BUTTON_INVALID;
|
||||
}
|
||||
|
||||
@@ -1317,7 +1317,7 @@ static void VirtualGamepadMouseUp(float x, float y)
|
||||
}
|
||||
|
||||
if (virtual_touchpad_active) {
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_RELEASED, virtual_touchpad_x, virtual_touchpad_y, 0.0f);
|
||||
SDL_SetJoystickVirtualTouchpad(virtual_joystick, 0, 0, SDL_FALSE, virtual_touchpad_x, virtual_touchpad_y, 0.0f);
|
||||
virtual_touchpad_active = SDL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -1772,7 +1772,7 @@ static void loop(void *arg)
|
||||
if (virtual_joystick && controller && controller->joystick == virtual_joystick) {
|
||||
VirtualGamepadMouseDown(event.button.x, event.button.y);
|
||||
}
|
||||
UpdateButtonHighlights(event.button.x, event.button.y, event.button.state ? SDL_TRUE : SDL_FALSE);
|
||||
UpdateButtonHighlights(event.button.x, event.button.y, event.button.down);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
@@ -1833,7 +1833,7 @@ static void loop(void *arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
UpdateButtonHighlights(event.button.x, event.button.y, event.button.state ? SDL_TRUE : SDL_FALSE);
|
||||
UpdateButtonHighlights(event.button.x, event.button.y, event.button.down);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
|
||||
@@ -285,7 +285,7 @@ static void HandleMouseButton(SDL_MouseButtonEvent *event)
|
||||
continue;
|
||||
}
|
||||
if (event->which == mouse_state->instance_id) {
|
||||
if (event->state) {
|
||||
if (event->down) {
|
||||
mouse_state->button_state |= SDL_BUTTON(event->button);
|
||||
} else {
|
||||
mouse_state->button_state &= ~SDL_BUTTON(event->button);
|
||||
|
||||
@@ -228,7 +228,7 @@ static void loop(void *arg)
|
||||
case SDL_EVENT_KEY_UP:
|
||||
switch (event.key.key) {
|
||||
case SDLK_LSHIFT:
|
||||
isRect = (event.key.state == SDL_PRESSED);
|
||||
isRect = event.key.down;
|
||||
if (active) {
|
||||
active->isRect = isRect;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user