2016-09-02 23:36:37 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include <thread>
|
|
|
|
#include <unordered_set>
|
2017-09-08 14:38:41 +00:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2016-09-02 23:36:37 +00:00
|
|
|
#include "EmulationSettings.h"
|
|
|
|
|
|
|
|
class ShortcutKeyHandler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::thread _thread;
|
|
|
|
atomic<bool> _stopThread;
|
2017-09-08 14:38:41 +00:00
|
|
|
SimpleLock _lock;
|
2016-09-02 23:36:37 +00:00
|
|
|
|
2017-09-08 14:38:41 +00:00
|
|
|
int _keySetIndex;
|
|
|
|
vector<uint32_t> _pressedKeys;
|
2017-09-17 14:25:20 +00:00
|
|
|
vector<uint32_t> _lastPressedKeys;
|
|
|
|
bool _isKeyUp;
|
2017-12-18 02:11:54 +00:00
|
|
|
bool _keyboardMode;
|
2017-09-08 14:38:41 +00:00
|
|
|
|
2017-09-08 15:25:10 +00:00
|
|
|
std::unordered_set<uint32_t> _keysDown[2];
|
|
|
|
std::unordered_set<uint32_t> _prevKeysDown[2];
|
2016-09-03 14:49:54 +00:00
|
|
|
|
2017-09-08 14:38:41 +00:00
|
|
|
void CheckMappedKeys();
|
2016-09-03 14:49:54 +00:00
|
|
|
|
2017-09-08 14:38:41 +00:00
|
|
|
bool IsKeyPressed(EmulatorShortcut key);
|
2017-09-17 14:25:20 +00:00
|
|
|
bool IsKeyPressed(KeyCombination comb);
|
2017-12-18 02:11:54 +00:00
|
|
|
bool IsKeyPressed(uint32_t keyCode);
|
2017-09-08 14:38:41 +00:00
|
|
|
|
|
|
|
bool DetectKeyPress(EmulatorShortcut key);
|
|
|
|
bool DetectKeyRelease(EmulatorShortcut key);
|
2016-09-02 23:36:37 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
ShortcutKeyHandler();
|
|
|
|
~ShortcutKeyHandler();
|
2017-09-08 14:38:41 +00:00
|
|
|
|
|
|
|
void ProcessKeys();
|
2016-09-02 23:36:37 +00:00
|
|
|
};
|