// SPDX-License-Identifier: MIT // // EmulationStation Desktop Edition // InputManager.h // // Low-level input handling. // Initiates and maps the keyboard and controllers. // Reads and writes the es_input.xml configuration file. // #ifndef ES_CORE_INPUT_MANAGER_H #define ES_CORE_INPUT_MANAGER_H #include #include #include #include #include class InputConfig; class Window; union SDL_Event; class InputManager { public: InputManager(); virtual ~InputManager(); static InputManager* getInstance(); void init(); void deinit(); void writeDeviceConfig(InputConfig* config); void doOnFinish(); static std::string getConfigPath(); static std::string getTemporaryConfigPath(); int getNumConfiguredDevices(); int getAxisCountByDevice(int deviceId); int getButtonCountByDevice(int deviceId); std::string getDeviceGUIDString(int deviceId); InputConfig* getInputConfigByDevice(int deviceId); bool parseEvent(const SDL_Event& event, Window* window); int getNumJoysticks() { return static_cast(mJoysticks.size()); } private: bool initialized() const { return mKeyboardInputConfig != nullptr; } bool loadInputConfig(InputConfig* config); void loadDefaultKBConfig(); void loadDefaultControllerConfig(SDL_JoystickID deviceIndex); void addControllerByDeviceIndex(Window* window, int deviceIndex); void removeControllerByJoystickID(Window* window, SDL_JoystickID joyID); static InputManager* sInstance; static const int DEADZONE_TRIGGERS = 18000; static const int DEADZONE_THUMBSTICKS = 23000; bool mConfigFileExists; std::map mJoysticks; std::map mControllers; std::map> mInputConfigs; std::unique_ptr mKeyboardInputConfig; std::unique_ptr mCECInputConfig; std::map, int> mPrevAxisValues; std::map, int> mPrevButtonValues; }; #endif // ES_CORE_INPUT_MANAGER_H