mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 01:46:42 +00:00
CGE: Improve keyboard behavior for non-US layouts
This commit is contained in:
parent
55df4d0635
commit
f898da53a4
@ -99,11 +99,16 @@ Sprite *Keyboard::setClient(Sprite *spr) {
|
|||||||
return spr;
|
return spr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
|
bool Keyboard::getKey(Common::Event &event, int &cgeCode) {
|
||||||
|
Common::KeyCode keycode = event.kbd.keycode;
|
||||||
if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) {
|
if ((keycode == Common::KEYCODE_LCTRL) || (keycode == Common::KEYCODE_RCTRL)) {
|
||||||
cgeCode = 29;
|
cgeCode = 29;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if ((keycode == Common::KEYCODE_LALT) || (keycode == Common::KEYCODE_RALT)) {
|
||||||
|
cgeCode = 56;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (keycode == Common::KEYCODE_KP_ENTER) {
|
if (keycode == Common::KEYCODE_KP_ENTER) {
|
||||||
cgeCode = 28;
|
cgeCode = 28;
|
||||||
return true;
|
return true;
|
||||||
@ -111,7 +116,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
|
|||||||
|
|
||||||
// Scan through the ScummVM mapping list
|
// Scan through the ScummVM mapping list
|
||||||
for (int idx = 0; idx < 0x60; idx++) {
|
for (int idx = 0; idx < 0x60; idx++) {
|
||||||
if (_scummVmCodes[idx] == keycode) {
|
if (_scummVmCodes[idx] == event.kbd.ascii) {
|
||||||
cgeCode = idx;
|
cgeCode = idx;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -122,7 +127,7 @@ bool Keyboard::getKey(uint16 keycode, int &cgeCode) {
|
|||||||
|
|
||||||
void Keyboard::newKeyboard(Common::Event &event) {
|
void Keyboard::newKeyboard(Common::Event &event) {
|
||||||
int keycode;
|
int keycode;
|
||||||
if (!getKey(event.kbd.keycode, keycode))
|
if (!getKey(event, keycode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (event.type == Common::EVENT_KEYUP) {
|
if (event.type == Common::EVENT_KEYUP) {
|
||||||
|
@ -47,7 +47,7 @@ namespace CGE {
|
|||||||
|
|
||||||
class Keyboard {
|
class Keyboard {
|
||||||
private:
|
private:
|
||||||
bool getKey(uint16 keycode, int &cgeCode);
|
bool getKey(Common::Event &event, int &cgeCode);
|
||||||
public:
|
public:
|
||||||
static const uint16 _code[0x60];
|
static const uint16 _code[0x60];
|
||||||
static const uint16 _scummVmCodes[0x60];
|
static const uint16 _scummVmCodes[0x60];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user