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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/* ============================================================================
Hardware HotKeys plugin for Miranda NG.
Copyright © Eugene f2065, http://f2065.narod.ru, f2065 mail.ru, ICQ 35078112
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., 59 Temple Place - Suite 330, Boston, MA 02111 - 1307, USA.
============================================================================ */
#include "HwHotKeys.h"
// ñðàâíèâàåò òåêóùèé íàæàòûé ñêàíêîä ñ óêàçàííûì
BOOL HwHotKeys_CompareCurrentScancode(DWORD scancode)
{
if (key_code == scancode) // key_code - òåêóùèé íàæàòûé íà êëàâèàòóðå ñêàíêîä.
{
return true; // ñêàíêîä íàïðÿìóþ ñîâïàë - TRUE.
}
if (!(scancode & 0x00F00000)) // ïðîâåðÿåì íåò ëè â ñêàíêîäå çàïðîñà íà ëþáîé èç ëåâîãî/ïðàâîãî ðåãèñòðà.
{
return false;
}
DWORD tmp1, tmp2; // áèòîâûå ìàñêè: 0xF0000000 - ëåâûå êíîïêè Sft/Ctr/Alt/Win, 0x0F000000 - ïðàâûå êíîïêè, 0x00F00000 - ëþáûå êíîïêè Sft/Ctr/Alt/Win
tmp1 = key_code >> 8; // ñäâèãàåì áèòû ëåâûõ è ïðàâûõ êíîïîê.
tmp2 = key_code >> 4;
tmp1 |= tmp2;
tmp1 &= 0x00F00000;
tmp2 = (key_code | tmp1) & 0x00FFFFFF;
if (tmp2 == scancode)
{
return true;
}
return false;
}
// ïå÷àòàåò â áóôåð key_name_buffer òåêñòîâîå îïèñàíèå íàæàòîé êîìáèíàöèè êíîïîê
// Êîäèðîâêà ANSI (äëÿ ýêîíîìèè ìåñòà, âñ¸ ðàâíî íàçâàíèÿ êëàâèø àíãëèéñêèå)
VOID HwHotKeys_PrintFullKeyname(DWORD scancode)
{
key_name_buffer[0] = 0;
if (!scancode) // åñëè íóëåâîé ñêàíêîä - òî ïóñòóþ ñòðîêó äåëàåì.
{
return;
}
if (scancode & key_flag_sl) // L_Shift
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_SL);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_sr) // R_Shift
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_SR);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_ss) // Shift
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_SS);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_cl) // L_Ctrl
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_CL);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_cr) // R_Ctrl
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_CR);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_cc) // Ctrl
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_CC);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_al) // L_Alt
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_AL);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_ar) // R_Alt
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_AR);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_aa) // Alt
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_AA);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_wl) // L_Win
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_WL);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_wr) // R_Win
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_WR);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if (scancode & key_flag_ww) // Win
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), t_WW);
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), " + ");
}
if ((scancode & 0x1FF) < sizeof(key_tab)) // çàùèòà îò îøèáî÷íûõ äàííûõ - ÷òîáû íå âûéòè èç òàáëèöû èì¸í.
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), key_tab[(scancode & 0x1FF)]);
}
else
{
StringCbCatA(key_name_buffer, sizeof(key_name_buffer), "out of range");
}
INT_PTR tmp1 = mir_strlen(key_name_buffer); // äîïå÷àòûâàåì â êîíåöå ñòðîêè ñêàíêîä - äëÿ óäîáñòâà ðàáîòû ñ ïîêà åù¸ íå èçâåñòíûìè (áåçèìÿííûìè) êíîïêàìè
StringCbPrintfA(key_name_buffer + tmp1, sizeof(key_name_buffer) - tmp1, " (%03X)", (scancode & 0x1FF));
return;
}
|