input_common: Allow keyboard to be backwards compatible

This commit is contained in:
german77
2021-11-14 10:45:07 -06:00
committed by Narr the Reg
parent b673857d7d
commit bca299e8e0
10 changed files with 115 additions and 48 deletions

View File

@ -609,7 +609,7 @@ int GRenderWindow::QtKeyToSwitchKey(Qt::Key qt_key) {
return Settings::NativeKeyboard::ZenkakuHankaku;
// Modifier keys are handled by the modifier property
default:
return 0;
return Settings::NativeKeyboard::None;
}
}
@ -662,8 +662,10 @@ void GRenderWindow::keyPressEvent(QKeyEvent* event) {
// Replace event->key() with event->nativeVirtualKey() since the second one provides raw key
// buttons
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
input_subsystem->GetKeyboard()->SetModifiers(moddifier);
input_subsystem->GetKeyboard()->PressKey(key);
input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier);
input_subsystem->GetKeyboard()->PressKeyboardKey(key);
// This is used for gamepads
input_subsystem->GetKeyboard()->PressKey(event->key());
}
}
@ -671,8 +673,10 @@ void GRenderWindow::keyReleaseEvent(QKeyEvent* event) {
if (!event->isAutoRepeat()) {
const auto moddifier = QtModifierToSwitchModdifier(event->nativeModifiers());
const auto key = QtKeyToSwitchKey(Qt::Key(event->key()));
input_subsystem->GetKeyboard()->SetModifiers(moddifier);
input_subsystem->GetKeyboard()->ReleaseKey(key);
input_subsystem->GetKeyboard()->SetKeyboardModifiers(moddifier);
input_subsystem->GetKeyboard()->ReleaseKeyboardKey(key);
// This is used for gamepads
input_subsystem->GetKeyboard()->ReleaseKey(event->key());
}
}