]> git.tdb.fi Git - libs/gui.git/blob - source/input/windows/gamecontroller_platform.h
Update .gitignore to include build products on Windows
[libs/gui.git] / source / input / windows / gamecontroller_platform.h
1 #ifndef MSP_INPUT_GAMECONTROLLER_PLATFORM_H_
2 #define MSP_INPUT_GAMECONTROLLER_PLATFORM_H_
3
4 #include <windows.h>
5 #include <xinput.h>
6 #include <msp/core/thread.h>
7 #include <msp/io/pipe.h>
8 #include <msp/time/timer.h>
9
10 namespace Msp {
11 namespace Input {
12
13 class GameControllerTimerThread: public Msp::Thread
14 {
15 private:
16         Time::Timer timer;
17         unsigned n_users = 0;
18
19         static GameControllerTimerThread *thread;
20
21         GameControllerTimerThread();
22         ~GameControllerTimerThread();
23 public:
24         static Time::Timer::Slot &add_slot();
25         static void remove_slot(Time::Timer::Slot &);
26
27 private:
28         void main() override;
29 };
30
31
32 struct GameController::Private
33 {
34         unsigned index = 0;
35         unsigned last_packet_number = 0;
36         IO::Pipe *event_pipe = nullptr;
37         Time::Timer::Slot *timer_slot = nullptr;
38
39         static std::vector<unsigned> detected_controllers;
40
41         bool generate_event();
42
43         void update_state(GameController &, const XINPUT_STATE &, bool);
44
45 };
46
47 } // namespace Input
48 } // namespace Msp
49
50 #endif