From 7a6dd0c46ed0cee6db239a8a92f0fde437fb99c6 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Mon, 20 Feb 2017 20:20:54 +0100 Subject: [PATCH] rcinput: add setKeyRepeatDelay() function this allows to get rid of the broken getFileHandle function later --- src/driver/rcinput.cpp | 35 +++++++++++++++++++++++++++++++++++ src/driver/rcinput.h | 1 + 2 files changed, 36 insertions(+) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index ff8e791e0..b2268631c 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1743,6 +1743,41 @@ void CRCInput::play_click() { } +void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms) +{ + for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { + int fd = (*it).fd; + std::string path = (*it).path; + if (path == "/tmp/neutrino.input") + continue; /* setting repeat rate does not work here */ +#ifdef HAVE_COOL_HARDWARE + /* this is ugly, but the driver does not support anything advanced... */ + if (path == "/dev/input/nevis_ir") { + d_printf("[rcinput:%s] %s(fd %d) using proprietary ioctl\n", __func__, path.c_str(), fd); + ioctl(fd, IOC_IR_SET_F_DELAY, start_ms); + ioctl(fd, IOC_IR_SET_X_DELAY, repeat_ms); + continue; + } +#endif + d_printf("[rcinput:%s] %s(fd %d) writing EV_REP (%d->%d)\n", + __func__, path.c_str(), fd, start_ms, repeat_ms); + /* if we have a good input device, we don't need the private ioctl above */ + struct input_event ie; + memset(&ie, 0, sizeof(ie)); + ie.type = EV_REP; + /* increase by 10 ms to trick the repeat checker code in the + * rcinput loop into accepting the key event... */ + ie.value = start_ms + 10; + ie.code = REP_DELAY; + if (write(fd, &ie, sizeof(ie)) == -1) + printf("[rcinput:%s] %s(fd %d) write %s: %m\n", __func__, path.c_str(), fd, "REP_DELAY"); + + ie.value = repeat_ms + 10; + ie.code = REP_PERIOD; + if (write(fd, &ie, sizeof(ie)) == -1) + printf("[rcinput:%s] %s(fd %d) write %s: %m\n", __func__, path.c_str(), fd, "REP_PERIOD"); + } +} #ifdef IOC_IR_SET_PRI_PROTOCOL // hint: ir_protocol_t and other useful things are defined in cs_ir_generic.h diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 9a859b929..ac2846745 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -335,6 +335,7 @@ class CRCInput void reset_dsp(int rate); void setLongPressAny(bool b) { longPressAny = b; }; + void setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms); };