Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/HidInputDevice.h
3185 views
1
// This file in particular along with its cpp file is public domain, use it for whatever you want.
2
3
#pragma once
4
5
#include "Input/InputState.h"
6
#include "Windows/InputDevice.h"
7
#include <set>
8
#include <windows.h>
9
10
enum class HIDControllerType {
11
DS4,
12
DS5,
13
SwitchPro,
14
};
15
16
struct HIDControllerState {
17
// Analog sticks
18
s8 stickAxes[4]; // LX LY RX RY
19
// Analog triggers
20
u8 triggerAxes[2];
21
// Buttons. Here the mapping is specific to the controller type and resolved
22
// later.
23
u32 buttons; // Bitmask, PSButton enum
24
};
25
26
struct ButtonInputMapping;
27
28
// Supports a few specific HID input devices, namely DualShock and DualSense.
29
// More may be added later. Just picks the first one available, for now.
30
class HidInputDevice : public InputDevice {
31
public:
32
void Init() override;
33
int UpdateState() override;
34
void Shutdown() override;
35
36
static void AddSupportedDevices(std::set<u32> *deviceVIDPIDs);
37
private:
38
void ReleaseAllKeys(const ButtonInputMapping *buttonMappings, int count);
39
InputDeviceID DeviceID(int pad);
40
HIDControllerState prevState_{};
41
42
HIDControllerType subType_{};
43
HANDLE controller_;
44
int pad_ = 0;
45
int pollCount_ = 0;
46
int reportSize_ = 0;
47
int outReportSize_ = 0;
48
enum {
49
POLL_FREQ = 283, // a prime number.
50
};
51
};
52
53