Add workaround for numpad home/end keys etc
parent
53053b901f
commit
be8d37241a
|
@ -1425,7 +1425,7 @@ Event CApplication::CreateVirtualEvent(const Event& sourceEvent)
|
|||
if ((sourceEvent.type == EVENT_KEY_DOWN) || (sourceEvent.type == EVENT_KEY_UP))
|
||||
{
|
||||
auto sourceData = sourceEvent.GetData<KeyEventData>();
|
||||
auto virtualKey = GetVirtualKey(sourceData->key);
|
||||
auto virtualKey = GetVirtualKey(sourceData->key, sourceEvent.kmodState);
|
||||
|
||||
if (virtualKey == sourceData->key)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "common/key.h"
|
||||
|
||||
unsigned int GetVirtualKey(unsigned int key)
|
||||
unsigned int GetVirtualKey(unsigned int key, unsigned int kmodState)
|
||||
{
|
||||
if(key == KEY(LCTRL) || key == KEY(RCTRL))
|
||||
return VIRTUAL_KMOD(CTRL);
|
||||
|
@ -33,5 +33,26 @@ unsigned int GetVirtualKey(unsigned int key)
|
|||
if(key == KEY(KP_ENTER))
|
||||
return KEY(RETURN);
|
||||
|
||||
// Remap keypad navigation keys as a workaround for the SDL issue: https://github.com/libsdl-org/SDL/issues/1766
|
||||
if ((kmodState & KEY_MOD(NUM)) == 0)
|
||||
{
|
||||
if(key == KEY(KP_7))
|
||||
return KEY(HOME);
|
||||
if(key == KEY(KP_1))
|
||||
return KEY(END);
|
||||
if(key == KEY(KP_9))
|
||||
return KEY(PAGEUP);
|
||||
if(key == KEY(KP_3))
|
||||
return KEY(PAGEDOWN);
|
||||
if(key == KEY(KP_4))
|
||||
return KEY(LEFT);
|
||||
if(key == KEY(KP_6))
|
||||
return KEY(RIGHT);
|
||||
if(key == KEY(KP_8))
|
||||
return KEY(UP);
|
||||
if(key == KEY(KP_2))
|
||||
return KEY(DOWN);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ enum VirtualKmod
|
|||
#define VIRTUAL_KMOD(x) VIRTUAL_KMOD_ ## x
|
||||
|
||||
//! Converts individual codes to virtual keys if needed
|
||||
unsigned int GetVirtualKey(unsigned int key);
|
||||
unsigned int GetVirtualKey(unsigned int key, unsigned int kmodState);
|
||||
|
||||
// Virtual key code generated on joystick button presses
|
||||
// num is number of joystick button
|
||||
|
|
|
@ -75,7 +75,7 @@ bool CKey::EventProcess(const Event &event)
|
|||
if (event.type == EVENT_KEY_DOWN && m_catch)
|
||||
{
|
||||
m_catch = false;
|
||||
unsigned int key = GetVirtualKey(event.GetData<KeyEventData>()->key);
|
||||
unsigned int key = GetVirtualKey(event.GetData<KeyEventData>()->key, event.kmodState);
|
||||
|
||||
if (TestKey(key)) // impossible ?
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue