mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-27 09:44:15 +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:
@@ -347,11 +347,7 @@ void SDL_EVDEV_Poll(void)
|
||||
case EV_KEY:
|
||||
if (event->code >= BTN_MOUSE && event->code < BTN_MOUSE + SDL_arraysize(EVDEV_MouseButtons)) {
|
||||
mouse_button = event->code - BTN_MOUSE;
|
||||
if (event->value == 0) {
|
||||
SDL_SendMouseButton(SDL_EVDEV_GetEventTimestamp(event), mouse->focus, (SDL_MouseID)item->fd, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]);
|
||||
} else if (event->value == 1) {
|
||||
SDL_SendMouseButton(SDL_EVDEV_GetEventTimestamp(event), mouse->focus, (SDL_MouseID)item->fd, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]);
|
||||
}
|
||||
SDL_SendMouseButton(SDL_EVDEV_GetEventTimestamp(event), mouse->focus, (SDL_MouseID)item->fd, EVDEV_MouseButtons[mouse_button], (event->value != 0));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -373,9 +369,9 @@ void SDL_EVDEV_Poll(void)
|
||||
// Probably keyboard
|
||||
scancode = SDL_EVDEV_translate_keycode(event->code);
|
||||
if (event->value == 0) {
|
||||
SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, SDL_RELEASED);
|
||||
SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, false);
|
||||
} else if (event->value == 1 || event->value == 2 /* key repeated */) {
|
||||
SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, SDL_PRESSED);
|
||||
SDL_SendKeyboardKey(SDL_EVDEV_GetEventTimestamp(event), (SDL_KeyboardID)item->fd, event->code, scancode, true);
|
||||
}
|
||||
SDL_EVDEV_kbd_keycode(_this->kbd, event->code, event->value);
|
||||
break;
|
||||
|
||||
@@ -379,11 +379,11 @@ void SDL_Fcitx_Reset(void)
|
||||
FcitxClientICCallMethod(&fcitx_client, "Reset");
|
||||
}
|
||||
|
||||
bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down)
|
||||
{
|
||||
Uint32 mod_state = Fcitx_ModState();
|
||||
Uint32 handled = false;
|
||||
Uint32 is_release = (state == SDL_RELEASED);
|
||||
Uint32 is_release = !down;
|
||||
Uint32 event_time = 0;
|
||||
|
||||
if (!fcitx_client.ic_path) {
|
||||
|
||||
@@ -28,7 +28,7 @@ extern bool SDL_Fcitx_Init(void);
|
||||
extern void SDL_Fcitx_Quit(void);
|
||||
extern void SDL_Fcitx_SetFocus(bool focused);
|
||||
extern void SDL_Fcitx_Reset(void);
|
||||
extern bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||
extern bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down);
|
||||
extern void SDL_Fcitx_UpdateTextInputArea(SDL_Window *window);
|
||||
extern void SDL_Fcitx_PumpEvents(void);
|
||||
|
||||
|
||||
@@ -660,7 +660,7 @@ void SDL_IBus_Reset(void)
|
||||
IBus_SimpleMessage("Reset");
|
||||
}
|
||||
|
||||
bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down)
|
||||
{
|
||||
Uint32 result = 0;
|
||||
SDL_DBusContext *dbus = SDL_DBus_GetContext();
|
||||
@@ -668,7 +668,7 @@ bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
if (IBus_CheckConnection(dbus)) {
|
||||
Uint32 mods = IBus_ModState();
|
||||
Uint32 ibus_keycode = keycode - 8;
|
||||
if (state == SDL_RELEASED) {
|
||||
if (!down) {
|
||||
mods |= (1 << 30); // IBUS_RELEASE_MASK
|
||||
}
|
||||
if (!SDL_DBus_CallMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, "ProcessKeyEvent",
|
||||
|
||||
@@ -40,7 +40,7 @@ extern void SDL_IBus_Reset(void);
|
||||
/* Sends a keypress event to IBus, returns true if IBus used this event to
|
||||
update its candidate list or change input methods. PumpEvents should be
|
||||
called some time after this, to receive the TextInput / TextEditing event back. */
|
||||
extern bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||
extern bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down);
|
||||
|
||||
/* Update the position of IBus' candidate list. If rect is NULL then this will
|
||||
just reposition it relative to the focused window's new position. */
|
||||
|
||||
@@ -28,7 +28,7 @@ typedef bool (*SDL_IME_Init_t)(void);
|
||||
typedef void (*SDL_IME_Quit_t)(void);
|
||||
typedef void (*SDL_IME_SetFocus_t)(bool);
|
||||
typedef void (*SDL_IME_Reset_t)(void);
|
||||
typedef bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, Uint8 state);
|
||||
typedef bool (*SDL_IME_ProcessKeyEvent_t)(Uint32, Uint32, bool down);
|
||||
typedef void (*SDL_IME_UpdateTextInputArea_t)(SDL_Window *window);
|
||||
typedef void (*SDL_IME_PumpEvents_t)(void);
|
||||
|
||||
@@ -126,10 +126,10 @@ void SDL_IME_Reset(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state)
|
||||
bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down)
|
||||
{
|
||||
if (SDL_IME_ProcessKeyEvent_Real) {
|
||||
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, state);
|
||||
return SDL_IME_ProcessKeyEvent_Real(keysym, keycode, down);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -28,7 +28,7 @@ extern bool SDL_IME_Init(void);
|
||||
extern void SDL_IME_Quit(void);
|
||||
extern void SDL_IME_SetFocus(bool focused);
|
||||
extern void SDL_IME_Reset(void);
|
||||
extern bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, Uint8 state);
|
||||
extern bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode, bool down);
|
||||
extern void SDL_IME_UpdateTextInputArea(SDL_Window *window);
|
||||
extern void SDL_IME_PumpEvents(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user