summaryrefslogtreecommitdiff
path: root/launcher/KonamiCode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/KonamiCode.cpp')
-rw-r--r--launcher/KonamiCode.cpp50
1 files changed, 18 insertions, 32 deletions
diff --git a/launcher/KonamiCode.cpp b/launcher/KonamiCode.cpp
index 16a24bd6b6..41db854a23 100644
--- a/launcher/KonamiCode.cpp
+++ b/launcher/KonamiCode.cpp
@@ -24,42 +24,28 @@
#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)
+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();
- }
- }
+ 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();
+ }
+ }
}