2 Copyright 2004-2005 Chris Tallon
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 "remotewin.h"
22 #include "vompreswin.h"
25 #define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
27 #define W_HCW_VK 1 /* virtual key */
28 #define W_HCW_AP 2 /* App command */
29 #define W_HCW_RI 3 /* remote control */
30 #define W_HCW_CH 4 /* char */
32 RemoteWin::RemoteWin()
40 RemoteWin::~RemoteWin()
44 int RemoteWin::init(const char* devName)
46 if (initted) return 0;
48 event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);
54 int RemoteWin::shutdown()
56 if (!initted) return 0;
62 UCHAR RemoteWin::getButtonPress(int waitType)
65 how = 1 - start new wait
66 how = 2 - continue wait
83 } else { //We do not distingish between 2 and 3
87 WaitForSingleObject(event,wait);
92 return NA_SIGNAL; //Since we have no signals on windows, we simulate this
103 UCHAR RemoteWin::TranslateHWCFixed(ULLONG code)
107 case W_G_HCW(W_HCW_VK,VK_DOWN):
109 case W_G_HCW(W_HCW_VK,VK_UP):
111 case W_G_HCW(W_HCW_VK,VK_LEFT):
113 case W_G_HCW(W_HCW_VK,VK_RIGHT):
115 case W_G_HCW(W_HCW_CH,'m'):
117 case W_G_HCW(W_HCW_VK,VK_BACK):
119 case W_G_HCW(W_HCW_VK,VK_RETURN):
120 case W_G_HCW(W_HCW_VK,VK_SPACE):
122 /* Menu IDs, no sense to make it user selectable */
123 case W_G_HCW(W_HCW_AP,APPCOMMAND_BROWSER_BACKWARD):
125 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_DOWN):
126 return CHANNELDOWN;break;
127 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_UP):
128 return CHANNELUP;break;
129 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_FAST_FORWARD):
130 return FORWARD;break;
131 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_MUTE):
133 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PAUSE):
135 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PLAY):
137 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_RECORD):
139 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PREVIOUSTRACK):
140 return SKIPBACK;break;
141 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_REWIND):
142 return REVERSE;break;
143 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_NEXTTRACK):
144 return SKIPFORWARD;break;
145 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_STOP):
147 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_DOWN):
148 return VOLUMEDOWN;break;
149 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_UP):
150 return VOLUMEUP;break;
151 case W_G_HCW(W_HCW_AP,VOMP_YELLOW):
152 return YELLOW; break;
153 case W_G_HCW(W_HCW_AP,VOMP_BLUE):
155 case W_G_HCW(W_HCW_AP,VOMP_RED):
157 case W_G_HCW(W_HCW_AP,VOMP_GREEN):
159 case W_G_HCW(W_HCW_AP,VOMP_ENTER):
161 case W_G_HCW(W_HCW_AP,VOMP_CANCEL):
163 case W_G_HCW(W_HCW_AP,VOMP_UP):
165 case W_G_HCW(W_HCW_AP,VOMP_DOWN):
167 case W_G_HCW(W_HCW_AP,VOMP_LEFT):
169 case W_G_HCW(W_HCW_AP,VOMP_RIGHT):
178 const char*RemoteWin::HardcodedTranslateStr(UCHAR command)
193 return tr("Backspace, Back");
195 return tr("Return, Space");
197 return tr("Insrt, C+Insrt, Pg down");
199 return tr("+, C++, Pg up");
229 void RemoteWin::InitHWCListwithDefaults()
231 //Processing VK_Messages
232 translist[W_G_HCW(W_HCW_CH,'9')] = NINE;
233 translist[W_G_HCW(W_HCW_CH,'8')] = EIGHT;
234 translist[W_G_HCW(W_HCW_CH,'7')] = SEVEN;
235 translist[W_G_HCW(W_HCW_CH,'6')] = SIX;
236 translist[W_G_HCW(W_HCW_CH,'5')] = FIVE;
237 translist[W_G_HCW(W_HCW_CH,'4')] = FOUR;
238 translist[W_G_HCW(W_HCW_CH,'3')] = THREE;
239 translist[W_G_HCW(W_HCW_CH,'2')] = TWO;
240 translist[W_G_HCW(W_HCW_CH,'1')] = ONE;
241 translist[W_G_HCW(W_HCW_CH,'0')] = ZERO;
242 translist[W_G_HCW(W_HCW_CH,'*')] = STAR;
243 translist[W_G_HCW(W_HCW_CH,'#')] = HASH;
244 translist[W_G_HCW(W_HCW_CH,'j')] = GO; //j for JUMP TO instead of go to
245 translist[W_G_HCW(W_HCW_CH,'r')] = RED;
246 translist[W_G_HCW(W_HCW_CH,'g')] = GREEN;
247 translist[W_G_HCW(W_HCW_CH,'y')] = YELLOW;
248 translist[W_G_HCW(W_HCW_CH,'b')] = BLUE;
249 //Processing RI Messages
250 translist[W_G_HCW(W_HCW_RI,0x35c)] = GREEN;
251 translist[W_G_HCW(W_HCW_RI,0x35b)] = RED;
252 translist[W_G_HCW(W_HCW_RI,0x35d)] = YELLOW;
253 translist[W_G_HCW(W_HCW_RI,0x35e)] = BLUE;
254 translist[W_G_HCW(W_HCW_RI,0x30d)] = MENU;//MCE Button, used for Menu
255 translist[W_G_HCW(W_HCW_RI,0x348)] = RECORD; //Record Television
256 translist[W_G_HCW(W_HCW_RI,0x325)] = PLAY; //Playback Televison
257 translist[W_G_HCW(W_HCW_RI,0x324)] = PLAY; //Playback DVD
258 translist[W_G_HCW(W_HCW_RI,0x209)] = OK;//Properties
259 translist[W_G_HCW(W_HCW_RI,0x35a)] = OK;//Teletext?
263 char* RemoteWin::HCWDesc(ULLONG hcw)
266 ULONG type = hcw >> 32;
272 ULONG scancode=MapVirtualKey(vk,0);
274 GetKeyNameText(scancode << 16,rt,10);
278 ULONG scancode=OemKeyScan(ch);
281 GetKeyNameText(scancode << 16,rt,10);
286 sprintf(rt,"R: %X",ri);
294 int RemoteWin::ReceiveButtonVK(UINT button) {
296 //should we use a translation table ? No APPCOMMAND iS DWORD!
297 switch (button) { //Processing VK_Messages
341 case 'J'://j for JUMP TO instead of go to
359 }; //All other commands are process via APPCOMMAND_MESSAGES
360 if (pb==NA_NONE) return 0;*/
362 pb=TranslateHWC(W_G_HCW(W_HCW_VK,button));
363 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
371 int RemoteWin::ReceiveButtonCH(UINT button) {
373 pb=TranslateHWC(W_G_HCW(W_HCW_CH,button));
374 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
382 int RemoteWin::ReceiveButtonAP(UINT button) {
384 //should we use a translation table ? No APPCOMMAND iS DWORD!
385 switch (button) { //Processing VK_Messages
386 case APPCOMMAND_BROWSER_BACKWARD:
388 case APPCOMMAND_MEDIA_CHANNEL_DOWN:
389 pb=CHANNELDOWN;break;
390 case APPCOMMAND_MEDIA_CHANNEL_UP:
392 case APPCOMMAND_MEDIA_FAST_FORWARD:
394 case APPCOMMAND_VOLUME_MUTE:
396 case APPCOMMAND_MEDIA_PAUSE:
398 case APPCOMMAND_MEDIA_PLAY:
400 case APPCOMMAND_MEDIA_RECORD:
402 case APPCOMMAND_MEDIA_PREVIOUSTRACK:
404 case APPCOMMAND_MEDIA_REWIND:
406 case APPCOMMAND_MEDIA_NEXTTRACK:
407 pb=SKIPFORWARD;break;
408 case APPCOMMAND_MEDIA_STOP:
410 case APPCOMMAND_VOLUME_DOWN:
412 case APPCOMMAND_VOLUME_UP:
436 //if (pb==NA_NONE) return 0;
438 pb=TranslateHWC(W_G_HCW(W_HCW_AP,button));
439 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
447 int RemoteWin::ReceiveButtonRI(UINT button) {
450 /* Note Codes above 0x29c are not listed in the specs on usb.org
451 therefore they are used by try, they might be device dependent
452 thus please supply codes of your remote control */
453 /* switch (button) { //Processing VK_Messages
462 case 0x30d: //MCE Button, used for Menu
464 case 0x348: //Record Television
466 case 0x28d: //Attach File Mmh, how should we assign this
468 case 0x325: //Playback Televison
470 case 0x324: //Playback DVD
472 case 0x209: //Properties
473 case 0x35a: //Teletext?
478 if (pb==NA_NONE) return 0;*/
481 pb=TranslateHWC(W_G_HCW(W_HCW_RI,button));
482 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
490 void RemoteWin::Signal() {
496 void RemoteWin::SendPower()