1 | /***
|
---|
2 | This file belongs to the Gotcha! distribution.
|
---|
3 | Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
|
---|
4 |
|
---|
5 | This program is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 2 of the License, or
|
---|
8 | (at your option) any later version.
|
---|
9 |
|
---|
10 | This program is distributed in the hope that it will be useful,
|
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | GNU General Public License for more details.
|
---|
14 |
|
---|
15 | You should have received a copy of the GNU General Public License
|
---|
16 | along with this program; if not, write to the Free Software
|
---|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | ***/
|
---|
19 |
|
---|
20 | #define INCL_WIN
|
---|
21 | #define INCL_DOS
|
---|
22 | #include <os2.h>
|
---|
23 | #include "../id.h"
|
---|
24 |
|
---|
25 | //#define __PMPRINTF__
|
---|
26 | //#include "PMPRINTF.H"
|
---|
27 |
|
---|
28 | /* pre-accelerator input hook, undocumented, */
|
---|
29 | #define HK_PREACCEL 17
|
---|
30 |
|
---|
31 | HAB habDLL;
|
---|
32 | HWND hwndFrame;
|
---|
33 | HMODULE hMod;
|
---|
34 | BOOL usePMps;
|
---|
35 |
|
---|
36 | void EXPENTRY InitDLL (HAB hab, HWND hwnd, BOOL g_usePMps)
|
---|
37 | {
|
---|
38 | habDLL = hab;
|
---|
39 | hwndFrame = hwnd;
|
---|
40 | usePMps = g_usePMps;
|
---|
41 | DosLoadModule (NULL, 0, "GOTCHDLL", &hMod);
|
---|
42 | }
|
---|
43 |
|
---|
44 | BOOL EXPENTRY InputProc (HAB hab, PQMSG pqmsg, ULONG ul)
|
---|
45 | {
|
---|
46 | USHORT usFlags;
|
---|
47 | USHORT usScan;
|
---|
48 |
|
---|
49 | if (pqmsg->msg != WM_CHAR
|
---|
50 | || (usFlags = SHORT1FROMMP(pqmsg->mp1), usScan =
|
---|
51 | SHORT2FROMMP (pqmsg->mp2), (usFlags & KC_SCANCODE)) == 0){
|
---|
52 | return FALSE;
|
---|
53 | }
|
---|
54 |
|
---|
55 | if (CHAR4FROMMP(pqmsg->mp1) == 0x54 ) {
|
---|
56 | if (usFlags & KC_KEYUP) {
|
---|
57 | WinPostMsg (hwndFrame, WM_COMMAND,
|
---|
58 | MPFROM2SHORT (WID_PB_SETTINGS,0), 0);
|
---|
59 | /*DosBeep( 1000, 10 );
|
---|
60 | DosBeep( 2000, 20 );
|
---|
61 | DosBeep( 3000, 30 ); */
|
---|
62 | return TRUE;
|
---|
63 | } else {
|
---|
64 | /* DosBeep( 3000, 30 );
|
---|
65 | DosBeep( 2000, 20 );
|
---|
66 | DosBeep( 1000, 10 );*/
|
---|
67 | return TRUE;
|
---|
68 | }
|
---|
69 | }
|
---|
70 | else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) &&
|
---|
71 | (usFlags & KC_CTRL)) {
|
---|
72 | if (usFlags & KC_KEYUP) {
|
---|
73 | WinPostMsg (hwndFrame, WM_COMMAND,
|
---|
74 | MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), MPFROMLONG(1));
|
---|
75 | return TRUE;
|
---|
76 | }
|
---|
77 |
|
---|
78 | }
|
---|
79 | else if ((usScan == VK_PRINTSCRN || CHAR4FROMMP(pqmsg->mp1) == 93 ) &&
|
---|
80 | (usFlags & KC_SHIFT)) {
|
---|
81 | if (usFlags & KC_KEYUP) {
|
---|
82 | WinPostMsg (hwndFrame, WM_COMMAND,
|
---|
83 | MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0);
|
---|
84 | return TRUE;
|
---|
85 | }
|
---|
86 | }
|
---|
87 | else if (!usePMps && (usScan == VK_PRINTSCRN ||
|
---|
88 | CHAR4FROMMP(pqmsg->mp1) == 93 )) {
|
---|
89 | if (usFlags & KC_KEYUP) {
|
---|
90 | WinPostMsg (hwndFrame, WM_COMMAND,
|
---|
91 | MPFROM2SHORT (WID_PB_SETCAPTURETYPE,0), 0);
|
---|
92 | return TRUE;
|
---|
93 | }
|
---|
94 | }
|
---|
95 | return FALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | void EXPENTRY StartInputHook (void)
|
---|
99 | {
|
---|
100 | WinSetHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
|
---|
101 | }
|
---|
102 |
|
---|
103 | void EXPENTRY StopInputHook (void)
|
---|
104 | {
|
---|
105 | WinReleaseHook (habDLL, NULLHANDLE, HK_PREACCEL, (PFN) InputProc, hMod);
|
---|
106 | DosFreeModule (hMod);
|
---|
107 | }
|
---|
108 |
|
---|
109 | USHORT Version (VOID)
|
---|
110 | {
|
---|
111 | return 2;
|
---|
112 | }
|
---|