fixed problem with QWERTZ keys

This commit is contained in:
thrust26 2020-11-06 23:57:34 +01:00
parent a7eb6d2696
commit 6b46f85fc9
4 changed files with 23 additions and 13 deletions

View File

@ -38,7 +38,7 @@ class EventHandlerSDL2 : public EventHandler
explicit EventHandlerSDL2(OSystem& osystem);
~EventHandlerSDL2() override;
private:
private:
/**
Enable/disable text events (distinct from single-key events).
*/

View File

@ -102,6 +102,15 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
// Otherwise, only reset the given event
bool eraseAll = !updateDefaults && (event == Event::NoType);
// Swap Y and Z for QWERTZ keyboards
if(mode == EventMode::kEditMode && myHandler.isQwertz())
{
if(map.key == KBDK_Z)
map.key = KBDK_Y;
else if(map.key == KBDK_Y)
map.key = KBDK_Z;
}
if (updateDefaults)
{
// if there is no existing mapping for the event and
@ -678,7 +687,7 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::FixedEditMap
{Event::Delete, KBDK_DELETE},
{Event::DeleteChar, KBDK_D, KBDM_CTRL},
{Event::DeleteWord, KBDK_W, KBDM_CTRL},
{Event::DeleteWord, KBDK_BACKSPACE, OPTION},
{Event::DeleteWord, KBDK_BACKSPACE, KBDM_CTRL},
{Event::DeleteHome, KBDK_U, KBDM_CTRL},
{Event::DeleteHome, KBDK_BACKSPACE, CMD},
{Event::DeleteEnd, KBDK_K, KBDM_CTRL},

View File

@ -69,16 +69,6 @@ using namespace std::placeholders;
EventHandler::EventHandler(OSystem& osystem)
: myOSystem(osystem)
{
// Create keyboard handler (to handle all physical keyboard functionality)
myPKeyHandler = make_unique<PhysicalKeyboardHandler>(osystem, *this);
// Create joystick handler (to handle all physical joystick functionality)
myPJoyHandler = make_unique<PhysicalJoystickHandler>(osystem, *this);
// Erase the 'combo' array
for(int i = 0; i < COMBO_SIZE; ++i)
for(int j = 0; j < EVENTS_PER_COMBO; ++j)
myComboTable[i][j] = Event::NoType;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -89,6 +79,17 @@ EventHandler::~EventHandler()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void EventHandler::initialize()
{
// Create keyboard handler (to handle all physical keyboard functionality)
myPKeyHandler = make_unique<PhysicalKeyboardHandler>(myOSystem, *this);
// Create joystick handler (to handle all physical joystick functionality)
myPJoyHandler = make_unique<PhysicalJoystickHandler>(myOSystem, *this);
// Erase the 'combo' array
for(int i = 0; i < COMBO_SIZE; ++i)
for(int j = 0; j < EVENTS_PER_COMBO; ++j)
myComboTable[i][j] = Event::NoType;
// Make sure the event/action mappings are correctly set,
// and fill the ActionList structure with valid values
setComboMap();

View File

@ -249,7 +249,7 @@ bool EditableWidget::handleKeyDown(StellaKey key, StellaMod mod)
myUndoHandler->endChars(_editString);
// Reverse Y and Z for QWERTZ keyboards
if(event == Event::Redo != instance().eventHandler().isQwertz())
if(event == Event::Redo)
handled = myUndoHandler->redo(_editString);
else
handled = myUndoHandler->undo(_editString);