2013-04-01 01:55:38 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2018-03-23 21:54:12 +00:00
|
|
|
#include "stdafx.h"
|
2013-04-01 01:55:38 +00:00
|
|
|
#include <limits.h>
|
2013-06-19 18:46:36 +00:00
|
|
|
#include <algorithm>
|
2018-03-23 21:54:12 +00:00
|
|
|
#include <mmsystem.h>
|
2013-06-19 18:46:36 +00:00
|
|
|
|
2013-05-17 10:31:06 +00:00
|
|
|
#include "Core/HLE/sceCtrl.h"
|
2013-04-01 01:55:38 +00:00
|
|
|
#include "DinputDevice.h"
|
2013-04-16 14:34:20 +00:00
|
|
|
#include "Core/Config.h"
|
2013-04-01 01:55:38 +00:00
|
|
|
#include "input/input_state.h"
|
2013-07-06 21:31:07 +00:00
|
|
|
#include "base/NativeApp.h"
|
2013-07-29 03:52:09 +00:00
|
|
|
#include "input/keycodes.h"
|
2013-04-01 01:55:38 +00:00
|
|
|
#include "Core/Reporting.h"
|
2013-04-01 18:16:23 +00:00
|
|
|
#include "Xinput.h"
|
2013-04-01 01:55:38 +00:00
|
|
|
#pragma comment(lib,"dinput8.lib")
|
|
|
|
|
2013-06-19 18:46:36 +00:00
|
|
|
#ifdef min
|
|
|
|
#undef min
|
|
|
|
#undef max
|
|
|
|
#endif
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
//initialize static members of DinputDevice
|
|
|
|
unsigned int DinputDevice::pInstances = 0;
|
|
|
|
LPDIRECTINPUT8 DinputDevice::pDI = NULL;
|
|
|
|
std::vector<DIDEVICEINSTANCE> DinputDevice::devices;
|
2018-11-02 04:42:12 +00:00
|
|
|
bool DinputDevice::needsCheck_ = true;
|
2014-05-30 19:32:25 +00:00
|
|
|
|
2013-07-07 17:22:01 +00:00
|
|
|
// In order from 0. There can be 128, but most controllers do not have that many.
|
|
|
|
static const int dinput_buttons[] = {
|
2013-08-04 17:31:40 +00:00
|
|
|
NKCODE_BUTTON_1,
|
|
|
|
NKCODE_BUTTON_2,
|
|
|
|
NKCODE_BUTTON_3,
|
|
|
|
NKCODE_BUTTON_4,
|
|
|
|
NKCODE_BUTTON_5,
|
|
|
|
NKCODE_BUTTON_6,
|
|
|
|
NKCODE_BUTTON_7,
|
|
|
|
NKCODE_BUTTON_8,
|
|
|
|
NKCODE_BUTTON_9,
|
|
|
|
NKCODE_BUTTON_10,
|
|
|
|
NKCODE_BUTTON_11,
|
|
|
|
NKCODE_BUTTON_12,
|
|
|
|
NKCODE_BUTTON_13,
|
|
|
|
NKCODE_BUTTON_14,
|
|
|
|
NKCODE_BUTTON_15,
|
|
|
|
NKCODE_BUTTON_16,
|
2013-04-01 01:55:38 +00:00
|
|
|
};
|
|
|
|
|
2013-07-07 23:09:06 +00:00
|
|
|
static float NormalizedDeadzoneFilter(short value);
|
2013-07-06 21:31:07 +00:00
|
|
|
|
2013-05-11 14:45:09 +00:00
|
|
|
#define DIFF (JOY_POVRIGHT - JOY_POVFORWARD) / 2
|
|
|
|
#define JOY_POVFORWARD_RIGHT JOY_POVFORWARD + DIFF
|
|
|
|
#define JOY_POVRIGHT_BACKWARD JOY_POVRIGHT + DIFF
|
|
|
|
#define JOY_POVBACKWARD_LEFT JOY_POVBACKWARD + DIFF
|
|
|
|
#define JOY_POVLEFT_FORWARD JOY_POVLEFT + DIFF
|
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
struct XINPUT_DEVICE_NODE {
|
2013-04-01 18:16:23 +00:00
|
|
|
DWORD dwVidPid;
|
|
|
|
XINPUT_DEVICE_NODE* pNext;
|
|
|
|
};
|
|
|
|
XINPUT_DEVICE_NODE* g_pXInputDeviceList = NULL;
|
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
bool IsXInputDevice( const GUID* pGuidProductFromDirectInput ) {
|
2013-04-01 18:16:23 +00:00
|
|
|
XINPUT_DEVICE_NODE* pNode = g_pXInputDeviceList;
|
|
|
|
while( pNode )
|
|
|
|
{
|
|
|
|
if( pNode->dwVidPid == pGuidProductFromDirectInput->Data1 )
|
|
|
|
return true;
|
|
|
|
pNode = pNode->pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
LPDIRECTINPUT8 DinputDevice::getPDI()
|
|
|
|
{
|
|
|
|
if (pDI == NULL)
|
|
|
|
{
|
|
|
|
if (FAILED(DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&pDI, NULL)))
|
|
|
|
{
|
|
|
|
pDI = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pDI;
|
|
|
|
}
|
|
|
|
|
2014-06-02 12:26:55 +00:00
|
|
|
BOOL CALLBACK DinputDevice::DevicesCallback(
|
2014-05-30 19:32:25 +00:00
|
|
|
LPCDIDEVICEINSTANCE lpddi,
|
|
|
|
LPVOID pvRef
|
|
|
|
)
|
|
|
|
{
|
|
|
|
//check if a device with the same Instance guid is already saved
|
|
|
|
auto res = std::find_if(devices.begin(), devices.end(),
|
|
|
|
[lpddi](const DIDEVICEINSTANCE &to_consider){
|
|
|
|
return lpddi->guidInstance == to_consider.guidInstance;
|
|
|
|
});
|
|
|
|
if (res == devices.end()) //not yet in the devices list
|
|
|
|
{
|
|
|
|
// Ignore if device supports XInput
|
|
|
|
if (!IsXInputDevice(&lpddi->guidProduct)) {
|
|
|
|
devices.push_back(*lpddi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DIENUM_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2018-10-09 04:21:37 +00:00
|
|
|
void DinputDevice::getDevices(bool refresh)
|
2014-05-30 19:32:25 +00:00
|
|
|
{
|
2018-11-02 04:42:12 +00:00
|
|
|
if (refresh)
|
2014-05-30 19:32:25 +00:00
|
|
|
{
|
|
|
|
getPDI()->EnumDevices(DI8DEVCLASS_GAMECTRL, &DinputDevice::DevicesCallback, NULL, DIEDFL_ATTACHEDONLY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DinputDevice::DinputDevice(int devnum) {
|
|
|
|
pInstances++;
|
|
|
|
pDevNum = devnum;
|
2013-04-01 01:55:38 +00:00
|
|
|
pJoystick = NULL;
|
2013-07-07 17:22:01 +00:00
|
|
|
memset(lastButtons_, 0, sizeof(lastButtons_));
|
|
|
|
memset(lastPOV_, 0, sizeof(lastPOV_));
|
2013-07-07 23:09:06 +00:00
|
|
|
last_lX_ = 0;
|
|
|
|
last_lY_ = 0;
|
|
|
|
last_lZ_ = 0;
|
2013-07-07 23:28:36 +00:00
|
|
|
last_lRx_ = 0;
|
|
|
|
last_lRy_ = 0;
|
2013-07-07 23:09:06 +00:00
|
|
|
last_lRz_ = 0;
|
2013-04-01 01:55:38 +00:00
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
if (getPDI() == NULL)
|
|
|
|
{
|
2013-04-01 01:55:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-01 10:22:38 +00:00
|
|
|
if (devnum >= MAX_NUM_PADS)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-09 04:21:37 +00:00
|
|
|
getDevices(false);
|
2014-06-15 17:01:54 +00:00
|
|
|
if ( (devnum >= (int)devices.size()) || FAILED(getPDI()->CreateDevice(devices.at(devnum).guidInstance, &pJoystick, NULL)))
|
2014-05-30 19:32:25 +00:00
|
|
|
{
|
2013-04-01 01:55:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
if (FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2))) {
|
2013-04-01 18:16:23 +00:00
|
|
|
pJoystick->Release();
|
|
|
|
pJoystick = NULL;
|
2014-05-30 19:32:25 +00:00
|
|
|
return;
|
2013-04-01 18:16:23 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 18:04:26 +00:00
|
|
|
DIPROPRANGE diprg;
|
|
|
|
diprg.diph.dwSize = sizeof(DIPROPRANGE);
|
2013-05-19 09:12:22 +00:00
|
|
|
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
2014-05-31 18:04:26 +00:00
|
|
|
diprg.diph.dwHow = DIPH_DEVICE;
|
|
|
|
diprg.diph.dwObj = 0;
|
|
|
|
diprg.lMin = -10000;
|
|
|
|
diprg.lMax = 10000;
|
2013-05-19 09:12:22 +00:00
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
analog = FAILED(pJoystick->SetProperty(DIPROP_RANGE, &diprg.diph)) ? false : true;
|
2013-05-19 09:12:22 +00:00
|
|
|
|
2013-07-07 00:19:17 +00:00
|
|
|
// Other devices suffer if the deadzone is not set.
|
|
|
|
// TODO: The dead zone will be made configurable in the Control dialog.
|
2013-05-19 09:12:22 +00:00
|
|
|
DIPROPDWORD dipw;
|
2014-05-31 18:04:26 +00:00
|
|
|
dipw.diph.dwSize = sizeof(DIPROPDWORD);
|
2013-05-19 09:12:22 +00:00
|
|
|
dipw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
2014-05-31 18:04:26 +00:00
|
|
|
dipw.diph.dwHow = DIPH_DEVICE;
|
|
|
|
dipw.diph.dwObj = 0;
|
2015-01-17 16:47:19 +00:00
|
|
|
// dwData 10000 is deadzone(0% - 100%), multiply by config scalar
|
|
|
|
dipw.dwData = (int)(g_Config.fDInputAnalogDeadzone * 10000);
|
2013-05-19 09:12:22 +00:00
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
analog |= FAILED(pJoystick->SetProperty(DIPROP_DEADZONE, &dipw.diph)) ? false : true;
|
2013-04-01 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
DinputDevice::~DinputDevice() {
|
|
|
|
if (pJoystick) {
|
2013-04-01 01:55:38 +00:00
|
|
|
pJoystick->Release();
|
2013-07-07 00:19:17 +00:00
|
|
|
pJoystick = NULL;
|
2013-04-01 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
pInstances--;
|
|
|
|
|
|
|
|
//the whole instance counter is obviously highly thread-unsafe
|
|
|
|
//but I don't think creation and destruction operations will be
|
|
|
|
//happening at the same time and other values like pDI are
|
|
|
|
//unsafe as well anyway
|
|
|
|
if (pInstances == 0 && pDI) {
|
2013-04-01 01:55:38 +00:00
|
|
|
pDI->Release();
|
2013-07-07 00:19:17 +00:00
|
|
|
pDI = NULL;
|
2013-04-01 01:55:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-07 23:09:06 +00:00
|
|
|
void SendNativeAxis(int deviceId, short value, short &lastValue, int axisId) {
|
|
|
|
if (value == lastValue)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AxisInput axis;
|
|
|
|
axis.deviceId = deviceId;
|
|
|
|
axis.axisId = axisId;
|
2015-02-05 05:48:29 +00:00
|
|
|
axis.value = (float)value / 10000.0f; // Convert axis to normalised float
|
2013-07-07 23:09:06 +00:00
|
|
|
NativeAxis(axis);
|
|
|
|
|
|
|
|
lastValue = value;
|
|
|
|
}
|
|
|
|
|
2015-02-05 05:30:39 +00:00
|
|
|
inline float Signs(short val) {
|
|
|
|
return (0 < val) - (val < 0);
|
2015-01-17 16:47:19 +00:00
|
|
|
}
|
|
|
|
|
2015-02-05 05:30:39 +00:00
|
|
|
inline float LinearMaps(short val, short a0, short a1, short b0, short b1) {
|
2015-01-17 16:47:19 +00:00
|
|
|
return b0 + (((val - a0) * (b1 - b0)) / (a1 - a0));
|
|
|
|
}
|
|
|
|
|
2017-03-15 05:01:18 +00:00
|
|
|
int DinputDevice::UpdateState() {
|
2013-04-01 01:55:38 +00:00
|
|
|
if (!pJoystick) return -1;
|
|
|
|
|
|
|
|
DIJOYSTATE2 js;
|
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
if (FAILED(pJoystick->Poll())) {
|
2013-04-01 01:55:38 +00:00
|
|
|
if(pJoystick->Acquire() == DIERR_INPUTLOST)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(FAILED(pJoystick->GetDeviceState(sizeof(DIJOYSTATE2), &js)))
|
2013-07-06 21:31:07 +00:00
|
|
|
return -1;
|
|
|
|
|
2017-03-15 05:01:18 +00:00
|
|
|
ApplyButtons(js);
|
2013-04-01 01:55:38 +00:00
|
|
|
|
2013-07-07 20:28:42 +00:00
|
|
|
if (analog) {
|
2013-07-06 21:31:07 +00:00
|
|
|
AxisInput axis;
|
2014-05-30 19:32:25 +00:00
|
|
|
axis.deviceId = DEVICE_ID_PAD_0 + pDevNum;
|
2015-02-05 05:48:29 +00:00
|
|
|
|
|
|
|
// Circle to Square mapping, cribbed from XInputDevice
|
|
|
|
float sx = js.lX;
|
|
|
|
float sy = js.lY;
|
|
|
|
float scaleFactor = sqrtf((sx * sx + sy * sy) / std::max(sx * sx, sy * sy));
|
|
|
|
js.lX = (short)(sx * scaleFactor);
|
|
|
|
js.lY = (short)(sy * scaleFactor);
|
2015-01-17 16:47:19 +00:00
|
|
|
|
|
|
|
// Linear range mapping (used to invert deadzones)
|
|
|
|
float dz = g_Config.fDInputAnalogDeadzone;
|
|
|
|
int idzm = g_Config.iDInputAnalogInverseMode;
|
|
|
|
float idz = g_Config.fDInputAnalogInverseDeadzone;
|
|
|
|
float md = std::max(dz, idz);
|
2015-02-05 05:30:39 +00:00
|
|
|
float st = g_Config.fDInputAnalogSensitivity;
|
2015-01-17 16:47:19 +00:00
|
|
|
|
|
|
|
float magnitude = sqrtf(js.lX * js.lX + js.lY * js.lY);
|
2015-02-05 05:30:39 +00:00
|
|
|
if (magnitude > dz * 10000.0f) {
|
|
|
|
if (idzm == 1)
|
|
|
|
{
|
|
|
|
short xSign = Signs(js.lX);
|
|
|
|
if (xSign != 0.0f) {
|
2015-02-05 06:30:29 +00:00
|
|
|
js.lX = LinearMaps(js.lX, xSign * (short)(dz * 10000), xSign * 10000, xSign * (short)(md * 10000), xSign * 10000 * st);
|
2015-02-05 05:30:39 +00:00
|
|
|
}
|
2015-01-17 16:47:19 +00:00
|
|
|
}
|
2015-02-05 05:30:39 +00:00
|
|
|
else if (idzm == 2)
|
|
|
|
{
|
|
|
|
short ySign = Signs(js.lY);
|
|
|
|
if (ySign != 0.0f) {
|
2015-02-05 06:30:29 +00:00
|
|
|
js.lY = LinearMaps(js.lY, ySign * (short)(dz * 10000.0f), ySign * 10000, ySign * (short)(md * 10000.0f), ySign * 10000 * st);
|
2015-02-05 05:30:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (idzm == 3)
|
|
|
|
{
|
|
|
|
float xNorm = (float)js.lX / magnitude;
|
|
|
|
float yNorm = (float)js.lY / magnitude;
|
2015-02-05 06:30:29 +00:00
|
|
|
float mapMag = LinearMaps(magnitude, dz * 10000.0f, 10000.0f, md * 10000.0f, 10000.0f * st);
|
2015-02-05 05:30:39 +00:00
|
|
|
js.lX = (short)(xNorm * mapMag);
|
|
|
|
js.lY = (short)(yNorm * mapMag);
|
2015-01-17 16:47:19 +00:00
|
|
|
}
|
|
|
|
}
|
2015-02-05 05:30:39 +00:00
|
|
|
else
|
2015-01-17 16:47:19 +00:00
|
|
|
{
|
2015-02-05 05:30:39 +00:00
|
|
|
js.lX = 0;
|
|
|
|
js.lY = 0;
|
2015-01-17 16:47:19 +00:00
|
|
|
}
|
2014-05-30 19:32:25 +00:00
|
|
|
|
2015-02-05 05:48:29 +00:00
|
|
|
js.lX = (short)std::min(10000.0f, std::max((float)js.lX, -10000.0f));
|
|
|
|
js.lY = (short)std::min(10000.0f, std::max((float)js.lY, -10000.0f));
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lX, last_lX_, JOYSTICK_AXIS_X);
|
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lY, last_lY_, JOYSTICK_AXIS_Y);
|
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lZ, last_lZ_, JOYSTICK_AXIS_Z);
|
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lRx, last_lRx_, JOYSTICK_AXIS_RX);
|
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lRy, last_lRy_, JOYSTICK_AXIS_RY);
|
|
|
|
SendNativeAxis(DEVICE_ID_PAD_0 + pDevNum, js.lRz, last_lRz_, JOYSTICK_AXIS_RZ);
|
2013-04-01 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 19:32:25 +00:00
|
|
|
//check if the values have changed from last time and skip polling the rest of the dinput devices if they did
|
|
|
|
//this doesn't seem to quite work if only the axis have changed
|
|
|
|
if ((memcmp(js.rgbButtons, pPrevState.rgbButtons, sizeof(BYTE) * 128) != 0)
|
|
|
|
|| (memcmp(js.rgdwPOV, pPrevState.rgdwPOV, sizeof(DWORD) * 4) != 0)
|
|
|
|
|| js.lVX != 0 || js.lVY != 0 || js.lVZ != 0 || js.lVRx != 0 || js.lVRy != 0 || js.lVRz != 0)
|
|
|
|
{
|
|
|
|
pPrevState = js;
|
|
|
|
return UPDATESTATE_SKIP_PAD;
|
|
|
|
}
|
|
|
|
return -1;
|
2013-04-01 01:55:38 +00:00
|
|
|
}
|
|
|
|
|
2017-03-15 05:01:18 +00:00
|
|
|
void DinputDevice::ApplyButtons(DIJOYSTATE2 &state) {
|
2013-07-07 17:22:01 +00:00
|
|
|
BYTE *buttons = state.rgbButtons;
|
|
|
|
u32 downMask = 0x80;
|
|
|
|
|
|
|
|
for (int i = 0; i < ARRAY_SIZE(dinput_buttons); ++i) {
|
|
|
|
if (state.rgbButtons[i] == lastButtons_[i]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool down = (state.rgbButtons[i] & downMask) == downMask;
|
|
|
|
KeyInput key;
|
2014-05-30 19:32:25 +00:00
|
|
|
key.deviceId = DEVICE_ID_PAD_0 + pDevNum;
|
2013-07-07 17:22:01 +00:00
|
|
|
key.flags = down ? KEY_DOWN : KEY_UP;
|
|
|
|
key.keyCode = dinput_buttons[i];
|
|
|
|
NativeKey(key);
|
|
|
|
|
|
|
|
lastButtons_[i] = state.rgbButtons[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now the POV hat, which can technically go in any degree but usually does not.
|
|
|
|
if (LOWORD(state.rgdwPOV[0]) != lastPOV_[0]) {
|
|
|
|
KeyInput dpad[4];
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
2014-05-30 19:32:25 +00:00
|
|
|
dpad[i].deviceId = DEVICE_ID_PAD_0 + pDevNum;
|
2013-07-07 17:22:01 +00:00
|
|
|
dpad[i].flags = KEY_UP;
|
|
|
|
}
|
2013-08-04 17:31:40 +00:00
|
|
|
dpad[0].keyCode = NKCODE_DPAD_UP;
|
|
|
|
dpad[1].keyCode = NKCODE_DPAD_LEFT;
|
|
|
|
dpad[2].keyCode = NKCODE_DPAD_DOWN;
|
|
|
|
dpad[3].keyCode = NKCODE_DPAD_RIGHT;
|
2013-07-07 17:22:01 +00:00
|
|
|
|
|
|
|
if (LOWORD(state.rgdwPOV[0]) != JOY_POVCENTERED) {
|
|
|
|
// These are the edges, so we use or.
|
|
|
|
if (state.rgdwPOV[0] >= JOY_POVLEFT_FORWARD || state.rgdwPOV[0] <= JOY_POVFORWARD_RIGHT) {
|
|
|
|
dpad[0].flags = KEY_DOWN;
|
|
|
|
}
|
|
|
|
if (state.rgdwPOV[0] >= JOY_POVBACKWARD_LEFT && state.rgdwPOV[0] <= JOY_POVLEFT_FORWARD) {
|
|
|
|
dpad[1].flags = KEY_DOWN;
|
|
|
|
}
|
|
|
|
if (state.rgdwPOV[0] >= JOY_POVRIGHT_BACKWARD && state.rgdwPOV[0] <= JOY_POVBACKWARD_LEFT) {
|
|
|
|
dpad[2].flags = KEY_DOWN;
|
|
|
|
}
|
|
|
|
if (state.rgdwPOV[0] >= JOY_POVFORWARD_RIGHT && state.rgdwPOV[0] <= JOY_POVRIGHT_BACKWARD) {
|
|
|
|
dpad[3].flags = KEY_DOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NativeKey(dpad[0]);
|
|
|
|
NativeKey(dpad[1]);
|
|
|
|
NativeKey(dpad[2]);
|
|
|
|
NativeKey(dpad[3]);
|
|
|
|
|
|
|
|
lastPOV_[0] = LOWORD(state.rgdwPOV[0]);
|
|
|
|
}
|
2013-07-06 21:31:07 +00:00
|
|
|
}
|
|
|
|
|
2014-06-01 22:25:35 +00:00
|
|
|
size_t DinputDevice::getNumPads()
|
2014-05-30 19:32:25 +00:00
|
|
|
{
|
2018-11-02 04:42:12 +00:00
|
|
|
getDevices(needsCheck_);
|
|
|
|
needsCheck_ = false;
|
2014-05-30 19:32:25 +00:00
|
|
|
return devices.size();
|
|
|
|
}
|