2017-06-10 20:01:55 +01:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct libevdev;
|
|
|
|
struct input_event;
|
|
|
|
|
|
|
|
class Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Input(const std::string & device);
|
|
|
|
~Input();
|
|
|
|
|
|
|
|
int poll();
|
|
|
|
|
|
|
|
bool getButton(int i) const;
|
|
|
|
int getAxis(int i) const;
|
|
|
|
|
2017-07-10 19:28:31 +01:00
|
|
|
static void initialise(const std::string & device);
|
|
|
|
|
|
|
|
static Input & instance();
|
|
|
|
|
2017-06-10 20:01:55 +01:00
|
|
|
private:
|
|
|
|
int myFD;
|
|
|
|
std::shared_ptr<libevdev> myDev;
|
|
|
|
|
|
|
|
void process(const input_event & ev);
|
|
|
|
|
|
|
|
std::vector<unsigned int> myButtonCodes;
|
|
|
|
std::vector<unsigned int> myAxisCodes;
|
|
|
|
std::vector<int> myAxisMins;
|
|
|
|
std::vector<int> myAxisMaxs;
|
2017-07-10 19:28:31 +01:00
|
|
|
|
|
|
|
static std::shared_ptr<Input> ourSingleton;
|
2017-06-10 20:01:55 +01:00
|
|
|
};
|