// Copyright (c) 2014- 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 <list>20#include <memory>21#include <atomic>22#include <thread>2324#include "Common/CommonTypes.h"2526class InputDevice {27public:28virtual ~InputDevice() {}2930virtual void Init() {}31virtual void Shutdown() {}3233enum { UPDATESTATE_SKIP_PAD = 0x1234, UPDATESTATE_NO_SLEEP = 0x2345};34virtual int UpdateState() = 0;35};3637class InputManager {38public:39void BeginPolling();40void StopPolling();4142void Shutdown() {43devices_.clear();44}4546void GainFocus() {47focused_.store(true, std::memory_order_relaxed);48}49void LoseFocus() {50focused_.store(false, std::memory_order_relaxed);51}5253void AddDevice(InputDevice *device) {54devices_.emplace_back(std::unique_ptr<InputDevice>(device));55}5657private:58void InputThread();5960std::vector<std::unique_ptr<InputDevice>> devices_;6162std::atomic<bool> runThread_;63std::thread inputThread_;64std::atomic<bool> focused_;65};6667extern InputManager g_InputManager;686970