2 Copyright 2004-2020 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, see <https://www.gnu.org/licenses/>.
20 #include "vompreswin.h"
25 #define W_G_HCW(type,code) ( (((u8)(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 static const char* TAG = "InputWin";
34 const char* InputWin::myModName = "InputWin";
46 if (initted) return false;
48 event = CreateEvent(NULL, /*FALSE*/TRUE, FALSE, NULL);
52 void InputWin::shutdown()
55 LogNT::getInstance()->debug(TAG, "Shutdown called");
61 u1 RemoteWin::getButtonPress(int waitType)
64 how = 1 - start new wait
65 how = 2 - continue wait
82 } else { //We do not distingish between 2 and 3
86 WaitForSingleObject(event,wait);
91 //return NA_SIGNAL; //Since we have no signals on windows, we simulate this
103 u1 InputWin::TranslateHWCFixed(HWC_TYPE 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):
127 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_UP):
129 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_FAST_FORWARD):
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):
141 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_REWIND):
143 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_NEXTTRACK):
145 case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_STOP):
147 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_DOWN):
149 case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_UP):
151 case W_G_HCW(W_HCW_AP,VOMP_YELLOW):
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* InputWin::getHardCodedHardwareKeyNameForVompKey(u1 vompKey)
193 return tr("Backspace, Back");
195 return tr("Return, Space");
197 return tr("Insrt, C+Insrt, Pg down");
199 return tr("+, C++, Pg up");
227 void InputWin::InitHWCListwithDefaults()
229 //Processing VK_Messages
230 translist[W_G_HCW(W_HCW_CH,'9')] = NINE;
231 translist[W_G_HCW(W_HCW_CH,'8')] = EIGHT;
232 translist[W_G_HCW(W_HCW_CH,'7')] = SEVEN;
233 translist[W_G_HCW(W_HCW_CH,'6')] = SIX;
234 translist[W_G_HCW(W_HCW_CH,'5')] = FIVE;
235 translist[W_G_HCW(W_HCW_CH,'4')] = FOUR;
236 translist[W_G_HCW(W_HCW_CH,'3')] = THREE;
237 translist[W_G_HCW(W_HCW_CH,'2')] = TWO;
238 translist[W_G_HCW(W_HCW_CH,'1')] = ONE;
239 translist[W_G_HCW(W_HCW_CH,'0')] = ZERO;
240 translist[W_G_HCW(W_HCW_CH,'*')] = STAR;
241 translist[W_G_HCW(W_HCW_CH,'#')] = HASH;
242 translist[W_G_HCW(W_HCW_CH,'j')] = GO; //j for JUMP TO instead of go to
243 translist[W_G_HCW(W_HCW_CH,'r')] = RED;
244 translist[W_G_HCW(W_HCW_CH,'g')] = GREEN;
245 translist[W_G_HCW(W_HCW_CH,'y')] = YELLOW;
246 translist[W_G_HCW(W_HCW_CH,'b')] = BLUE;
247 //Processing RI Messages
248 translist[W_G_HCW(W_HCW_RI,0x35c)] = GREEN;
249 translist[W_G_HCW(W_HCW_RI,0x35b)] = RED;
250 translist[W_G_HCW(W_HCW_RI,0x35d)] = YELLOW;
251 translist[W_G_HCW(W_HCW_RI,0x35e)] = BLUE;
252 translist[W_G_HCW(W_HCW_RI,0x30d)] = MENU; //MCE Button, used for Menu
253 translist[W_G_HCW(W_HCW_RI,0x348)] = RECORD; //Record Television
254 translist[W_G_HCW(W_HCW_RI,0x325)] = PLAY; //Playback Televison
255 translist[W_G_HCW(W_HCW_RI,0x324)] = PLAY; //Playback DVD
256 translist[W_G_HCW(W_HCW_RI,0x209)] = OK; //Properties
257 translist[W_G_HCW(W_HCW_RI,0x35a)] = OK; //Teletext?
260 std::string InputWin::getHardwareKeyName(HWC_TYPE hardwareKey)
263 u4 type = hardwareKey >> 32;
270 u4 vk = (u4)hardwareKey;
271 u4 scancode = MapVirtualKey(vk,0);
272 GetKeyNameText(scancode << 16, rt, 10);
277 u4 ch = (u4)hardwareKey;
278 u4 scancode = OemKeyScan(ch);
279 GetKeyNameText(scancode << 16, rt, 10);
284 u4 ri = (u4)hardwareKey;
285 sprintf(rt, "R: %X", ri);
290 std::string retval = rt;
294 int InputWin::ReceiveButtonVK(u4 button)
297 //should we use a translation table ? No APPCOMMAND iS DWORD!
298 switch (button) { //Processing VK_Messages
342 case 'J'://j for JUMP TO instead of go to
360 }; //All other commands are process via APPCOMMAND_MESSAGES
361 if (pb==NA_NONE) return 0;*/
363 u1 pb = TranslateHWC(W_G_HCW(W_HCW_VK,button));
364 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
376 int InputWin::ReceiveButtonCH(u4 button)
378 u1 pb = TranslateHWC(W_G_HCW(W_HCW_CH,button));
379 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
392 int InputWin::ReceiveButtonAP(u4 button)
395 //should we use a translation table ? No APPCOMMAND iS DWORD!
396 switch (button) { //Processing VK_Messages
397 case APPCOMMAND_BROWSER_BACKWARD:
399 case APPCOMMAND_MEDIA_CHANNEL_DOWN:
400 pb=CHANNELDOWN;break;
401 case APPCOMMAND_MEDIA_CHANNEL_UP:
403 case APPCOMMAND_MEDIA_FAST_FORWARD:
405 case APPCOMMAND_VOLUME_MUTE:
407 case APPCOMMAND_MEDIA_PAUSE:
409 case APPCOMMAND_MEDIA_PLAY:
411 case APPCOMMAND_MEDIA_RECORD:
413 case APPCOMMAND_MEDIA_PREVIOUSTRACK:
415 case APPCOMMAND_MEDIA_REWIND:
417 case APPCOMMAND_MEDIA_NEXTTRACK:
418 pb=SKIPFORWARD;break;
419 case APPCOMMAND_MEDIA_STOP:
421 case APPCOMMAND_VOLUME_DOWN:
423 case APPCOMMAND_VOLUME_UP:
447 //if (pb==NA_NONE) return 0;
450 u1 pb = TranslateHWC(W_G_HCW(W_HCW_AP,button));
451 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
463 int InputWin::ReceiveButtonRI(u4 button)
467 /* Note Codes above 0x29c are not listed in the specs on usb.org
468 therefore they are used by try, they might be device dependent
469 thus please supply codes of your remote control */
470 /* switch (button) { //Processing VK_Messages
479 case 0x30d: //MCE Button, used for Menu
481 case 0x348: //Record Television
483 case 0x28d: //Attach File Mmh, how should we assign this
485 case 0x325: //Playback Televison
487 case 0x324: //Playback DVD
489 case 0x209: //Properties
490 case 0x35a: //Teletext?
495 if (pb==NA_NONE) return 0;*/
497 u1 pb = TranslateHWC(W_G_HCW(W_HCW_RI,button));
498 if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
511 void InputWin::Signal()