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):
322 case W_G_HCW(W_HCW_KC,KEY_MEDIA):
324 case W_G_HCW(W_HCW_KC,KEY_BACKSPACE):
325 case W_G_HCW(W_HCW_KC,KEY_EXIT):
327 case W_G_HCW(W_HCW_KC,KEY_ENTER):
328 case W_G_HCW(W_HCW_KC,KEY_SPACE):
329 case W_G_HCW(W_HCW_KC,KEY_OK):
332 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_DOWN):
334 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_UP):
336 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_LEFT):
338 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RIGHT):
340 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ROOT_MENU):
341 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CONTENTS_MENU):
342 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SETUP_MENU):
344 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_EXIT ):
346 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_ENTER):
347 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_SELECT):
348 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_AN_RETURN):
350 case W_G_HCW(W_HCW_KC,KEY_SLEEP):
351 case W_G_HCW(W_HCW_KC,KEY_POWER):
352 case W_G_HCW(W_HCW_KC,KEY_ESC):
353 case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_POWER):
361 const char*RemoteLinux::HardcodedTranslateStr(UCHAR command)
376 return tr("Backspace, Back");
378 return tr("Return, Space");
386 void RemoteLinux::InitHWCListwithDefaults()
388 //Processing VK_Messages
389 translist[W_G_HCW(W_HCW_KC,KEY_9)] = NINE;
390 translist[W_G_HCW(W_HCW_KC,KEY_8)] = EIGHT;
391 translist[W_G_HCW(W_HCW_KC,KEY_7)] = SEVEN;
392 translist[W_G_HCW(W_HCW_KC,KEY_6)] = SIX;
393 translist[W_G_HCW(W_HCW_KC,KEY_5)] = FIVE;
394 translist[W_G_HCW(W_HCW_KC,KEY_4)] = FOUR;
395 translist[W_G_HCW(W_HCW_KC,KEY_3)] = THREE;
396 translist[W_G_HCW(W_HCW_KC,KEY_2)] = TWO;
397 translist[W_G_HCW(W_HCW_KC,KEY_1)] = ONE;
398 translist[W_G_HCW(W_HCW_KC,KEY_0)] = ZERO;
399 translist[W_G_HCW(W_HCW_KC,KEY_KPDOT)] = STAR;
400 // translist[W_G_HCW(W_HCW_KC,KEY_#)] = HASH;
402 translist[W_G_HCW(W_HCW_KC,KEY_KP9)] = NINE;
403 translist[W_G_HCW(W_HCW_KC,KEY_KP8)] = EIGHT;
404 translist[W_G_HCW(W_HCW_KC,KEY_KP7)] = SEVEN;
405 translist[W_G_HCW(W_HCW_KC,KEY_KP6)] = SIX;
406 translist[W_G_HCW(W_HCW_KC,KEY_KP5)] = FIVE;
407 translist[W_G_HCW(W_HCW_KC,KEY_KP4)] = FOUR;
408 translist[W_G_HCW(W_HCW_KC,KEY_KP3)] = THREE;
409 translist[W_G_HCW(W_HCW_KC,KEY_KP2)] = TWO;
410 translist[W_G_HCW(W_HCW_KC,KEY_KP1)] = ONE;
411 translist[W_G_HCW(W_HCW_KC,KEY_KP0)] = ZERO;
413 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_9)] = NINE;
414 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_8)] = EIGHT;
415 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_7)] = SEVEN;
416 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_6)] = SIX;
417 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_5)] = FIVE;
418 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_4)] = FOUR;
419 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_3)] = THREE;
420 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_2)] = TWO;
421 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_1)] = ONE;
422 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_0)] = ZERO;
423 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_STAR)] = STAR;
424 translist[W_G_HCW(W_HCW_KC,KEY_NUMERIC_POUND)] = HASH;
427 translist[W_G_HCW(W_HCW_KC,KEY_J)] = GO; //j for JUMP TO instead of go to
428 translist[W_G_HCW(W_HCW_KC,KEY_R)] = RED;
429 translist[W_G_HCW(W_HCW_KC,KEY_G)] = GREEN;
430 translist[W_G_HCW(W_HCW_KC,KEY_Y)] = YELLOW;
431 translist[W_G_HCW(W_HCW_KC,KEY_B)] = BLUE;
432 //Processing Remote Style Messages
433 translist[W_G_HCW(W_HCW_KC,KEY_GREEN)] = GREEN;
434 translist[W_G_HCW(W_HCW_KC,KEY_RED)] = RED;
435 translist[W_G_HCW(W_HCW_KC,KEY_YELLOW)] = YELLOW;
436 translist[W_G_HCW(W_HCW_KC,KEY_BLUE)] = BLUE;
437 translist[W_G_HCW(W_HCW_KC,KEY_MENU)] = MENU;
439 translist[W_G_HCW(W_HCW_KC,KEY_RECORD)] = RECORD;
440 translist[W_G_HCW(W_HCW_KC,KEY_PLAY)] = PLAY; //Playback Televison
441 translist[W_G_HCW(W_HCW_KC,KEY_PAUSE)] = PAUSE;
442 translist[W_G_HCW(W_HCW_KC,KEY_STOP)] = STOP;
443 translist[W_G_HCW(W_HCW_KC,KEY_PLAYPAUSE)] = PLAYPAUSE;
444 translist[W_G_HCW(W_HCW_KC,KEY_P)] = PLAYPAUSE;
445 translist[W_G_HCW(W_HCW_KC,KEY_NEXT)] = SKIPFORWARD;
446 translist[W_G_HCW(W_HCW_KC,KEY_F2)] = SKIPFORWARD;
447 translist[W_G_HCW(W_HCW_KC,KEY_PREVIOUS)] = SKIPBACK;
448 translist[W_G_HCW(W_HCW_KC,KEY_F1)] = SKIPBACK;
449 translist[W_G_HCW(W_HCW_KC,KEY_FORWARD)] = FORWARD;
450 translist[W_G_HCW(W_HCW_KC,KEY_FASTFORWARD)] = FORWARD;
451 translist[W_G_HCW(W_HCW_KC,KEY_F)] = FORWARD;
452 translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE;
453 translist[W_G_HCW(W_HCW_KC,KEY_REWIND)] = REVERSE;
454 translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE;
455 translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE;
456 translist[W_G_HCW(W_HCW_KC,KEY_F8)] = MUTE;
457 translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEUP;
458 translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEDOWN;
459 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP;
460 translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN;
461 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP;
462 translist[W_G_HCW(W_HCW_KC,KEY_CHANNELDOWN)] = CHANNELDOWN;
463 translist[W_G_HCW(W_HCW_KC,KEY_PAGEUP)] = CHANNELUP;
464 translist[W_G_HCW(W_HCW_KC,KEY_PAGEDOWN)] = CHANNELDOWN;
467 //Processing CEC_Messages
468 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER9)] = NINE;
469 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER8)] = EIGHT;
470 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER7)] = SEVEN;
471 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER6)] = SIX;
472 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER5)] = FIVE;
473 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER4)] = FOUR;
474 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER3)] = THREE;
475 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER2)] = TWO;
476 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER1)] = ONE;
477 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_NUMBER0)] = ZERO;
478 //translist[W_G_HCW(W_HCW_CEC,KEY_KPDOT)] = STAR;
482 //translist[W_G_HCW(W_HCW_CEC,KEY_J)] = GO; //j for JUMP TO instead of go to
483 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F2_RED)] = RED;
484 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F3_GREEN)] = GREEN;
485 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F4_YELLOW)] = YELLOW;
486 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_F1_BLUE)] = BLUE;
487 //Processing Remote Style Messages
488 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAVORITE_MENU)] = MENU;
490 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RECORD)] = RECORD;
491 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PLAY)] = PLAY; //Playback Televison
492 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE)] = PAUSE;
493 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_STOP)] = STOP;
494 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_PAUSE_PLAY_FUNCTION)] = PLAYPAUSE;
495 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FORWARD)] = SKIPFORWARD;
496 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_BACKWARD)] = SKIPBACK;
497 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_FAST_FORWARD )] = FORWARD;
498 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_REWIND)] = REVERSE;
499 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_MUTE)] = MUTE;
500 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_UP)] = VOLUMEUP;
501 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_VOLUME_DOWN)] = VOLUMEDOWN;
502 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_UP )] = CHANNELUP;
503 translist[W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_CHANNEL_DOWN)] = CHANNELDOWN;
507 #define NAMETRICK(pre, code) linux_keymap[pre ## code]= #code
508 #define NAMETRICK2(pre, code) cec_keymap[pre ## code]= #code
509 //extracte from linux/input.h
511 static const char * linux_keymap[KEY_MAX+1];
512 static const char * cec_keymap[CEC_USER_CONTROL_CODE_MAX+1];
514 void RemoteLinux::InitKeymap()
516 for (int i=0;i<KEY_MAX+1;i++) {
517 linux_keymap[i]=NULL;
519 NAMETRICK(KEY_,RESERVED);
531 NAMETRICK(KEY_,MINUS);
532 NAMETRICK(KEY_,EQUAL);
533 NAMETRICK(KEY_,BACKSPACE);
545 NAMETRICK(KEY_,LEFTBRACE);
546 NAMETRICK(KEY_,RIGHTBRACE);
547 NAMETRICK(KEY_,ENTER);
548 NAMETRICK(KEY_,LEFTCTRL);
558 NAMETRICK(KEY_,SEMICOLON);
559 NAMETRICK(KEY_,APOSTROPHE);
560 NAMETRICK(KEY_,GRAVE);
561 NAMETRICK(KEY_,LEFTSHIFT);
562 NAMETRICK(KEY_,BACKSLASH);
570 NAMETRICK(KEY_,COMMA);
572 NAMETRICK(KEY_,SLASH);
573 NAMETRICK(KEY_,RIGHTSHIFT);
574 NAMETRICK(KEY_,KPASTERISK);
575 NAMETRICK(KEY_,LEFTALT);
576 NAMETRICK(KEY_,SPACE);
577 NAMETRICK(KEY_,CAPSLOCK);
588 NAMETRICK(KEY_,NUMLOCK);
589 NAMETRICK(KEY_,SCROLLLOCK);
593 NAMETRICK(KEY_,KPMINUS);
597 NAMETRICK(KEY_,KPPLUS);
602 NAMETRICK(KEY_,KPDOT);
605 NAMETRICK(KEY_,KPENTER);
606 NAMETRICK(KEY_,RIGHTCTRL);
607 NAMETRICK(KEY_,KPSLASH);
608 NAMETRICK(KEY_,SYSRQ);
609 NAMETRICK(KEY_,RIGHTALT);
610 NAMETRICK(KEY_,LINEFEED);
611 NAMETRICK(KEY_,HOME);
613 NAMETRICK(KEY_,PAGEUP);
614 NAMETRICK(KEY_,LEFT);
615 NAMETRICK(KEY_,RIGHT);
617 NAMETRICK(KEY_,DOWN);
618 NAMETRICK(KEY_,PAGEDOWN);
619 NAMETRICK(KEY_,INSERT);
620 NAMETRICK(KEY_,DELETE);
621 NAMETRICK(KEY_,MACRO);
622 NAMETRICK(KEY_,MUTE);
623 NAMETRICK(KEY_,VOLUMEDOWN);
624 NAMETRICK(KEY_,VOLUMEUP);
625 NAMETRICK(KEY_,POWER);
626 NAMETRICK(KEY_,KPEQUAL);
627 NAMETRICK(KEY_,KPPLUSMINUS);
628 NAMETRICK(KEY_,PLAY);
629 NAMETRICK(KEY_,PAUSE);
630 NAMETRICK(KEY_,SCALE);
631 NAMETRICK(KEY_,KPCOMMA);
633 NAMETRICK(KEY_,LEFTMETA);
634 NAMETRICK(KEY_,RIGHTMETA);
635 NAMETRICK(KEY_,COMPOSE);
636 NAMETRICK(KEY_,STOP);
637 NAMETRICK(KEY_,AGAIN);
638 NAMETRICK(KEY_,PROPS);
639 NAMETRICK(KEY_,UNDO);
640 NAMETRICK(KEY_,FRONT);
641 NAMETRICK(KEY_,COPY);
642 NAMETRICK(KEY_,OPEN);
643 NAMETRICK(KEY_,PASTE);
644 NAMETRICK(KEY_,FIND);
646 NAMETRICK(KEY_,HELP);
647 NAMETRICK(KEY_,MENU);
648 NAMETRICK(KEY_,CALC);
649 NAMETRICK(KEY_,SETUP);
650 NAMETRICK(KEY_,SLEEP);
651 NAMETRICK(KEY_,WAKEUP);
652 NAMETRICK(KEY_,FILE);
653 NAMETRICK(KEY_,SENDFILE);
654 NAMETRICK(KEY_,DELETEFILE);
655 NAMETRICK(KEY_,XFER);
656 NAMETRICK(KEY_,PROG1);
657 NAMETRICK(KEY_,PROG2);
659 NAMETRICK(KEY_,MSDOS);
660 NAMETRICK(KEY_,COFFEE);
661 NAMETRICK(KEY_,DIRECTION);
662 NAMETRICK(KEY_,CYCLEWINDOWS);
663 NAMETRICK(KEY_,MAIL);
664 NAMETRICK(KEY_,BOOKMARKS);
665 NAMETRICK(KEY_,COMPUTER);
666 NAMETRICK(KEY_,BACK);
667 NAMETRICK(KEY_,FORWARD);
668 NAMETRICK(KEY_,FASTFORWARD);
669 NAMETRICK(KEY_,CLOSECD);
670 NAMETRICK(KEY_,EJECTCD);
671 NAMETRICK(KEY_,EJECTCLOSECD);
672 NAMETRICK(KEY_,NEXTSONG);
673 NAMETRICK(KEY_,PLAYPAUSE);
674 NAMETRICK(KEY_,PREVIOUSSONG);
675 NAMETRICK(KEY_,STOPCD);
676 NAMETRICK(KEY_,RECORD);
677 NAMETRICK(KEY_,REWIND);
678 NAMETRICK(KEY_,PHONE);
680 NAMETRICK(KEY_,CONFIG);
681 NAMETRICK(KEY_,HOMEPAGE);
682 NAMETRICK(KEY_,REFRESH);
683 NAMETRICK(KEY_,EXIT);
684 NAMETRICK(KEY_,MOVE);
685 NAMETRICK(KEY_,EDIT);
686 NAMETRICK(KEY_,SCROLLUP);
687 NAMETRICK(KEY_,SCROLLDOWN);
688 NAMETRICK(KEY_,KPLEFTPAREN);
689 NAMETRICK(KEY_,KPRIGHTPAREN);
691 NAMETRICK(KEY_,REDO);
693 NAMETRICK(KEY_,SELECT);
694 NAMETRICK(KEY_,GOTO);
695 NAMETRICK(KEY_,CLEAR);
696 NAMETRICK(KEY_,POWER2);
697 NAMETRICK(KEY_,OPTION);
698 NAMETRICK(KEY_,INFO);
699 NAMETRICK(KEY_,TIME);
700 NAMETRICK(KEY_,VENDOR);
701 NAMETRICK(KEY_,ARCHIVE);
702 NAMETRICK(KEY_,PROGRAM);
703 NAMETRICK(KEY_,CHANNEL);
704 NAMETRICK(KEY_,FAVORITES);
708 NAMETRICK(KEY_,LANGUAGE);
709 NAMETRICK(KEY_,TITLE);
710 NAMETRICK(KEY_,SUBTITLE);
711 NAMETRICK(KEY_,ANGLE);
712 NAMETRICK(KEY_,ZOOM);
713 NAMETRICK(KEY_,MODE);
714 NAMETRICK(KEY_,KEYBOARD);
715 NAMETRICK(KEY_,SCREEN);
717 NAMETRICK(KEY_,GREEN);
718 NAMETRICK(KEY_,YELLOW);
719 NAMETRICK(KEY_,BLUE);
720 NAMETRICK(KEY_,CHANNELUP);
721 NAMETRICK(KEY_,CHANNELDOWN);
722 NAMETRICK(KEY_,FIRST);
723 NAMETRICK(KEY_,LAST);
725 NAMETRICK(KEY_,NEXT);
726 NAMETRICK(KEY_,RESTART);
727 NAMETRICK(KEY_,SLOW);
728 NAMETRICK(KEY_,SHUFFLE);
729 NAMETRICK(KEY_,BREAK);
730 NAMETRICK(KEY_,PREVIOUS);
731 NAMETRICK(KEY_,DIGITS);
732 NAMETRICK(KEY_,TEEN);
733 NAMETRICK(KEY_,TWEN);
734 NAMETRICK(KEY_,VIDEOPHONE);
735 NAMETRICK(KEY_,GAMES);
736 NAMETRICK(KEY_,ZOOMIN);
737 NAMETRICK(KEY_,ZOOMOUT);
738 NAMETRICK(KEY_,ZOOMRESET);
739 NAMETRICK(KEY_,DOLLAR);
740 NAMETRICK(KEY_,EURO);
741 NAMETRICK(KEY_,MEDIA);
742 NAMETRICK(KEY_,FRAMEBACK);
743 NAMETRICK(KEY_,FRAMEFORWARD);
744 NAMETRICK(KEY_,CONTEXT_MENU);
745 NAMETRICK(KEY_,MEDIA_REPEAT);
746 NAMETRICK(KEY_,NUMERIC_0);
747 NAMETRICK(KEY_,NUMERIC_1);
748 NAMETRICK(KEY_,NUMERIC_2);
749 NAMETRICK(KEY_,NUMERIC_3);
750 NAMETRICK(KEY_,NUMERIC_4);
751 NAMETRICK(KEY_,NUMERIC_5);
752 NAMETRICK(KEY_,NUMERIC_6);
753 NAMETRICK(KEY_,NUMERIC_7);
754 NAMETRICK(KEY_,NUMERIC_8);
755 NAMETRICK(KEY_,NUMERIC_9);
756 NAMETRICK(KEY_,NUMERIC_STAR);
757 NAMETRICK(KEY_,NUMERIC_POUND);
759 for (int i=0;i<CEC_USER_CONTROL_CODE_MAX+1;i++) {
762 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT);
763 NAMETRICK2(CEC_USER_CONTROL_CODE_,UP);
764 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOWN);
765 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT);
766 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT);
767 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_UP);
768 NAMETRICK2(CEC_USER_CONTROL_CODE_,RIGHT_DOWN);
769 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_UP);
770 NAMETRICK2(CEC_USER_CONTROL_CODE_,LEFT_DOWN);
771 NAMETRICK2(CEC_USER_CONTROL_CODE_,ROOT_MENU);
772 NAMETRICK2(CEC_USER_CONTROL_CODE_,SETUP_MENU);
773 NAMETRICK2(CEC_USER_CONTROL_CODE_,CONTENTS_MENU);
774 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAVORITE_MENU);
775 NAMETRICK2(CEC_USER_CONTROL_CODE_,EXIT);
776 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER0);
777 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER1);
778 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER2);
779 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER3);
780 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER4);
781 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER5);
782 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER6);
783 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER7);
784 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER8);
785 NAMETRICK2(CEC_USER_CONTROL_CODE_,NUMBER9);
786 NAMETRICK2(CEC_USER_CONTROL_CODE_,DOT);
787 NAMETRICK2(CEC_USER_CONTROL_CODE_,ENTER);
788 NAMETRICK2(CEC_USER_CONTROL_CODE_,CLEAR);
789 NAMETRICK2(CEC_USER_CONTROL_CODE_,NEXT_FAVORITE);
790 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_UP);
791 NAMETRICK2(CEC_USER_CONTROL_CODE_,CHANNEL_DOWN);
792 NAMETRICK2(CEC_USER_CONTROL_CODE_,PREVIOUS_CHANNEL);
793 NAMETRICK2(CEC_USER_CONTROL_CODE_,SOUND_SELECT);
794 NAMETRICK2(CEC_USER_CONTROL_CODE_,INPUT_SELECT);
795 NAMETRICK2(CEC_USER_CONTROL_CODE_,DISPLAY_INFORMATION);
796 NAMETRICK2(CEC_USER_CONTROL_CODE_,HELP);
797 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_UP);
798 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAGE_DOWN);
799 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER );
800 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_UP );
801 NAMETRICK2(CEC_USER_CONTROL_CODE_,VOLUME_DOWN );
802 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE );
803 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY );
804 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP );
805 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE );
806 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD );
807 NAMETRICK2(CEC_USER_CONTROL_CODE_,REWIND );
808 NAMETRICK2(CEC_USER_CONTROL_CODE_,FAST_FORWARD );
809 NAMETRICK2(CEC_USER_CONTROL_CODE_,EJECT );
810 NAMETRICK2(CEC_USER_CONTROL_CODE_,FORWARD );
811 NAMETRICK2(CEC_USER_CONTROL_CODE_,BACKWARD );
812 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_RECORD );
813 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD );
814 NAMETRICK2(CEC_USER_CONTROL_CODE_,ANGLE );
815 NAMETRICK2(CEC_USER_CONTROL_CODE_,SUB_PICTURE );
816 NAMETRICK2(CEC_USER_CONTROL_CODE_,VIDEO_ON_DEMAND );
817 NAMETRICK2(CEC_USER_CONTROL_CODE_,ELECTRONIC_PROGRAM_GUIDE );
818 NAMETRICK2(CEC_USER_CONTROL_CODE_,TIMER_PROGRAMMING );
819 NAMETRICK2(CEC_USER_CONTROL_CODE_,INITIAL_CONFIGURATION );
820 NAMETRICK2(CEC_USER_CONTROL_CODE_,PLAY_FUNCTION );
821 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_PLAY_FUNCTION );
822 NAMETRICK2(CEC_USER_CONTROL_CODE_,RECORD_FUNCTION );
823 NAMETRICK2(CEC_USER_CONTROL_CODE_,PAUSE_RECORD_FUNCTION );
824 NAMETRICK2(CEC_USER_CONTROL_CODE_,STOP_FUNCTION );
825 NAMETRICK2(CEC_USER_CONTROL_CODE_,MUTE_FUNCTION );
826 NAMETRICK2(CEC_USER_CONTROL_CODE_,RESTORE_VOLUME_FUNCTION );
827 NAMETRICK2(CEC_USER_CONTROL_CODE_,TUNE_FUNCTION );
828 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_MEDIA_FUNCTION );
829 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AV_INPUT_FUNCTION );
830 NAMETRICK2(CEC_USER_CONTROL_CODE_,SELECT_AUDIO_INPUT_FUNCTION );
831 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_TOGGLE_FUNCTION );
832 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_OFF_FUNCTION );
833 NAMETRICK2(CEC_USER_CONTROL_CODE_,POWER_ON_FUNCTION );
834 NAMETRICK2(CEC_USER_CONTROL_CODE_,F1_BLUE );
835 NAMETRICK2(CEC_USER_CONTROL_CODE_,F2_RED );
836 NAMETRICK2(CEC_USER_CONTROL_CODE_,F3_GREEN );
837 NAMETRICK2(CEC_USER_CONTROL_CODE_,F4_YELLOW );
838 NAMETRICK2(CEC_USER_CONTROL_CODE_,F5 );
839 NAMETRICK2(CEC_USER_CONTROL_CODE_,DATA );
840 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_RETURN );
841 NAMETRICK2(CEC_USER_CONTROL_CODE_,AN_CHANNELS_LIST );
842 NAMETRICK2(CEC_USER_CONTROL_CODE_,MAX );
848 char* RemoteLinux::HCWDesc(unsigned long long hcw)
851 unsigned int type = hcw >> 32;
856 unsigned int vk=(ULONG)hcw;
858 const char *desc=linux_keymap[vk];
862 sprintf(rt,"0x%x",vk);
866 unsigned int vk=(ULONG)hcw;
868 const char *desc=cec_keymap[vk];
872 sprintf(rt,"0x%x",vk);
879 sprintf(rt,"R: %X",ri);
886 void RemoteLinux::changePowerState(bool poweron){
889 Log::getInstance()->log("Remote", Log::DEBUG, "CEC set active source" );
890 cec_adap->SetActiveSource();
892 Log::getInstance()->log("Remote", Log::DEBUG, "CEC set inactive view" );
893 cec_adap->SetInactiveView();
899 int RemoteLinux::cecLogMessage(void *param, const cec_log_message &message)
901 Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s",message.time , message.level, message.message );
905 int RemoteLinux::cecKeyPress(void*param, const cec_keypress &key)
907 //Log::getInstance()->log("Remote", Log::DEBUG, "Incoming cec key %d %d", key.keycode,key.duration);
908 if (key.duration==0) ((RemoteLinux*)Remote::getInstance())->incomingCECkey(key.keycode);
911 int RemoteLinux::cecCommand(void *param, const cec_command &command)
913 Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode);
917 int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration &config)
919 Log::getInstance()->log("Remote", Log::DEBUG, "CECConfig:"/*,config.string()*/);
924 void RemoteLinux::incomingCECkey(int keys)
931 bool RemoteLinux::loadOptionsfromServer(VDR* vdr)
936 name = vdr->configLoad("RemoteLinux", "HandleVolume");
939 if (STRCASECMP(name, "Vomp") == 0) {
940 cechandlesvolume=false;
941 } else if (STRCASECMP(name, "Cec") == 0) {
942 cechandlesvolume=true;
945 return Remote::loadOptionsfromServer(vdr);
948 bool RemoteLinux::saveOptionstoServer()
950 if (cechandlesvolume) VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Cec");
951 else VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Vomp");
953 return Remote::saveOptionstoServer();
956 bool RemoteLinux::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane)
958 if (!Remote::addOptionsToPanes(panenumber,options,pane)) return false;
964 static const char* volumeopts[]={"Vomp","Cec"};
965 option = new Option(100,tr("Volume handled by"), "RemoteLinux","HandleVolume",Option::TYPE_TEXT,/*4,2*/2,0,0,volumeopts,NULL,false,this);
966 options->push_back(option);
967 pane->addOptionLine(option);
973 bool RemoteLinux::handleOptionChanges(Option* option)
975 if (Remote::handleOptionChanges(option))
977 switch (option->id) {
979 if (STRCASECMP(option->options[option->userSetChoice], "Vomp") == 0) {
980 cechandlesvolume=false;
981 } else if (STRCASECMP(option->options[option->userSetChoice], "Cec")
983 cechandlesvolume=true;
985 Log::getInstance()->log("Remote", Log::DEBUG, "Set volume handling to to %s %d",option->options[option->userSetChoice],cechandlesvolume);
994 void RemoteLinux::volumeUp()
996 cec_adap->VolumeUp();
999 void RemoteLinux::volumeDown()
1001 cec_adap->VolumeDown();
1004 void RemoteLinux::volumeMute()
1006 cec_adap->MuteAudio();