mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
Merge pull request #369 from dariomanesku/master
Fixing SDL char input.
This commit is contained in:
commit
b29e2290ac
1 changed files with 16 additions and 8 deletions
|
@ -451,15 +451,23 @@ namespace entry
|
||||||
uint8_t modifiers = translateKeyModifiers(kev.keysym.mod);
|
uint8_t modifiers = translateKeyModifiers(kev.keysym.mod);
|
||||||
Key::Enum key = translateKey(kev.keysym.scancode);
|
Key::Enum key = translateKey(kev.keysym.scancode);
|
||||||
|
|
||||||
const uint8_t shiftMask = Modifier::LeftShift|Modifier::RightShift;
|
// TODO: These keys are not captured by SDL_TEXTINPUT. Should be probably handled by SDL_TEXTEDITING. This is a workaround for now.
|
||||||
const bool nonShiftModifiers = (0 != (modifiers&(~shiftMask) ) );
|
if (key == 1) // Escape
|
||||||
const bool isCharPressed = (Key::Key0 <= key && key <= Key::KeyZ) || (Key::Esc <= key && key <= Key::Minus);
|
|
||||||
const bool isText = isCharPressed && !nonShiftModifiers;
|
|
||||||
|
|
||||||
if (isText)
|
|
||||||
{
|
{
|
||||||
uint8_t pressedChar[4];
|
uint8_t pressedChar[4];
|
||||||
pressedChar[0] = keyToAscii(key, modifiers);
|
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] = 0x08;
|
||||||
m_eventQueue.postCharEvent(handle, 1, pressedChar);
|
m_eventQueue.postCharEvent(handle, 1, pressedChar);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue