-
Notifications
You must be signed in to change notification settings - Fork 2
/
wkb-hook.c
61 lines (47 loc) · 1.76 KB
/
wkb-hook.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Copyright (C) 2016-2020 Dimitar Toshkov Zhekov <[email protected]>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#define STRICT
#include <windows.h>
#define WKB_MINI_DLL __declspec(dllexport)
#include "wkb-hook.h"
static UINT layoutMessage;
LRESULT CALLBACK windowProc(INT nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION)
{
const CWPSTRUCT *const cwp = (const CWPSTRUCT *) lParam;
if (cwp->message == layoutMessage)
{
ActivateKeyboardLayout((HKL) cwp->lParam, 0);
return TRUE;
}
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
LRESULT CALLBACK keyboardProc(INT nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION || nCode == HC_NOREMOVE)
if (wParam == VK_SCROLL && ((lParam >> 16) & 0xFF) == 0xE0)
return TRUE;
return CallNextHookEx(0, nCode, wParam, lParam);
}
BOOL WINAPI DllMainCRTStartup(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
(void) hinstDLL;
(void) lpvReserved;
if (fdwReason == DLL_PROCESS_ATTACH)
layoutMessage = RegisterWindowMessage(WKB_LAYOUT_MESSAGE);
return TRUE;
}