Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/RSDKv5/RSDK/Input/Steam/SteamInputDevice.cpp
1172 views
1
2
using namespace RSDK;
3
4
void InputDeviceSteam::UpdateInput()
5
{
6
// TODO (maybe): document the actual steamAPI code that sets these values
7
8
this->prevButtonMasks = this->buttonMasks;
9
this->buttonMasks = this->activeButtons;
10
11
int32 changedButtons = ~this->prevButtonMasks & (this->prevButtonMasks ^ this->buttonMasks);
12
if (changedButtons) {
13
this->inactiveTimer[0] = 0;
14
this->anyPress = true;
15
}
16
else {
17
++this->inactiveTimer[0];
18
this->anyPress = false;
19
}
20
21
if ((changedButtons & KEYMASK_A) || (changedButtons & KEYMASK_START))
22
this->inactiveTimer[1] = 0;
23
else
24
++this->inactiveTimer[1];
25
26
this->ProcessInput(CONT_ANY);
27
}
28
29
void InputDeviceSteam::ProcessInput(int32 controllerID)
30
{
31
controller[controllerID].keyUp.press |= this->stateUp;
32
controller[controllerID].keyDown.press |= this->stateDown;
33
controller[controllerID].keyLeft.press |= this->stateLeft;
34
controller[controllerID].keyRight.press |= this->stateRight;
35
controller[controllerID].keyA.press |= this->stateA;
36
controller[controllerID].keyB.press |= this->stateB;
37
controller[controllerID].keyX.press |= this->stateX;
38
controller[controllerID].keyY.press |= this->stateY;
39
controller[controllerID].keyStart.press |= this->stateStart;
40
}
41
42
InputDeviceSteam *RSDK::SKU::InitSteamInputDevice(uint32 id)
43
{
44
if (inputDeviceCount == INPUTDEVICE_COUNT)
45
return NULL;
46
47
if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)
48
return NULL;
49
50
if (inputDeviceList[inputDeviceCount])
51
delete inputDeviceList[inputDeviceCount];
52
53
inputDeviceList[inputDeviceCount] = new InputDeviceSteam();
54
55
InputDeviceSteam *device = (InputDeviceSteam *)inputDeviceList[inputDeviceCount];
56
57
device->gamepadType = (DEVICE_API_STEAM << 16) | (DEVICE_TYPE_STEAMOVERLAY << 8) | (DEVICE_KEYBOARD << 0);
58
device->disabled = false;
59
device->id = id;
60
device->active = true;
61
62
device->keyMasks[0] = KEYMASK_UP;
63
device->keyMasks[1] = KEYMASK_DOWN;
64
device->keyMasks[2] = KEYMASK_LEFT;
65
device->keyMasks[3] = KEYMASK_RIGHT;
66
device->keyMasks[4] = KEYMASK_A;
67
device->keyMasks[5] = KEYMASK_B;
68
device->keyMasks[6] = KEYMASK_X;
69
device->keyMasks[7] = KEYMASK_Y;
70
device->keyMasks[8] = KEYMASK_START;
71
72
device->buttonMasks = 0;
73
device->prevButtonMasks = 0;
74
75
for (int32 i = 0; i < PLAYER_COUNT; ++i) {
76
if (inputSlots[i] == id) {
77
inputSlotDevices[i] = device;
78
device->isAssigned = true;
79
}
80
}
81
82
inputDeviceCount++;
83
return device;
84
}
85
86
void RSDK::SKU::InitSteamInputAPI()
87
{
88
// TODO (maybe): document this?
89
}
90