From 85686359f5b0a6fcb47b36feece07c8a82866e7c Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 27 Sep 2022 23:58:23 +0200 Subject: [PATCH] introduce src/driver/rcinput_fake.h Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/1e520b10323c1894b532d515f15669a3dd5425e8 Author: vanhofen Date: 2022-09-27 (Tue, 27 Sep 2022) Origin message was: ------------------ - introduce src/driver/rcinput_fake.h --- src/create_rcsim_h.sh | 37 +----- src/driver/rcinput.h | 230 ++++++++++++++------------------------ src/driver/rcinput_fake.h | 96 ++++++++++++++++ 3 files changed, 181 insertions(+), 182 deletions(-) create mode 100644 src/driver/rcinput_fake.h diff --git a/src/create_rcsim_h.sh b/src/create_rcsim_h.sh index 6d83ec155..a1148b4d8 100644 --- a/src/create_rcsim_h.sh +++ b/src/create_rcsim_h.sh @@ -7,40 +7,13 @@ # usage: sh ./create_rcsim_h.sh > rcsim.h cat << EOF -// rcsim.h - automatically created from driver/rcinput.h +// rcsim.h - automatically created from driver/rcinput.h and driver/rcinput_fake.h -#ifndef KEY_NONEXISTING -#define KEY_NONEXISTING 0x0 -#endif +EOF -#ifndef KEY_GAMES -#define KEY_GAMES 0x1a1 /* Media Select Games */ -#endif +cat driver/rcinput_fake.h -#ifndef KEY_TOPLEFT -#define KEY_TOPLEFT 0x1a2 -#endif - -#ifndef KEY_TOPRIGHT -#define KEY_TOPRIGHT 0x1a3 -#endif - -#ifndef KEY_BOTTOMLEFT -#define KEY_BOTTOMLEFT 0x1a4 -#endif - -#ifndef KEY_BOTTOMRIGHT -#define KEY_BOTTOMRIGHT 0x1a5 -#endif - -#define KEY_POWERON KEY_FN_F1 -#define KEY_POWEROFF KEY_FN_F2 -#define KEY_STANDBYON KEY_FN_F3 -#define KEY_STANDBYOFF KEY_FN_F4 -#define KEY_MUTEON KEY_FN_F5 -#define KEY_MUTEOFF KEY_FN_F6 -#define KEY_ANALOGON KEY_FN_F7 -#define KEY_ANALOGOFF KEY_FN_F8 +cat << EOF enum { EOF @@ -67,6 +40,4 @@ cat << EOF { "KEY_SETUP", KEY_MENU }, { "KEY_HOME", KEY_EXIT }, }; - EOF - diff --git a/src/driver/rcinput.h b/src/driver/rcinput.h index 28a1af247..831d22234 100644 --- a/src/driver/rcinput.h +++ b/src/driver/rcinput.h @@ -29,8 +29,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __MOD_rcinput__ -#define __MOD_rcinput__ +#ifndef __rcinput_h__ +#define __rcinput_h__ #include #include @@ -53,91 +53,23 @@ #endif #include - -#ifndef KEY_NONEXISTING -#define KEY_NONEXISTING 0x0 -#endif - -#ifndef KEY_OK -#define KEY_OK 0x160 -#endif - -#ifndef KEY_RED -#define KEY_RED 0x18e -#endif - -#ifndef KEY_GREEN -#define KEY_GREEN 0x18f -#endif - -#ifndef KEY_YELLOW -#define KEY_YELLOW 0x190 -#endif - -#ifndef KEY_BLUE -#define KEY_BLUE 0x191 -#endif - -#ifndef KEY_GAMES -#define KEY_GAMES 0x1a1 /* Media Select Games */ -#endif -/* SAGEM remote controls have the following additional keys */ - -#ifndef KEY_TOPLEFT -#define KEY_TOPLEFT 0x1a2 -#endif - -#ifndef KEY_TOPRIGHT -#define KEY_TOPRIGHT 0x1a3 -#endif - -#ifndef KEY_BOTTOMLEFT -#define KEY_BOTTOMLEFT 0x1a4 -#endif - -#ifndef KEY_BOTTOMRIGHT -#define KEY_BOTTOMRIGHT 0x1a5 -#endif - -#define KEY_POWERON KEY_FN_F1 -#define KEY_POWEROFF KEY_FN_F2 -#define KEY_STANDBYON KEY_FN_F3 -#define KEY_STANDBYOFF KEY_FN_F4 -#define KEY_MUTEON KEY_FN_F5 -#define KEY_MUTEOFF KEY_FN_F6 -#define KEY_ANALOGON KEY_FN_F7 -#define KEY_ANALOGOFF KEY_FN_F8 - -#define KEY_TTTV KEY_FN_1 -#define KEY_TTZOOM KEY_FN_2 -#define KEY_REVEAL KEY_FN_D -/* only defined in newer kernels / headers... */ -#ifndef KEY_ZOOMIN -#define KEY_ZOOMIN KEY_FN_E -#endif -#ifndef KEY_ZOOMOUT -#define KEY_ZOOMOUT KEY_FN_F -#endif -/* still available, even in 2.6.12: - #define KEY_FN_S - #define KEY_FN_B -*/ +#include class CRCInput { private: struct event { - neutrino_msg_t msg; + neutrino_msg_t msg; neutrino_msg_data_t data; }; struct timer { - uint id; - uint64_t interval; - uint64_t times_out; - bool correct_time; + uint id; + uint64_t interval; + uint64_t times_out; + bool correct_time; }; struct in_dev @@ -146,20 +78,19 @@ class CRCInput std::string path; }; - uint32_t timerid; + uint32_t timerid; std::vector timers; - uint32_t *repeatkeys; - uint64_t longPressEnd; - bool longPressAny; - int fd_pipe_high_priority[2]; - int fd_pipe_low_priority[2]; - int fd_gamerc; + uint32_t *repeatkeys; + uint64_t longPressEnd; + bool longPressAny; + int fd_pipe_high_priority[2]; + int fd_pipe_low_priority[2]; + int fd_gamerc; std::vector indev; - int fd_keyb; - int fd_event; - - int fd_max; + int fd_keyb; + int fd_event; + int fd_max; __u16 rc_last_key; OpenThreads::Mutex mutex; OpenThreads::Mutex timer_mutex; @@ -177,52 +108,52 @@ class CRCInput void set_rc_hw(ir_protocol_t ir_protocol, unsigned int ir_address); #endif public: - //rc-code definitions + // rc-code definitions; see /include/linux/input.h static const neutrino_msg_t RC_Repeat = 0x0400; static const neutrino_msg_t RC_Release = 0x0800; - static const neutrino_msg_t RC_MaxRC = KEY_MAX | RC_Repeat | RC_Release; /* /include/linux/input.h: #define KEY_MAX 0x1ff */ + static const neutrino_msg_t RC_MaxRC = KEY_MAX | RC_Repeat | RC_Release; static const neutrino_msg_t RC_KeyBoard = 0x4000; static const neutrino_msg_t RC_Events = 0x80000000; static const neutrino_msg_t RC_Messages = 0x90000000; static const neutrino_msg_t RC_WithData = 0xA0000000; enum { - RC_0 = KEY_0, /* /include/linux/input.h: #define KEY_0 11 */ - RC_1 = KEY_1, /* /include/linux/input.h: #define KEY_1 2 */ - RC_2 = KEY_2, /* /include/linux/input.h: #define KEY_2 3 */ - RC_3 = KEY_3, /* /include/linux/input.h: #define KEY_3 4 */ - RC_4 = KEY_4, /* /include/linux/input.h: #define KEY_4 5 */ - RC_5 = KEY_5, /* /include/linux/input.h: #define KEY_5 6 */ - RC_6 = KEY_6, /* /include/linux/input.h: #define KEY_6 7 */ - RC_7 = KEY_7, /* /include/linux/input.h: #define KEY_7 8 */ - RC_8 = KEY_8, /* /include/linux/input.h: #define KEY_8 9 */ - RC_9 = KEY_9, /* /include/linux/input.h: #define KEY_9 10 */ - RC_backspace = KEY_BACKSPACE, /* /include/linux/input.h: #define KEY_BACKSPACE 14 */ - RC_up = KEY_UP, /* /include/linux/input.h: #define KEY_UP 103 */ - RC_left = KEY_LEFT, /* /include/linux/input.h: #define KEY_LEFT 105 */ - RC_right = KEY_RIGHT, /* /include/linux/input.h: #define KEY_RIGHT 106 */ - RC_down = KEY_DOWN, /* /include/linux/input.h: #define KEY_DOWN 108 */ - RC_spkr = KEY_MUTE, /* /include/linux/input.h: #define KEY_MUTE 113 */ - RC_minus = KEY_VOLUMEDOWN, /* /include/linux/input.h: #define KEY_VOLUMEDOWN 114 */ - RC_plus = KEY_VOLUMEUP, /* /include/linux/input.h: #define KEY_VOLUMEUP 115 */ - RC_standby = KEY_POWER, /* /include/linux/input.h: #define KEY_POWER 116 */ - RC_help = KEY_HELP, /* /include/linux/input.h: #define KEY_HELP 138 */ - RC_back = KEY_BACK, /* /include/linux/input.h: #define KEY_BACK 158 */ - RC_home = KEY_HOME, /* /include/linux/input.h: #define KEY_HOME 102 */ - RC_setup = KEY_MENU, /* /include/linux/input.h: #define KEY_SETUP 141 */ - RC_topleft = KEY_TOPLEFT, - RC_topright = KEY_TOPRIGHT, - RC_page_up = KEY_PAGEUP, /* /include/linux/input.h: #define KEY_PAGEUP 104 */ - RC_page_down = KEY_PAGEDOWN, /* /include/linux/input.h: #define KEY_PAGEDOWN 109 */ - RC_ok = KEY_OK, /* /include/linux/input.h: #define KEY_OK 0x160 */ /* in patched input.h */ - RC_red = KEY_RED, /* /include/linux/input.h: #define KEY_RED 0x18e */ /* in patched input.h */ - RC_green = KEY_GREEN, /* /include/linux/input.h: #define KEY_GREEN 0x18f */ /* in patched input.h */ - RC_yellow = KEY_YELLOW, /* /include/linux/input.h: #define KEY_YELLOW 0x190 */ /* in patched input.h */ - RC_blue = KEY_BLUE, /* /include/linux/input.h: #define KEY_BLUE 0x191 */ /* in patched input.h */ - RC_top_left = KEY_TOPLEFT, /* /include/linux/input.h: #define KEY_TOPLEFT 0x1a2 */ /* in patched input.h */ - RC_top_right = KEY_TOPRIGHT, /* /include/linux/input.h: #define KEY_TOPRIGHT 0x1a3 */ /* in patched input.h */ - RC_bottom_left = KEY_BOTTOMLEFT, /* /include/linux/input.h: #define KEY_BOTTOMLEFT 0x1a4 */ /* in patched input.h */ - RC_bottom_right = KEY_BOTTOMRIGHT, /* /include/linux/input.h: #define KEY_BOTTOMRIGHT 0x1a5 */ /* in patched input.h */ + RC_0 = KEY_0, + RC_1 = KEY_1, + RC_2 = KEY_2, + RC_3 = KEY_3, + RC_4 = KEY_4, + RC_5 = KEY_5, + RC_6 = KEY_6, + RC_7 = KEY_7, + RC_8 = KEY_8, + RC_9 = KEY_9, + RC_backspace = KEY_BACKSPACE, + RC_up = KEY_UP, + RC_left = KEY_LEFT, + RC_right = KEY_RIGHT, + RC_down = KEY_DOWN, + RC_spkr = KEY_MUTE, + RC_minus = KEY_VOLUMEDOWN, + RC_plus = KEY_VOLUMEUP, + RC_standby = KEY_POWER, + RC_help = KEY_HELP, + RC_back = KEY_BACK, + RC_home = KEY_HOME, + RC_setup = KEY_MENU, + RC_topleft = KEY_TOPLEFT, + RC_topright = KEY_TOPRIGHT, + RC_page_up = KEY_PAGEUP, + RC_page_down = KEY_PAGEDOWN, + RC_ok = KEY_OK, + RC_red = KEY_RED, + RC_green = KEY_GREEN, + RC_yellow = KEY_YELLOW, + RC_blue = KEY_BLUE, + RC_top_left = KEY_TOPLEFT, + RC_top_right = KEY_TOPRIGHT, + RC_bottom_left = KEY_BOTTOMLEFT, + RC_bottom_right = KEY_BOTTOMRIGHT, RC_aux = KEY_AUX, RC_audio = KEY_AUDIO, @@ -261,15 +192,6 @@ class CRCInput RC_program = KEY_PROGRAM, RC_playpause = KEY_PLAYPAUSE, - RC_power_on = KEY_POWERON, - RC_power_off = KEY_POWEROFF, - RC_standby_on = KEY_STANDBYON, - RC_standby_off = KEY_STANDBYOFF, - RC_mute_on = KEY_MUTEON, - RC_mute_off = KEY_MUTEOFF, - RC_analog_on = KEY_ANALOGON, - RC_analog_off = KEY_ANALOGOFF, - RC_f1 = KEY_F1, RC_f2 = KEY_F2, RC_f3 = KEY_F3, @@ -281,16 +203,27 @@ class CRCInput RC_f9 = KEY_F9, RC_f10 = KEY_F10, + RC_power_on = KEY_POWERON, + RC_power_off = KEY_POWEROFF, + RC_standby_on = KEY_STANDBYON, + RC_standby_off = KEY_STANDBYOFF, + RC_mute_on = KEY_MUTEON, + RC_mute_off = KEY_MUTEOFF, + RC_analog_on = KEY_ANALOGON, + RC_analog_off = KEY_ANALOGOFF, + + /* RC_analog_off should be the last entry. See src/create_rcsim_h.sh */ + RC_timeout = 0xFFFFFFFF, RC_nokey = RC_NOKEY }; - //rc-hardware definitions + // rc-hardware definitions enum { - RC_HW_COOLSTREAM = 0, - RC_HW_DBOX = 1, - RC_HW_PHILIPS = 2 + RC_HW_COOLSTREAM = 0, + RC_HW_DBOX = 1, + RC_HW_PHILIPS = 2 }; void set_rc_hw(void); @@ -300,9 +233,9 @@ class CRCInput uint64_t repeat_block; uint64_t repeat_block_generic; - bool firstKey; - CRCInput(); //constructor - opens rc-device and starts needed threads - ~CRCInput(); //destructor - closes rc-device + bool firstKey; + CRCInput(); //constructor - opens rc-device and starts needed threads + ~CRCInput(); //destructor - closes rc-device static bool isNumeric(const neutrino_msg_t key); @@ -311,11 +244,11 @@ class CRCInput static const char *getUnicodeValue(const neutrino_msg_t key); uint32_t *setAllowRepeat(uint32_t *); - static const char * getSpecialKeyName(const unsigned int key); + static const char *getSpecialKeyName(const unsigned int key); static const char *getKeyNameC(const unsigned int key); static std::string getKeyName(const unsigned int key); - int addTimer(uint64_t Interval, bool oneshot= true, bool correct_time= true ); + int addTimer(uint64_t Interval, bool oneshot = true, bool correct_time = true); int addTimer(struct timeval Timeout); int addTimer(const time_t *Timeout); @@ -324,18 +257,17 @@ class CRCInput static int64_t calcTimeoutEnd_MS(const int timeout_in_milliseconds); static int64_t calcTimeoutEnd(const int timeout_in_seconds); - void getMsgAbsoluteTimeout(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint64_t *TimeoutEnd, bool bAllowRepeatLR= false); - void getMsg(neutrino_msg_t * msg, neutrino_msg_data_t * data, int Timeout, bool bAllowRepeatLR= false); //get message, timeout in 1/10 secs :) - void getMsg_ms(neutrino_msg_t * msg, neutrino_msg_data_t * data, int Timeout, bool bAllowRepeatLR= false); //get message, timeout in msecs :) - void getMsg_us(neutrino_msg_t * msg, neutrino_msg_data_t * data, uint64_t Timeout, bool bAllowRepeatLR= false);//get message, timeout in µsecs :) + void getMsgAbsoluteTimeout(neutrino_msg_t *msg, neutrino_msg_data_t *data, uint64_t *TimeoutEnd, bool bAllowRepeatLR = false); + void getMsg(neutrino_msg_t *msg, neutrino_msg_data_t *data, int Timeout, bool bAllowRepeatLR = false); // get message, timeout in 1/10 secs + void getMsg_ms(neutrino_msg_t *msg, neutrino_msg_data_t *data, int Timeout, bool bAllowRepeatLR = false); // get message, timeout in msecs + void getMsg_us(neutrino_msg_t *msg, neutrino_msg_data_t *data, uint64_t Timeout, bool bAllowRepeatLR = false); // get message, timeout in µsecs void postMsg(const neutrino_msg_t msg, const neutrino_msg_data_t data, const bool Priority = true); // push message back into buffer void clearRCMsg(); - int messageLoop( bool anyKeyCancels = false, int timeout= -1 ); + int messageLoop(bool anyKeyCancels = false, int timeout = -1); void setLongPressAny(bool b) { longPressAny = b; }; void setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms); }; - #endif diff --git a/src/driver/rcinput_fake.h b/src/driver/rcinput_fake.h new file mode 100644 index 000000000..1255e6a8e --- /dev/null +++ b/src/driver/rcinput_fake.h @@ -0,0 +1,96 @@ +/* + Neutrino-GUI - DBoxII-Project + + License: GPL + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __rcinput_fake_h__ +#define __rcinput_fake_h__ + +#ifndef KEY_NONEXISTING +#define KEY_NONEXISTING 0x0 +#endif + +#ifndef KEY_OK +#define KEY_OK 0x160 +#endif + +#ifndef KEY_RED +#define KEY_RED 0x18e +#endif + +#ifndef KEY_GREEN +#define KEY_GREEN 0x18f +#endif + +#ifndef KEY_YELLOW +#define KEY_YELLOW 0x190 +#endif + +#ifndef KEY_BLUE +#define KEY_BLUE 0x191 +#endif + +#ifndef KEY_GAMES +#define KEY_GAMES 0x1a1 +#endif + +#ifndef KEY_TOPLEFT +#define KEY_TOPLEFT 0x1a2 +#endif + +#ifndef KEY_TOPRIGHT +#define KEY_TOPRIGHT 0x1a3 +#endif + +#ifndef KEY_BOTTOMLEFT +#define KEY_BOTTOMLEFT 0x1a4 +#endif + +#ifndef KEY_BOTTOMRIGHT +#define KEY_BOTTOMRIGHT 0x1a5 +#endif + +#define KEY_POWERON KEY_FN_F1 +#define KEY_POWEROFF KEY_FN_F2 +#define KEY_STANDBYON KEY_FN_F3 +#define KEY_STANDBYOFF KEY_FN_F4 +#define KEY_MUTEON KEY_FN_F5 +#define KEY_MUTEOFF KEY_FN_F6 +#define KEY_ANALOGON KEY_FN_F7 +#define KEY_ANALOGOFF KEY_FN_F8 + +#define KEY_TTTV KEY_FN_1 +#define KEY_TTZOOM KEY_FN_2 +#define KEY_REVEAL KEY_FN_D + +// only defined in newer kernels / headers... + +#ifndef KEY_ZOOMIN +#define KEY_ZOOMIN KEY_FN_E +#endif + +#ifndef KEY_ZOOMOUT +#define KEY_ZOOMOUT KEY_FN_F +#endif + +/* still available, even in 2.6.12: + #define KEY_FN_S + #define KEY_FN_B +*/ + +#endif