From c7023d7635f78f50cd0d20c2ad09b62f1ab39a47 Mon Sep 17 00:00:00 2001 From: Souryo Date: Sat, 3 Sep 2016 10:49:54 -0400 Subject: [PATCH] Shortcuts: Added VS Service button --- Core/EmulationSettings.h | 1 + Core/ShortcutKeyHandler.cpp | 44 ++++++++++++++++----------- Core/ShortcutKeyHandler.h | 5 +-- GUI.NET/Dependencies/resources.fr.xml | 1 + GUI.NET/Dependencies/resources.ja.xml | 3 +- 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index ec8883f4..4411ad8a 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -219,6 +219,7 @@ struct EmulatorKeyMappings uint32_t InsertCoin1; uint32_t InsertCoin2; + uint32_t VsServiceButton; uint32_t TakeScreenshot; }; diff --git a/Core/ShortcutKeyHandler.cpp b/Core/ShortcutKeyHandler.cpp index 3e380c06..38a65b5f 100644 --- a/Core/ShortcutKeyHandler.cpp +++ b/Core/ShortcutKeyHandler.cpp @@ -36,25 +36,41 @@ bool ShortcutKeyHandler::DetectKeyPress(uint32_t keyCode) return false; } +bool ShortcutKeyHandler::DetectKeyRelease(uint32_t keyCode) +{ + if(!ControlManager::IsKeyPressed(keyCode)) { + if(_prevKeysDown.find(keyCode) != _prevKeysDown.end()) { + return true; + } + } + return false; +} + void ShortcutKeyHandler::CheckMappedKeys(EmulatorKeyMappings mappings) { - if(ControlManager::IsKeyPressed(mappings.FastForward)) { - _turboEnabled = true; + if(DetectKeyPress(mappings.FastForward)) { + EmulationSettings::SetFlags(EmulationFlags::Turbo); + } else if(DetectKeyRelease(mappings.FastForward)) { + EmulationSettings::ClearFlags(EmulationFlags::Turbo); } if(DetectKeyPress(mappings.TakeScreenshot)) { VideoDecoder::GetInstance()->TakeScreenshot(); } - if(DetectKeyPress(mappings.InsertCoin1)) { - if(VsControlManager::GetInstance()) { - VsControlManager::GetInstance()->InsertCoin(0); + if(VsControlManager::GetInstance()) { + VsControlManager* manager = VsControlManager::GetInstance(); + if(DetectKeyPress(mappings.InsertCoin1)) { + manager->InsertCoin(0); } - } - - if(DetectKeyPress(mappings.InsertCoin2)) { - if(VsControlManager::GetInstance()) { - VsControlManager::GetInstance()->InsertCoin(1); + if(DetectKeyPress(mappings.InsertCoin2)) { + manager->InsertCoin(1); + } + if(DetectKeyPress(mappings.VsServiceButton)) { + manager->SetServiceButtonState(true); + } + if(DetectKeyRelease(mappings.VsServiceButton)) { + manager->SetServiceButtonState(false); } } @@ -100,15 +116,7 @@ void ShortcutKeyHandler::ProcessKeys(EmulatorKeyMappingSet mappings) ControlManager::RefreshKeyState(); _keysDown.clear(); - - _turboEnabled = false; CheckMappedKeys(mappings.KeySet1); CheckMappedKeys(mappings.KeySet2); - if(_turboEnabled) { - EmulationSettings::SetFlags(EmulationFlags::Turbo); - } else { - EmulationSettings::ClearFlags(EmulationFlags::Turbo); - } - _prevKeysDown = _keysDown; } \ No newline at end of file diff --git a/Core/ShortcutKeyHandler.h b/Core/ShortcutKeyHandler.h index be6bb743..3639dd55 100644 --- a/Core/ShortcutKeyHandler.h +++ b/Core/ShortcutKeyHandler.h @@ -12,11 +12,12 @@ private: std::unordered_set _keysDown; std::unordered_set _prevKeysDown; - bool _turboEnabled; - + void CheckMappedKeys(EmulatorKeyMappings mappings); void ProcessKeys(EmulatorKeyMappingSet mappings); + bool DetectKeyPress(uint32_t keyCode); + bool DetectKeyRelease(uint32_t keyCode); public: ShortcutKeyHandler(); diff --git a/GUI.NET/Dependencies/resources.fr.xml b/GUI.NET/Dependencies/resources.fr.xml index 119fae99..84ec8e68 100644 --- a/GUI.NET/Dependencies/resources.fr.xml +++ b/GUI.NET/Dependencies/resources.fr.xml @@ -521,6 +521,7 @@ FDS - Insérer le disque suivant VS - Insérer une pièce (1) VS - Insérer une pièce (2) + VS - Bouton de service Position de sauvegarde suivante Position de sauvegarde précédente Sauvegarder l'état à la position courante diff --git a/GUI.NET/Dependencies/resources.ja.xml b/GUI.NET/Dependencies/resources.ja.xml index a377242c..3d033a7c 100644 --- a/GUI.NET/Dependencies/resources.ja.xml +++ b/GUI.NET/Dependencies/resources.ja.xml @@ -500,9 +500,10 @@ リセット スクリーンショットを撮る FDS - A面B面切り替え - FDS - 次のディスクを入れる + FDS - 次のディスクを入れる VS - インサートコイン 1 VS - インサートコイン 2 + VS - サービスボタン 次のクイックセーブスロットを選ぶ 前のクイックセーブスロットを選ぶ 選択中スロットにクイックセーブ