CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Windows/DinputDevice.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <vector>20#include <InitGuid.h>21#define DIRECTINPUT_VERSION 0x080022#define DIRECTINPUT_RGBBUTTONS_MAX 12823#include "InputDevice.h"24#include "dinput.h"2526class DinputDevice final :27public InputDevice28{29public:30//instantiates device number devnum as explored by the first call to31//getDevices(), enumerates all devices if not done yet32DinputDevice(int devnum);33~DinputDevice();34int UpdateState() override;35static size_t getNumPads();36static void CheckDevices() {37needsCheck_ = true;38}3940private:41void ApplyButtons(DIJOYSTATE2 &state);42//unfortunate and unclean way to keep only one DirectInput instance around43static LPDIRECTINPUT8 getPDI();44//unfortunate and unclean way to keep track of the number of devices and the45//GUIDs of the plugged in devices. This function will only search for devices46//if none have been found yet and will only list plugged in devices47//also, it excludes the devices that are compatible with XInput48static void getDevices(bool refresh);49//callback for the WinAPI to call50static BOOL CALLBACK DevicesCallback(51LPCDIDEVICEINSTANCE lpddi,52LPVOID pvRef53);54static unsigned int pInstances;55static std::vector<DIDEVICEINSTANCE> devices;56static LPDIRECTINPUT8 pDI;57static bool needsCheck_;58int pDevNum;59LPDIRECTINPUTDEVICE8 pJoystick;60DIJOYSTATE2 pPrevState;61bool analog;62BYTE lastButtons_[128];63WORD lastPOV_[4];64int last_lX_;65int last_lY_;66int last_lZ_;67int last_lRx_;68int last_lRy_;69int last_lRz_;70};717273