/* * This file is part of Chiaki. * * Chiaki 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, either version 3 of the License, or * (at your option) any later version. * * Chiaki 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 for more details. * * You should have received a copy of the GNU General Public License * along with Chiaki. If not, see . */ #ifndef CHIAKI_CONTROLLERMANAGER_H #define CHIAKI_CONTROLLERMANAGER_H #include #include #include #include #include #ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER #include #endif class Controller; class ControllerManager : public QObject { Q_OBJECT friend class Controller; private: #ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER QSet available_controllers; #endif QMap open_controllers; void ControllerClosed(Controller *controller); private slots: void UpdateAvailableControllers(); void HandleEvents(); void ControllerEvent(int device_id); public: static ControllerManager *GetInstance(); ControllerManager(QObject *parent = nullptr); ~ControllerManager(); QList GetAvailableControllers(); Controller *OpenController(int device_id); signals: void AvailableControllersUpdated(); }; class Controller : public QObject { Q_OBJECT friend class ControllerManager; private: Controller(int device_id, ControllerManager *manager); void UpdateState(); ControllerManager *manager; int id; #ifdef CHIAKI_GUI_ENABLE_SDL_GAMECONTROLLER SDL_GameController *controller; #endif public: ~Controller(); bool IsConnected(); int GetDeviceID(); QString GetName(); ChiakiControllerState GetState(); signals: void StateChanged(); }; #endif // CHIAKI_CONTROLLERMANAGER_H