Path: blob/master/RSDKv5/RSDK/Input/Steam/SteamInputDevice.cpp
1172 views
1using namespace RSDK;23void InputDeviceSteam::UpdateInput()4{5// TODO (maybe): document the actual steamAPI code that sets these values67this->prevButtonMasks = this->buttonMasks;8this->buttonMasks = this->activeButtons;910int32 changedButtons = ~this->prevButtonMasks & (this->prevButtonMasks ^ this->buttonMasks);11if (changedButtons) {12this->inactiveTimer[0] = 0;13this->anyPress = true;14}15else {16++this->inactiveTimer[0];17this->anyPress = false;18}1920if ((changedButtons & KEYMASK_A) || (changedButtons & KEYMASK_START))21this->inactiveTimer[1] = 0;22else23++this->inactiveTimer[1];2425this->ProcessInput(CONT_ANY);26}2728void InputDeviceSteam::ProcessInput(int32 controllerID)29{30controller[controllerID].keyUp.press |= this->stateUp;31controller[controllerID].keyDown.press |= this->stateDown;32controller[controllerID].keyLeft.press |= this->stateLeft;33controller[controllerID].keyRight.press |= this->stateRight;34controller[controllerID].keyA.press |= this->stateA;35controller[controllerID].keyB.press |= this->stateB;36controller[controllerID].keyX.press |= this->stateX;37controller[controllerID].keyY.press |= this->stateY;38controller[controllerID].keyStart.press |= this->stateStart;39}4041InputDeviceSteam *RSDK::SKU::InitSteamInputDevice(uint32 id)42{43if (inputDeviceCount == INPUTDEVICE_COUNT)44return NULL;4546if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)47return NULL;4849if (inputDeviceList[inputDeviceCount])50delete inputDeviceList[inputDeviceCount];5152inputDeviceList[inputDeviceCount] = new InputDeviceSteam();5354InputDeviceSteam *device = (InputDeviceSteam *)inputDeviceList[inputDeviceCount];5556device->gamepadType = (DEVICE_API_STEAM << 16) | (DEVICE_TYPE_STEAMOVERLAY << 8) | (DEVICE_KEYBOARD << 0);57device->disabled = false;58device->id = id;59device->active = true;6061device->keyMasks[0] = KEYMASK_UP;62device->keyMasks[1] = KEYMASK_DOWN;63device->keyMasks[2] = KEYMASK_LEFT;64device->keyMasks[3] = KEYMASK_RIGHT;65device->keyMasks[4] = KEYMASK_A;66device->keyMasks[5] = KEYMASK_B;67device->keyMasks[6] = KEYMASK_X;68device->keyMasks[7] = KEYMASK_Y;69device->keyMasks[8] = KEYMASK_START;7071device->buttonMasks = 0;72device->prevButtonMasks = 0;7374for (int32 i = 0; i < PLAYER_COUNT; ++i) {75if (inputSlots[i] == id) {76inputSlotDevices[i] = device;77device->isAssigned = true;78}79}8081inputDeviceCount++;82return device;83}8485void RSDK::SKU::InitSteamInputAPI()86{87// TODO (maybe): document this?88}8990