• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • util
kkeyserver_win.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Carlo Segato <brandon.ml@gmail.com>
3 
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.
8 
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.
13 
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.
18  */
19 
20 #include "kkeyserver_win.h"
21 
22 #include <kdebug.h>
23 #include <windows.h>
24 
25 namespace KKeyServer
26 {
27 
28  struct TransKey {
29  uint keySymQt;
30  uint keySymWin;
31  };
32 
33  static const TransKey KeyTbl[] =
34  {
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 //FIXME: under wince VK_MODECHANGE is not defined
47 #ifndef _WIN32_WCE
48  { Qt::Key_Mode_switch, VK_MODECHANGE },
49 #endif
50  { Qt::Key_Space, VK_SPACE },
51  { Qt::Key_PageUp, VK_PRIOR },
52  { Qt::Key_PageDown, VK_NEXT },
53  { Qt::Key_End, VK_END },
54  { Qt::Key_Home, VK_HOME },
55  { Qt::Key_Left, VK_LEFT },
56  { Qt::Key_Up, VK_UP },
57  { Qt::Key_Right, VK_RIGHT },
58  { Qt::Key_Down, VK_DOWN },
59  { Qt::Key_Select, VK_SELECT },
60  { Qt::Key_Printer, VK_PRINT },
61  { Qt::Key_Execute, VK_EXECUTE },
62  { Qt::Key_Print, VK_SNAPSHOT },
63  { Qt::Key_Insert, VK_INSERT },
64  { Qt::Key_Delete, VK_DELETE },
65  { Qt::Key_Help, VK_HELP },
66 /* { 0, VK_0 },
67  { 0, VK_1 },
68  { 0, VK_2 },
69  { 0, VK_3 },
70  { 0, VK_4 },
71  { 0, VK_5 },
72  { 0, VK_6 },
73  { 0, VK_7 },
74  { 0, VK_8 },
75  { 0, VK_9 },
76  { 0, VK_A },
77  { 0, VK_B },
78  { 0, VK_C },
79  { 0, VK_D },
80  { 0, VK_E },
81  { 0, VK_F },
82  { 0, VK_G },
83  { 0, VK_H },
84  { 0, VK_I },
85  { 0, VK_J },
86  { 0, VK_K },
87  { 0, VK_L },
88  { 0, VK_M },
89  { 0, VK_N },
90  { 0, VK_O },
91  { 0, VK_P },
92  { 0, VK_Q },
93  { 0, VK_R },
94  { 0, VK_S },
95  { 0, VK_T },
96  { 0, VK_U },
97  { 0, VK_V },
98  { 0, VK_W },
99  { 0, VK_X },
100  { 0, VK_Y },
101  { 0, VK_Z },*/
102  { Qt::Key_Meta, VK_LWIN },
103  { Qt::Key_Meta, VK_RWIN },
104  { Qt::Key_Menu, VK_APPS },
105  { Qt::Key_Sleep, VK_SLEEP },
106  { Qt::Key_0, VK_NUMPAD0 },
107  { Qt::Key_1, VK_NUMPAD1 },
108  { Qt::Key_2, VK_NUMPAD2 },
109  { Qt::Key_3, VK_NUMPAD3 },
110  { Qt::Key_4, VK_NUMPAD4 },
111  { Qt::Key_5, VK_NUMPAD5 },
112  { Qt::Key_6, VK_NUMPAD6 },
113  { Qt::Key_7, VK_NUMPAD7 },
114  { Qt::Key_8, VK_NUMPAD8 },
115  { Qt::Key_9, VK_NUMPAD9 },
116  { Qt::Key_Asterisk, VK_MULTIPLY },
117  { Qt::Key_Plus, VK_ADD },
118  { Qt::Key_Comma, VK_SEPARATOR },
119  { Qt::Key_Minus, VK_SUBTRACT },
120  { Qt::Key_Period, VK_DECIMAL },
121  { Qt::Key_Slash, VK_DIVIDE },
122  { Qt::Key_F1, VK_F1 },
123  { Qt::Key_F2, VK_F2 },
124  { Qt::Key_F3, VK_F3 },
125  { Qt::Key_F4, VK_F4 },
126  { Qt::Key_F5, VK_F5 },
127  { Qt::Key_F6, VK_F6 },
128  { Qt::Key_F7, VK_F7 },
129  { Qt::Key_F8, VK_F8 },
130  { Qt::Key_F9, VK_F9 },
131  { Qt::Key_F10, VK_F10 },
132  { Qt::Key_F11, VK_F11 },
133  { Qt::Key_F12, VK_F12 },
134  { Qt::Key_F13, VK_F13 },
135  { Qt::Key_F14, VK_F14 },
136  { Qt::Key_F15, VK_F15 },
137  { Qt::Key_F16, VK_F16 },
138  { Qt::Key_F17, VK_F17 },
139  { Qt::Key_F18, VK_F18 },
140  { Qt::Key_F19, VK_F19 },
141  { Qt::Key_F20, VK_F20 },
142  { Qt::Key_F21, VK_F21 },
143  { Qt::Key_F22, VK_F22 },
144  { Qt::Key_F23, VK_F23 },
145  { Qt::Key_F24, VK_F24 },
146  { Qt::Key_NumLock, VK_NUMLOCK },
147  { Qt::Key_ScrollLock, VK_SCROLL },
148 // { 0, VK_OEM_FJ_JISHO },
149 // { Qt::Key_Massyo, VK_OEM_FJ_MASSHOU },
150 // { Qt::Key_Touroku, VK_OEM_FJ_TOUROKU },
151 // { 0, VK_OEM_FJ_LOYA },
152 // { 0, VK_OEM_FJ_ROYA },
153  { Qt::Key_Shift, VK_LSHIFT },
154  { Qt::Key_Shift, VK_RSHIFT },
155  { Qt::Key_Control, VK_LCONTROL },
156  { Qt::Key_Control, VK_RCONTROL },
157  { Qt::Key_Alt, VK_LMENU },
158  { Qt::Key_Alt, VK_RMENU },
159 
160 // winuser.h from psdk w2kserver2003R2 defines the following constants only for _WIN32_WINNT >= 0x0500
161 // and we should also do so - otherwise the constants may not be available
162 #if(_WIN32_WINNT >= 0x0500)
163  { Qt::Key_Back, VK_BROWSER_BACK },
164  { Qt::Key_Forward, VK_BROWSER_FORWARD },
165  { Qt::Key_Refresh, VK_BROWSER_REFRESH },
166  { Qt::Key_Stop, VK_BROWSER_STOP },
167  { Qt::Key_Search, VK_BROWSER_SEARCH },
168  { Qt::Key_Favorites, VK_BROWSER_FAVORITES },
169  { Qt::Key_HomePage, VK_BROWSER_HOME },
170  { Qt::Key_VolumeMute, VK_VOLUME_MUTE },
171  { Qt::Key_VolumeDown, VK_VOLUME_DOWN },
172  { Qt::Key_VolumeUp, VK_VOLUME_UP },
173  { Qt::Key_MediaNext, VK_MEDIA_NEXT_TRACK },
174  { Qt::Key_MediaPrevious, VK_MEDIA_PREV_TRACK },
175  { Qt::Key_MediaStop, VK_MEDIA_STOP },
176  { Qt::Key_MediaPlay, VK_MEDIA_PLAY_PAUSE },
177  { Qt::Key_LaunchMail, VK_LAUNCH_MAIL },
178  { Qt::Key_LaunchMedia, VK_LAUNCH_MEDIA_SELECT },
179  { Qt::Key_Launch0, VK_LAUNCH_APP1 },
180  { Qt::Key_Launch1, VK_LAUNCH_APP2 },
181 #endif
182 /* { 0, VK_OEM_1 },
183  { 0, VK_OEM_PLUS },
184  { 0, VK_OEM_COMMA },
185  { 0, VK_OEM_MINUS },
186  { 0, VK_OEM_PERIOD },
187  { 0, VK_OEM_2 },
188  { 0, VK_OEM_3 },
189  { 0, VK_OEM_4 },
190  { 0, VK_OEM_5 },
191  { 0, VK_OEM_6 },
192  { 0, VK_OEM_7 },
193  { 0, VK_OEM_8 },*/
194  { Qt::Key_Play, VK_PLAY },
195  { Qt::Key_Zoom, VK_ZOOM },
196  { Qt::Key_Clear, VK_OEM_CLEAR },
197 // { 0
198  };
199 
200  bool keyQtToModWin( int keyQt, uint* mod )
201  {
202  *mod = 0;
203  if (keyQt & Qt::ShiftModifier) {
204  *mod |= MOD_SHIFT;
205  }
206  if (keyQt & Qt::ControlModifier) {
207  *mod |= MOD_CONTROL;
208  }
209  if (keyQt & Qt::AltModifier) {
210  *mod |= MOD_ALT;
211  }
212  if (keyQt & Qt::MetaModifier) {
213  *mod |= MOD_WIN;
214  }
215 
216  return true;
217  }
218 
219  bool modWinToKeyQt( uint mod, int *keyQt )
220  {
221  *keyQt = 0;
222  if (mod & MOD_SHIFT) {
223  *keyQt |= Qt::ShiftModifier;
224  }
225  if (mod & MOD_CONTROL) {
226  *keyQt |= Qt::ControlModifier;
227  }
228  if (mod & MOD_ALT) {
229  *keyQt |= Qt::AltModifier;
230  }
231  if (mod & MOD_WIN) {
232  *keyQt |= Qt::MetaModifier;
233  }
234 
235  return true;
236  }
237 
238  bool keyQtToCodeWin( int keyQt, uint* sym )
239  {
240  int symQt = keyQt & ~Qt::KeyboardModifierMask;
241 
242  if( symQt >= Qt::Key_A && symQt <= Qt::Key_Z ) {
243  *sym = symQt;
244  return true;
245  }
246 
247  for( uint i = 0; i < sizeof(KeyTbl); i++ ) {
248  if( KeyTbl[i].keySymQt == symQt ) {
249  *sym = KeyTbl[i].keySymWin;
250  return true;
251  }
252  }
253 
254  *sym = 0;
255  if( symQt != Qt::Key_Shift && symQt != Qt::Key_Control && symQt != Qt::Key_Alt &&
256  symQt != Qt::Key_Meta && symQt != Qt::Key_Direction_L && symQt != Qt::Key_Direction_R )
257  kDebug(125) << "Sym::initQt( " << QString::number(keyQt,16) << " ): failed to convert key.";
258  return false;
259  }
260 
261  bool codeWinToKeyQt( uint sym, int* keyQt )
262  {
263  if( sym >= Qt::Key_A && sym <= Qt::Key_Z ) {
264  *keyQt = sym;
265  return true;
266  }
267 
268  for( uint i = 0; i < sizeof(KeyTbl); i++ ) {
269  if( KeyTbl[i].keySymWin == sym ) {
270  *keyQt = KeyTbl[i].keySymQt;
271  return true;
272  }
273  }
274 
275  *keyQt = 0;
276  return false;
277  }
278 
279 }
kdebug.h
KKeyServer::codeWinToKeyQt
bool codeWinToKeyQt(uint sym, int *keyQt)
Definition: kkeyserver_win.cpp:261
kDebug
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString::number
QString number(int n, int base)
KKeyServer::modWinToKeyQt
bool modWinToKeyQt(uint mod, int *keyQt)
Definition: kkeyserver_win.cpp:219
kkeyserver_win.h
KKeyServer::keyQtToCodeWin
bool keyQtToCodeWin(int keyQt, uint *sym)
Extracts the symbol from the given Qt key and converts it to a Windows symbol.
Definition: kkeyserver_win.cpp:238
KKeyServer::keyQtToModWin
bool keyQtToModWin(int keyQt, uint *mod)
Extracts the modifiers from the given Qt key and converts them in a mask of Windows modifiers...
Definition: kkeyserver_win.cpp:200
KKeyServer::KeyTbl
static const TransKey KeyTbl[]
Definition: kkeyserver_win.cpp:33
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:23:59 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal