mirror of https://github.com/libsdl-org/SDL.git
haiku: Fixed keyboard input.
_GetWinID() doesn't work with keyboard-related BMessages, because Haiku assumes you know what window has keyboard focus at the time, so these events don't have a `window-id` property. So when this call failed, the key event handler would return early. This was probably a copy/paste error that snuck in at some point, as SDL2 doesn't have this issue.
This commit is contained in:
parent
d2b7a84651
commit
1354affd28
|
|
@ -293,12 +293,9 @@ class SDL_BLooper : public BLooper
|
||||||
|
|
||||||
void _HandleKey(BMessage *msg)
|
void _HandleKey(BMessage *msg)
|
||||||
{
|
{
|
||||||
SDL_Window *win;
|
|
||||||
int32 winID;
|
|
||||||
int32 scancode;
|
int32 scancode;
|
||||||
bool down;
|
bool down;
|
||||||
if (
|
if (
|
||||||
!_GetWinID(msg, &winID) ||
|
|
||||||
msg->FindInt32("key-scancode", &scancode) != B_OK ||
|
msg->FindInt32("key-scancode", &scancode) != B_OK ||
|
||||||
msg->FindBool("key-down", &down) != B_OK) {
|
msg->FindBool("key-down", &down) != B_OK) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -306,15 +303,17 @@ class SDL_BLooper : public BLooper
|
||||||
|
|
||||||
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, scancode, HAIKU_GetScancodeFromBeKey(scancode), down);
|
SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, scancode, HAIKU_GetScancodeFromBeKey(scancode), down);
|
||||||
|
|
||||||
win = GetSDLWindow(winID);
|
if (down) {
|
||||||
if (down && SDL_TextInputActive(win)) {
|
SDL_Window *win = SDL_GetKeyboardFocus();
|
||||||
const int8 *keyUtf8;
|
if (win && SDL_TextInputActive(win)) {
|
||||||
ssize_t count;
|
const int8 *keyUtf8;
|
||||||
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
|
ssize_t count;
|
||||||
char text[64];
|
if (msg->FindData("key-utf8", B_INT8_TYPE, (const void **)&keyUtf8, &count) == B_OK) {
|
||||||
SDL_zeroa(text);
|
char text[64];
|
||||||
SDL_memcpy(text, keyUtf8, count);
|
SDL_zeroa(text);
|
||||||
SDL_SendKeyboardText(text);
|
SDL_memcpy(text, keyUtf8, count);
|
||||||
|
SDL_SendKeyboardText(text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue