From 3d0c385f6e4439b2f9805eee6b66f3c2d33d6ab1 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Sun, 11 Jun 2023 20:14:51 +0200 Subject: [PATCH] rcinput: try to fix some key handlings Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/8056fa8688e6ddbe2a2c114e9aa9e70e45e773be Author: vanhofen Date: 2023-06-11 (Sun, 11 Jun 2023) Origin message was: ------------------ - rcinput: try to fix some key handlings ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/rcinput.cpp | 44 +++++++++++++++++++++++++++-- src/driver/rcinput.h | 3 +- src/nhttpd/tuxboxapi/controlapi.cpp | 30 +------------------- 3 files changed, 44 insertions(+), 33 deletions(-) diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp index 29be6c0c3..40aedb394 100644 --- a/src/driver/rcinput.cpp +++ b/src/driver/rcinput.cpp @@ -1780,15 +1780,15 @@ int CRCInput::translate(int code) case KEY_CHANNELDOWN: return RC_page_down; #if HAVE_ARM_HARDWARE || HAVE_MIPS_HARDWARE -#if BOXMODEL_HD51 || BOXMODEL_BRE2ZE4K || BOXMODEL_H7 || BOXMODEL_E4HDULTRA || BOXMODEL_PROTEK4K || BOXMODEL_HD60 || BOXMODEL_HD61 || BOXMODEL_MULTIBOX || BOXMODEL_MULTIBOXSE +#if BOXMODEL_HD51 || BOXMODEL_BRE2ZE4K || BOXMODEL_H7 || BOXMODEL_HD60 || BOXMODEL_HD61 || BOXMODEL_MULTIBOX || BOXMODEL_MULTIBOXSE case KEY_VIDEO: return RC_favorites; - case KEY_TV2: - return RC_tv; #elif BOXMODEL_OSMIO4K || BOXMODEL_OSMIO4KPLUS case KEY_VIDEO: return RC_mode; #endif + case KEY_TV2: + return RC_tv; case KEY_SWITCHVIDEOMODE: return RC_mode; case KEY_FASTFORWARD: @@ -1805,6 +1805,44 @@ int CRCInput::translate(int code) return (int)RC_nokey; } +/************************************************************************** +* revert the transformations above - used by controlapi +* +**************************************************************************/ +int CRCInput::translate_revert(int code) +{ + switch(code) + { + case RC_home: + return KEY_EXIT; + case RC_page_up: + return KEY_CHANNELUP; + case RC_page_down: + return KEY_CHANNELDOWN; +#ifdef HAVE_ARM_HARDWARE +#if BOXMODEL_HD51 || BOXMODEL_BRE2ZE4K || BOXMODEL_H7 || BOXMODEL_HD60 || BOXMODEL_HD61 || BOXMODEL_MULTIBOX || BOXMODEL_MULTIBOXSE + case RC_favorites: + return KEY_VIDEO; +#elif BOXMODEL_OSMIO4K || BOXMODEL_OSMIO4KPLUS + case RC_mode: + return KEY_VIDEO; +#endif + case RC_tv: + return KEY_TV2; + case RC_mode: + return KEY_SWITCHVIDEOMODE; + case RC_forward: + return KEY_FASTFORWARD; + case RC_play: + case RC_pause: + return KEY_PLAYPAUSE; +#endif + default: + break; + } + return code; +} + void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms) { if (start_ms == 0 && repeat_ms == 0) { diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 21d3b7b81..91eb31a16 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -100,6 +100,7 @@ class CRCInput bool checkdev(); void close(); int translate(int code); + int translate_revert(int code); void calculateMaxFd(void); int checkTimers(); bool mayRepeat(uint32_t key, bool bAllowRepeatLR = false); @@ -239,7 +240,6 @@ class CRCInput CRCInput(); //constructor - opens rc-device and starts needed threads ~CRCInput(); //destructor - closes rc-device - static bool isNumeric(const neutrino_msg_t key); static int getNumericValue(const neutrino_msg_t key); static unsigned int convertDigitToKey(const unsigned int digit); @@ -268,6 +268,7 @@ class CRCInput int messageLoop(bool anyKeyCancels = false, int timeout = -1); + int translateRevert(int c) { return translate_revert(c); }; void setLongPressAny(bool b) { longPressAny = b; }; void setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms); }; diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index ec20d5e0a..dae5e1213 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -963,34 +963,6 @@ void CControlAPI::RestartCGI(CyhookHandler *hh) } //----------------------------------------------------------------------------- -unsigned int revert_translate(unsigned int code) -{ - switch(code) - { - case RC_home: - return KEY_EXIT; - case RC_page_up: - return KEY_CHANNELUP; - case RC_page_down: - return KEY_CHANNELDOWN; -#ifdef HAVE_ARM_HARDWARE -#if BOXMODEL_HD51 || BOXMODEL_BRE2ZE4K || BOXMODEL_H7 || BOXMODEL_HD60 || BOXMODEL_HD61 || BOXMODEL_MULTIBOX || BOXMODEL_MULTIBOXSE || BOXMODEL_OSMIO4K || BOXMODEL_OSMIO4KPLUS - case RC_favorites: - return KEY_VIDEO; -#endif - case RC_mode: - return KEY_SWITCHVIDEOMODE; - case RC_play: - case RC_pause: - return KEY_PLAYPAUSE; - case RC_forward: - return KEY_FASTFORWARD; -#endif - default: - break; - } - return code; -} void CControlAPI::rc_sync(int fd) { @@ -1053,7 +1025,7 @@ void CControlAPI::RCEmCGI(CyhookHandler *hh) hh->SendError(); return; } - sendcode = revert_translate(sendcode); + sendcode = g_RCInput->translateRevert(sendcode); if (rc_send(evd, sendcode, KEY_PRESSED) < 0) { perror("writing 'KEY_PRESSED' event failed"); hh->SendError();