1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Unified game controller input with keyboard/mouse

This commit is contained in:
Ivan Savenko
2024-04-30 13:36:29 +03:00
parent 9a71614588
commit 1dc27046ef
10 changed files with 202 additions and 403 deletions

View File

@@ -15,6 +15,7 @@
#include "CGuiHandler.h"
#include "MouseButton.h"
#include "WindowHandler.h"
#include "gui/Shortcut.h"
#include "../../lib/Rect.h"
@@ -74,6 +75,12 @@ void EventDispatcher::dispatchShortcutPressed(const std::vector<EShortcut> & sho
{
bool keysCaptured = false;
if (vstd::contains(shortcutsVector, EShortcut::MOUSE_LEFT))
dispatchMouseLeftButtonPressed(GH.getCursorPosition(), 0);
if (vstd::contains(shortcutsVector, EShortcut::MOUSE_RIGHT))
dispatchShowPopup(GH.getCursorPosition(), 0);
for(auto & i : keyinterested)
for(EShortcut shortcut : shortcutsVector)
if(i->captureThisKey(shortcut))
@@ -97,6 +104,12 @@ void EventDispatcher::dispatchShortcutReleased(const std::vector<EShortcut> & sh
{
bool keysCaptured = false;
if (vstd::contains(shortcutsVector, EShortcut::MOUSE_LEFT))
dispatchMouseLeftButtonReleased(GH.getCursorPosition(), 0);
if (vstd::contains(shortcutsVector, EShortcut::MOUSE_RIGHT))
dispatchClosePopup(GH.getCursorPosition());
for(auto & i : keyinterested)
for(EShortcut shortcut : shortcutsVector)
if(i->captureThisKey(shortcut))