Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/Hid/DualShock.h
5703 views
1
#pragma once
2
3
#include "Common/CommonWindows.h"
4
#include "Windows/Hid/HidInputDevice.h"
5
6
enum PSDPadButton : u32 {
7
PS_DPAD_UP = 1, // These dpad ones are not real, we convert from hat switch format.
8
PS_DPAD_DOWN = 2,
9
PS_DPAD_LEFT = 4,
10
PS_DPAD_RIGHT = 8,
11
};
12
13
enum PSHIDButton : u32 {
14
PS_BTN_SQUARE = 16,
15
PS_BTN_CROSS = 32,
16
PS_BTN_TRIANGLE = 64,
17
PS_BTN_CIRCLE = 128,
18
19
PS_BTN_L1 = (1 << 8),
20
PS_BTN_R1 = (1 << 9),
21
PS_BTN_L2 = (1 << 10),
22
PS_BTN_R2 = (1 << 11),
23
PS_BTN_SHARE = (1 << 12),
24
PS_BTN_OPTIONS = (1 << 13),
25
PS_BTN_L3 = (1 << 14),
26
PS_BTN_R3 = (1 << 15),
27
PS_BTN_PS_BUTTON = (1 << 16),
28
PS_BTN_TOUCHPAD = (1 << 17),
29
};
30
31
inline u32 DecodePSHatSwitch(u8 dpad) {
32
u32 buttons = 0;
33
if (dpad == 0 || dpad == 1 || dpad == 7) {
34
buttons |= PS_DPAD_UP;
35
}
36
if (dpad == 1 || dpad == 2 || dpad == 3) {
37
buttons |= PS_DPAD_RIGHT;
38
}
39
if (dpad == 3 || dpad == 4 || dpad == 5) {
40
buttons |= PS_DPAD_DOWN;
41
}
42
if (dpad == 5 || dpad == 6 || dpad == 7) {
43
buttons |= PS_DPAD_LEFT;
44
}
45
return buttons;
46
}
47
48
bool InitializeDualShock(HANDLE handle, int outReportSize);
49
bool ShutdownDualShock(HANDLE handle, int outReportSize);
50
bool ReadDualShockInput(HANDLE handle, HIDControllerState *state, int inReportSize);
51
void GetPSButtonInputMappings(const ButtonInputMapping **mappings, size_t *size);
52
53