2 Copyright (C) 2008 Carlo Segato <brandon.ml@gmail.com>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "kkeyserver_win.h"
33 static const TransKey KeyTbl
[] =
35 { Qt::Key_Cancel
, VK_CANCEL
},
36 { Qt::Key_Backspace
, VK_BACK
},
37 { Qt::Key_Tab
, VK_TAB
},
38 { Qt::Key_Clear
, VK_CLEAR
},
39 { Qt::Key_Return
, VK_RETURN
},
40 { Qt::Key_Shift
, VK_SHIFT
},
41 { Qt::Key_Control
, VK_CONTROL
},
42 { Qt::Key_Alt
, VK_MENU
},
43 { Qt::Key_Pause
, VK_PAUSE
},
44 { Qt::Key_CapsLock
, VK_CAPITAL
},
45 { Qt::Key_Escape
, VK_ESCAPE
},
46 { Qt::Key_Mode_switch
, VK_MODECHANGE
},
47 { Qt::Key_Space
, VK_SPACE
},
48 { Qt::Key_PageUp
, VK_PRIOR
},
49 { Qt::Key_PageDown
, VK_NEXT
},
50 { Qt::Key_End
, VK_END
},
51 { Qt::Key_Home
, VK_HOME
},
52 { Qt::Key_Left
, VK_LEFT
},
53 { Qt::Key_Up
, VK_UP
},
54 { Qt::Key_Right
, VK_RIGHT
},
55 { Qt::Key_Down
, VK_DOWN
},
56 { Qt::Key_Select
, VK_SELECT
},
57 { Qt::Key_Printer
, VK_PRINT
},
58 { Qt::Key_Execute
, VK_EXECUTE
},
59 { Qt::Key_Print
, VK_SNAPSHOT
},
60 { Qt::Key_Insert
, VK_INSERT
},
61 { Qt::Key_Delete
, VK_DELETE
},
62 { Qt::Key_Help
, VK_HELP
},
99 { Qt::Key_Meta
, VK_LWIN
},
100 { Qt::Key_Meta
, VK_RWIN
},
101 { Qt::Key_Menu
, VK_APPS
},
102 { Qt::Key_Sleep
, VK_SLEEP
},
103 { Qt::Key_0
, VK_NUMPAD0
},
104 { Qt::Key_1
, VK_NUMPAD1
},
105 { Qt::Key_2
, VK_NUMPAD2
},
106 { Qt::Key_3
, VK_NUMPAD3
},
107 { Qt::Key_4
, VK_NUMPAD4
},
108 { Qt::Key_5
, VK_NUMPAD5
},
109 { Qt::Key_6
, VK_NUMPAD6
},
110 { Qt::Key_7
, VK_NUMPAD7
},
111 { Qt::Key_8
, VK_NUMPAD8
},
112 { Qt::Key_9
, VK_NUMPAD9
},
113 { Qt::Key_Asterisk
, VK_MULTIPLY
},
114 { Qt::Key_Plus
, VK_ADD
},
115 { Qt::Key_Comma
, VK_SEPARATOR
},
116 { Qt::Key_Minus
, VK_SUBTRACT
},
117 { Qt::Key_Period
, VK_DECIMAL
},
118 { Qt::Key_Slash
, VK_DIVIDE
},
119 { Qt::Key_F1
, VK_F1
},
120 { Qt::Key_F2
, VK_F2
},
121 { Qt::Key_F3
, VK_F3
},
122 { Qt::Key_F4
, VK_F4
},
123 { Qt::Key_F5
, VK_F5
},
124 { Qt::Key_F6
, VK_F6
},
125 { Qt::Key_F7
, VK_F7
},
126 { Qt::Key_F8
, VK_F8
},
127 { Qt::Key_F9
, VK_F9
},
128 { Qt::Key_F10
, VK_F10
},
129 { Qt::Key_F11
, VK_F11
},
130 { Qt::Key_F12
, VK_F12
},
131 { Qt::Key_F13
, VK_F13
},
132 { Qt::Key_F14
, VK_F14
},
133 { Qt::Key_F15
, VK_F15
},
134 { Qt::Key_F16
, VK_F16
},
135 { Qt::Key_F17
, VK_F17
},
136 { Qt::Key_F18
, VK_F18
},
137 { Qt::Key_F19
, VK_F19
},
138 { Qt::Key_F20
, VK_F20
},
139 { Qt::Key_F21
, VK_F21
},
140 { Qt::Key_F22
, VK_F22
},
141 { Qt::Key_F23
, VK_F23
},
142 { Qt::Key_F24
, VK_F24
},
143 { Qt::Key_NumLock
, VK_NUMLOCK
},
144 { Qt::Key_ScrollLock
, VK_SCROLL
},
145 // { 0, VK_OEM_FJ_JISHO },
146 // { Qt::Key_Massyo, VK_OEM_FJ_MASSHOU },
147 // { Qt::Key_Touroku, VK_OEM_FJ_TOUROKU },
148 // { 0, VK_OEM_FJ_LOYA },
149 // { 0, VK_OEM_FJ_ROYA },
150 { Qt::Key_Shift
, VK_LSHIFT
},
151 { Qt::Key_Shift
, VK_RSHIFT
},
152 { Qt::Key_Control
, VK_LCONTROL
},
153 { Qt::Key_Control
, VK_RCONTROL
},
154 { Qt::Key_Alt
, VK_LMENU
},
155 { Qt::Key_Alt
, VK_RMENU
},
157 // winuser.h from psdk w2kserver2003R2 defines the following constants only for _WIN32_WINNT >= 0x0500
158 // and we should also do so - otherwise the constants may not be available
159 #if(_WIN32_WINNT >= 0x0500)
160 { Qt::Key_Back
, VK_BROWSER_BACK
},
161 { Qt::Key_Forward
, VK_BROWSER_FORWARD
},
162 { Qt::Key_Refresh
, VK_BROWSER_REFRESH
},
163 { Qt::Key_Stop
, VK_BROWSER_STOP
},
164 { Qt::Key_Search
, VK_BROWSER_SEARCH
},
165 { Qt::Key_Favorites
, VK_BROWSER_FAVORITES
},
166 { Qt::Key_HomePage
, VK_BROWSER_HOME
},
167 { Qt::Key_VolumeMute
, VK_VOLUME_MUTE
},
168 { Qt::Key_VolumeDown
, VK_VOLUME_DOWN
},
169 { Qt::Key_VolumeUp
, VK_VOLUME_UP
},
170 { Qt::Key_MediaNext
, VK_MEDIA_NEXT_TRACK
},
171 { Qt::Key_MediaPrevious
, VK_MEDIA_PREV_TRACK
},
172 { Qt::Key_MediaStop
, VK_MEDIA_STOP
},
173 { Qt::Key_MediaPlay
, VK_MEDIA_PLAY_PAUSE
},
174 { Qt::Key_LaunchMail
, VK_LAUNCH_MAIL
},
175 { Qt::Key_LaunchMedia
, VK_LAUNCH_MEDIA_SELECT
},
176 { Qt::Key_Launch0
, VK_LAUNCH_APP1
},
177 { Qt::Key_Launch1
, VK_LAUNCH_APP2
},
183 { 0, VK_OEM_PERIOD },
191 { Qt::Key_Play
, VK_PLAY
},
192 { Qt::Key_Zoom
, VK_ZOOM
},
193 { Qt::Key_Clear
, VK_OEM_CLEAR
},
197 bool keyQtToModWin( int keyQt
, uint
* mod
)
200 if (keyQt
& Qt::ShiftModifier
) {
203 if (keyQt
& Qt::ControlModifier
) {
206 if (keyQt
& Qt::AltModifier
) {
209 if (keyQt
& Qt::MetaModifier
) {
216 bool modWinToKeyQt( uint mod
, int *keyQt
)
219 if (mod
& MOD_SHIFT
) {
220 *keyQt
|= Qt::ShiftModifier
;
222 if (mod
& MOD_CONTROL
) {
223 *keyQt
|= Qt::ControlModifier
;
226 *keyQt
|= Qt::AltModifier
;
229 *keyQt
|= Qt::MetaModifier
;
235 bool keyQtToCodeWin( int keyQt
, uint
* sym
)
237 int symQt
= keyQt
& ~Qt::KeyboardModifierMask
;
239 if( symQt
>= Qt::Key_A
&& symQt
<= Qt::Key_Z
) {
244 for( uint i
= 0; i
< sizeof(KeyTbl
); i
++ ) {
245 if( KeyTbl
[i
].keySymQt
== symQt
) {
246 *sym
= KeyTbl
[i
].keySymWin
;
252 if( symQt
!= Qt::Key_Shift
&& symQt
!= Qt::Key_Control
&& symQt
!= Qt::Key_Alt
&&
253 symQt
!= Qt::Key_Meta
&& symQt
!= Qt::Key_Direction_L
&& symQt
!= Qt::Key_Direction_R
)
254 kDebug(125) << "Sym::initQt( " << QString::number(keyQt
,16) << " ): failed to convert key.";
258 bool codeWinToKeyQt( uint sym
, int* keyQt
)
260 if( sym
>= Qt::Key_A
&& sym
<= Qt::Key_Z
) {
265 for( uint i
= 0; i
< sizeof(KeyTbl
); i
++ ) {
266 if( KeyTbl
[i
].keySymWin
== sym
) {
267 *keyQt
= KeyTbl
[i
].keySymQt
;