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/.
|
|
|
|
|
|
|
|
#pragma once
|
2016-12-05 15:51:28 +00:00
|
|
|
|
|
|
|
#include <vector>
|
2013-04-08 16:26:01 +00:00
|
|
|
#include <InitGuid.h>
|
2013-04-01 01:55:38 +00:00
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
2013-05-17 10:31:06 +00:00
|
|
|
#define DIRECTINPUT_RGBBUTTONS_MAX 128
|
2013-04-01 01:55:38 +00:00
|
|
|
#include "InputDevice.h"
|
|
|
|
#include "dinput.h"
|
|
|
|
|
2019-06-28 22:55:45 +00:00
|
|
|
class DinputDevice final :
|
2013-04-01 01:55:38 +00:00
|
|
|
public InputDevice
|
|
|
|
{
|
|
|
|
public:
|
2014-05-30 19:32:25 +00:00
|
|
|
//instantiates device number devnum as explored by the first call to
|
|
|
|
//getDevices(), enumerates all devices if not done yet
|
|
|
|
DinputDevice(int devnum);
|
2013-04-01 01:55:38 +00:00
|
|
|
~DinputDevice();
|
2019-06-28 22:55:45 +00:00
|
|
|
virtual int UpdateState() override;
|
2014-06-01 22:25:35 +00:00
|
|
|
static size_t getNumPads();
|
2018-11-02 04:42:12 +00:00
|
|
|
static void CheckDevices() {
|
|
|
|
needsCheck_ = true;
|
|
|
|
}
|
|
|
|
|
2013-04-01 01:55:38 +00:00
|
|
|
private:
|
2017-03-15 05:01:18 +00:00
|
|
|
void ApplyButtons(DIJOYSTATE2 &state);
|
2014-05-30 19:32:25 +00:00
|
|
|
//unfortunate and unclean way to keep only one DirectInput instance around
|
2014-05-31 18:01:06 +00:00
|
|
|
static LPDIRECTINPUT8 getPDI();
|
2014-05-30 19:32:25 +00:00
|
|
|
//unfortunate and unclean way to keep track of the number of devices and the
|
|
|
|
//GUIDs of the plugged in devices. This function will only search for devices
|
|
|
|
//if none have been found yet and will only list plugged in devices
|
|
|
|
//also, it excludes the devices that are compatible with XInput
|
2018-10-09 04:21:37 +00:00
|
|
|
static void getDevices(bool refresh);
|
2014-05-30 19:32:25 +00:00
|
|
|
//callback for the WinAPI to call
|
2014-06-02 12:26:55 +00:00
|
|
|
static BOOL CALLBACK DevicesCallback(
|
2014-05-31 18:01:06 +00:00
|
|
|
LPCDIDEVICEINSTANCE lpddi,
|
|
|
|
LPVOID pvRef
|
|
|
|
);
|
|
|
|
static unsigned int pInstances;
|
2014-05-30 19:32:25 +00:00
|
|
|
static std::vector<DIDEVICEINSTANCE> devices;
|
2014-05-31 18:01:06 +00:00
|
|
|
static LPDIRECTINPUT8 pDI;
|
2018-11-02 04:42:12 +00:00
|
|
|
static bool needsCheck_;
|
2014-05-31 18:01:06 +00:00
|
|
|
int pDevNum;
|
2013-04-01 01:55:38 +00:00
|
|
|
LPDIRECTINPUTDEVICE8 pJoystick;
|
2014-05-31 18:01:06 +00:00
|
|
|
DIJOYSTATE2 pPrevState;
|
|
|
|
bool analog;
|
2013-07-07 17:22:01 +00:00
|
|
|
BYTE lastButtons_[128];
|
|
|
|
WORD lastPOV_[4];
|
2013-07-07 23:09:06 +00:00
|
|
|
short last_lX_;
|
|
|
|
short last_lY_;
|
|
|
|
short last_lZ_;
|
2013-07-07 23:28:36 +00:00
|
|
|
short last_lRx_;
|
|
|
|
short last_lRy_;
|
2013-07-07 23:09:06 +00:00
|
|
|
short last_lRz_;
|
2013-04-01 01:55:38 +00:00
|
|
|
};
|