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"
24 #include "woptionpane.h"
26 #include <linux/input.h>
27 #include <sys/types.h>
44 #include <libcec/cecloader.h>
49 #define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
51 #define W_HCW_KC 1 /* key code as defined by kernel for keyboard and remotes through /dev/input */
52 #define W_HCW_CEC 2 /* HDMI_CEC */
53 #define W_HCW_LIRC 3 /* remote control LIRC*/
56 RemoteLinux::RemoteLinux()
64 cechandlesvolume=false;
68 RemoteLinux::~RemoteLinux()
70 for (unsigned int i=0; i<devices.size();i++) {
75 #define test_bit(input,b) ((1 << ((b) % 8))&(input)[b / 8] )
78 int RemoteLinux::init(char* devName)
80 if (initted) return 0;
85 for (int eventid=0;eventid<100;eventid++){
87 sprintf(buffer,"/dev/input/event%d",eventid);
91 if (stat(buffer,&test_buf)==0) {
92 Log::getInstance()->log("Remote", Log::NOTICE, "Probe /dev/input/event%d",eventid);
94 unsigned long ev_type=0;
95 int new_fd=open(buffer,O_RDONLY);
97 Log::getInstance()->log("Remote", Log::NOTICE, "Can not open /dev/input/event%d",eventid);
100 if (ioctl(new_fd, EVIOCGBIT(0, EV_MAX), &ev_type) < 0) {
101 Log::getInstance()->log("Remote", Log::NOTICE, "Ioctl failed /dev/input/event%d %d",eventid,errno);
104 //Now test if it generates keyboard presses
105 if (test_bit((char*)&ev_type , EV_KEY)) {
106 Log::getInstance()->log("Remote", Log::NOTICE, "Add /dev/input/event%d to List",eventid);
107 devices.push_back(new_fd);
125 int RemoteLinux::initCec() {
127 // bcm_host_init(); //may be move to custom hardware init?
129 Log::getInstance()->log("Remote", Log::NOTICE, "Init LibCEC");
131 cec_callbacks.Clear();
132 cec_callbacks.CBCecLogMessage = cecLogMessage;
133 cec_callbacks.CBCecKeyPress = cecKeyPress;
134 cec_callbacks.CBCecCommand = cecCommand;
135 cec_callbacks.CBCecConfigurationChanged = cecConfigurationChanged;
136 cec_config.clientVersion=LIBCEC_VERSION_CURRENT;
137 cec_config.bActivateSource=1;
138 cec_config.bUseTVMenuLanguage=1;
139 //cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
140 cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_RECORDING_DEVICE);
141 //cec_config.deviceTypes.Add(CEC_DEVICE_TYPE_TUNER);
143 strncpy(cec_config.strDeviceName,"vomp",sizeof(cec_config.strDeviceName));
146 cec_config.callbackParam = NULL; // I do not care
147 cec_config.callbacks = &cec_callbacks;
149 cec_adap = LibCecInitialise(&cec_config);
151 Log::getInstance()->log("Remote", Log::ERR, "Init LibCEC failed");
154 cec_adap->InitVideoStandalone();
157 cec_adapter cec_devices[10];
158 int adap_num=cec_adap->FindAdapters(cec_devices,10,NULL);
160 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to find adapter");
165 Log::getInstance()->log("Remote", Log::NOTICE, "CEC: No adapter found");
169 if (!cec_adap->Open(cec_devices[0].comm)) {
170 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to open adapter");
174 if (!cec_adap->SetActiveSource(cec_config.deviceTypes[0])) {
175 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed set active source");
185 int RemoteLinux::shutdown()
187 if (!initted) return 0;
189 while (devices.size()) {
190 int cur_fd = devices.back();
199 void RemoteLinux::deinitCec()
202 Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec begin");
203 cec_adap->SetInactiveView();
205 vc_cec_register_callback(NULL, NULL);//deactivate callback!
206 UnloadLibCec(cec_adap);
208 Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec end");
213 UCHAR RemoteLinux::getButtonPress(int waitType) {
215 how = 1 - start new wait
216 how = 2 - continue wait
230 } else if (waitType == 1) {
233 } else if (waitType == 2) {
234 if (num_loop<=0) num_loop = 25;
235 } else if (waitType == 3) {
243 while (num_loop!=0) {
248 for (int i = 0; i < devices.size(); i++) {
249 int cur_fd = devices[i];
250 maxfd = max(cur_fd, maxfd);
251 FD_SET(cur_fd, &readfds);
254 retval = select(maxfd + 1, &readfds, NULL, NULL, &tv);
257 // 0 = nothing happened
258 // 1 = data arrived (actually num of descriptors that changed)
259 // other value = signal or error
263 return (UCHAR) TranslateHWC(W_G_HCW(W_HCW_CEC,curcec));
268 Log::getInstance()->log("Remote", Log::NOTICE, "na_signal");
272 for (int i = 0; i < devices.size(); i++) {
273 int cur_fd = devices[i];
274 if (FD_ISSET(cur_fd, &readfds)) {
275 struct input_event ev;
276 int count = read(cur_fd, &ev, sizeof(ev));
277 if (count == sizeof(ev)) {
278 if (ev.type == EV_KEY && ev.value == 1) {
279 UCHAR retty=(UCHAR) TranslateHWC(
280 W_G_HCW(W_HCW_KC,ev.code));
290 //Log::getInstance()->log("Remote", Log::NOTICE, "numloop: %d %d",num_loop,retval);
301 void RemoteLinux::clearBuffer()
303 UCHAR buttonpress=getButtonPress(3);
304 while(buttonpress != NA_NONE && buttonpress!=NA_UNKNOWN){
305 buttonpress=getButtonPress(3);
309 UCHAR RemoteLinux::TranslateHWCFixed(ULLONG code)
313 case W_G_HCW(W_HCW_KC,KEY_DOWN):
315 case W_G_HCW(W_HCW_KC,KEY_UP):
317 case W_G_HCW(W_HCW_KC,KEY_LEFT):
319 case W_G_HCW(W_HCW_KC,KEY_RIGHT):
321 case W_G_HCW(W_HCW_KC,KEY_M):
323 case W_G_HCW(W_HCW_KC,KEY_BACKSPACE):
325 case W_G_HCW(W_HCW_KC,KEY_ENTER):
326 case W_G_HCW(W_HCW_KC,KEY_SPACE):
327 case W_G_HCW(W_HCW_KC,KEY_OK):
330 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_DOWN):
332 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_UP):
334 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_LEFT):
336 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RIGHT):
338 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ROOT_MENU):
339 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CONTENTS_MENU):
340 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SETUP_MENU):
342 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_EXIT ):
344 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ENTER):
345 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SELECT):
346 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_AN_RETURN):
348 case W_G_HCW(W_HCW_KC,KEY_POWER):
349 case W_G_HCW(W_HCW_KC,KEY_ESC):
350 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_POWER):
358 const char*RemoteLinux::HardcodedTranslateStr(UCHAR command)
373 return tr("Backspace, Back");
375 return tr("Return, Space");
383 void RemoteLinux::InitHWCListwithDefaults()
385 //Processing VK_Messages
386 translist[W_G_HCW(W_HCW_KC,KEY_9)] = NINE;
387 translist[W_G_HCW(W_HCW_KC,KEY_8)] = EIGHT;
388 translist[W_G_HCW(W_HCW_KC,KEY_7)] = SEVEN;
389 translist[W_G_HCW(W_HCW_KC,KEY_6)] = SIX;
390 translist[W_G_HCW(W_HCW_KC,KEY_5)] = FIVE;
391 translist[W_G_HCW(W_HCW_KC,KEY_4)] = FOUR;
392 translist[W_G_HCW(W_HCW_KC,KEY_3)] = THREE;
393 translist[W_G_HCW(W_HCW_KC,KEY_2)] = TWO;
394 translist[W_G_HCW(W_HCW_KC,KEY_1)] = ONE;
395 translist[W_G_HCW(W_HCW_KC,KEY_0)] = ZERO;
396 translist[W_G_HCW(W_HCW_KC,KEY_KPDOT)] = STAR;
397 // translist[W_G_HCW(W_HCW_KC,KEY_#)] = HASH;
399 translist[W_G_HCW(W_HCW_KC,KEY_KP9)] = NINE;
400 translist[W_G_HCW(W_HCW_KC,KEY_KP8)] = EIGHT;
401 translist[W_G_HCW(W_HCW_KC,KEY_KP7)] = SEVEN;
402 translist[W_G_HCW(W_HCW_KC,KEY_KP6)] = SIX;
403 translist[W_G_HCW(W_HCW_KC,KEY_KP5)] = FIVE;
404 translist[W_G_HCW(W_HCW_KC,KEY_KP4)] = FOUR;
405 translist[W_G_HCW(W_HCW_KC,KEY_KP3)] = THREE;
406 translist[W_G_HCW(W_HCW_KC,KEY_KP2)] = TWO;
407 translist[W_G_HCW(W_HCW_KC,KEY_KP1)] = ONE;
408 translist[W_G_HCW(W_HCW_KC,KEY_KP0)] = ZERO;
410 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_9)] = NINE;
411 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_8)] = EIGHT;
412 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_7)] = SEVEN;
413 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_6)] = SIX;
414 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_5)] = FIVE;
415 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_4)] = FOUR;
416 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_3)] = THREE;
417 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_2)] = TWO;
418 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_1)] = ONE;
419 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_0)] = ZERO;
420 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_STAR)] = STAR;
421 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_POUND)] = HASH;
424 translist[W_G_HCW(W_HCW_KC,KEY_J)] = GO; //j for JUMP TO instead of go to
425 translist[W_G_HCW(W_HCW_KC,KEY_R)] = RED;
426 translist[W_G_HCW(W_HCW_KC,KEY_G)] = GREEN;
427 translist[W_G_HCW(W_HCW_KC,KEY_Y)] = YELLOW;
428 translist[W_G_HCW(W_HCW_KC,KEY_B)] = BLUE;
429 //Processing Remote Style Messages
430 translist[W_G_HCW(W_HCW_KC,KEY_GREEN)] = GREEN;
431 translist[W_G_HCW(W_HCW_KC,KEY_RED)] = RED;
432 translist[W_G_HCW(W_HCW_KC,KEY_YELLOW)] = YELLOW;
433 translist[W_G_HCW(W_HCW_KC,KEY_BLUE)] = BLUE;
434 translist[W_G_HCW(W_HCW_KC,KEY_MENU)] = MENU;
436 translist[W_G_HCW(W_HCW_KC,KEY_RECORD)] = RECORD;
437 translist[W_G_HCW(W_HCW_KC,KEY_PLAY)] = PLAY; //Playback Televison
438 translist[W_G_HCW(W_HCW_KC,KEY_PAUSE)] = PAUSE;
439 translist[W_G_HCW(W_HCW_KC,KEY_STOP)] = STOP;
440 translist[W_G_HCW(W_HCW_KC,KEY_PLAYPAUSE)] = PLAYPAUSE;
441 translist[W_G_HCW(W_HCW_KC,KEY_P)] = PLAYPAUSE;
442 translist[W_G_HCW(W_HCW_KC,KEY_NEXT)] = SKIPFORWARD;
443 translist[W_G_HCW(W_HCW_KC,KEY_F2)] = SKIPFORWARD;
444 translist[W_G_HCW(W_HCW_KC,KEY_PREVIOUS)] = SKIPBACK;
445 translist[W_G_HCW(W_HCW_KC,KEY_F1)] = SKIPBACK;
446 translist[W_G_HCW(W_HCW_KC,KEY_FORWARD)] = FORWARD;
447 translist[W_G_HCW(W_HCW_KC,KEY_F)] = FORWARD;
448 translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE;
449 translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE;
450 translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE;
451 translist[W_G_HCW(W_HCW_KC,KEY_F8)] = MUTE;
452 translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEUP;
453 translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEDOWN;
454 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP;
455 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN;
456 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP;
457 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELDOWN)] = CHANNELDOWN;
458 translist[W_G_HCW(W_HCW_KC,KEY_PAGEUP)] = CHANNELUP;
459 translist[W_G_HCW(W_HCW_KC,KEY_PAGEDOWN)] = CHANNELDOWN;
462 //Processing CEC_Messages
463 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER9)] = NINE;
464 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER8)] = EIGHT;
465 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER7)] = SEVEN;
466 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER6)] = SIX;
467 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER5)] = FIVE;
468 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER4)] = FOUR;
469 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER3)] = THREE;
470 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER2)] = TWO;
471 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER1)] = ONE;
472 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER0)] = ZERO;
473 //translist[W_G_HCW(W_HCW_CEC,KEY_KPDOT)] = STAR;
477 //translist[W_G_HCW(W_HCW_CEC,KEY_J)] = GO; //j for JUMP TO instead of go to
478 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F2_RED)] = RED;
479 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F3_GREEN)] = GREEN;
480 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F4_YELLOW)] = YELLOW;
481 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F1_BLUE)] = BLUE;
482 //Processing Remote Style Messages
483 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAVORITE_MENU)] = MENU;
485 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RECORD)] = RECORD;
486 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PLAY)] = PLAY; //Playback Televison
487 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE)] = PAUSE;
488 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_STOP)] = STOP;
489 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION)] = PLAYPAUSE;
490 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FORWARD)] = SKIPFORWARD;
491 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_BACKWARD)] = SKIPBACK;
492 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAST_FORWARD )] = FORWARD;
493 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_REWIND)] = REVERSE;
494 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_MUTE)] = MUTE;
495 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_UP)] = VOLUMEUP;
496 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_DOWN)] = VOLUMEDOWN;
497 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_UP )] = CHANNELUP;
498 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_DOWN)] = CHANNELDOWN;
502 #define NAMETRICK(pre, code) linux_keymap[pre ## code]= #code
503 #define NAMETRICK2(pre, code) cec_keymap[pre ## code]= #code
504 //extracte from linux/input.h
506 static const char * linux_keymap[KEY_MAX+1];
507 static const char * cec_keymap[CEC_USER_CONTROL_CODE_MAX+1];
509 void RemoteLinux::InitKeymap()
511 for (int i=0;i<KEY_MAX+1;i++) {
512 linux_keymap[i]=NULL;
514 NAMETRICK(KEY_,RESERVED);
526 NAMETRICK(KEY_,MINUS);
527 NAMETRICK(KEY_,EQUAL);
528 NAMETRICK(KEY_,BACKSPACE);
540 NAMETRICK(KEY_,LEFTBRACE);
541 NAMETRICK(KEY_,RIGHTBRACE);
542 NAMETRICK(KEY_,ENTER);
543 NAMETRICK(KEY_,LEFTCTRL);
553 NAMETRICK(KEY_,SEMICOLON);
554 NAMETRICK(KEY_,APOSTROPHE);
555 NAMETRICK(KEY_,GRAVE);
556 NAMETRICK(KEY_,LEFTSHIFT);
557 NAMETRICK(KEY_,BACKSLASH);
565 NAMETRICK(KEY_,COMMA);
567 NAMETRICK(KEY_,SLASH);
568 NAMETRICK(KEY_,RIGHTSHIFT);
569 NAMETRICK(KEY_,KPASTERISK);
570 NAMETRICK(KEY_,LEFTALT);
571 NAMETRICK(KEY_,SPACE);
572 NAMETRICK(KEY_,CAPSLOCK);
583 NAMETRICK(KEY_,NUMLOCK);
584 NAMETRICK(KEY_,SCROLLLOCK);
588 NAMETRICK(KEY_,KPMINUS);
592 NAMETRICK(KEY_,KPPLUS);
597 NAMETRICK(KEY_,KPDOT);
600 NAMETRICK(KEY_,KPENTER);
601 NAMETRICK(KEY_,RIGHTCTRL);
602 NAMETRICK(KEY_,KPSLASH);
603 NAMETRICK(KEY_,SYSRQ);
604 NAMETRICK(KEY_,RIGHTALT);
605 NAMETRICK(KEY_,LINEFEED);
606 NAMETRICK(KEY_,HOME);
608 NAMETRICK(KEY_,PAGEUP);
609 NAMETRICK(KEY_,LEFT);
610 NAMETRICK(KEY_,RIGHT);
612 NAMETRICK(KEY_,DOWN);
613 NAMETRICK(KEY_,PAGEDOWN);
614 NAMETRICK(KEY_,INSERT);
615 NAMETRICK(KEY_,DELETE);
616 NAMETRICK(KEY_,MACRO);
617 NAMETRICK(KEY_,MUTE);
618 NAMETRICK(KEY_,VOLUMEDOWN);
619 NAMETRICK(KEY_,VOLUMEUP);
620 NAMETRICK(KEY_,POWER);
621 NAMETRICK(KEY_,KPEQUAL);
622 NAMETRICK(KEY_,KPPLUSMINUS);
623 NAMETRICK(KEY_,PLAY);
624 NAMETRICK(KEY_,PAUSE);
625 NAMETRICK(KEY_,SCALE);
626 NAMETRICK(KEY_,KPCOMMA);
628 NAMETRICK(KEY_,LEFTMETA);
629 NAMETRICK(KEY_,RIGHTMETA);
630 NAMETRICK(KEY_,COMPOSE);
631 NAMETRICK(KEY_,STOP);
632 NAMETRICK(KEY_,AGAIN);
633 NAMETRICK(KEY_,PROPS);
634 NAMETRICK(KEY_,UNDO);
635 NAMETRICK(KEY_,FRONT);
636 NAMETRICK(KEY_,COPY);
637 NAMETRICK(KEY_,OPEN);
638 NAMETRICK(KEY_,PASTE);
639 NAMETRICK(KEY_,FIND);
641 NAMETRICK(KEY_,HELP);
642 NAMETRICK(KEY_,MENU);
643 NAMETRICK(KEY_,CALC);
644 NAMETRICK(KEY_,SETUP);
645 NAMETRICK(KEY_,SLEEP);
646 NAMETRICK(KEY_,WAKEUP);
647 NAMETRICK(KEY_,FILE);
648 NAMETRICK(KEY_,SENDFILE);
649 NAMETRICK(KEY_,DELETEFILE);
650 NAMETRICK(KEY_,XFER);
651 NAMETRICK(KEY_,PROG1);
652 NAMETRICK(KEY_,PROG2);
654 NAMETRICK(KEY_,MSDOS);
655 NAMETRICK(KEY_,COFFEE);
656 NAMETRICK(KEY_,DIRECTION);
657 NAMETRICK(KEY_,CYCLEWINDOWS);
658 NAMETRICK(KEY_,MAIL);
659 NAMETRICK(KEY_,BOOKMARKS);
660 NAMETRICK(KEY_,COMPUTER);
661 NAMETRICK(KEY_,BACK);
662 NAMETRICK(KEY_,FORWARD);
663 NAMETRICK(KEY_,CLOSECD);
664 NAMETRICK(KEY_,EJECTCD);
665 NAMETRICK(KEY_,EJECTCLOSECD);
666 NAMETRICK(KEY_,NEXTSONG);
667 NAMETRICK(KEY_,PLAYPAUSE);
668 NAMETRICK(KEY_,PREVIOUSSONG);
669 NAMETRICK(KEY_,STOPCD);
670 NAMETRICK(KEY_,RECORD);
671 NAMETRICK(KEY_,REWIND);
672 NAMETRICK(KEY_,PHONE);
674 NAMETRICK(KEY_,CONFIG);
675 NAMETRICK(KEY_,HOMEPAGE);
676 NAMETRICK(KEY_,REFRESH);
677 NAMETRICK(KEY_,EXIT);
678 NAMETRICK(KEY_,MOVE);
679 NAMETRICK(KEY_,EDIT);
680 NAMETRICK(KEY_,SCROLLUP);
681 NAMETRICK(KEY_,SCROLLDOWN);
682 NAMETRICK(KEY_,KPLEFTPAREN);
683 NAMETRICK(KEY_,KPRIGHTPAREN);
685 NAMETRICK(KEY_,REDO);
687 NAMETRICK(KEY_,SELECT);
688 NAMETRICK(KEY_,GOTO);
689 NAMETRICK(KEY_,CLEAR);
690 NAMETRICK(KEY_,POWER2);
691 NAMETRICK(KEY_,OPTION);
692 NAMETRICK(KEY_,INFO);
693 NAMETRICK(KEY_,TIME);
694 NAMETRICK(KEY_,VENDOR);
695 NAMETRICK(KEY_,ARCHIVE);
696 NAMETRICK(KEY_,PROGRAM);
697 NAMETRICK(KEY_,CHANNEL);
698 NAMETRICK(KEY_,FAVORITES);
702 NAMETRICK(KEY_,LANGUAGE);
703 NAMETRICK(KEY_,TITLE);
704 NAMETRICK(KEY_,SUBTITLE);
705 NAMETRICK(KEY_,ANGLE);
706 NAMETRICK(KEY_,ZOOM);
707 NAMETRICK(KEY_,MODE);
708 NAMETRICK(KEY_,KEYBOARD);
709 NAMETRICK(KEY_,SCREEN);
711 NAMETRICK(KEY_,GREEN);
712 NAMETRICK(KEY_,YELLOW);
713 NAMETRICK(KEY_,BLUE);
714 NAMETRICK(KEY_,CHANNELUP);
715 NAMETRICK(KEY_,CHANNELDOWN);
716 NAMETRICK(KEY_,FIRST);
717 NAMETRICK(KEY_,LAST);
719 NAMETRICK(KEY_,NEXT);
720 NAMETRICK(KEY_,RESTART);
721 NAMETRICK(KEY_,SLOW);
722 NAMETRICK(KEY_,SHUFFLE);
723 NAMETRICK(KEY_,BREAK);
724 NAMETRICK(KEY_,PREVIOUS);
725 NAMETRICK(KEY_,DIGITS);
726 NAMETRICK(KEY_,TEEN);
727 NAMETRICK(KEY_,TWEN);
728 NAMETRICK(KEY_,VIDEOPHONE);
729 NAMETRICK(KEY_,GAMES);
730 NAMETRICK(KEY_,ZOOMIN);
731 NAMETRICK(KEY_,ZOOMOUT);
732 NAMETRICK(KEY_,ZOOMRESET);
733 NAMETRICK(KEY_,DOLLAR);
734 NAMETRICK(KEY_,EURO);
735 NAMETRICK(KEY_,FRAMEBACK);
736 NAMETRICK(KEY_,FRAMEFORWARD);
737 NAMETRICK(KEY_,CONTEXT_MENU);
738 NAMETRICK(KEY_,MEDIA_REPEAT);
739 NAMETRICK(KEY_,NUMERIC_0);
740 NAMETRICK(KEY_,NUMERIC_1);
741 NAMETRICK(KEY_,NUMERIC_2);
742 NAMETRICK(KEY_,NUMERIC_3);
743 NAMETRICK(KEY_,NUMERIC_4);
744 NAMETRICK(KEY_,NUMERIC_5);
745 NAMETRICK(KEY_,NUMERIC_6);
746 NAMETRICK(KEY_,NUMERIC_7);
747 NAMETRICK(KEY_,NUMERIC_8);
748 NAMETRICK(KEY_,NUMERIC_9);
749 NAMETRICK(KEY_,NUMERIC_STAR);
750 NAMETRICK(KEY_,NUMERIC_POUND);
752 for (int i=0;i<CEC_USER_CONTROL_CODE_MAX+1;i++) {
755 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT);
756 NAMETRICK2(CEC_USER_CONTROL_CODE_,UP);
757 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOWN);
758 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT);
759 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT);
760 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_UP);
761 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_DOWN);
762 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_UP);
763 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_DOWN);
764 NAMETRICK2(CEC_USER_CONTROL_CODE_,ROOT_MENU);
765 NAMETRICK2(CEC_USER_CONTROL_CODE_,SETUP_MENU);
766 NAMETRICK2(CEC_USER_CONTROL_CODE_,CONTENTS_MENU);
767 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAVORITE_MENU);
768 NAMETRICK2(CEC_USER_CONTROL_CODE_,EXIT);
769 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER0);
770 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER1);
771 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER2);
772 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER3);
773 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER4);
774 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER5);
775 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER6);
776 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER7);
777 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER8);
778 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER9);
779 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOT);
780 NAMETRICK2(CEC_USER_CONTROL_CODE_,ENTER);
781 NAMETRICK2(CEC_USER_CONTROL_CODE_,CLEAR);
782 NAMETRICK2(CEC_USER_CONTROL_CODE_,NEXT_FAVORITE);
783 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_UP);
784 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_DOWN);
785 NAMETRICK2(CEC_USER_CONTROL_CODE_,PREVIOUS_CHANNEL);
786 NAMETRICK2(CEC_USER_CONTROL_CODE_,SOUND_SELECT);
787 NAMETRICK2(CEC_USER_CONTROL_CODE_,INPUT_SELECT);
788 NAMETRICK2(CEC_USER_CONTROL_CODE_,DISPLAY_INFORMATION);
789 NAMETRICK2(CEC_USER_CONTROL_CODE_,HELP);
790 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_UP);
791 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_DOWN);
792 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER );
793 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_UP );
794 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_DOWN );
795 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE );
796 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY );
797 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP );
798 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE );
799 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD );
800 NAMETRICK2(CEC_USER_CONTROL_CODE_,REWIND );
801 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAST_FORWARD );
802 NAMETRICK2(CEC_USER_CONTROL_CODE_,EJECT );
803 NAMETRICK2(CEC_USER_CONTROL_CODE_,FORWARD );
804 NAMETRICK2(CEC_USER_CONTROL_CODE_,BACKWARD );
805 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_RECORD );
806 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD );
807 NAMETRICK2(CEC_USER_CONTROL_CODE_,ANGLE );
808 NAMETRICK2(CEC_USER_CONTROL_CODE_,SUB_PICTURE );
809 NAMETRICK2(CEC_USER_CONTROL_CODE_,VIDEO_ON_DEMAND );
810 NAMETRICK2(CEC_USER_CONTROL_CODE_,ELECTRONIC_PROGRAM_GUIDE );
811 NAMETRICK2(CEC_USER_CONTROL_CODE_,TIMER_PROGRAMMING );
812 NAMETRICK2(CEC_USER_CONTROL_CODE_,INITIAL_CONFIGURATION );
813 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY_FUNCTION );
814 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_PLAY_FUNCTION );
815 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD_FUNCTION );
816 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD_FUNCTION );
817 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_FUNCTION );
818 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE_FUNCTION );
819 NAMETRICK2(CEC_USER_CONTROL_CODE_,RESTORE_VOLUME_FUNCTION );
820 NAMETRICK2(CEC_USER_CONTROL_CODE_,TUNE_FUNCTION );
821 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_MEDIA_FUNCTION );
822 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AV_INPUT_FUNCTION );
823 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AUDIO_INPUT_FUNCTION );
824 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_TOGGLE_FUNCTION );
825 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_OFF_FUNCTION );
826 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_ON_FUNCTION );
827 NAMETRICK2(CEC_USER_CONTROL_CODE_,F1_BLUE );
828 NAMETRICK2(CEC_USER_CONTROL_CODE_,F2_RED );
829 NAMETRICK2(CEC_USER_CONTROL_CODE_,F3_GREEN );
830 NAMETRICK2(CEC_USER_CONTROL_CODE_,F4_YELLOW );
831 NAMETRICK2(CEC_USER_CONTROL_CODE_,F5 );
832 NAMETRICK2(CEC_USER_CONTROL_CODE_,DATA );
833 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_RETURN );
834 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_CHANNELS_LIST );
835 NAMETRICK2(CEC_USER_CONTROL_CODE_,MAX );
841 char* RemoteLinux::HCWDesc(unsigned long long hcw)
844 unsigned int type = hcw >> 32;
849 unsigned int vk=(ULONG)hcw;
851 const char *desc=linux_keymap[vk];
855 sprintf(rt,"0x%x",vk);
859 unsigned int vk=(ULONG)hcw;
861 const char *desc=cec_keymap[vk];
865 sprintf(rt,"0x%x",vk);
872 sprintf(rt,"R: %X",ri);
880 int RemoteLinux::cecLogMessage(void *param, const cec_log_message &message)
882 Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s",message.time , message.level, message.message );
886 int RemoteLinux::cecKeyPress(void*param, const cec_keypress &key)
888 //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key.keycode,key.duration);
889 if (key.duration==0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key.keycode);
892 int RemoteLinux::cecCommand(void *param, const cec_command &command)
894 //Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode);
898 int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration &config)
900 //Log::getInstance()->log("Remote", Log::DEBUG, "CECConfig:"/*,config.string()*/);
905 void RemoteLinux::incomingCECkey(int keys)
912 bool RemoteLinux::loadOptionsfromServer(VDR* vdr)
917 name = vdr->configLoad("RemoteLinux", "HandleVolume");
920 if (STRCASECMP(name, "Vomp") == 0) {
921 cechandlesvolume=false;
922 } else if (STRCASECMP(name, "Cec") == 0) {
923 cechandlesvolume=true;
926 return Remote::loadOptionsfromServer(vdr);
929 bool RemoteLinux::saveOptionstoServer()
931 if (cechandlesvolume) VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Cec");
932 else VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Vomp");
934 return Remote::saveOptionstoServer();
937 bool RemoteLinux::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane)
939 if (!Remote::addOptionsToPanes(panenumber,options,pane)) return false;
945 static const char* volumeopts[]={"Vomp","Cec"};
946 option = new Option(100,tr("Volume handled by"), "RemoteLinux","HandleVolume",Option::TYPE_TEXT,/*4,2*/2,0,0,volumeopts,NULL,false,this);
947 options->push_back(option);
948 pane->addOptionLine(option);
954 bool RemoteLinux::handleOptionChanges(Option* option)
956 if (Remote::handleOptionChanges(option))
958 switch (option->id) {
960 if (STRCASECMP(option->options[option->userSetChoice], "Vomp") == 0) {
961 cechandlesvolume=false;
962 } else if (STRCASECMP(option->options[option->userSetChoice], "Cec")
964 cechandlesvolume=true;
966 Log::getInstance()->log("Remote", Log::DEBUG, "Set volume handling to to %s %d",option->options[option->userSetChoice],cechandlesvolume);
975 void RemoteLinux::volumeUp()
977 cec_adap->VolumeUp();
980 void RemoteLinux::volumeDown()
982 cec_adap->VolumeDown();
985 void RemoteLinux::volumeMute()
987 cec_adap->MuteAudio();