2 Copyright 2004-2005 Chris Tallon; 2012 Marten Richter
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "remotelinux.h"
23 #include <linux/input.h>
24 #include <sys/types.h>
41 #include <libcec/cecloader.h>
46 #define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
48 #define W_HCW_KC 1 /* key code as defined by kernel for keyboard and remotes through /dev/input */
49 #define W_HCW_CEC 2 /* HDMI_CEC */
50 #define W_HCW_LIRC 3 /* remote control LIRC*/
53 RemoteLinux::RemoteLinux()
64 RemoteLinux::~RemoteLinux()
66 for (unsigned int i=0; i<devices.size();i++) {
71 #define test_bit(input,b) ((1 << ((b) % 8))&(input)[b / 8] )
74 int RemoteLinux::init(char* devName)
76 if (initted) return 0;
81 for (int eventid=0;eventid<100;eventid++){
83 sprintf(buffer,"/dev/input/event%d",eventid);
87 if (stat(buffer,&test_buf)==0) {
88 Log::getInstance()->log("Remote", Log::NOTICE, "Probe /dev/input/event%d",eventid);
90 unsigned long ev_type=0;
91 int new_fd=open(buffer,O_RDONLY);
93 Log::getInstance()->log("Remote", Log::NOTICE, "Can not open /dev/input/event%d",eventid);
96 if (ioctl(new_fd, EVIOCGBIT(0, EV_MAX), &ev_type) < 0) {
97 Log::getInstance()->log("Remote", Log::NOTICE, "Ioctl failed /dev/input/event%d %d",eventid,errno);
100 //Now test if it generates keyboard presses
101 if (test_bit((char*)&ev_type , EV_KEY)) {
102 Log::getInstance()->log("Remote", Log::NOTICE, "Add /dev/input/event%d to List",eventid);
103 devices.push_back(new_fd);
121 int RemoteLinux::initCec() {
123 // bcm_host_init(); //may be move to custom hardware init?
125 Log::getInstance()->log("Remote", Log::NOTICE, "Init LibCEC");
127 cec_callbacks.Clear();
128 cec_callbacks.CBCecLogMessage = cecLogMessage;
129 cec_callbacks.CBCecKeyPress = cecKeyPress;
130 cec_callbacks.CBCecCommand = cecCommand;
131 cec_callbacks.CBCecConfigurationChanged = cecConfigurationChanged;
132 cec_config.clientVersion=LIBCEC_VERSION_CURRENT;
133 cec_config.bActivateSource=1;
134 cec_config.bUseTVMenuLanguage=1;
135 //cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
136 cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_TUNER);
138 strncpy(cec_config.strDeviceName,"vomp",sizeof(cec_config.strDeviceName));
141 cec_config.callbackParam = NULL; // I do not care
142 cec_config.callbacks = &cec_callbacks;
144 cec_adap = LibCecInitialise(&cec_config);
146 Log::getInstance()->log("Remote", Log::ERR, "Init LibCEC failed");
149 cec_adap->InitVideoStandalone();
152 cec_adapter cec_devices[10];
153 int adap_num=cec_adap->FindAdapters(cec_devices,10,NULL);
155 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to find adapter");
160 Log::getInstance()->log("Remote", Log::NOTICE, "CEC: No adapter found");
164 if (!cec_adap->Open(cec_devices[0].comm)) {
165 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to open adapter");
169 if (!cec_adap->SetActiveSource(cec_config.deviceTypes[0])) {
170 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed set active source");
180 int RemoteLinux::shutdown()
182 if (!initted) return 0;
190 void RemoteLinux::deinitCec()
193 cec_adap->SetInactiveView();
195 UnloadLibCec(cec_adap);
201 UCHAR RemoteLinux::getButtonPress(int waitType) {
203 how = 1 - start new wait
204 how = 2 - continue wait
218 } else if (waitType == 1) {
221 } else if (waitType == 2) {
222 if (num_loop<=0) num_loop = 25;
223 } else if (waitType == 3) {
231 while (num_loop!=0) {
236 for (int i = 0; i < devices.size(); i++) {
237 int cur_fd = devices[i];
238 maxfd = max(cur_fd, maxfd);
239 FD_SET(cur_fd, &readfds);
242 retval = select(maxfd + 1, &readfds, NULL, NULL, &tv);
245 // 0 = nothing happened
246 // 1 = data arrived (actually num of descriptors that changed)
247 // other value = signal or error
251 return (UCHAR) TranslateHWC(W_G_HCW(W_HCW_CEC,curcec));
256 Log::getInstance()->log("Remote", Log::NOTICE, "na_signal");
260 for (int i = 0; i < devices.size(); i++) {
261 int cur_fd = devices[i];
262 if (FD_ISSET(cur_fd, &readfds)) {
263 struct input_event ev;
264 int count = read(cur_fd, &ev, sizeof(ev));
265 if (count == sizeof(ev)) {
266 if (ev.type == EV_KEY && ev.value == 1) {
267 UCHAR retty=(UCHAR) TranslateHWC(
268 W_G_HCW(W_HCW_KC,ev.code));
278 //Log::getInstance()->log("Remote", Log::NOTICE, "numloop: %d %d",num_loop,retval);
289 void RemoteLinux::clearBuffer()
291 while(getButtonPress(3) != NA_NONE);
294 UCHAR RemoteLinux::TranslateHWCFixed(ULLONG code)
298 case W_G_HCW(W_HCW_KC,KEY_DOWN):
300 case W_G_HCW(W_HCW_KC,KEY_UP):
302 case W_G_HCW(W_HCW_KC,KEY_LEFT):
304 case W_G_HCW(W_HCW_KC,KEY_RIGHT):
306 case W_G_HCW(W_HCW_KC,KEY_M):
308 case W_G_HCW(W_HCW_KC,KEY_BACKSPACE):
310 case W_G_HCW(W_HCW_KC,KEY_ENTER):
311 case W_G_HCW(W_HCW_KC,KEY_SPACE):
312 case W_G_HCW(W_HCW_KC,KEY_OK):
315 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_DOWN):
317 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_UP):
319 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_LEFT):
321 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RIGHT):
323 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ROOT_MENU):
324 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CONTENTS_MENU):
325 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SETUP_MENU):
327 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_EXIT ):
329 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ENTER):
330 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SELECT):
331 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_AN_RETURN):
340 const char*RemoteLinux::HardcodedTranslateStr(UCHAR command)
355 return tr("Backspace, Back");
357 return tr("Return, Space");
365 void RemoteLinux::InitHWCListwithDefaults()
367 //Processing VK_Messages
368 translist[W_G_HCW(W_HCW_KC,KEY_9)] = NINE;
369 translist[W_G_HCW(W_HCW_KC,KEY_8)] = EIGHT;
370 translist[W_G_HCW(W_HCW_KC,KEY_7)] = SEVEN;
371 translist[W_G_HCW(W_HCW_KC,KEY_6)] = SIX;
372 translist[W_G_HCW(W_HCW_KC,KEY_5)] = FIVE;
373 translist[W_G_HCW(W_HCW_KC,KEY_4)] = FOUR;
374 translist[W_G_HCW(W_HCW_KC,KEY_3)] = THREE;
375 translist[W_G_HCW(W_HCW_KC,KEY_2)] = TWO;
376 translist[W_G_HCW(W_HCW_KC,KEY_1)] = ONE;
377 translist[W_G_HCW(W_HCW_KC,KEY_0)] = ZERO;
378 translist[W_G_HCW(W_HCW_KC,KEY_KPDOT)] = STAR;
379 // translist[W_G_HCW(W_HCW_KC,KEY_#)] = HASH;
381 translist[W_G_HCW(W_HCW_KC,KEY_KP9)] = NINE;
382 translist[W_G_HCW(W_HCW_KC,KEY_KP8)] = EIGHT;
383 translist[W_G_HCW(W_HCW_KC,KEY_KP7)] = SEVEN;
384 translist[W_G_HCW(W_HCW_KC,KEY_KP6)] = SIX;
385 translist[W_G_HCW(W_HCW_KC,KEY_KP5)] = FIVE;
386 translist[W_G_HCW(W_HCW_KC,KEY_KP4)] = FOUR;
387 translist[W_G_HCW(W_HCW_KC,KEY_KP3)] = THREE;
388 translist[W_G_HCW(W_HCW_KC,KEY_KP2)] = TWO;
389 translist[W_G_HCW(W_HCW_KC,KEY_KP1)] = ONE;
390 translist[W_G_HCW(W_HCW_KC,KEY_KP0)] = ZERO;
392 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_9)] = NINE;
393 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_8)] = EIGHT;
394 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_7)] = SEVEN;
395 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_6)] = SIX;
396 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_5)] = FIVE;
397 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_4)] = FOUR;
398 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_3)] = THREE;
399 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_2)] = TWO;
400 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_1)] = ONE;
401 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_0)] = ZERO;
402 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_STAR)] = STAR;
403 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_POUND)] = HASH;
406 translist[W_G_HCW(W_HCW_KC,KEY_J)] = GO; //j for JUMP TO instead of go to
407 translist[W_G_HCW(W_HCW_KC,KEY_R)] = RED;
408 translist[W_G_HCW(W_HCW_KC,KEY_G)] = GREEN;
409 translist[W_G_HCW(W_HCW_KC,KEY_Y)] = YELLOW;
410 translist[W_G_HCW(W_HCW_KC,KEY_B)] = BLUE;
411 //Processing Remote Style Messages
412 translist[W_G_HCW(W_HCW_KC,KEY_GREEN)] = GREEN;
413 translist[W_G_HCW(W_HCW_KC,KEY_RED)] = RED;
414 translist[W_G_HCW(W_HCW_KC,KEY_YELLOW)] = YELLOW;
415 translist[W_G_HCW(W_HCW_KC,KEY_BLUE)] = BLUE;
416 translist[W_G_HCW(W_HCW_KC,KEY_MENU)] = MENU;
418 translist[W_G_HCW(W_HCW_KC,KEY_RECORD)] = RECORD;
419 translist[W_G_HCW(W_HCW_KC,KEY_PLAY)] = PLAY; //Playback Televison
420 translist[W_G_HCW(W_HCW_KC,KEY_PAUSE)] = PAUSE;
421 translist[W_G_HCW(W_HCW_KC,KEY_STOP)] = STOP;
422 translist[W_G_HCW(W_HCW_KC,KEY_PLAYPAUSE)] = PLAYPAUSE;
423 translist[W_G_HCW(W_HCW_KC,KEY_P)] = PLAYPAUSE;
424 translist[W_G_HCW(W_HCW_KC,KEY_NEXT)] = SKIPFORWARD;
425 translist[W_G_HCW(W_HCW_KC,KEY_F2)] = SKIPFORWARD;
426 translist[W_G_HCW(W_HCW_KC,KEY_PREVIOUS)] = SKIPBACK;
427 translist[W_G_HCW(W_HCW_KC,KEY_F1)] = SKIPBACK;
428 translist[W_G_HCW(W_HCW_KC,KEY_FORWARD)] = FORWARD;
429 translist[W_G_HCW(W_HCW_KC,KEY_F)] = FORWARD;
430 translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE;
431 translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE;
432 translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE;
433 translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEUP;
434 translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEDOWN;
435 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP;
436 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN;
437 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP;
438 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELDOWN)] = CHANNELDOWN;
439 translist[W_G_HCW(W_HCW_KC,KEY_PAGEUP)] = CHANNELUP;
440 translist[W_G_HCW(W_HCW_KC,KEY_PAGEDOWN)] = CHANNELDOWN;
443 //Processing CEC_Messages
444 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER9)] = NINE;
445 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER8)] = EIGHT;
446 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER7)] = SEVEN;
447 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER6)] = SIX;
448 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER5)] = FIVE;
449 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER4)] = FOUR;
450 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER3)] = THREE;
451 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER2)] = TWO;
452 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER1)] = ONE;
453 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER0)] = ZERO;
454 translist[W_G_HCW(W_HCW_CEC,KEY_KPDOT)] = STAR;
458 //translist[W_G_HCW(W_HCW_CEC,KEY_J)] = GO; //j for JUMP TO instead of go to
459 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F2_RED)] = RED;
460 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F3_GREEN)] = GREEN;
461 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F4_YELLOW)] = YELLOW;
462 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F1_BLUE)] = BLUE;
463 //Processing Remote Style Messages
464 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAVORITE_MENU)] = MENU;
466 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RECORD)] = RECORD;
467 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PLAY)] = PLAY; //Playback Televison
468 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE)] = PAUSE;
469 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_STOP)] = STOP;
470 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION)] = PLAYPAUSE;
471 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FORWARD)] = SKIPFORWARD;
472 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_BACKWARD)] = SKIPBACK;
473 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAST_FORWARD )] = FORWARD;
474 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_REWIND)] = REVERSE;
475 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_MUTE)] = MUTE;
476 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_UP)] = VOLUMEUP;
477 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_DOWN)] = VOLUMEDOWN;
478 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_UP )] = CHANNELUP;
479 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_DOWN)] = CHANNELDOWN;
485 #define NAMETRICK(pre, code) linux_keymap[pre ## code]= #code
486 #define NAMETRICK2(pre, code) cec_keymap[pre ## code]= #code
487 //extracte from linux/input.h
489 static const char * linux_keymap[KEY_MAX+1];
490 static const char * cec_keymap[CEC_USER_CONTROL_CODE_MAX+1];
492 void RemoteLinux::InitKeymap()
494 for (int i=0;i<KEY_MAX+1;i++) {
495 linux_keymap[i]=NULL;
497 NAMETRICK(KEY_,RESERVED);
509 NAMETRICK(KEY_,MINUS);
510 NAMETRICK(KEY_,EQUAL);
511 NAMETRICK(KEY_,BACKSPACE);
523 NAMETRICK(KEY_,LEFTBRACE);
524 NAMETRICK(KEY_,RIGHTBRACE);
525 NAMETRICK(KEY_,ENTER);
526 NAMETRICK(KEY_,LEFTCTRL);
536 NAMETRICK(KEY_,SEMICOLON);
537 NAMETRICK(KEY_,APOSTROPHE);
538 NAMETRICK(KEY_,GRAVE);
539 NAMETRICK(KEY_,LEFTSHIFT);
540 NAMETRICK(KEY_,BACKSLASH);
548 NAMETRICK(KEY_,COMMA);
550 NAMETRICK(KEY_,SLASH);
551 NAMETRICK(KEY_,RIGHTSHIFT);
552 NAMETRICK(KEY_,KPASTERISK);
553 NAMETRICK(KEY_,LEFTALT);
554 NAMETRICK(KEY_,SPACE);
555 NAMETRICK(KEY_,CAPSLOCK);
566 NAMETRICK(KEY_,NUMLOCK);
567 NAMETRICK(KEY_,SCROLLLOCK);
571 NAMETRICK(KEY_,KPMINUS);
575 NAMETRICK(KEY_,KPPLUS);
580 NAMETRICK(KEY_,KPDOT);
583 NAMETRICK(KEY_,KPENTER);
584 NAMETRICK(KEY_,RIGHTCTRL);
585 NAMETRICK(KEY_,KPSLASH);
586 NAMETRICK(KEY_,SYSRQ);
587 NAMETRICK(KEY_,RIGHTALT);
588 NAMETRICK(KEY_,LINEFEED);
589 NAMETRICK(KEY_,HOME);
591 NAMETRICK(KEY_,PAGEUP);
592 NAMETRICK(KEY_,LEFT);
593 NAMETRICK(KEY_,RIGHT);
595 NAMETRICK(KEY_,DOWN);
596 NAMETRICK(KEY_,PAGEDOWN);
597 NAMETRICK(KEY_,INSERT);
598 NAMETRICK(KEY_,DELETE);
599 NAMETRICK(KEY_,MACRO);
600 NAMETRICK(KEY_,MUTE);
601 NAMETRICK(KEY_,VOLUMEDOWN);
602 NAMETRICK(KEY_,VOLUMEUP);
603 NAMETRICK(KEY_,POWER);
604 NAMETRICK(KEY_,KPEQUAL);
605 NAMETRICK(KEY_,KPPLUSMINUS);
606 NAMETRICK(KEY_,PLAY);
607 NAMETRICK(KEY_,PAUSE);
608 NAMETRICK(KEY_,SCALE);
609 NAMETRICK(KEY_,KPCOMMA);
611 NAMETRICK(KEY_,LEFTMETA);
612 NAMETRICK(KEY_,RIGHTMETA);
613 NAMETRICK(KEY_,COMPOSE);
614 NAMETRICK(KEY_,STOP);
615 NAMETRICK(KEY_,AGAIN);
616 NAMETRICK(KEY_,PROPS);
617 NAMETRICK(KEY_,UNDO);
618 NAMETRICK(KEY_,FRONT);
619 NAMETRICK(KEY_,COPY);
620 NAMETRICK(KEY_,OPEN);
621 NAMETRICK(KEY_,PASTE);
622 NAMETRICK(KEY_,FIND);
624 NAMETRICK(KEY_,HELP);
625 NAMETRICK(KEY_,MENU);
626 NAMETRICK(KEY_,CALC);
627 NAMETRICK(KEY_,SETUP);
628 NAMETRICK(KEY_,SLEEP);
629 NAMETRICK(KEY_,WAKEUP);
630 NAMETRICK(KEY_,FILE);
631 NAMETRICK(KEY_,SENDFILE);
632 NAMETRICK(KEY_,DELETEFILE);
633 NAMETRICK(KEY_,XFER);
634 NAMETRICK(KEY_,PROG1);
635 NAMETRICK(KEY_,PROG2);
637 NAMETRICK(KEY_,MSDOS);
638 NAMETRICK(KEY_,COFFEE);
639 NAMETRICK(KEY_,DIRECTION);
640 NAMETRICK(KEY_,CYCLEWINDOWS);
641 NAMETRICK(KEY_,MAIL);
642 NAMETRICK(KEY_,BOOKMARKS);
643 NAMETRICK(KEY_,COMPUTER);
644 NAMETRICK(KEY_,BACK);
645 NAMETRICK(KEY_,FORWARD);
646 NAMETRICK(KEY_,CLOSECD);
647 NAMETRICK(KEY_,EJECTCD);
648 NAMETRICK(KEY_,EJECTCLOSECD);
649 NAMETRICK(KEY_,NEXTSONG);
650 NAMETRICK(KEY_,PLAYPAUSE);
651 NAMETRICK(KEY_,PREVIOUSSONG);
652 NAMETRICK(KEY_,STOPCD);
653 NAMETRICK(KEY_,RECORD);
654 NAMETRICK(KEY_,REWIND);
655 NAMETRICK(KEY_,PHONE);
657 NAMETRICK(KEY_,CONFIG);
658 NAMETRICK(KEY_,HOMEPAGE);
659 NAMETRICK(KEY_,REFRESH);
660 NAMETRICK(KEY_,EXIT);
661 NAMETRICK(KEY_,MOVE);
662 NAMETRICK(KEY_,EDIT);
663 NAMETRICK(KEY_,SCROLLUP);
664 NAMETRICK(KEY_,SCROLLDOWN);
665 NAMETRICK(KEY_,KPLEFTPAREN);
666 NAMETRICK(KEY_,KPRIGHTPAREN);
668 NAMETRICK(KEY_,REDO);
670 NAMETRICK(KEY_,SELECT);
671 NAMETRICK(KEY_,GOTO);
672 NAMETRICK(KEY_,CLEAR);
673 NAMETRICK(KEY_,POWER2);
674 NAMETRICK(KEY_,OPTION);
675 NAMETRICK(KEY_,INFO);
676 NAMETRICK(KEY_,TIME);
677 NAMETRICK(KEY_,VENDOR);
678 NAMETRICK(KEY_,ARCHIVE);
679 NAMETRICK(KEY_,PROGRAM);
680 NAMETRICK(KEY_,CHANNEL);
681 NAMETRICK(KEY_,FAVORITES);
685 NAMETRICK(KEY_,LANGUAGE);
686 NAMETRICK(KEY_,TITLE);
687 NAMETRICK(KEY_,SUBTITLE);
688 NAMETRICK(KEY_,ANGLE);
689 NAMETRICK(KEY_,ZOOM);
690 NAMETRICK(KEY_,MODE);
691 NAMETRICK(KEY_,KEYBOARD);
692 NAMETRICK(KEY_,SCREEN);
694 NAMETRICK(KEY_,GREEN);
695 NAMETRICK(KEY_,YELLOW);
696 NAMETRICK(KEY_,BLUE);
697 NAMETRICK(KEY_,CHANNELUP);
698 NAMETRICK(KEY_,CHANNELDOWN);
699 NAMETRICK(KEY_,FIRST);
700 NAMETRICK(KEY_,LAST);
702 NAMETRICK(KEY_,NEXT);
703 NAMETRICK(KEY_,RESTART);
704 NAMETRICK(KEY_,SLOW);
705 NAMETRICK(KEY_,SHUFFLE);
706 NAMETRICK(KEY_,BREAK);
707 NAMETRICK(KEY_,PREVIOUS);
708 NAMETRICK(KEY_,DIGITS);
709 NAMETRICK(KEY_,TEEN);
710 NAMETRICK(KEY_,TWEN);
711 NAMETRICK(KEY_,VIDEOPHONE);
712 NAMETRICK(KEY_,GAMES);
713 NAMETRICK(KEY_,ZOOMIN);
714 NAMETRICK(KEY_,ZOOMOUT);
715 NAMETRICK(KEY_,ZOOMRESET);
716 NAMETRICK(KEY_,DOLLAR);
717 NAMETRICK(KEY_,EURO);
718 NAMETRICK(KEY_,FRAMEBACK);
719 NAMETRICK(KEY_,FRAMEFORWARD);
720 NAMETRICK(KEY_,CONTEXT_MENU);
721 NAMETRICK(KEY_,MEDIA_REPEAT);
722 NAMETRICK(KEY_,NUMERIC_0);
723 NAMETRICK(KEY_,NUMERIC_1);
724 NAMETRICK(KEY_,NUMERIC_2);
725 NAMETRICK(KEY_,NUMERIC_3);
726 NAMETRICK(KEY_,NUMERIC_4);
727 NAMETRICK(KEY_,NUMERIC_5);
728 NAMETRICK(KEY_,NUMERIC_6);
729 NAMETRICK(KEY_,NUMERIC_7);
730 NAMETRICK(KEY_,NUMERIC_8);
731 NAMETRICK(KEY_,NUMERIC_9);
732 NAMETRICK(KEY_,NUMERIC_STAR);
733 NAMETRICK(KEY_,NUMERIC_POUND);
735 for (int i=0;i<CEC_USER_CONTROL_CODE_MAX+1;i++) {
738 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT);
739 NAMETRICK2(CEC_USER_CONTROL_CODE_,UP);
740 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOWN);
741 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT);
742 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT);
743 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_UP);
744 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_DOWN);
745 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_UP);
746 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_DOWN);
747 NAMETRICK2(CEC_USER_CONTROL_CODE_,ROOT_MENU);
748 NAMETRICK2(CEC_USER_CONTROL_CODE_,SETUP_MENU);
749 NAMETRICK2(CEC_USER_CONTROL_CODE_,CONTENTS_MENU);
750 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAVORITE_MENU);
751 NAMETRICK2(CEC_USER_CONTROL_CODE_,EXIT);
752 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER0);
753 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER1);
754 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER2);
755 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER3);
756 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER4);
757 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER5);
758 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER6);
759 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER7);
760 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER8);
761 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER9);
762 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOT);
763 NAMETRICK2(CEC_USER_CONTROL_CODE_,ENTER);
764 NAMETRICK2(CEC_USER_CONTROL_CODE_,CLEAR);
765 NAMETRICK2(CEC_USER_CONTROL_CODE_,NEXT_FAVORITE);
766 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_UP);
767 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_DOWN);
768 NAMETRICK2(CEC_USER_CONTROL_CODE_,PREVIOUS_CHANNEL);
769 NAMETRICK2(CEC_USER_CONTROL_CODE_,SOUND_SELECT);
770 NAMETRICK2(CEC_USER_CONTROL_CODE_,INPUT_SELECT);
771 NAMETRICK2(CEC_USER_CONTROL_CODE_,DISPLAY_INFORMATION);
772 NAMETRICK2(CEC_USER_CONTROL_CODE_,HELP);
773 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_UP);
774 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_DOWN);
775 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER );
776 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_UP );
777 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_DOWN );
778 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE );
779 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY );
780 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP );
781 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE );
782 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD );
783 NAMETRICK2(CEC_USER_CONTROL_CODE_,REWIND );
784 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAST_FORWARD );
785 NAMETRICK2(CEC_USER_CONTROL_CODE_,EJECT );
786 NAMETRICK2(CEC_USER_CONTROL_CODE_,FORWARD );
787 NAMETRICK2(CEC_USER_CONTROL_CODE_,BACKWARD );
788 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_RECORD );
789 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD );
790 NAMETRICK2(CEC_USER_CONTROL_CODE_,ANGLE );
791 NAMETRICK2(CEC_USER_CONTROL_CODE_,SUB_PICTURE );
792 NAMETRICK2(CEC_USER_CONTROL_CODE_,VIDEO_ON_DEMAND );
793 NAMETRICK2(CEC_USER_CONTROL_CODE_,ELECTRONIC_PROGRAM_GUIDE );
794 NAMETRICK2(CEC_USER_CONTROL_CODE_,TIMER_PROGRAMMING );
795 NAMETRICK2(CEC_USER_CONTROL_CODE_,INITIAL_CONFIGURATION );
796 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY_FUNCTION );
797 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_PLAY_FUNCTION );
798 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD_FUNCTION );
799 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD_FUNCTION );
800 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_FUNCTION );
801 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE_FUNCTION );
802 NAMETRICK2(CEC_USER_CONTROL_CODE_,RESTORE_VOLUME_FUNCTION );
803 NAMETRICK2(CEC_USER_CONTROL_CODE_,TUNE_FUNCTION );
804 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_MEDIA_FUNCTION );
805 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AV_INPUT_FUNCTION );
806 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AUDIO_INPUT_FUNCTION );
807 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_TOGGLE_FUNCTION );
808 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_OFF_FUNCTION );
809 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_ON_FUNCTION );
810 NAMETRICK2(CEC_USER_CONTROL_CODE_,F1_BLUE );
811 NAMETRICK2(CEC_USER_CONTROL_CODE_,F2_RED );
812 NAMETRICK2(CEC_USER_CONTROL_CODE_,F3_GREEN );
813 NAMETRICK2(CEC_USER_CONTROL_CODE_,F4_YELLOW );
814 NAMETRICK2(CEC_USER_CONTROL_CODE_,F5 );
815 NAMETRICK2(CEC_USER_CONTROL_CODE_,DATA );
816 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_RETURN );
817 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_CHANNELS_LIST );
818 NAMETRICK2(CEC_USER_CONTROL_CODE_,MAX );
824 char* RemoteLinux::HCWDesc(unsigned long long hcw)
827 unsigned int type = hcw >> 32;
832 unsigned int vk=(ULONG)hcw;
834 const char *desc=linux_keymap[vk];
838 sprintf(rt,"0x%x",vk);
842 unsigned int vk=(ULONG)hcw;
844 const char *desc=cec_keymap[vk];
848 sprintf(rt,"0x%x",vk);
855 sprintf(rt,"R: %X",ri);
863 int RemoteLinux::cecLogMessage(void *param, const cec_log_message &message)
865 Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s",message.time , message.level, message.message );
869 int RemoteLinux::cecKeyPress(void*param, const cec_keypress &key)
871 //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key.keycode,key.duration);
872 if (key.duration==0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key.keycode);
875 int RemoteLinux::cecCommand(void *param, const cec_command &command)
877 //Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode);
881 int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration &config)
883 //Log::getInstance()->log("Remote", Log::DEBUG, "CECConfig:"/*,config.string()*/);
888 void RemoteLinux::incomingCECkey(int keys)
896 void RemoteLinux::Signal() {
902 void RemoteLinux::SendPower()