2016-12-11 16:39:11 -05:00
|
|
|
|
#pragma once
|
|
|
|
|
#include <unordered_map>
|
2016-12-18 20:39:31 -05:00
|
|
|
|
#include <vector>
|
|
|
|
|
#include <thread>
|
2016-12-11 16:39:11 -05:00
|
|
|
|
#include "../Core/IKeyManager.h"
|
2018-06-09 18:47:11 -04:00
|
|
|
|
#include "../Utilities/AutoResetEvent.h"
|
2016-12-11 16:39:11 -05:00
|
|
|
|
|
2016-12-18 20:39:31 -05:00
|
|
|
|
class LinuxGameController;
|
2018-07-02 19:01:10 -04:00
|
|
|
|
class Console;
|
2016-12-18 20:39:31 -05:00
|
|
|
|
|
2016-12-11 16:39:11 -05:00
|
|
|
|
struct KeyDefinition {
|
|
|
|
|
string name;
|
|
|
|
|
uint32_t keyCode;
|
|
|
|
|
string description;
|
|
|
|
|
string extDescription;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class LinuxKeyManager : public IKeyManager
|
|
|
|
|
{
|
|
|
|
|
private:
|
2018-07-02 19:01:10 -04:00
|
|
|
|
shared_ptr<Console> _console;
|
2016-12-18 20:39:31 -05:00
|
|
|
|
std::vector<shared_ptr<LinuxGameController>> _controllers;
|
2016-12-14 18:26:52 -05:00
|
|
|
|
bool _keyState[0x200];
|
|
|
|
|
bool _mouseState[0x03];
|
2016-12-11 16:39:11 -05:00
|
|
|
|
std::unordered_map<uint32_t, string> _keyNames;
|
|
|
|
|
std::unordered_map<string, uint32_t> _keyCodes;
|
|
|
|
|
|
2016-12-18 20:39:31 -05:00
|
|
|
|
std::thread _updateDeviceThread;
|
|
|
|
|
atomic<bool> _stopUpdateDeviceThread;
|
2018-06-09 18:47:11 -04:00
|
|
|
|
AutoResetEvent _stopSignal;
|
2017-09-08 10:38:41 -04:00
|
|
|
|
bool _disableAllKeys;
|
2016-12-18 20:39:31 -05:00
|
|
|
|
|
|
|
|
|
void StartUpdateDeviceThread();
|
2019-02-08 20:34:10 -05:00
|
|
|
|
void CheckForGamepads(bool logInformation);
|
2016-12-18 20:39:31 -05:00
|
|
|
|
|
2016-12-11 16:39:11 -05:00
|
|
|
|
public:
|
2018-07-02 19:01:10 -04:00
|
|
|
|
LinuxKeyManager(shared_ptr<Console> console);
|
2016-12-11 16:39:11 -05:00
|
|
|
|
virtual ~LinuxKeyManager();
|
|
|
|
|
|
|
|
|
|
void RefreshState();
|
|
|
|
|
bool IsKeyPressed(uint32_t key);
|
|
|
|
|
bool IsMouseButtonPressed(MouseButton button);
|
2017-09-08 10:38:41 -04:00
|
|
|
|
std::vector<uint32_t> GetPressedKeys();
|
2016-12-11 16:39:11 -05:00
|
|
|
|
string GetKeyName(uint32_t key);
|
|
|
|
|
uint32_t GetKeyCode(string keyName);
|
|
|
|
|
|
|
|
|
|
void UpdateDevices();
|
|
|
|
|
void SetKeyState(uint16_t scanCode, bool state);
|
|
|
|
|
void ResetKeyState();
|
2017-09-08 10:38:41 -04:00
|
|
|
|
|
|
|
|
|
void SetDisabled(bool disabled);
|
2016-12-11 16:39:11 -05:00
|
|
|
|
};
|