mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-23 04:59:10 +00:00
Removed raw key events
They weren't adding any value over the existing keyboard events
This commit is contained in:
parent
c44fa5bb07
commit
d07bb0e679
12 changed files with 4 additions and 78 deletions
|
@ -174,8 +174,6 @@ typedef enum SDL_EventType
|
|||
SDL_EVENT_KEYBOARD_ADDED, /**< A new keyboard has been inserted into the system */
|
||||
SDL_EVENT_KEYBOARD_REMOVED, /**< A keyboard has been removed */
|
||||
SDL_EVENT_TEXT_EDITING_CANDIDATES, /**< Keyboard text editing candidates */
|
||||
SDL_EVENT_RAW_KEY_DOWN, /**< Key pressed (raw key press) */
|
||||
SDL_EVENT_RAW_KEY_UP, /**< Key released (raw key release) */
|
||||
|
||||
/* Mouse events */
|
||||
SDL_EVENT_MOUSE_MOTION = 0x400, /**< Mouse moved */
|
||||
|
@ -368,22 +366,6 @@ typedef struct SDL_KeyboardEvent
|
|||
bool repeat; /**< true if this is a key repeat */
|
||||
} SDL_KeyboardEvent;
|
||||
|
||||
/**
|
||||
* Raw keyboard button event structure (event.raw_key.*)
|
||||
*
|
||||
* \since This struct is available since SDL 3.1.8.
|
||||
*/
|
||||
typedef struct SDL_RawKeyboardEvent
|
||||
{
|
||||
SDL_EventType type; /**< SDL_EVENT_RAW_KEY_DOWN or SDL_EVENT_RAW_KEY_UP */
|
||||
Uint32 reserved;
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
SDL_KeyboardID which; /**< The keyboard instance id */
|
||||
SDL_Scancode scancode; /**< SDL physical key code */
|
||||
Uint16 raw; /**< The platform dependent scancode for this event */
|
||||
bool down; /**< true if the key is pressed */
|
||||
} SDL_RawKeyboardEvent;
|
||||
|
||||
/**
|
||||
* Keyboard text editing event structure (event.edit.*)
|
||||
*
|
||||
|
@ -1061,7 +1043,6 @@ typedef union SDL_Event
|
|||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardDeviceEvent kdevice; /**< Keyboard device change event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_RawKeyboardEvent raw_key; /**< Raw keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
SDL_TextEditingCandidatesEvent edit_candidates; /**< Text editing candidates event data */
|
||||
SDL_TextInputEvent text; /**< Text input event data */
|
||||
|
|
|
@ -373,10 +373,8 @@ void SDL_EVDEV_Poll(void)
|
|||
Uint64 timestamp = SDL_EVDEV_GetEventTimestamp(event);
|
||||
scancode = SDL_EVDEV_translate_keycode(event->code);
|
||||
if (event->value == 0) {
|
||||
SDL_SendRawKeyboardKey(timestamp, (SDL_KeyboardID)item->fd, event->code, scancode, false);
|
||||
SDL_SendKeyboardKey(timestamp, (SDL_KeyboardID)item->fd, event->code, scancode, false);
|
||||
} else if (event->value == 1 || event->value == 2 /* key repeated */) {
|
||||
SDL_SendRawKeyboardKey(timestamp, (SDL_KeyboardID)item->fd, event->code, scancode, true);
|
||||
SDL_SendKeyboardKey(timestamp, (SDL_KeyboardID)item->fd, event->code, scancode, true);
|
||||
}
|
||||
SDL_EVDEV_kbd_keycode(_this->kbd, event->code, event->value);
|
||||
|
|
|
@ -573,12 +573,10 @@ static void Translate_to_keycode(SDL_WSCONS_input_data *input, int type, keysym_
|
|||
}
|
||||
for (i = 0; i < SDL_arraysize(conversion_table); i++) {
|
||||
if (conversion_table[i].sourcekey == group[0]) {
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboardID, group[0], conversion_table[i].targetKey, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
SDL_SendKeyboardKey(timestamp, input->keyboardID, group[0], conversion_table[i].targetKey, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
return;
|
||||
}
|
||||
}
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboardID, group[0], SDL_SCANCODE_UNKNOWN, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
SDL_SendKeyboardKey(timestamp, input->keyboardID, group[0], SDL_SCANCODE_UNKNOWN, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
}
|
||||
|
||||
|
@ -820,7 +818,6 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
|
|||
} break;
|
||||
case WSCONS_EVENT_ALL_KEYS_UP:
|
||||
for (i = 0; i < SDL_SCANCODE_COUNT; i++) {
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboardID, 0, (SDL_Scancode)i, false);
|
||||
SDL_SendKeyboardKey(timestamp, input->keyboardID, 0, (SDL_Scancode)i, false);
|
||||
}
|
||||
break;
|
||||
|
@ -829,7 +826,6 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
|
|||
}
|
||||
|
||||
if (input->type == WSKBD_TYPE_USB && events[i].value <= 0xE7) {
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboardID, 0, (SDL_Scancode)events[i].value, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
SDL_SendKeyboardKey(timestamp, input->keyboardID, 0, (SDL_Scancode)events[i].value, (type == WSCONS_EVENT_KEY_DOWN));
|
||||
} else {
|
||||
Translate_to_keycode(input, type, events[i].value, timestamp);
|
||||
|
|
|
@ -62,8 +62,6 @@ SDL_EventCategory SDL_GetEventCategory(Uint32 type)
|
|||
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
case SDL_EVENT_RAW_KEY_DOWN:
|
||||
case SDL_EVENT_RAW_KEY_UP:
|
||||
return SDL_EVENTCATEGORY_KEY;
|
||||
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
|
|
|
@ -535,19 +535,6 @@ static void SDL_LogEvent(const SDL_Event *event)
|
|||
break;
|
||||
#undef PRINT_KEY_EVENT
|
||||
|
||||
#define PRINT_RAW_KEY_EVENT(event) \
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u which=%u state=%s scancode=%u)", \
|
||||
(uint)event->raw_key.timestamp, (uint)event->raw_key.which, \
|
||||
event->raw_key.down ? "pressed" : "released", \
|
||||
(uint)event->raw_key.scancode);
|
||||
SDL_EVENT_CASE(SDL_EVENT_RAW_KEY_DOWN)
|
||||
PRINT_RAW_KEY_EVENT(event);
|
||||
break;
|
||||
SDL_EVENT_CASE(SDL_EVENT_RAW_KEY_UP)
|
||||
PRINT_RAW_KEY_EVENT(event);
|
||||
break;
|
||||
#undef PRINT_RAW_KEY_EVENT
|
||||
|
||||
SDL_EVENT_CASE(SDL_EVENT_TEXT_EDITING)
|
||||
(void)SDL_snprintf(details, sizeof(details), " (timestamp=%u windowid=%u text='%s' start=%d length=%d)",
|
||||
(uint)event->edit.timestamp, (uint)event->edit.windowID,
|
||||
|
|
|
@ -690,22 +690,6 @@ bool SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scancode)
|
|||
return SDL_SendKeyboardKeyInternal(timestamp, KEYBOARD_AUTORELEASE, SDL_GLOBAL_KEYBOARD_ID, 0, scancode, true);
|
||||
}
|
||||
|
||||
void SDL_SendRawKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down)
|
||||
{
|
||||
const SDL_EventType type = down ? SDL_EVENT_RAW_KEY_DOWN : SDL_EVENT_RAW_KEY_UP;
|
||||
|
||||
if (SDL_EventEnabled(type)) {
|
||||
SDL_Event event;
|
||||
event.type = type;
|
||||
event.common.timestamp = timestamp;
|
||||
event.raw_key.which = keyboardID;
|
||||
event.raw_key.scancode = scancode;
|
||||
event.raw_key.raw = rawcode;
|
||||
event.raw_key.down = down;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_ReleaseAutoReleaseKeys(void)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
|
|
@ -63,9 +63,6 @@ extern bool SDL_SendKeyboardKeyAutoRelease(Uint64 timestamp, SDL_Scancode scanco
|
|||
Most platforms should prefer to optionally call SDL_SetKeymap and then use SDL_SendKeyboardKey. */
|
||||
extern bool SDL_SendKeyboardKeyAndKeycode(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, SDL_Keycode keycode, bool down);
|
||||
|
||||
// Send a raw keyboard key event
|
||||
extern void SDL_SendRawKeyboardKey(Uint64 timestamp, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down);
|
||||
|
||||
// Release all the autorelease keys
|
||||
extern void SDL_ReleaseAutoReleaseKeys(void);
|
||||
|
||||
|
|
|
@ -188,7 +188,6 @@ static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0
|
|||
|
||||
keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed) {
|
||||
Uint64 timestamp = SDL_GetTicksNS();
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, 0, (SDL_Scancode)keyCode, pressed);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, 0, (SDL_Scancode)keyCode, pressed);
|
||||
};
|
||||
|
||||
|
|
|
@ -1732,7 +1732,6 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
|
|||
case SDLK_RGUI:
|
||||
case SDLK_MODE:
|
||||
Wayland_HandleModifierKeys(input, scancode, true);
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboard_id, *key, scancode, true);
|
||||
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, input->keyboard_id, *key, scancode, true);
|
||||
break;
|
||||
default:
|
||||
|
@ -1870,7 +1869,6 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||
scancode = Wayland_get_scancode_from_key(input, key + 8);
|
||||
Wayland_HandleModifierKeys(input, scancode, state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
Uint64 timestamp = Wayland_GetKeyboardTimestamp(input, time);
|
||||
SDL_SendRawKeyboardKey(timestamp, input->keyboard_id, key, scancode, (state == WL_KEYBOARD_KEY_STATE_PRESSED));
|
||||
SDL_SendKeyboardKeyIgnoreModifiers(timestamp, input->keyboard_id, key, scancode, (state == WL_KEYBOARD_KEY_STATE_PRESSED));
|
||||
|
||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||
|
|
|
@ -721,6 +721,10 @@ static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_VideoData *data, HA
|
|||
{
|
||||
SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)hDevice;
|
||||
|
||||
if (!data->raw_keyboard_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rawkeyboard->Flags & RI_KEY_E1) {
|
||||
// First key in a Ctrl+{key} sequence
|
||||
data->pending_E1_key_sequence = true;
|
||||
|
@ -764,12 +768,6 @@ static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_VideoData *data, HA
|
|||
code = windows_scancode_table[index];
|
||||
}
|
||||
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, rawcode, code, down);
|
||||
|
||||
if (!data->raw_keyboard_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (down) {
|
||||
SDL_Window *focus = SDL_GetKeyboardFocus();
|
||||
if (!focus || focus->text_input_active) {
|
||||
|
|
|
@ -383,14 +383,12 @@ static void GAMEINPUT_InitialKeyboardReading(WIN_GameInputData *data, SDL_Window
|
|||
const bool *keyboard_state = SDL_GetKeyboardState(&num_scancodes);
|
||||
for (int i = 0; i < num_scancodes; ++i) {
|
||||
if (keyboard_state[i] && !KeysHaveScancode(keys, num_keys, (SDL_Scancode)i)) {
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, keys[i].scanCode, (SDL_Scancode)i, false);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, keys[i].scanCode, (SDL_Scancode)i, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Go through and send key down events for any key that's held down
|
||||
for (uint32_t i = 0; i < num_keys; ++i) {
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, keys[i].scanCode, GetScancodeFromKeyState(&keys[i]), true);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, keys[i].scanCode, GetScancodeFromKeyState(&keys[i]), true);
|
||||
}
|
||||
}
|
||||
|
@ -436,18 +434,15 @@ static void GAMEINPUT_HandleKeyboardDelta(WIN_GameInputData *data, SDL_Window *w
|
|||
++index_keys;
|
||||
} else {
|
||||
// This key was released
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false);
|
||||
++index_last;
|
||||
}
|
||||
} else if (index_last < num_last) {
|
||||
// This key was released
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false);
|
||||
++index_last;
|
||||
} else {
|
||||
// This key was pressed
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, keys[index_keys].scanCode, GetScancodeFromKeyState(&keys[index_keys]), true);
|
||||
SDL_SendKeyboardKey(timestamp, keyboardID, keys[index_keys].scanCode, GetScancodeFromKeyState(&keys[index_keys]), true);
|
||||
++index_keys;
|
||||
}
|
||||
|
|
|
@ -827,11 +827,6 @@ void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_
|
|||
}
|
||||
#endif // DEBUG SCANCODES
|
||||
|
||||
if (keyboardID != SDL_GLOBAL_KEYBOARD_ID) {
|
||||
const bool down = (xevent->type == KeyPress);
|
||||
SDL_SendRawKeyboardKey(timestamp, keyboardID, keycode, videodata->key_layout[keycode], down);
|
||||
}
|
||||
|
||||
text[0] = '\0';
|
||||
|
||||
if (SDL_TextInputActive(windowdata->window)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue