2019-03-11 17:56:54 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "../Utilities/SimpleLock.h"
|
|
|
|
#include "../Utilities/Timer.h"
|
|
|
|
#include "SettingTypes.h"
|
|
|
|
|
|
|
|
class Console;
|
|
|
|
|
|
|
|
class ShortcutKeyHandler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
shared_ptr<Console> _console;
|
|
|
|
|
|
|
|
thread _thread;
|
|
|
|
atomic<bool> _stopThread;
|
|
|
|
SimpleLock _lock;
|
2021-03-10 11:13:28 -05:00
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
int _keySetIndex;
|
|
|
|
vector<uint32_t> _pressedKeys;
|
|
|
|
vector<uint32_t> _lastPressedKeys;
|
|
|
|
bool _isKeyUp;
|
|
|
|
|
|
|
|
shared_ptr<Timer> _runSingleFrameRepeatTimer;
|
|
|
|
bool _repeatStarted;
|
|
|
|
|
|
|
|
unordered_set<uint32_t> _keysDown[2];
|
|
|
|
unordered_set<uint32_t> _prevKeysDown[2];
|
2021-03-10 11:13:28 -05:00
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
void CheckMappedKeys();
|
2021-03-10 11:13:28 -05:00
|
|
|
|
2019-03-11 17:56:54 -04:00
|
|
|
bool IsKeyPressed(EmulatorShortcut key);
|
|
|
|
bool IsKeyPressed(KeyCombination comb);
|
|
|
|
bool IsKeyPressed(uint32_t keyCode);
|
|
|
|
|
|
|
|
bool DetectKeyPress(EmulatorShortcut key);
|
|
|
|
bool DetectKeyRelease(EmulatorShortcut key);
|
|
|
|
|
|
|
|
void ProcessRunSingleFrame();
|
|
|
|
|
|
|
|
public:
|
|
|
|
ShortcutKeyHandler(shared_ptr<Console> console);
|
|
|
|
~ShortcutKeyHandler();
|
|
|
|
|
|
|
|
void ProcessKeys();
|
2021-03-10 11:13:28 -05:00
|
|
|
};
|