rcinput: use a dynamic list of input devices

Instead of the fixed, static list of input devices, scan /dev/input/ for
proper event devices. A "good" input device is one that supports the
EVIOCGBIT ioctl and at least the EV_KEY event type.
This probably needs further fixes, e.g. in repeat rate setting code.
This commit is contained in:
Stefan Seyfried
2017-02-19 23:16:09 +01:00
committed by M. Liebmann
parent e35969afe2
commit 7b3aa2b181
2 changed files with 139 additions and 66 deletions

View File

@@ -39,6 +39,9 @@
#include <string>
#include <vector>
#include <OpenThreads/Mutex>
#include <OpenThreads/ScopedLock>
#ifdef BOXMODEL_CS_HD2
#ifdef HAVE_COOLSTREAM_CS_IR_GENERIC_H
#include <cs_ir_generic.h>
@@ -138,6 +141,12 @@ class CRCInput
bool correct_time;
};
struct in_dev
{
int fd;
std::string path;
};
uint32_t timerid;
std::vector<timer> timers;
@@ -147,21 +156,19 @@ class CRCInput
int fd_pipe_high_priority[2];
int fd_pipe_low_priority[2];
int fd_gamerc;
#ifdef HAVE_SPARK_HARDWARE
#define NUMBER_OF_EVENT_DEVICES 2
#else
#define NUMBER_OF_EVENT_DEVICES 1
#endif
int fd_rc[NUMBER_OF_EVENT_DEVICES];
std::vector<in_dev> indev;
int fd_keyb;
int fd_event;
int fd_max;
int clickfd;
__u16 rc_last_key;
OpenThreads::Mutex mutex;
void set_dsp();
void open(int dev = -1);
void open(bool recheck = false);
bool checkpath(in_dev id);
bool checkdev();
void close();
int translate(int code);
void calculateMaxFd(void);
@@ -280,7 +287,9 @@ class CRCInput
inline int getFileHandle(void) /* used for plugins (i.e. games) only */
{
return fd_rc[0];
if (indev.empty())
return -1;
return indev[0].fd;
}
void stopInput(const bool ext = false);
void restartInput(const bool ext = false);