Skip to content

Commit 65974d5

Browse files
committed
Part 1 refactor of keyboard controls.
1 parent a215f95 commit 65974d5

38 files changed

+1349
-518
lines changed

Common/Cpp/Options/KeyBindingOption.cpp

Lines changed: 0 additions & 82 deletions
This file was deleted.

Common/Qt/Options/KeyBindingWidget.cpp

Lines changed: 0 additions & 60 deletions
This file was deleted.

SerialPrograms/Source/CommonFramework/Main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "Startup/NewVersionCheck.h"
2929
#include "CommonFramework/VideoPipeline/Backends/CameraImplementations.h"
3030
#include "CommonTools/OCR/OCR_RawOCR.h"
31+
#include "ControllerInput/Keyboard/GlobalKeyboardHidTracker.h"
3132
#include "Windows/MainWindow.h"
3233

3334
#include <iostream>
@@ -164,7 +165,7 @@ int main(int argc, char *argv[]){
164165
int ret = run_program(argc, argv);
165166

166167

167-
// Write program settings back to the json file.
168+
// Write program settings back to the json file.
168169
PERSISTENT_SETTINGS().write();
169170

170171

@@ -176,7 +177,10 @@ int main(int argc, char *argv[]){
176177
Integration::DppClient::Client::instance().disconnect();
177178
#endif
178179

179-
// Force stop the thread pool
180+
// Stop the controllers.
181+
global_keyboard_tracker().stop();
182+
183+
// Force stop the thread pool
180184
PokemonAutomation::GlobalThreadPools::realtime_inference().stop();
181185
PokemonAutomation::GlobalThreadPools::normal_inference().stop();
182186

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* Controller Input
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#include "ControllerInput.h"
8+
9+
namespace PokemonAutomation{
10+
11+
12+
13+
14+
15+
16+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* Controller Input
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_ControllerInput_ControllerInput_H
8+
#define PokemonAutomation_ControllerInput_ControllerInput_H
9+
10+
#include "Common/Compiler.h"
11+
12+
namespace PokemonAutomation{
13+
14+
15+
enum class ControllerInputType{
16+
HID_Keyboard,
17+
StandardGamepad,
18+
};
19+
20+
21+
22+
class ControllerInputState{
23+
public:
24+
ControllerInputState(ControllerInputType type)
25+
: m_type(type)
26+
{}
27+
28+
ControllerInputType type() const{
29+
return m_type;
30+
}
31+
32+
virtual void clear() = 0;
33+
virtual bool is_neutral() const = 0;
34+
virtual bool operator==(const ControllerInputState& state) const = 0;
35+
bool operator!=(const ControllerInputState& state) const{
36+
return !operator==(state);
37+
}
38+
39+
private:
40+
const ControllerInputType m_type;
41+
};
42+
43+
44+
45+
46+
struct ControllerInputListener{
47+
virtual void controller_input_state(ControllerInputState& state){}
48+
};
49+
50+
51+
52+
53+
}
54+
#endif

0 commit comments

Comments
 (0)