ES-DE/es-core/src/InputManager.h
Conn O'Griofa 03341f236d Implement filterTrigger for PS3 controllers
The hid-sony driver has both analog and digital buttons for the triggers,
and the analog values range from -32767 to 32767, which can cause two unwanted
input events (digital button and negative axis) per press.

Implement a function to filter out unwanted input events during configuration,
but isolate detection to known PS3 controllers with 6 axes so that older versions
of hid-sony and the sixad driver (which use 25+ axes) are not impacted negatively.
2019-04-06 11:19:12 +01:00

63 lines
1.4 KiB
C++

#pragma once
#ifndef ES_CORE_INPUT_MANAGER_H
#define ES_CORE_INPUT_MANAGER_H
#include <SDL_joystick.h>
#include <map>
class InputConfig;
class Window;
union SDL_Event;
//you should only ever instantiate one of these, by the way
class InputManager
{
private:
InputManager();
static InputManager* mInstance;
static const int DEADZONE = 23000;
void loadDefaultKBConfig();
std::map<SDL_JoystickID, SDL_Joystick*> mJoysticks;
std::map<SDL_JoystickID, InputConfig*> mInputConfigs;
InputConfig* mKeyboardInputConfig;
InputConfig* mCECInputConfig;
std::map<SDL_JoystickID, int*> mPrevAxisValues;
bool initialized() const;
void addJoystickByDeviceIndex(int id);
void removeJoystickByJoystickID(SDL_JoystickID id);
bool loadInputConfig(InputConfig* config); // returns true if successfully loaded, false if not (or didn't exist)
public:
virtual ~InputManager();
static InputManager* getInstance();
void writeDeviceConfig(InputConfig* config);
void doOnFinish();
static std::string getConfigPath();
static std::string getTemporaryConfigPath();
void init();
void deinit();
int getNumJoysticks();
int getAxisCountByDevice(int deviceId);
int getButtonCountByDevice(int deviceId);
int getNumConfiguredDevices();
std::string getDeviceGUIDString(int deviceId);
InputConfig* getInputConfigByDevice(int deviceId);
bool parseEvent(const SDL_Event& ev, Window* window);
};
#endif // ES_CORE_INPUT_MANAGER_H