From 0e435bb389d3923325d8f92bb452e45268e88966 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 08:59:56 +0100 Subject: [PATCH 1/9] - rc_input: rename checkLnkDev() to checkdev_lnk(); ... just to align form-style to latest changes --- src/driver/rcinput.cpp | 41 ++++++++++++++++++++--------------------- src/driver/rcinput.h | 2 +- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index b7974a09c..0541b69f1 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -174,6 +174,25 @@ bool CRCInput::checkdev() return true; /* need to check anyway... */ } +#ifdef BOXMODEL_CS_HD2 +bool CRCInput::checkdev_lnk(std::string lnk) +{ + static struct stat info; + if (lstat(lnk.c_str(), &info) != -1) { + if (S_ISLNK(info.st_mode)) { + std::string tmp = readLink(lnk); + if (!tmp.empty()) { + if (lstat(tmp.c_str(), &info) != -1) { + if (S_ISCHR(info.st_mode)) + return true; + } + } + } + } + return false; +} +#endif + bool CRCInput::checkpath(in_dev id) { for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { @@ -206,25 +225,6 @@ bool CRCInput::checkpath(in_dev id) return false; } -#ifdef BOXMODEL_CS_HD2 -bool CRCInput::checkLnkDev(std::string lnk) -{ - static struct stat info; - if (lstat(lnk.c_str(), &info) != -1) { - if (S_ISLNK(info.st_mode)) { - std::string tmp = readLink(lnk); - if (!tmp.empty()) { - if (lstat(tmp.c_str(), &info) != -1) { - if (S_ISCHR(info.st_mode)) - return true; - } - } - } - } - return false; -} -#endif - /* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */ void CRCInput::open(bool recheck) { @@ -249,13 +249,12 @@ void CRCInput::open(bool recheck) #ifdef BOXMODEL_CS_HD2 && (dentry->d_type != DT_LNK) #endif - ) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } #ifdef BOXMODEL_CS_HD2 - if ((dentry->d_type == DT_LNK) && (!checkLnkDev("/dev/input/" + std::string(dentry->d_name)))) { + if ((dentry->d_type == DT_LNK) && (!checkdev_lnk("/dev/input/" + std::string(dentry->d_name)))) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 37cfd4b8a..450dd4dd7 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -171,7 +171,7 @@ class CRCInput bool checkpath(in_dev id); bool checkdev(); #ifdef BOXMODEL_CS_HD2 - bool checkLnkDev(std::string lnk); + bool checkdev_lnk(std::string lnk); #endif void close(); int translate(int code); From d7ed439e53cc55b5c936fe843044ff8fc708b17d Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 08:59:56 +0100 Subject: [PATCH 2/9] - rc_input: just cosmetics to satisfy syntax-highlighters --- src/driver/rcinput.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 0541b69f1..9facaaf59 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -574,8 +574,6 @@ int CRCInput::checkTimers() return _id; } - - int64_t CRCInput::calcTimeoutEnd(const int timeout_in_seconds) { return time_monotonic_us() + ((uint64_t)timeout_in_seconds * (uint64_t) 1000000); @@ -1432,13 +1430,13 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 if (trkey == rc_last_key) { /* only allow selected keys to be repeated */ if (mayRepeat(trkey, bAllowRepeatLR) || - (g_settings.shutdown_real_rcdelay && - ((trkey == RC_standby) && + (g_settings.shutdown_real_rcdelay && ((trkey == RC_standby) && #if HAVE_COOL_HARDWARE - (cs_get_revision() > 7)))) + (cs_get_revision() > 7) #else - (g_info.hw_caps->can_shutdown)))) + (g_info.hw_caps->can_shutdown) #endif + ))) { #ifdef ENABLE_REPEAT_CHECK if (rc_last_repeat_key != trkey) { From 1eec78ccfd7d672ef2cc814ee8ff245696fe3a78 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 11:50:09 +0100 Subject: [PATCH 3/9] - rc_input: we have d_printf, so let's use it --- src/driver/rcinput.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 9facaaf59..ff2907ef5 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1382,9 +1382,7 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } uint32_t trkey = translate(ev.code); -#ifdef _DEBUG - printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); -#endif + d_printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); if (trkey == RC_nokey) continue; @@ -1418,9 +1416,7 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } if (ev.value) { -#ifdef RCDEBUG - printf("rc_last_key %04x rc_last_repeat_key %04x\n\n", rc_last_key, rc_last_repeat_key); -#endif + d_printf("rc_last_key %04x rc_last_repeat_key %04x\n\n", rc_last_key, rc_last_repeat_key); bool keyok = true; #if 0 uint64_t now_pressed; From 383af04cb786296a3325d186c73fca05ebdaea3e Mon Sep 17 00:00:00 2001 From: "M. Liebmann" Date: Wed, 22 Feb 2017 11:36:04 +0100 Subject: [PATCH 4/9] CRCInput::setKeyRepeatDelay: Change hardware dependency, HD2 driver is not so very ugly. ;) --- src/driver/rcinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index ff2907ef5..1678addeb 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1775,7 +1775,7 @@ void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms) std::string path = (*it).path; if (path == "/tmp/neutrino.input") continue; /* setting repeat rate does not work here */ -#ifdef HAVE_COOL_HARDWARE +#ifdef BOXMODEL_CS_HD1 /* 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); From 056b47c09b8794bbca1f00d62dc25d33808ade26 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 14:53:25 +0100 Subject: [PATCH 5/9] - rc_input: do always show key-presses in console; ... by mistake removed in 1eec78ccfd7d672ef2cc814ee8ff245696fe3a78 --- src/driver/rcinput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 1678addeb..8357f2355 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1382,7 +1382,7 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 } uint32_t trkey = translate(ev.code); - d_printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); + printf("key: %04x value %d, translate: %04x -%s-\n", ev.code, ev.value, trkey, getKeyName(trkey).c_str()); if (trkey == RC_nokey) continue; From 7c2e25103f77d9480a2501612c498e7e8466be0d Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 15:25:04 +0100 Subject: [PATCH 6/9] - controlapi: fix perror message --- src/nhttpd/tuxboxapi/controlapi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index a228f09b9..49f9bee1f 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -882,8 +882,8 @@ void CControlAPI::RCEmCGI(CyhookHandler *hh) #endif int evd = open(EVENTDEV, O_RDWR); if (evd < 0) { + perror("opening " EVENTDEV " failed"); hh->SendError(); - perror("opening event0 failed"); return; } if (rc_send(evd, sendcode, KEY_PRESSED) < 0) { @@ -894,8 +894,8 @@ void CControlAPI::RCEmCGI(CyhookHandler *hh) } if (rc_send(evd, sendcode, KEY_RELEASED) < 0) { perror("writing 'KEY_RELEASED' event failed"); - close(evd); hh->SendError(); + close(evd); return; } close(evd); From f0f7aec577044d9c8ac02c58ffe3a03ff666b2e9 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Wed, 22 Feb 2017 15:25:04 +0100 Subject: [PATCH 7/9] - rcsim: fix perror message --- src/rcsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rcsim.c b/src/rcsim.c index 2ae56a39c..ccfdb6c59 100644 --- a/src/rcsim.c +++ b/src/rcsim.c @@ -219,7 +219,7 @@ int main (int argc, char **argv){ #if defined (EVENTDEV) evd=open (EVENTDEV,O_RDWR); if (evd<0){ - perror ("opening event0 failed"); + perror ("opening " EVENTDEV " failed"); return 1; } #else From 63dce04974aaf858f43260024006cfe7e049a1ec Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:05:26 +0100 Subject: [PATCH 8/9] Revert "- rc_input: rename checkLnkDev() to checkdev_lnk(); ..." This reverts commit 0e435bb389d3923325d8f92bb452e45268e88966. --- src/driver/rcinput.cpp | 41 +++++++++++++++++++++-------------------- src/driver/rcinput.h | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 8357f2355..54fac46d7 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -174,25 +174,6 @@ bool CRCInput::checkdev() return true; /* need to check anyway... */ } -#ifdef BOXMODEL_CS_HD2 -bool CRCInput::checkdev_lnk(std::string lnk) -{ - static struct stat info; - if (lstat(lnk.c_str(), &info) != -1) { - if (S_ISLNK(info.st_mode)) { - std::string tmp = readLink(lnk); - if (!tmp.empty()) { - if (lstat(tmp.c_str(), &info) != -1) { - if (S_ISCHR(info.st_mode)) - return true; - } - } - } - } - return false; -} -#endif - bool CRCInput::checkpath(in_dev id) { for (std::vector::iterator it = indev.begin(); it != indev.end(); ++it) { @@ -225,6 +206,25 @@ bool CRCInput::checkpath(in_dev id) return false; } +#ifdef BOXMODEL_CS_HD2 +bool CRCInput::checkLnkDev(std::string lnk) +{ + static struct stat info; + if (lstat(lnk.c_str(), &info) != -1) { + if (S_ISLNK(info.st_mode)) { + std::string tmp = readLink(lnk); + if (!tmp.empty()) { + if (lstat(tmp.c_str(), &info) != -1) { + if (S_ISCHR(info.st_mode)) + return true; + } + } + } + } + return false; +} +#endif + /* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */ void CRCInput::open(bool recheck) { @@ -249,12 +249,13 @@ void CRCInput::open(bool recheck) #ifdef BOXMODEL_CS_HD2 && (dentry->d_type != DT_LNK) #endif + ) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } #ifdef BOXMODEL_CS_HD2 - if ((dentry->d_type == DT_LNK) && (!checkdev_lnk("/dev/input/" + std::string(dentry->d_name)))) { + if ((dentry->d_type == DT_LNK) && (!checkLnkDev("/dev/input/" + std::string(dentry->d_name)))) { d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name); continue; } diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 450dd4dd7..37cfd4b8a 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -171,7 +171,7 @@ class CRCInput bool checkpath(in_dev id); bool checkdev(); #ifdef BOXMODEL_CS_HD2 - bool checkdev_lnk(std::string lnk); + bool checkLnkDev(std::string lnk); #endif void close(); int translate(int code); From 3d7f6f13c4646bddd536b6d119c217396c7ce488 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Wed, 22 Feb 2017 20:05:54 +0100 Subject: [PATCH 9/9] Revert "- rc_input: just cosmetics to satisfy syntax-highlighters" This reverts commit d7ed439e53cc55b5c936fe843044ff8fc708b17d. --- src/driver/rcinput.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 54fac46d7..931e23ca7 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -575,6 +575,8 @@ int CRCInput::checkTimers() return _id; } + + int64_t CRCInput::calcTimeoutEnd(const int timeout_in_seconds) { return time_monotonic_us() + ((uint64_t)timeout_in_seconds * (uint64_t) 1000000); @@ -1427,13 +1429,13 @@ void CRCInput::getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint6 if (trkey == rc_last_key) { /* only allow selected keys to be repeated */ if (mayRepeat(trkey, bAllowRepeatLR) || - (g_settings.shutdown_real_rcdelay && ((trkey == RC_standby) && + (g_settings.shutdown_real_rcdelay && + ((trkey == RC_standby) && #if HAVE_COOL_HARDWARE - (cs_get_revision() > 7) + (cs_get_revision() > 7)))) #else - (g_info.hw_caps->can_shutdown) + (g_info.hw_caps->can_shutdown)))) #endif - ))) { #ifdef ENABLE_REPEAT_CHECK if (rc_last_repeat_key != trkey) {