summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2015-05-30 14:57:13 +0200
committer ImJezze <jezze@gmx.net>2015-05-30 14:57:13 +0200
commitd1d9dfc2d4be85cee8c8c990950d72ee6df78e5e (patch)
tree495d4e5a066ee13be131f08437732b3588d43a42 /3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
parentfe71f92dd24270ae7c5621166b096c665ca0e4f5 (diff)
parent51709eef04f9f0c6d621447c568e170927fa9472 (diff)
Merge pull request #4 from mamedev/master
Sync to base master
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_sdl.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_sdl.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
index b9564339c11..91bfef74865 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_sdl.cpp
@@ -12,6 +12,7 @@
#endif // BX_PLATFORM_WINDOWS
#include <SDL2/SDL.h>
+#include <SDL2/SDL_syswm.h>
#include <bgfxplatform.h>
#include <stdio.h>
@@ -450,20 +451,28 @@ namespace entry
uint8_t modifiers = translateKeyModifiers(kev.keysym.mod);
Key::Enum key = translateKey(kev.keysym.scancode);
- const uint8_t shiftMask = Modifier::LeftShift|Modifier::RightShift;
- const bool nonShiftModifiers = (0 != (modifiers&(~shiftMask) ) );
- const bool isCharPressed = (Key::Key0 <= key && key <= Key::KeyZ) || (Key::Esc <= key && key <= Key::Minus);
- const bool isText = isCharPressed && !nonShiftModifiers;
-
- if (isText)
+ // TODO: These keys are not captured by SDL_TEXTINPUT. Should be probably handled by SDL_TEXTEDITING. This is a workaround for now.
+ if (key == 1) // Escape
+ {
+ uint8_t pressedChar[4];
+ pressedChar[0] = 0x1b;
+ m_eventQueue.postCharEvent(handle, 1, pressedChar);
+ }
+ else if (key == 2) // Enter
+ {
+ uint8_t pressedChar[4];
+ pressedChar[0] = 0x0d;
+ m_eventQueue.postCharEvent(handle, 1, pressedChar);
+ }
+ else if (key == 5) // Backspace
{
uint8_t pressedChar[4];
- pressedChar[0] = keyToAscii(key, modifiers);
+ pressedChar[0] = 0x08;
m_eventQueue.postCharEvent(handle, 1, pressedChar);
}
else
{
- m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED);
+ m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED);
}
}
}