1 | /*
|
---|
2 | * synergy -- mouse and keyboard sharing utility
|
---|
3 | * Copyright (C) 2002 Chris Schoeneman
|
---|
4 | * Copyright (C) 2006 Knut St. Osmundsen
|
---|
5 | *
|
---|
6 | * This package is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the GNU General Public License
|
---|
8 | * found in the file COPYING that should have accompanied this file.
|
---|
9 | *
|
---|
10 | * This package 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 |
|
---|
16 | #ifndef CSYNERGYHOOK_H
|
---|
17 | #define CSYNERGYHOOK_H
|
---|
18 |
|
---|
19 | #include "BasicTypes.h"
|
---|
20 | #define INCL_BASE
|
---|
21 | #define INCL_ERRORS
|
---|
22 | #define INCL_PM
|
---|
23 | #include <os2.h>
|
---|
24 |
|
---|
25 | #if defined(SYNRGYHK_EXPORTS)
|
---|
26 | # define CSYNERGYHOOK_API extern "C" __declspec(dllexport)
|
---|
27 | #else
|
---|
28 | # define CSYNERGYHOOK_API extern "C" __declspec(dllimport)
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | /** @name The messages posted from the input hook on the synergy message queue.
|
---|
32 | * @{
|
---|
33 | */
|
---|
34 | #define SYNERGY_PM_MSG_MARK WM_USER + 20 // mark id; <unused>
|
---|
35 | #define SYNERGY_PM_MSG_KEY WM_USER + 21 // vk code; key data
|
---|
36 | /**
|
---|
37 | * mp1.s1: msg
|
---|
38 | * mp1.s2: 0 reserved.
|
---|
39 | * mp2.s1: mouse x
|
---|
40 | * mp2.s2: mouse y
|
---|
41 | */
|
---|
42 | #define SYNERGY_PM_MSG_MOUSE_BUTTON WM_USER + 22
|
---|
43 | /** WM_MOUSEMOVE mp1 and mp2. */
|
---|
44 | #define SYNERGY_PM_MSG_MOUSE_MOVE WM_USER + 23
|
---|
45 |
|
---|
46 | #define SYNERGY_PM_MSG_POST_WARP WM_USER + 24 // <unused>; <unused>
|
---|
47 | #define SYNERGY_PM_MSG_PRE_WARP WM_USER + 25 // x; y
|
---|
48 | #define SYNERGY_PM_MSG_DEBUG WM_USER + 27 // data, data
|
---|
49 |
|
---|
50 | #define SYNERGY_PM_MSG_FIRST SYNERGY_PM_MSG_MARK /**< The first message. */
|
---|
51 | #define SYNERGY_PM_MSG_LAST SYNERGY_PM_MSG_DEBUG /**< The last message. */
|
---|
52 | #define SYNERGY_PM_MSG_INPUT_FIRST SYNERGY_PM_MSG_KEY /**< The first input message. */
|
---|
53 | #define SYNERGY_PM_MSG_INPUT_LAST SYNERGY_PM_MSG_PRE_WARP /**< The last input message. */
|
---|
54 | /** @} */
|
---|
55 |
|
---|
56 | #define SYNERGY_PM_HOOK_FAKE_INPUT_MP1_FIXED MPFROM2SHORT(KC_VIRTUALKEY | KC_SCANCODE, 0)
|
---|
57 | #define SYNERGY_PM_HOOK_FAKE_INPUT_MP2_SET MPFROM2SHORT(0x8f70, 0x708f)
|
---|
58 | #define SYNERGY_PM_HOOK_FAKE_INPUT_MP2_CLEAR MPFROM2SHORT(0x9f70, 0x708f)
|
---|
59 |
|
---|
60 | enum EHookResult {
|
---|
61 | kHOOK_FAILED,
|
---|
62 | kHOOK_OKAY,
|
---|
63 | kHOOK_OKAY_LL
|
---|
64 | };
|
---|
65 |
|
---|
66 | enum EHookMode {
|
---|
67 | kHOOK_DISABLE,
|
---|
68 | kHOOK_WATCH_JUMP_ZONE,
|
---|
69 | kHOOK_RELAY_EVENTS
|
---|
70 | };
|
---|
71 |
|
---|
72 | typedef bool (*InitFunc)(HMQ hmq, int tid, int pid);
|
---|
73 | typedef bool (*CleanupFunc)(HAB hab);
|
---|
74 | typedef EHookResult (*InstallFunc)(HAB hab);
|
---|
75 | typedef bool (*UninstallFunc)(HAB hab);
|
---|
76 | typedef void (*SetSidesFunc)(UInt32);
|
---|
77 | typedef void (*SetZoneFunc)(SInt32, SInt32, SInt32, SInt32, SInt32);
|
---|
78 | typedef void (*SetModeFunc)(int);
|
---|
79 | typedef const char * (*FakeMsgFunc)(HAB hab, const QMSG *pQmsg);
|
---|
80 |
|
---|
81 | CSYNERGYHOOK_API bool init(HMQ hmq, int tid, int pid);
|
---|
82 | CSYNERGYHOOK_API bool cleanup(HAB hab);
|
---|
83 | CSYNERGYHOOK_API EHookResult install(HAB hab);
|
---|
84 | CSYNERGYHOOK_API bool uninstall(HAB hab);
|
---|
85 | CSYNERGYHOOK_API void setSides(UInt32 sides);
|
---|
86 | CSYNERGYHOOK_API void setZone(SInt32 x, SInt32 y, SInt32 cx, SInt32 cy, SInt32 jumpZoneSize);
|
---|
87 | CSYNERGYHOOK_API const char * fakeMsg(HAB hab, const QMSG *pQmsg);
|
---|
88 |
|
---|
89 |
|
---|
90 |
|
---|
91 | //
|
---|
92 | // Various OS/2 stuff from the DDK.
|
---|
93 | //
|
---|
94 |
|
---|
95 | /*
|
---|
96 | * video/rel/.../pmwinp.mac and pmwinx.h in the ddk.
|
---|
97 | */
|
---|
98 | typedef struct _KBDEVENT { /* kevt */
|
---|
99 | BYTE monFlags; /* Open, Close and Flush monitor flags */
|
---|
100 | BYTE scancode; /* Original scan code (actually high byte of
|
---|
101 | monitor flags */
|
---|
102 | BYTE xlatedchar; /* Output of interrupt level character translation
|
---|
103 | table */
|
---|
104 |
|
---|
105 | BYTE xlatedscan; /* Translated scan code. Different only for
|
---|
106 | the enhanced keyboard */
|
---|
107 |
|
---|
108 | USHORT shiftDBCS; /* DBCS shift state and status */
|
---|
109 | USHORT shiftstate; /* Current state of shift keys */
|
---|
110 | ULONG time; /* millisecond counter time stamp */
|
---|
111 | USHORT ddFlags; /* Keyboard device driver flags */
|
---|
112 | } KBDEVENT;
|
---|
113 | typedef KBDEVENT *PKBDEVENT;
|
---|
114 | // guess MON_* are for the monFlags field.
|
---|
115 | #define MON_OPEN EQU 0001H
|
---|
116 | #define MON_CLOSE EQU 0002H
|
---|
117 | #define MON_FLUSH EQU 0004H
|
---|
118 | // guess KSS_* is for the shiftstate field.
|
---|
119 | #define KSS_SYSREQ EQU 8000H
|
---|
120 | #define KSS_CAPSLOCK EQU 4000H
|
---|
121 | #define KSS_NUMLOCK EQU 2000H
|
---|
122 | #define KSS_SCROLLLOCK EQU 1000H
|
---|
123 | #define KSS_RIGHTALT EQU 0800H
|
---|
124 | #define KSS_RIGHTCTRL EQU 0400H
|
---|
125 | #define KSS_LEFTALT EQU 0200H
|
---|
126 | #define KSS_LEFTCTRL EQU 0100H
|
---|
127 | #define KSS_INSERTON EQU 0080H
|
---|
128 | #define KSS_CAPSLOCKON EQU 0040H
|
---|
129 | #define KSS_NUMLOCKON EQU 0020H
|
---|
130 | #define KSS_SCROLLLOCKON EQU 0010H
|
---|
131 | #define KSS_EITHERALT EQU 0008H
|
---|
132 | #define KSS_EITHERCTRL EQU 0004H
|
---|
133 | #define KSS_LEFTSHIFT EQU 0002H
|
---|
134 | #define KSS_RIGHTSHIFT EQU 0001H
|
---|
135 | #define KSS_EITHERSHIFT EQU 0003H
|
---|
136 | /* Valid values for ddFlags field */
|
---|
137 | #define KDD_MONFLAG1 0x8000 // bird: conflicts with KDD_KC_LONEKEY - relevant for VIOCHAR?
|
---|
138 | #define KDD_MONFLAG2 0x4000 // bird: conflicts with KDD_KC_PREVDOWN - relevant for VIOCHAR?
|
---|
139 | #define KDD_RESERVED 0x3C00
|
---|
140 | #define KDD_ACCENTED 0x0200
|
---|
141 | #define KDD_MULTIMAKE 0x0100
|
---|
142 | #define KDD_SECONDARY 0x0080
|
---|
143 | #define KDD_BREAK 0x0040
|
---|
144 | #define KDD_EXTENDEDKEY 0x0020
|
---|
145 | #define KDD_ACTIONFIELD 0x001F
|
---|
146 | #define KDD_KC_LONEKEY 0x8000
|
---|
147 | #define KDD_KC_PREVDOWN 0x4000
|
---|
148 | #define KDD_KC_KEYUP 0x2000
|
---|
149 | #define KDD_KC_ALT 0x1000
|
---|
150 | #define KDD_KC_CTRL 0x0800
|
---|
151 | #define KDD_KC_SHIFT 0x0400
|
---|
152 | #define KDD_KC_FLAGS 0x0FC00
|
---|
153 | /* Valid values for KDD_ACTIONFIELD portion of ddFlags field */
|
---|
154 | #define KDD_PUTINKIB 0x0000
|
---|
155 | #define KDD_ACK 0x0001
|
---|
156 | #define KDD_PREFIXKEY 0x0002
|
---|
157 | #define KDD_OVERRUN 0x0003
|
---|
158 | #define KDD_RESEND 0x0004
|
---|
159 | #define KDD_REBOOTKEY 0x0005
|
---|
160 | #define KDD_DUMPKEY 0x0006
|
---|
161 | #define KDD_SHIFTKEY 0x0007
|
---|
162 | #define KDD_PAUSEKEY 0x0008
|
---|
163 | #define KDD_PSEUDOPAUSE 0x0009
|
---|
164 | #define KDD_WAKEUPKEY 0x000A
|
---|
165 | #define KDD_BADACCENT 0x000B
|
---|
166 | #define KDD_HOTKEY 0x000C
|
---|
167 | #define KDD_ACCENTKEY 0x0010
|
---|
168 | #define KDD_BREAKKEY 0x0011
|
---|
169 | #define KDD_PSEUDOBREAK 0x0012
|
---|
170 | #define KDD_PRTSCKEY 0x0013
|
---|
171 | #define KDD_PRTECHOKEY 0x0014
|
---|
172 | #define KDD_PSEUDOPRECH 0x0015
|
---|
173 | #define KDD_STATUSCHG 0x0016
|
---|
174 | #define KDD_WRITTENKEY 0x0017
|
---|
175 | #define KDD_UNDEFINED 0x001F
|
---|
176 |
|
---|
177 | /// PMWIN.174
|
---|
178 | // This needs to be used when pushing stuff to VIO programs. (pmvnc does anyway)
|
---|
179 | extern "C" KBDEVENT KbdPacket[2];
|
---|
180 |
|
---|
181 | #endif
|
---|