]> git.vomp.tv Git - vompclient.git/blob - remotelinux.cc
Add led patch by dingo35
[vompclient.git] / remotelinux.cc
1 /*
2     Copyright 2004-2005 Chris Tallon; 2012 Marten Richter
3
4     This file is part of VOMP.
5
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.
10
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.
15
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.
19 */
20
21 #include "remotelinux.h"
22 #include "i18n.h"
23 #include "vdr.h"
24 #include "woptionpane.h"
25
26 #include <linux/input.h>
27 #include <sys/types.h>
28
29
30 #include <errno.h>
31
32 #include <sys/stat.h>
33 #include <fcntl.h>
34
35 #include <cstdio>
36 #include <iostream>
37 #include <ostream>
38
39 #include <bcm_host.h>
40
41 using namespace std;
42 using namespace CEC;
43
44 #include <libcec/cecloader.h>
45
46
47
48
49 #define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
50
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*/
54
55
56 RemoteLinux::RemoteLinux()
57 {
58   initted = 0;
59   curcec=0;
60   hascurcec=false;
61   signal=false;
62   cec_adap=NULL;
63   num_loop=0;
64   cechandlesvolume=false;
65
66 }
67
68 RemoteLinux::~RemoteLinux()
69 {
70         for (unsigned int i=0; i<devices.size();i++) {
71                 close(devices[i]);
72         }
73 }
74
75 #define test_bit(input,b)  ((1 << ((b) % 8))&(input)[b / 8] )
76
77
78 int RemoteLinux::init(char* devName)
79 {
80   if (initted) return 0;
81   initted = 1;
82
83   InitKeymap();
84
85   for (int eventid=0;eventid<100;eventid++){
86           char buffer[1024];
87           sprintf(buffer,"/dev/input/event%d",eventid);
88
89
90           struct stat test_buf;
91           if (stat(buffer,&test_buf)==0) {
92                   Log::getInstance()->log("Remote", Log::NOTICE, "Probe /dev/input/event%d",eventid);
93                   // file exists
94                   unsigned long ev_type=0;
95                   int new_fd=open(buffer,O_RDONLY);
96                   if (new_fd<0) {
97                           Log::getInstance()->log("Remote", Log::NOTICE, "Can not open /dev/input/event%d",eventid);
98                           continue;
99                   }
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);
102                       close(new_fd);
103                   }
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);
108                   } else {
109                           close(new_fd);
110                   }
111
112
113
114
115           }
116
117
118
119
120
121   }
122   return initCec();
123 }
124
125 int RemoteLinux::initCec() {
126
127   // bcm_host_init(); //may be move to custom hardware init?
128 // now init cec
129         Log::getInstance()->log("Remote", Log::NOTICE, "Init LibCEC");
130         cec_config.Clear();
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);
142
143         strncpy(cec_config.strDeviceName,"vomp",sizeof(cec_config.strDeviceName));
144
145
146         cec_config.callbackParam = NULL; // I do not care
147         cec_config.callbacks = &cec_callbacks;
148
149         cec_adap = LibCecInitialise(&cec_config);
150         if (!cec_adap) {
151                 Log::getInstance()->log("Remote", Log::ERR, "Init LibCEC failed");
152                 return 1;
153         }
154         cec_adap->InitVideoStandalone();
155
156
157         cec_adapter  cec_devices[10];
158         int adap_num=cec_adap->FindAdapters(cec_devices,10,NULL);
159         if (adap_num<0) {
160                 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to find adapter");
161                 return 1;
162
163         }
164         if (adap_num==0) {
165                 Log::getInstance()->log("Remote", Log::NOTICE, "CEC: No adapter found");
166                 return 1;
167
168         }
169         if (!cec_adap->Open(cec_devices[0].comm)) {
170                 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed to open adapter");
171                 return 1;
172         }
173
174         if (!cec_adap->SetActiveSource(cec_config.deviceTypes[0])) {
175                 Log::getInstance()->log("Remote", Log::ERR, "CEC:Failed set active source");
176                 return 1;
177         }
178
179
180
181
182   return 1;
183 }
184
185 int RemoteLinux::shutdown()
186 {
187   if (!initted) return 0;
188   deinitCec();
189   while (devices.size()) {
190           int cur_fd = devices.back();
191           devices.pop_back();
192           close(cur_fd);
193   }
194
195   initted = 0;
196   return 1;
197 }
198
199 void RemoteLinux::deinitCec()
200 {
201         if (cec_adap) {
202                 Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec begin");
203                 cec_adap->SetInactiveView();
204                 cec_adap->Close();
205                 vc_cec_register_callback(NULL, NULL);//deactivate callback!
206                 UnloadLibCec(cec_adap);
207                 cec_adap = NULL;
208                 Log::getInstance()->log("Remote", Log::NOTICE, "Shutdown libcec end");
209         }
210
211 }
212
213 UCHAR RemoteLinux::getButtonPress(int waitType) {
214         /* how = 0 - block
215          how = 1 - start new wait
216          how = 2 - continue wait
217          how = 3 - no wait
218          */
219
220          //in units of 40 ms
221
222         int retval;
223         fd_set readfds;
224         struct timeval tv;
225
226         tv.tv_sec = 0;
227         tv.tv_usec = 40000;
228         if (waitType == 0) {
229                 num_loop = -1;
230         } else if (waitType == 1) {
231
232                 num_loop = 25;
233         } else if (waitType == 2) {
234                 if (num_loop<=0) num_loop = 25;
235         } else if (waitType == 3) {
236                 tv.tv_sec = 0;
237                 tv.tv_usec = 0;
238                 num_loop = 0;
239         }
240
241
242         int ret = 0;
243         while (num_loop!=0) {
244                 ret = NA_UNKNOWN;
245                 FD_ZERO(&readfds);
246
247                 int maxfd = 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);
252                 }
253
254                 retval = select(maxfd + 1, &readfds, NULL, NULL, &tv);
255                 tv.tv_sec = 0;
256                 tv.tv_usec = 40000;
257                 // 0 = nothing happened
258                 // 1 = data arrived (actually num of descriptors that changed)
259                 // other value = signal or error
260                 if (retval == 0) {
261                         if (hascurcec) {
262                                 hascurcec = false;
263                                 return (UCHAR) TranslateHWC(W_G_HCW(W_HCW_CEC,curcec));
264                         }
265                         ret = NA_NONE;
266                 } else {
267                         if (retval == -1) {
268                                 Log::getInstance()->log("Remote", Log::NOTICE, "na_signal");
269                                 return NA_SIGNAL;
270
271                         }
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));
281                                                         return retty;
282                                                 }
283                                         }
284
285                                 }
286
287                         }
288
289                 }
290                 //Log::getInstance()->log("Remote", Log::NOTICE, "numloop: %d %d",num_loop,retval);
291                 if (num_loop > 0)
292                 num_loop--;
293         }
294         if (ret != 0)
295                 return ret;
296
297         return NA_UNKNOWN;
298
299 }
300
301 void RemoteLinux::clearBuffer()
302 {
303         UCHAR buttonpress=getButtonPress(3);
304           while(buttonpress != NA_NONE && buttonpress!=NA_UNKNOWN){
305                   buttonpress=getButtonPress(3);
306           };
307 }
308
309 UCHAR RemoteLinux::TranslateHWCFixed(ULLONG code)
310 {
311     switch (code) 
312     {
313     case W_G_HCW(W_HCW_KC,KEY_DOWN):
314         return DOWN;
315     case W_G_HCW(W_HCW_KC,KEY_UP):
316         return UP;
317     case W_G_HCW(W_HCW_KC,KEY_LEFT):
318         return LEFT;
319     case W_G_HCW(W_HCW_KC,KEY_RIGHT):
320         return RIGHT;
321     case W_G_HCW(W_HCW_KC,KEY_M):
322     case W_G_HCW(W_HCW_KC,KEY_MEDIA):
323         return MENU;
324     case W_G_HCW(W_HCW_KC,KEY_BACKSPACE):
325     case W_G_HCW(W_HCW_KC,KEY_EXIT):
326         return BACK;
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):
330         return OK;
331     //CEC
332     case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_DOWN):
333         return DOWN;
334     case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_UP):
335         return UP;
336     case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_LEFT):
337         return LEFT;
338     case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_RIGHT):
339         return 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):
343         return MENU;
344     case W_G_HCW(W_HCW_CEC,CEC_USER_CONTROL_CODE_EXIT ):
345         return BACK;
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):
349         return OK;
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):
354     case POWER:
355         return POWER;
356     default:
357         return NA_UNKNOWN;
358     };
359 }
360
361 const char*RemoteLinux::HardcodedTranslateStr(UCHAR command)
362 {
363     switch (command) 
364     {
365     case DOWN:
366         return tr("Down");
367     case UP:
368         return tr("Up");
369     case LEFT:
370         return tr("Left");
371     case RIGHT:
372         return tr("Right");
373     case MENU:
374         return tr("M");
375     case BACK:
376         return tr("Backspace, Back");
377     case OK:
378         return tr("Return, Space");
379     default:
380         return NULL;
381     };
382     
383 }
384
385
386 void RemoteLinux::InitHWCListwithDefaults()
387 {
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;
401
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;
412
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;
425
426
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;
438
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;
465
466
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;
479
480
481
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;
489
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;
504
505 }
506
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
510
511 static const char * linux_keymap[KEY_MAX+1];
512 static const char * cec_keymap[CEC_USER_CONTROL_CODE_MAX+1];
513
514 void RemoteLinux::InitKeymap()
515 {
516         for (int i=0;i<KEY_MAX+1;i++) {
517                 linux_keymap[i]=NULL;
518         }
519         NAMETRICK(KEY_,RESERVED);
520         NAMETRICK(KEY_,ESC);
521         NAMETRICK(KEY_,1);
522         NAMETRICK(KEY_,2);
523         NAMETRICK(KEY_,3);
524         NAMETRICK(KEY_,4);
525         NAMETRICK(KEY_,5);
526         NAMETRICK(KEY_,6);
527         NAMETRICK(KEY_,7);
528         NAMETRICK(KEY_,8);
529         NAMETRICK(KEY_,9);
530         NAMETRICK(KEY_,0);
531         NAMETRICK(KEY_,MINUS);
532         NAMETRICK(KEY_,EQUAL);
533         NAMETRICK(KEY_,BACKSPACE);
534         NAMETRICK(KEY_,TAB);
535         NAMETRICK(KEY_,Q);
536         NAMETRICK(KEY_,W);
537         NAMETRICK(KEY_,E);
538         NAMETRICK(KEY_,R);
539         NAMETRICK(KEY_,T);
540         NAMETRICK(KEY_,Y);
541         NAMETRICK(KEY_,U);
542         NAMETRICK(KEY_,I);
543         NAMETRICK(KEY_,O);
544         NAMETRICK(KEY_,P);
545         NAMETRICK(KEY_,LEFTBRACE);
546         NAMETRICK(KEY_,RIGHTBRACE);
547         NAMETRICK(KEY_,ENTER);
548         NAMETRICK(KEY_,LEFTCTRL);
549         NAMETRICK(KEY_,A);
550         NAMETRICK(KEY_,S);
551         NAMETRICK(KEY_,D);
552         NAMETRICK(KEY_,F);
553         NAMETRICK(KEY_,G);
554         NAMETRICK(KEY_,H);
555         NAMETRICK(KEY_,J);
556         NAMETRICK(KEY_,K);
557         NAMETRICK(KEY_,L);
558         NAMETRICK(KEY_,SEMICOLON);
559         NAMETRICK(KEY_,APOSTROPHE);
560         NAMETRICK(KEY_,GRAVE);
561         NAMETRICK(KEY_,LEFTSHIFT);
562         NAMETRICK(KEY_,BACKSLASH);
563         NAMETRICK(KEY_,Z);
564         NAMETRICK(KEY_,X);
565         NAMETRICK(KEY_,C);
566         NAMETRICK(KEY_,V);
567         NAMETRICK(KEY_,B);
568         NAMETRICK(KEY_,N);
569         NAMETRICK(KEY_,M);
570         NAMETRICK(KEY_,COMMA);
571         NAMETRICK(KEY_,DOT);
572         NAMETRICK(KEY_,SLASH);
573         NAMETRICK(KEY_,RIGHTSHIFT);
574         NAMETRICK(KEY_,KPASTERISK);
575         NAMETRICK(KEY_,LEFTALT);
576         NAMETRICK(KEY_,SPACE);
577         NAMETRICK(KEY_,CAPSLOCK);
578         NAMETRICK(KEY_,F1);
579         NAMETRICK(KEY_,F2);
580         NAMETRICK(KEY_,F3);
581         NAMETRICK(KEY_,F4);
582         NAMETRICK(KEY_,F5);
583         NAMETRICK(KEY_,F6);
584         NAMETRICK(KEY_,F7);
585         NAMETRICK(KEY_,F8);
586         NAMETRICK(KEY_,F9);
587         NAMETRICK(KEY_,F10);
588         NAMETRICK(KEY_,NUMLOCK);
589         NAMETRICK(KEY_,SCROLLLOCK);
590         NAMETRICK(KEY_,KP7);
591         NAMETRICK(KEY_,KP8);
592         NAMETRICK(KEY_,KP9);
593         NAMETRICK(KEY_,KPMINUS);
594         NAMETRICK(KEY_,KP4);
595         NAMETRICK(KEY_,KP5);
596         NAMETRICK(KEY_,KP6);
597         NAMETRICK(KEY_,KPPLUS);
598         NAMETRICK(KEY_,KP1);
599         NAMETRICK(KEY_,KP2);
600         NAMETRICK(KEY_,KP3);
601         NAMETRICK(KEY_,KP0);
602         NAMETRICK(KEY_,KPDOT);
603         NAMETRICK(KEY_,F11);
604         NAMETRICK(KEY_,F12);
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);
612         NAMETRICK(KEY_,UP);
613         NAMETRICK(KEY_,PAGEUP);
614         NAMETRICK(KEY_,LEFT);
615         NAMETRICK(KEY_,RIGHT);
616         NAMETRICK(KEY_,END);
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);
632         NAMETRICK(KEY_,YEN);
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);
645         NAMETRICK(KEY_,CUT);
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);
658         NAMETRICK(KEY_,WWW);
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);
679         NAMETRICK(KEY_,ISO);
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);
690         NAMETRICK(KEY_,NEW);
691         NAMETRICK(KEY_,REDO);
692         NAMETRICK(KEY_,OK);
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);
705         NAMETRICK(KEY_,EPG);
706         NAMETRICK(KEY_,PVR);
707         NAMETRICK(KEY_,MHP);
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);
716         NAMETRICK(KEY_,RED);
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);
724         NAMETRICK(KEY_,AB);
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);
758
759         for (int i=0;i<CEC_USER_CONTROL_CODE_MAX+1;i++) {
760                         cec_keymap[i]=NULL;
761         }
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 );
843
844 }
845
846
847
848 char* RemoteLinux::HCWDesc(unsigned long long hcw)
849 {
850     //Determine type
851     unsigned int type =  hcw >> 32;
852     char *rt=NULL;
853     switch(type)
854     {
855     case W_HCW_KC:{
856         unsigned int vk=(ULONG)hcw;
857         rt=new char[10];
858         const char *desc=linux_keymap[vk];
859         if (desc) {
860                 strncpy(rt,desc,9);
861         } else {
862                 sprintf(rt,"0x%x",vk);
863         }
864                   }break;
865     case W_HCW_CEC:{
866         unsigned int vk=(ULONG)hcw;
867         rt=new char[10];
868         const char *desc=cec_keymap[vk];
869         if (desc) {
870                 strncpy(rt,desc,9);
871         } else {
872                 sprintf(rt,"0x%x",vk);
873         }
874                   }break;
875   /*
876     case W_HCW_LIRC:{
877         ULONG ri=(ULONG)hcw;
878         rt=new char[10];
879         sprintf(rt,"R: %X",ri);
880                   }break;*/
881
882     };
883     return rt;
884 }
885
886 void RemoteLinux::changePowerState(bool poweron){
887         if (cec_adap) {
888                 if (poweron) {
889                         Log::getInstance()->log("Remote", Log::DEBUG, "CEC set active source" );
890                         cec_adap->SetActiveSource();
891                 } else {
892                         Log::getInstance()->log("Remote", Log::DEBUG, "CEC set inactive view" );
893                         cec_adap->SetInactiveView();
894                 }
895         }
896 }
897
898
899 int RemoteLinux::cecLogMessage(void *param, const cec_log_message &message)
900 {
901         Log::getInstance()->log("Remote", Log::DEBUG, "CECLOG: %lld %d %s",message.time , message.level, message.message );
902         return 0;
903 }
904
905 int RemoteLinux::cecKeyPress(void*param, const cec_keypress &key)
906 {
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);
909         return 1;
910 }
911 int RemoteLinux::cecCommand(void *param, const cec_command &command)
912 {
913         Log::getInstance()->log("Remote", Log::DEBUG, "CECCommand: %d",command.opcode);
914         return 1;
915 }
916
917 int RemoteLinux::cecConfigurationChanged(void *param, const libcec_configuration &config)
918 {
919         Log::getInstance()->log("Remote", Log::DEBUG, "CECConfig:"/*,config.string()*/);
920         return 1;
921
922 }
923
924 void RemoteLinux::incomingCECkey(int keys)
925 {
926         curcec=keys;
927         hascurcec=true;
928
929 }
930
931 bool RemoteLinux::loadOptionsfromServer(VDR* vdr)
932 {
933
934    // Set remote keys
935   char * name;
936   name = vdr->configLoad("RemoteLinux", "HandleVolume");
937
938   if (name != NULL) {
939                 if (STRCASECMP(name, "Vomp") == 0) {
940                         cechandlesvolume=false;
941                 } else if (STRCASECMP(name, "Cec") == 0) {
942                         cechandlesvolume=true;
943                 }
944         }
945   return Remote::loadOptionsfromServer(vdr);
946 }
947
948 bool RemoteLinux::saveOptionstoServer()
949 {
950         if (cechandlesvolume) VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Cec");
951         else VDR::getInstance()->configSave("RemoteLinux", "HandleVolume","Vomp");
952
953     return Remote::saveOptionstoServer();
954 }
955
956 bool RemoteLinux::addOptionsToPanes(int panenumber,Options *options,WOptionPane* pane)
957 {
958     if (!Remote::addOptionsToPanes(panenumber,options,pane)) return false;
959
960
961     Option* option;
962     if (panenumber == 2)
963     {
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);
968     }
969
970     return true;
971 }
972
973 bool RemoteLinux::handleOptionChanges(Option* option)
974 {
975     if (Remote::handleOptionChanges(option))
976                 return true;
977         switch (option->id) {
978         case 100: {
979                 if (STRCASECMP(option->options[option->userSetChoice], "Vomp") == 0) {
980                         cechandlesvolume=false;
981                 }  else if (STRCASECMP(option->options[option->userSetChoice], "Cec")
982                                 == 0) {
983                         cechandlesvolume=true;
984                 }
985                 Log::getInstance()->log("Remote", Log::DEBUG, "Set volume handling to to %s %d",option->options[option->userSetChoice],cechandlesvolume);
986                 return true;
987         }
988         break;
989         };
990         return false;
991
992 }
993
994 void RemoteLinux::volumeUp()
995 {
996         cec_adap->VolumeUp();
997 }
998
999 void RemoteLinux::volumeDown()
1000 {
1001         cec_adap->VolumeDown();
1002 }
1003
1004 void RemoteLinux::volumeMute()
1005 {
1006         cec_adap->MuteAudio();
1007 }
1008