2 * Copyright (c) 2007, IRTrans GmbH
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of IRTrans GmbH nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY IRTrans GmbH ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL IRTrans GmbH BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #define _WIN32_WINNT 0x501
39 #include <sys/timeb.h>
54 extern DEVICEINFO IRDevices
[MAX_IR_DEVICES
];
55 extern APP app_pnt
[30];
58 void SendMediaCenterAction (int app
,int com
);
59 void IRTransSendInput (int key
,int flags
);
60 void SendKey (APP
*app
,APPCOMMAND
*appcom
,byte flag
);
61 void ConvertLcase (char *pnt
,int len
);
62 void SendMediacenterEvent (int eventcode
);
63 void SendAppcommand (APP
*app
,APPCOMMAND
*appcom
);
64 void SendWMChar (APP
*app
,APPCOMMAND
*appcom
);
65 void HandleKeyboardScancodes (char scan
[]);
66 void HandleDirectScancodes (char scan
[]);
67 void HandleMouse (char mov
[]);
68 //------------------------------------------modified------------------------------------------
69 void HandleShortcut (char shortcut
[]);
73 unsigned int GetFineTime (void);
82 //#define MULTIKEY_TIMEOUT 1000
83 //------------------------------------------modified------------------------------------------
84 #define MULTIKEY_TIMEOUT 500
101 void PostWindowsMessage (int rem
,int com
,char name
[])
105 for (i
=0;i
< app_cnt
;i
++) if (app_pnt
[i
].remnum
== rem
) {
106 if (app_pnt
[i
].type
== TYPE_KEYBOARD
) HandleKeyboardScancodes (name
);
107 else if (app_pnt
[i
].type
== TYPE_SCANCODE
) HandleDirectScancodes (name
);
108 else if (app_pnt
[i
].type
== TYPE_MOUSE
) HandleMouse (name
);
109 //------------------------------------------modified------------------------------------------
110 else if (app_pnt
[i
].type
== TYPE_SHORTCUT
) HandleShortcut (name
);
113 else for (j
=0;j
< app_pnt
[i
].com_cnt
;j
++) if (app_pnt
[i
].com
[j
].comnum
== com
) {
114 appcom
= &(app_pnt
[i
].com
[j
]);
115 if (appcom
->type
[0] == TYPE_MCE
) SendMediaCenterAction (i
,j
);
116 if (appcom
->type
[0] == TYPE_KEY
) SendKey (app_pnt
+ i
,appcom
,0);
117 if (appcom
->type
[0] == TYPE_KEYF
) SendKey (app_pnt
+ i
,appcom
,1);
118 if (appcom
->type
[0] == TYPE_APPCOM
) SendAppcommand (app_pnt
+ i
,appcom
);
119 if (appcom
->type
[0] == TYPE_CHR
) SendWMChar (app_pnt
+ i
,appcom
);
124 //------------------------------------------modified------------------------------------------
125 void HandleShortcut (char shortcut
[])
127 ShellExecute(NULL
,"open",shortcut
,NULL
,NULL
,SW_SHOWNORMAL
); //execute shortcut in remotes folder
131 void HandleMouse (char mov
[])
133 static byte last_m1
,last_m2
;
145 memset (InpInfo
,0,sizeof (InpInfo
));
148 InpInfo
[p
].type
= INPUT_MOUSE
;
149 if (m1
) InpInfo
[p
].mi
.dwFlags
= MOUSEEVENTF_LEFTDOWN
;
150 else InpInfo
[p
].mi
.dwFlags
= MOUSEEVENTF_LEFTUP
;
154 InpInfo
[p
].type
= INPUT_MOUSE
;
155 if (m1
) InpInfo
[p
].mi
.dwFlags
= MOUSEEVENTF_RIGHTDOWN
;
156 else InpInfo
[p
].mi
.dwFlags
= MOUSEEVENTF_RIGHTUP
;
161 InpInfo
[p
].type
= INPUT_MOUSE
;
162 InpInfo
[p
].mi
.dx
= x
;
163 InpInfo
[p
].mi
.dy
= y
;
164 InpInfo
[p
].mi
.dwFlags
= MOUSEEVENTF_MOVE
;
168 if (p
) SendInput (p
,InpInfo
,sizeof (INPUT
));
174 void HandleDirectScancodes (char scan
[])
176 static byte last_scan
;
177 static byte last_flags
;
178 static unsigned int last_time
;
189 if (chr
>= 'a' && chr
<= 'f') chr
= chr
- 'a' + 10;
195 if (chr
>= 'a' && chr
<= 'f') chr
= chr
- 'a' + 10;
197 scancode
= scancode
* 16 + chr
;
204 if (scan
[p
] == '1') flags
|= key
;
209 if (flags
& SC_ALTGR
) flags
|= SC_ALT
| SC_CTRL_L
;
211 if (last_scan
== scancode
&& last_flags
!= flags
&& (GetFineTime () - last_time
) < 250) return;
213 layout
= GetKeyboardLayout (0);
215 if (scancode
== VK_APPS
) key
= VK_APPS
;
216 else key
= MapVirtualKeyEx (scancode
,1,layout
);
219 memset (InpInfo
,0,sizeof (InpInfo
));
222 if (flags
& SC_SHIFT_L
) {
223 InpInfo
[p
].type
= INPUT_KEYBOARD
;
224 InpInfo
[p
].ki
.wVk
= VK_LSHIFT
;
227 if (flags
& SC_SHIFT_R
) {
228 InpInfo
[p
].type
= INPUT_KEYBOARD
;
229 InpInfo
[p
].ki
.wVk
= VK_RSHIFT
;
232 if (flags
& SC_CTRL_L
) {
233 InpInfo
[p
].type
= INPUT_KEYBOARD
;
234 InpInfo
[p
].ki
.wVk
= VK_LCONTROL
;
237 if (flags
& SC_CTRL_R
) {
238 InpInfo
[p
].type
= INPUT_KEYBOARD
;
239 InpInfo
[p
].ki
.wVk
= VK_RCONTROL
;
242 if (flags
& SC_ALT
) {
243 InpInfo
[p
].type
= INPUT_KEYBOARD
;
244 InpInfo
[p
].ki
.wVk
= VK_MENU
;
247 if (flags
& SC_WIN_R
) {
248 InpInfo
[p
].type
= INPUT_KEYBOARD
;
249 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
254 InpInfo
[p
].type
= INPUT_KEYBOARD
;
255 InpInfo
[p
].ki
.wVk
= key
;
258 InpInfo
[p
].type
= INPUT_KEYBOARD
;
259 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
260 InpInfo
[p
].ki
.wVk
= key
;
264 if (flags
& SC_WIN_R
) {
265 InpInfo
[p
].type
= INPUT_KEYBOARD
;
266 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
267 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
270 if (flags
& SC_ALT
) {
271 InpInfo
[p
].type
= INPUT_KEYBOARD
;
272 InpInfo
[p
].ki
.wVk
= VK_MENU
;
273 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
276 if (flags
& SC_CTRL_R
) {
277 InpInfo
[p
].type
= INPUT_KEYBOARD
;
278 InpInfo
[p
].ki
.wVk
= VK_RCONTROL
;
279 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
282 if (flags
& SC_CTRL_L
) {
283 InpInfo
[p
].type
= INPUT_KEYBOARD
;
284 InpInfo
[p
].ki
.wVk
= VK_LCONTROL
;
285 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
288 if (flags
& SC_SHIFT_R
) {
289 InpInfo
[p
].type
= INPUT_KEYBOARD
;
290 InpInfo
[p
].ki
.wVk
= VK_RSHIFT
;
291 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
294 if (flags
& SC_SHIFT_L
) {
295 InpInfo
[p
].type
= INPUT_KEYBOARD
;
296 InpInfo
[p
].ki
.wVk
= VK_LSHIFT
;
297 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
300 SendInput (p
,InpInfo
,sizeof (INPUT
));
302 last_scan
= scancode
;
304 last_time
= GetFineTime ();
308 void HandleKeyboardScancodes (char scan
[])
310 static byte last_scan
;
311 static byte last_flags
;
312 static unsigned int last_time
;
323 if (chr
>= 'a' && chr
<= 'f') chr
= chr
- 'a' + 10;
329 if (chr
>= 'a' && chr
<= 'f') chr
= chr
- 'a' + 10;
331 scancode
= scancode
* 16 + chr
;
333 flags
= scan
[2] - '0';
335 if (last_scan
== scancode
&& last_flags
!= flags
&& (GetFineTime () - last_time
) < 250) return;
337 layout
= GetKeyboardLayout (0);
339 if (scancode
== VK_APPS
) key
= VK_APPS
;
340 else key
= MapVirtualKeyEx (scancode
,1,layout
);
343 memset (InpInfo
,0,sizeof (InpInfo
));
346 if (flags
& SCAN_CTRL
) {
347 InpInfo
[p
].type
= INPUT_KEYBOARD
;
348 InpInfo
[p
].ki
.wVk
= VK_CONTROL
;
351 if (flags
& SCAN_SHIFT
) {
352 InpInfo
[p
].type
= INPUT_KEYBOARD
;
353 InpInfo
[p
].ki
.wVk
= VK_SHIFT
;
356 if (flags
& SCAN_ALT
) {
357 InpInfo
[p
].type
= INPUT_KEYBOARD
;
358 InpInfo
[p
].ki
.wVk
= VK_MENU
;
361 if (flags
& SCAN_WIN
) {
362 InpInfo
[p
].type
= INPUT_KEYBOARD
;
363 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
368 InpInfo
[p
].type
= INPUT_KEYBOARD
;
369 InpInfo
[p
].ki
.wVk
= key
;
372 InpInfo
[p
].type
= INPUT_KEYBOARD
;
373 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
374 InpInfo
[p
].ki
.wVk
= key
;
378 if (flags
& SCAN_WIN
) {
379 InpInfo
[p
].type
= INPUT_KEYBOARD
;
380 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
381 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
384 if (flags
& SCAN_ALT
) {
385 InpInfo
[p
].type
= INPUT_KEYBOARD
;
386 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
387 InpInfo
[p
].ki
.wVk
= VK_MENU
;
390 if (flags
& SCAN_SHIFT
) {
391 InpInfo
[p
].type
= INPUT_KEYBOARD
;
392 InpInfo
[p
].ki
.wVk
= VK_SHIFT
;
393 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
396 if (flags
& SCAN_CTRL
) {
397 InpInfo
[p
].type
= INPUT_KEYBOARD
;
398 InpInfo
[p
].ki
.wVk
= VK_CONTROL
;
399 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
402 SendInput (p
,InpInfo
,sizeof (INPUT
));
404 last_scan
= scancode
;
406 last_time
= GetFineTime ();
410 void SendWMChar (APP
*app
,APPCOMMAND
*appcom
)
414 win
= FindWindow (app
->classname
,NULL
);
417 PostMessage (win
,WM_KEYDOWN
,(WPARAM
)appcom
->function
[0],(LPARAM
)0);
418 // PostMessage (win,WM_KEYUP,(WPARAM)appcom->function[0],(LPARAM)0xC0000001);
421 void SendAppcommand (APP
*app
,APPCOMMAND
*appcom
)
425 win
= FindWindow (app
->classname
,NULL
);
428 PostMessage (win
,WM_APPCOMMAND
,(WPARAM
)1,(LPARAM
)(appcom
->function
[0] << 16));
431 void SendKey (APP
*app
,APPCOMMAND
*appcom
,byte flag
)
440 static APPCOMMAND
*lastcom
;
441 static unsigned int lasttime
;
443 if (app
&& app
->classname
[0]) {
444 win
= FindWindow (app
->classname
,NULL
);
447 thr
= GetWindowThreadProcessId (win
,NULL
);
448 AttachThreadInput (GetCurrentThreadId (),thr
,TRUE
);
452 AttachThreadInput (GetCurrentThreadId (),thr
,FALSE
);
457 tv
= (unsigned int)((tb
.time
& 0x7fffff) * 1000 + tb
.millitm
);
459 if (appcom
!= lastcom
) cindex
= 0;
461 if ((tv
- lasttime
) < MULTIKEY_TIMEOUT
) mf
= ++cindex
;
465 if (appcom
->type
[cindex
] != TYPE_KEY
) {
466 if (cindex
== 1) mf
= 0;
470 // if (mf) IRTransSendInput (VK_BACK,0);
471 //------------------------------------------modified------------------------------------------
472 //send (backspace + left winkey) to delete letters as it has no effect when changing channels,
473 //and backspace is used to switch to the previous scren in MCE and
476 IRTransSendInput (VK_BACK
,LWINKEY
);
479 IRTransSendInput (appcom
->function
[cindex
] & 0xff,(appcom
->function
[cindex
] & 0xff00) >> 8);
485 void SendMediaCenterAction (int app
,int com
)
489 char *sysdir
,prog
[256];
491 mcewin
= FindWindow (app_pnt
[app
].classname
,NULL
);
492 if (mcewin
== NULL
) {
493 if (app_pnt
[app
].com
[com
].type
[0] == TYPE_RUN
|| app_pnt
[app
].com
[com
].type
[1] == TYPE_RUN
) {
494 sysdir
= getenv ("SystemRoot");
496 sprintf (prog
,"%s\\ehome\\ehshell.exe",sysdir
);
497 if (app_pnt
[app
].com
[com
].function
[0] == 40) strcat (prog
," /homepage:VideoCollection.xml /pushstartpage:true"); // Video
498 if (app_pnt
[app
].com
[com
].function
[0] == 35) strcat (prog
," /homepage:Audio.Home.xml /pushstartpage:true"); // Music
499 if (app_pnt
[app
].com
[com
].function
[0] == 39) strcat (prog
," /homepage:VideoHome.xml /pushstartpage:true"); // TV
500 if (app_pnt
[app
].com
[com
].function
[0] == 45) strcat (prog
," /homepage:Radio.xml /pushstartpage:true"); // Radio
501 if (app_pnt
[app
].com
[com
].function
[0] == 36) strcat (prog
," /homepage:Photos.xml /pushstartpage:true"); // Pictures
502 if (app_pnt
[app
].com
[com
].function
[0] == 37) strcat (prog
," /homepage:VideoRecordedPrograms.xml /pushstartpage:true"); // RecTV
503 res
= WinExec (prog
,SW_SHOWMAXIMIZED
);
506 else if (app_pnt
[app
].com
[com
].function
[0] == 42) IRTransSendInput (VK_RETURN
,ALT
| LWINKEY
);
509 switch (app_pnt
[app
].com
[com
].function
[0]) {
511 IRTransSendInput (VK_ESCAPE
,0);
514 // IRTransSendInput (119,0);
515 SendMediacenterEvent (APPCOMMAND_VOLUME_MUTE
);
518 // IRTransSendInput (120,0);
519 SendMediacenterEvent (APPCOMMAND_VOLUME_DOWN
);
522 // IRTransSendInput (121,0);
523 SendMediacenterEvent (APPCOMMAND_VOLUME_UP
);
526 // IRTransSendInput (80,SHIFT | CONTROL);
527 SendMediacenterEvent (APPCOMMAND_MEDIA_PLAY
);
530 // IRTransSendInput (83,SHIFT | CONTROL);
531 SendMediacenterEvent (APPCOMMAND_MEDIA_STOP
);
534 // IRTransSendInput (70,CONTROL);
535 SendMediacenterEvent (APPCOMMAND_MEDIA_NEXTTRACK
);
538 // IRTransSendInput (66,CONTROL);
539 SendMediacenterEvent (APPCOMMAND_MEDIA_PREVIOUSTRACK
);
542 // IRTransSendInput (82,CONTROL);
543 SendMediacenterEvent (APPCOMMAND_MEDIA_RECORD
);
546 // IRTransSendInput (80,CONTROL);
547 SendMediacenterEvent (APPCOMMAND_MEDIA_PAUSE
);
550 // IRTransSendInput (66,SHIFT | CONTROL);
551 SendMediacenterEvent (APPCOMMAND_MEDIA_REWIND
);
554 // IRTransSendInput (70,SHIFT | CONTROL);
555 SendMediacenterEvent (APPCOMMAND_MEDIA_FAST_FORWARD
);
558 IRTransSendInput (187,CONTROL
);
559 // SendMediacenterEvent (APPCOMMAND_MEDIA_CHANNEL_UP);
562 IRTransSendInput (189,CONTROL
);
563 // SendMediacenterEvent (APPCOMMAND_MEDIA_CHANNEL_DOWN);
566 IRTransSendInput (77,SHIFT
| CONTROL
);
569 IRTransSendInput (65,SHIFT
| CONTROL
);
571 case 33: // DVDSubtitle
572 IRTransSendInput (85,SHIFT
| CONTROL
);
575 IRTransSendInput (71,CONTROL
);
578 IRTransSendInput (77,CONTROL
);
581 IRTransSendInput (73,CONTROL
);
584 IRTransSendInput (79,CONTROL
);
587 IRTransSendInput (84,CONTROL
| SHIFT
);
590 IRTransSendInput (84,CONTROL
);
593 IRTransSendInput (69,CONTROL
);
596 IRTransSendInput (68,CONTROL
);
599 IRTransSendInput (VK_RETURN
,ALT
| LWINKEY
);
601 case 43: // Messenger
602 IRTransSendInput (78,CONTROL
);
605 IRTransSendInput (68,CONTROL
);
608 IRTransSendInput (65,CONTROL
);
611 SendMediacenterEvent (APPCOMMAND_BROWSER_BACKWARD
);
618 void SendMediacenterEvent (int eventcode
)
622 mcewin
= FindWindow ("eHome Render Window",NULL
);
624 PostMessage (mcewin
,WM_APPCOMMAND
,(WPARAM
)1,(LPARAM
)(eventcode
<< 16));
628 int GetKeyCode (char *com
)
633 if (!strcmp (com
,"space")) return ' ';
634 if (!strcmp (com
,"enter")) return VK_RETURN
;
635 if (!strcmp (com
,"up")) return VK_UP
;
636 if (!strcmp (com
,"down")) return VK_DOWN
;
637 if (!strcmp (com
,"right")) return VK_RIGHT
;
638 if (!strcmp (com
,"left")) return VK_LEFT
;
639 if (!strcmp (com
,"backspace")) return VK_BACK
;
640 if (!strcmp (com
,"end")) return VK_END
;
641 if (!strcmp (com
,"home")) return VK_HOME
;
642 if (!strcmp (com
,"pgup")) return VK_PRIOR
;
643 if (!strcmp (com
,"pgdown")) return VK_NEXT
;
644 if (!strcmp (com
,"esc")) return VK_ESCAPE
;
645 if (!strcmp (com
,"tab")) return VK_TAB
;
646 if (!strcmp (com
,"f1")) return VK_F1
;
647 if (!strcmp (com
,"f2")) return VK_F2
;
648 if (!strcmp (com
,"f3")) return VK_F3
;
649 if (!strcmp (com
,"f4")) return VK_F4
;
650 if (!strcmp (com
,"f5")) return VK_F5
;
651 if (!strcmp (com
,"f6")) return VK_F6
;
652 if (!strcmp (com
,"f7")) return VK_F7
;
653 if (!strcmp (com
,"f8")) return VK_F8
;
654 if (!strcmp (com
,"f9")) return VK_F9
;
655 if (!strcmp (com
,"f10")) return VK_F10
;
656 if (!strcmp (com
,"f11")) return VK_F11
;
657 if (!strcmp (com
,"f12")) return VK_F12
;
658 while (!strncmp (com
,"alt",3) || !strncmp (com
,"ctrl",4) || !strncmp (com
,"shift",5)) {
659 if (!strncmp (com
,"alt",3)) {
663 if (!strncmp (com
,"ctrl",4)) {
667 if (!strncmp (com
,"shift",5)) {
671 if (*com
== 0) return (0);
673 if (*com
== '\\') com
++;
674 else return (key
| *com
);
679 if (*com
>= 'a' && *com
<= 'z') return (*com
- ('a' - 'A'));
683 int GetFunctionCode (byte type
,char *com
)
685 if (type
== TYPE_APPCOM
) {
686 if (!strcmp (com
,"appcommand_media_play")) return APPCOMMAND_MEDIA_PLAY
;
687 if (!strcmp (com
,"appcommand_volume_mute")) return APPCOMMAND_VOLUME_MUTE
;
688 if (!strcmp (com
,"appcommand_volume_down")) return APPCOMMAND_VOLUME_DOWN
;
689 if (!strcmp (com
,"appcommand_volume_up")) return APPCOMMAND_VOLUME_UP
;
690 if (!strcmp (com
,"appcommand_media_stop")) return APPCOMMAND_MEDIA_STOP
;
691 if (!strcmp (com
,"appcommand_media_nexttrack")) return APPCOMMAND_MEDIA_NEXTTRACK
;
692 if (!strcmp (com
,"appcommand_media_previoustrack")) return APPCOMMAND_MEDIA_PREVIOUSTRACK
;
693 if (!strcmp (com
,"appcommand_media_record")) return APPCOMMAND_MEDIA_RECORD
;
694 if (!strcmp (com
,"appcommand_media_pause")) return APPCOMMAND_MEDIA_PAUSE
;
695 if (!strcmp (com
,"appcommand_media_rewind")) return APPCOMMAND_MEDIA_REWIND
;
696 if (!strcmp (com
,"appcommand_media_fast_forward")) return APPCOMMAND_MEDIA_FAST_FORWARD
;
697 if (!strcmp (com
,"appcommand_browser_backward")) return APPCOMMAND_BROWSER_BACKWARD
;
700 else if (type
== TYPE_MCE
) {
701 if (!strcmp (com
,"clear")) return 12;
702 if (!strcmp (com
,"mute")) return 17;
703 if (!strcmp (com
,"vol-")) return 18;
704 if (!strcmp (com
,"vol+")) return 19;
705 if (!strcmp (com
,"play")) return 20;
706 if (!strcmp (com
,"stop")) return 21;
707 if (!strcmp (com
,"next")) return 22;
708 if (!strcmp (com
,"prev")) return 23;
709 if (!strcmp (com
,"rec")) return 24;
710 if (!strcmp (com
,"pause")) return 25;
711 if (!strcmp (com
,"rew")) return 26;
712 if (!strcmp (com
,"fwd")) return 27;
713 if (!strcmp (com
,"ch+")) return 28;
714 if (!strcmp (com
,"ch-")) return 29;
715 if (!strcmp (com
,"dvdmenu")) return 31;
716 if (!strcmp (com
,"dvdaudio")) return 32;
717 if (!strcmp (com
,"dvdsubtitle")) return 33;
718 if (!strcmp (com
,"epg")) return 34;
719 if (!strcmp (com
,"music")) return 35;
720 if (!strcmp (com
,"pictures")) return 36;
721 if (!strcmp (com
,"rectv")) return 37;
722 if (!strcmp (com
,"tv")) return 38;
723 if (!strcmp (com
,"livetv")) return 39;
724 if (!strcmp (com
,"video")) return 40;
725 if (!strcmp (com
,"info")) return 41;
726 if (!strcmp (com
,"ehome")) return 42;
727 if (!strcmp (com
,"messenger")) return 43;
728 if (!strcmp (com
,"teletext")) return 44;
729 if (!strcmp (com
,"radio")) return 45;
730 if (!strcmp (com
,"back")) return 46;
737 //typedef BOOL (WINAPI *PtrKbdSim)(KBDSIM_INPUT_DATA *);
738 //PtrKbdSim m_KbdSim = 0;
745 kdll = LoadLibrary("kbdsim.dll");
748 sprintf (msg,"Error: Can't Load kbdsim.dll\n");
749 log_print (msg,LOG_FATAL);
753 m_KbdSim = (PtrKbdSim)GetProcAddress(kdll, "KbdSimSendInput");
757 BOOL WINAPI KbdSimSendInput(KBDSIM_INPUT_DATA *pInput)
759 return (*m_KbdSim)(pInput);
763 void IRTransSendInput (int key
,int flags
)
765 // KBDSIM_INPUT_DATA Input;
772 if (flags & CONTROL) {
773 Input.UnitId = 0; // Keyboard 0
774 Input.MakeCode = 29; // Scancode for CTRL
775 Input.Flags = 0; // Key down
777 Input.ExtraInformation = 0;
778 KbdSimSendInput(&Input);
783 Input.UnitId = 0; // Keyboard 0
784 Input.MakeCode = 50; // Scancode for '1'
785 Input.Flags = 0; // Key down
787 Input.ExtraInformation = 0;
789 KbdSimSendInput(&Input);
791 Input.UnitId = 0; // Keyboard 0
792 Input.MakeCode = 50; // Scancode for '1'
793 Input.Flags = 1; // Key up
795 Input.ExtraInformation = 0;
797 KbdSimSendInput(&Input);
800 Input.UnitId = 0; // Keyboard 0
801 Input.MakeCode = 29; // Scancode for '1'
802 Input.Flags = 1; // Key up
804 Input.ExtraInformation = 0;
806 KbdSimSendInput(&Input);
813 Input.UnitId = 0; // Keyboard 0
814 Input.MakeCode = 2; // Scancode for '1'
815 Input.Flags = 0; // Key down
817 Input.ExtraInformation = 0;
819 KbdSimSendInput(&Input);
821 Input.UnitId = 0; // Keyboard 0
822 Input.MakeCode = 2; // Scancode for '1'
823 Input.Flags = 1; // Key up
825 Input.ExtraInformation = 0;
827 KbdSimSendInput(&Input);
836 memset (InpInfo
,0,sizeof (InpInfo
));
839 if (flags
& CONTROL
) {
840 InpInfo
[p
].type
= INPUT_KEYBOARD
;
841 InpInfo
[p
].ki
.wVk
= VK_CONTROL
;
845 InpInfo
[p
].type
= INPUT_KEYBOARD
;
846 InpInfo
[p
].ki
.wVk
= VK_SHIFT
;
850 InpInfo
[p
].type
= INPUT_KEYBOARD
;
851 InpInfo
[p
].ki
.wVk
= VK_MENU
;
854 if (flags
& LWINKEY
) {
855 InpInfo
[p
].type
= INPUT_KEYBOARD
;
856 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
861 InpInfo
[p
].type
= INPUT_KEYBOARD
;
862 InpInfo
[p
].ki
.wVk
= key
;
865 if (!(flags
& NO_KEYUP
)) {
866 InpInfo
[p
].type
= INPUT_KEYBOARD
;
867 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
868 InpInfo
[p
].ki
.wVk
= key
;
872 if (flags
& LWINKEY
) {
873 InpInfo
[p
].type
= INPUT_KEYBOARD
;
874 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
875 InpInfo
[p
].ki
.wVk
= VK_LWIN
;
879 InpInfo
[p
].type
= INPUT_KEYBOARD
;
880 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
881 InpInfo
[p
].ki
.wVk
= VK_MENU
;
885 InpInfo
[p
].type
= INPUT_KEYBOARD
;
886 InpInfo
[p
].ki
.wVk
= VK_SHIFT
;
887 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
890 if (flags
& CONTROL
) {
891 InpInfo
[p
].type
= INPUT_KEYBOARD
;
892 InpInfo
[p
].ki
.wVk
= VK_CONTROL
;
893 InpInfo
[p
].ki
.dwFlags
= KEYEVENTF_KEYUP
;
896 SendInput (p
,InpInfo
,sizeof (INPUT
));