aboutsummaryrefslogtreecommitdiff
path: root/launcher/KonamiCode.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2021-07-25 19:11:59 +0200
committerPetr Mrázek <peterix@gmail.com>2021-07-25 19:50:44 +0200
commit20b9f2b42a3b58b6081af271774fbcc34025dccb (patch)
tree064fa59facb3357139b47bd4e60bfc8edb35ca11 /launcher/KonamiCode.cpp
parentdd133680858351e3e07690e286882327a4f42ba5 (diff)
downloadPrismLauncher-20b9f2b42a3b58b6081af271774fbcc34025dccb.tar.gz
PrismLauncher-20b9f2b42a3b58b6081af271774fbcc34025dccb.tar.bz2
PrismLauncher-20b9f2b42a3b58b6081af271774fbcc34025dccb.zip
NOISSUE Flatten gui and logic libraries into MultiMC
Diffstat (limited to 'launcher/KonamiCode.cpp')
-rw-r--r--launcher/KonamiCode.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/launcher/KonamiCode.cpp b/launcher/KonamiCode.cpp
new file mode 100644
index 00000000..46a2a0b2
--- /dev/null
+++ b/launcher/KonamiCode.cpp
@@ -0,0 +1,44 @@
+#include "KonamiCode.h"
+
+#include <array>
+#include <QDebug>
+
+namespace {
+const std::array<Qt::Key, 10> konamiCode =
+{
+ {
+ Qt::Key_Up, Qt::Key_Up,
+ Qt::Key_Down, Qt::Key_Down,
+ Qt::Key_Left, Qt::Key_Right,
+ Qt::Key_Left, Qt::Key_Right,
+ Qt::Key_B, Qt::Key_A
+ }
+};
+}
+
+KonamiCode::KonamiCode(QObject* parent) : QObject(parent)
+{
+}
+
+
+void KonamiCode::input(QEvent* event)
+{
+ if( event->type() == QEvent::KeyPress )
+ {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent*>( event );
+ auto key = Qt::Key(keyEvent->key());
+ if(key == konamiCode[m_progress])
+ {
+ m_progress ++;
+ }
+ else
+ {
+ m_progress = 0;
+ }
+ if(m_progress == static_cast<int>(konamiCode.size()))
+ {
+ m_progress = 0;
+ emit triggered();
+ }
+ }
+}