aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/qt_sdl')
-rw-r--r--src/frontend/qt_sdl/InputConfigDialog.cpp22
-rw-r--r--src/frontend/qt_sdl/main.h21
2 files changed, 36 insertions, 7 deletions
diff --git a/src/frontend/qt_sdl/InputConfigDialog.cpp b/src/frontend/qt_sdl/InputConfigDialog.cpp
index 54251a1..0ef29bb 100644
--- a/src/frontend/qt_sdl/InputConfigDialog.cpp
+++ b/src/frontend/qt_sdl/InputConfigDialog.cpp
@@ -24,6 +24,7 @@
#include "Config.h"
#include "PlatformConfig.h"
+#include "main.h"
#include "InputConfigDialog.h"
#include "ui_InputConfigDialog.h"
@@ -231,7 +232,9 @@ KeyMapButton::~KeyMapButton()
void KeyMapButton::keyPressEvent(QKeyEvent* event)
{
if (!isChecked()) return QPushButton::keyPressEvent(event);
-printf("KEY PRESSED = %08X %08X | %08X %08X %08X | %08X\n", event->key(), event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode(), Qt::SHIFT);
+
+ printf("KEY PRESSED = %08X %08X | %08X %08X %08X\n", event->key(), event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode());
+
int key = event->key();
bool ismod = (key == Qt::Key_Control ||
key == Qt::Key_Alt ||
@@ -247,6 +250,8 @@ printf("KEY PRESSED = %08X %08X | %08X %08X %08X | %08X\n", event->key(), event-
if (!ismod)
key |= event->modifiers();
+ else if (IsRightModKey(event))
+ key |= (1<<31);
*mapping = key;
click();
@@ -279,23 +284,26 @@ QString KeyMapButton::mappingText()
{
int key = *mapping;
+ if (key == -1) return "None";
+
+ QString isright = (key & (1<<31)) ? "Right " : "Left ";
+ key &= ~(1<<31);
+
switch (key)
{
- case -1: return "None";
-
- case Qt::Key_Control: return "Ctrl";
+ case Qt::Key_Control: return isright + "Ctrl";
case Qt::Key_Alt: return "Alt";
case Qt::Key_AltGr: return "AltGr";
- case Qt::Key_Shift: return "Shift";
+ case Qt::Key_Shift: return isright + "Shift";
case Qt::Key_Meta: return "Meta";
}
QKeySequence seq(key);
QString ret = seq.toString();
-
+
// weak attempt at detecting garbage key names
if (ret.length() == 2 && ret[0].unicode() > 0xFF)
return QString("[%1]").arg(key, 8, 16);
-
+
return ret.replace("&", "&&");
}
diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h
index 4553875..5d6638c 100644
--- a/src/frontend/qt_sdl/main.h
+++ b/src/frontend/qt_sdl/main.h
@@ -23,6 +23,7 @@
#include <QWidget>
#include <QMainWindow>
#include <QImage>
+#include <QKeyEvent>
class EmuThread : public QThread
@@ -131,4 +132,24 @@ private:
QAction* actInputConfig;
};
+
+// TODO: MacOS version of this!
+// distinguish between left and right modifier keys (Ctrl, Alt, Shift)
+// Qt provides no real cross-platform way to do this, so here we go
+// for Windows and Linux we can distinguish via scancodes (but both
+// provide different scancodes)
+#ifdef __WIN32__
+inline bool IsRightModKey(QKeyEvent* event)
+{
+ quint32 scan = event->nativeScanCode();
+ return (scan == 0x11D || scan == 0x138 || scan == 0x36);
+}
+#else
+inline bool IsRightModKey(QKeyEvent* event)
+{
+ quint32 scan = event->nativeScanCode();
+ return (scan == 0x69 || scan == 0x6C || scan == 0x3E);
+}
+#endif
+
#endif // MAIN_H