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(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 void RemoteWin::clearBuffer()
107 UCHAR RemoteWin::TranslateHWCFixed(ULLONG code)
111 case W_G_HCW(W_HCW_VK,VK_DOWN):
113 case W_G_HCW(W_HCW_VK,VK_UP):
115 case W_G_HCW(W_HCW_VK,VK_LEFT):
117 case W_G_HCW(W_HCW_VK,VK_RIGHT):
119 case W_G_HCW(W_HCW_CH,'m'):
121 case W_G_HCW(W_HCW_VK,VK_BACK):
123 case W_G_HCW(W_HCW_VK,VK_RETURN):
124 case W_G_HCW(W_HCW_VK,VK_SPACE):
126 /* Menu IDs, no sense to make it user selectable */
127 case W_G_HCW(W_HCW_AP,APPCOMMAND_BROWSER_BACKWARD):
129 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_DOWN):
130 return CHANNELDOWN;break;
131 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_UP):
132 return CHANNELUP;break;
133 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_FAST_FORWARD):
134 return FORWARD;break;
135 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_MUTE):
137 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PAUSE):
139 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PLAY):
141 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_RECORD):
143 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PREVIOUSTRACK):
144 return SKIPBACK;break;
145 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_REWIND):
146 return REVERSE;break;
147 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_NEXTTRACK):
148 return SKIPFORWARD;break;
149 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_STOP):
151 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_DOWN):
152 return VOLUMEDOWN;break;
153 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_UP):
154 return VOLUMEUP;break;
155 case W_G_HCW(W_HCW_AP,VOMP_YELLOW):
156 return YELLOW; break;
157 case W_G_HCW(W_HCW_AP,VOMP_BLUE):
159 case W_G_HCW(W_HCW_AP,VOMP_RED):
161 case W_G_HCW(W_HCW_AP,VOMP_GREEN):
163 case W_G_HCW(W_HCW_AP,VOMP_ENTER):
165 case W_G_HCW(W_HCW_AP,VOMP_CANCEL):
167 case W_G_HCW(W_HCW_AP,VOMP_UP):
169 case W_G_HCW(W_HCW_AP,VOMP_DOWN):
171 case W_G_HCW(W_HCW_AP,VOMP_LEFT):
173 case W_G_HCW(W_HCW_AP,VOMP_RIGHT):
182 const char*RemoteWin::HardcodedTranslateStr(UCHAR command)
197 return tr("Backspace, Back");
199 return tr("Return, Space");
201 return tr("Insrt, C+Insrt, Pg down");
203 return tr("+, C++, Pg up");
233 void RemoteWin::InitHWCListwithDefaults()
235 //Processing VK_Messages
236 translist[W_G_HCW(W_HCW_CH,'9')] = NINE;
237 translist[W_G_HCW(W_HCW_CH,'8')] = EIGHT;
238 translist[W_G_HCW(W_HCW_CH,'7')] = SEVEN;
239 translist[W_G_HCW(W_HCW_CH,'6')] = SIX;
240 translist[W_G_HCW(W_HCW_CH,'5')] = FIVE;
241 translist[W_G_HCW(W_HCW_CH,'4')] = FOUR;
242 translist[W_G_HCW(W_HCW_CH,'3')] = THREE;
243 translist[W_G_HCW(W_HCW_CH,'2')] = TWO;
244 translist[W_G_HCW(W_HCW_CH,'1')] = ONE;
245 translist[W_G_HCW(W_HCW_CH,'0')] = ZERO;
246 translist[W_G_HCW(W_HCW_CH,'*')] = STAR;
247 translist[W_G_HCW(W_HCW_CH,'#')] = HASH;
248 translist[W_G_HCW(W_HCW_CH,'j')] = GO; //j for JUMP TO instead of go to
249 translist[W_G_HCW(W_HCW_CH,'r')] = RED;
250 translist[W_G_HCW(W_HCW_CH,'g')] = GREEN;
251 translist[W_G_HCW(W_HCW_CH,'y')] = YELLOW;
252 translist[W_G_HCW(W_HCW_CH,'b')] = BLUE;
253 //Processing RI Messages
254 translist[W_G_HCW(W_HCW_RI,0x35c)] = GREEN;
255 translist[W_G_HCW(W_HCW_RI,0x35b)] = RED;
256 translist[W_G_HCW(W_HCW_RI,0x35d)] = YELLOW;
257 translist[W_G_HCW(W_HCW_RI,0x35e)] = BLUE;
258 translist[W_G_HCW(W_HCW_RI,0x30d)] = MENU;//MCE Button, used for Menu
259 translist[W_G_HCW(W_HCW_RI,0x348)] = RECORD; //Record Television
260 translist[W_G_HCW(W_HCW_RI,0x325)] = PLAY; //Playback Televison
261 translist[W_G_HCW(W_HCW_RI,0x324)] = PLAY; //Playback DVD
262 translist[W_G_HCW(W_HCW_RI,0x209)] = OK;//Properties
263 translist[W_G_HCW(W_HCW_RI,0x35a)] = OK;//Teletext?
267 char* RemoteWin::HCWDesc(ULLONG hcw)
270 ULONG type = hcw >> 32;
276 ULONG scancode=MapVirtualKey(vk,0);
278 GetKeyNameText(scancode << 16,rt,10);
282 ULONG scancode=OemKeyScan(ch);
285 GetKeyNameText(scancode << 16,rt,10);
290 sprintf(rt,"R: %X",ri);
298 int RemoteWin::ReceiveButtonVK(UINT button) {
300 //should we use a translation table ? No APPCOMMAND iS DWORD!
301 switch (button) { //Processing VK_Messages
345 case 'J'://j for JUMP TO instead of go to
363 }; //All other commands are process via APPCOMMAND_MESSAGES
364 if (pb==NA_NONE) return 0;*/
366 pb=TranslateHWC(W_G_HCW(W_HCW_VK,button));
367 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
375 int RemoteWin::ReceiveButtonCH(UINT button) {
377 pb=TranslateHWC(W_G_HCW(W_HCW_CH,button));
378 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
386 int RemoteWin::ReceiveButtonAP(UINT button) {
388 //should we use a translation table ? No APPCOMMAND iS DWORD!
389 switch (button) { //Processing VK_Messages
390 case APPCOMMAND_BROWSER_BACKWARD:
392 case APPCOMMAND_MEDIA_CHANNEL_DOWN:
393 pb=CHANNELDOWN;break;
394 case APPCOMMAND_MEDIA_CHANNEL_UP:
396 case APPCOMMAND_MEDIA_FAST_FORWARD:
398 case APPCOMMAND_VOLUME_MUTE:
400 case APPCOMMAND_MEDIA_PAUSE:
402 case APPCOMMAND_MEDIA_PLAY:
404 case APPCOMMAND_MEDIA_RECORD:
406 case APPCOMMAND_MEDIA_PREVIOUSTRACK:
408 case APPCOMMAND_MEDIA_REWIND:
410 case APPCOMMAND_MEDIA_NEXTTRACK:
411 pb=SKIPFORWARD;break;
412 case APPCOMMAND_MEDIA_STOP:
414 case APPCOMMAND_VOLUME_DOWN:
416 case APPCOMMAND_VOLUME_UP:
440 //if (pb==NA_NONE) return 0;
442 pb=TranslateHWC(W_G_HCW(W_HCW_AP,button));
443 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
451 int RemoteWin::ReceiveButtonRI(UINT button) {
454 /* Note Codes above 0x29c are not listed in the specs on usb.org
455 therefore they are used by try, they might be device dependent
456 thus please supply codes of your remote control */
457 /* switch (button) { //Processing VK_Messages
466 case 0x30d: //MCE Button, used for Menu
468 case 0x348: //Record Television
470 case 0x28d: //Attach File Mmh, how should we assign this
472 case 0x325: //Playback Televison
474 case 0x324: //Playback DVD
476 case 0x209: //Properties
477 case 0x35a: //Teletext?
482 if (pb==NA_NONE) return 0;*/
485 pb=TranslateHWC(W_G_HCW(W_HCW_RI,button));
486 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
494 void RemoteWin::Signal() {
500 void RemoteWin::SendPower()