summaryrefslogtreecommitdiffstats
path: root/application/KonamiCode.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-03-15 09:27:45 +0100
committerPetr Mrázek <peterix@gmail.com>2018-03-15 09:27:45 +0100
commit303842a19e4893e4ac6784d60aca990b4276d0ec (patch)
tree6dcaffa82816bfa00e58c9e824be9d69cd2f0102 /application/KonamiCode.cpp
parentea151ca9d4124851e96553699cee1c2832c10b8f (diff)
downloadMultiMC-303842a19e4893e4ac6784d60aca990b4276d0ec.tar
MultiMC-303842a19e4893e4ac6784d60aca990b4276d0ec.tar.gz
MultiMC-303842a19e4893e4ac6784d60aca990b4276d0ec.tar.lz
MultiMC-303842a19e4893e4ac6784d60aca990b4276d0ec.tar.xz
MultiMC-303842a19e4893e4ac6784d60aca990b4276d0ec.zip
NOISSUE Add Konami Code
Fun little thing for hiding extra debug options in the future.
Diffstat (limited to 'application/KonamiCode.cpp')
-rw-r--r--application/KonamiCode.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/application/KonamiCode.cpp b/application/KonamiCode.cpp
new file mode 100644
index 00000000..07c285bc
--- /dev/null
+++ b/application/KonamiCode.cpp
@@ -0,0 +1,42 @@
+#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 == konamiCode.size())
+ {
+ m_progress = 0;
+ emit triggered();
+ }
+ }
+}