1 |
/******************************************************************************* |
= |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
|
2 |
* Copyright (c) 2000, 2005 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
|
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
|
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
|
7 |
* |
8 |
* Contributors: |
|
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
|
9 |
* IBM Corporation - initial API and implementation |
10 |
*******************************************************************************/ |
|
10 |
*******************************************************************************/ |
|
|
<> |
11 |
|
|
|
|
12 |
/******************************************************************************* |
|
|
|
13 |
* Additions/modifications to this source file by Oracle America, Inc. 2011 |
|
|
|
14 |
*******************************************************************************/ |
|
|
|
15 |
|
11 |
#include "KeyUtils.h" |
= |
16 |
#include "KeyUtils.h" |
12 |
|
|
17 |
|
13 |
/** |
|
18 |
/** |
14 |
* This method converts the incomming UGL keycode to be a native |
|
19 |
* This method converts the incomming UGL keycode to be a native |
15 |
* VK_* keycode. |
|
20 |
* VK_* keycode. |
16 |
*/ |
|
21 |
*/ |
17 |
int KeyUtils_ConvertToNativeKeycode(int keycode) { |
|
22 |
int KeyUtils_ConvertToNativeKeycode(int keycode) { |
18 |
int i=0; |
|
23 |
int i=0; |
19 |
for (i=0; i < KeyTableSize; i++) { |
|
24 |
for (i=0; i < KeyTableSize; i++) { |
20 |
if (KeyTable[i][1] == keycode) { |
|
25 |
if (KeyTable[i][1] == keycode) { |
21 |
return KeyTable[i][0]; |
|
26 |
return KeyTable[i][0]; |
22 |
} |
|
27 |
} |
23 |
} |
|
28 |
} |
24 |
|
|
29 |
|
25 |
#ifndef _WIN32_WCE |
|
30 |
#ifndef _WIN32_WCE |
26 |
{ |
|
31 |
{ |
27 |
LPTSTR lowerChar; |
|
32 |
LPTSTR lowerChar; |
28 |
// The incomming keycodes from Java are captial letters for |
|
33 |
// The incomming keycodes from Java are captial letters for |
29 |
// the a-z keys, but VkKeyScan returns incorrect values for captial |
|
34 |
// the a-z keys, but VkKeyScan returns incorrect values for captial |
30 |
// letters. The workaround is to convert the keycode to lowercase, |
|
35 |
// letters. The workaround is to convert the keycode to lowercase, |
31 |
// which should not affect the other character keys |
|
36 |
// which should not affect the other character keys |
32 |
lowerChar = CharLower((LPTSTR)keycode); |
|
37 |
lowerChar = CharLower((LPTSTR)keycode); |
33 |
return VkKeyScan((WCHAR)lowerChar) & 0x0000FFFF; |
|
38 |
return VkKeyScan((WCHAR)lowerChar) & 0x0000FFFF; |
34 |
} |
|
39 |
} |
35 |
#else |
<> |
40 |
#else |
|
|
|
41 |
for (i=0; i < WMKeyTableSize; ++i) { |
|
|
|
42 |
if (WMKeyTable[i][1] == keycode) { |
|
|
|
43 |
return WMKeyTable[i][0]; |
|
|
|
44 |
} |
|
|
|
45 |
} |
36 |
return (int)(CharUpper((LPTSTR)keycode)); |
= |
46 |
return (int)(CharUpper((LPTSTR)keycode)); |
37 |
#endif |
|
47 |
#endif |
38 |
} |
|
48 |
} |