Archive for the Keyboard Category

Keyboard driver for Multi language layer support on WinCE

Posted in Driver, Keyboard, WinCE on 2008 年 04 月 09 日 by Kun-Yi

重點是 在HKUSERKeyboard LayoutPreload 與下面的子Key要match, Layout manager 才會載入正確的 Layout

子Key 範圍依照目前標準的LayoutManager 是 1 ~ 15, 覺得不夠,可以去改Layout Manager

[HKUSERKeyboard LayoutPreload]
@="xxxxxxxx" ; like to “00000409″/"e0010409″/"0000040C"
HKUSERKeyboard LayoutPreload1]
@="yyyyyyyy"
[HKUSERKeyboard LayoutPreloadN]
@="xxxxxxxx" ; match [HKUSERKeyboard LayoutPreload] key
[HKUSERKeyboard LayoutPreload15]
@="zzzzzzzz"

每個Layout 的設定 Registry 在[HKLMSYSTEMCurrentControlSetControlLayoutsxxxxxxxx] 下面設定

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLayouts0000409]
“Layout File"="kbdmouse.dll"        ;
“Layout Text"="US"
“PS2_AT"="kbdmouse.dll"              ; funciton Prefix , Layout Manager use it PS2_AT_00000409 function
“BuiltInKeypad"="kbdmouse.dll"    ; funciton Prefix , Layout Manager use it BuiltInKeypad_00000409 function

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLayouts000040C]
“Layout File"="kbdmouse.dll"        ;
“Layout Text"="US"
“PS2_AT"="kbdmouse.dll"              ; funciton Prefix , Layout Manager use it PS2_AT_0000040C function
“BuiltInKeypad"="kbdmouse.dll"    ; funciton Prefix , Layout Manager use it BuiltInKeypad_0000040C function

Keyboard layout 可以透過 kbdgen 去產生,正確的 PS_AT_XXXXXXXX 與 IL_XXXXXXXX 給MapVirtualKey(nCode, 3) 呼叫(某測試規範要求必測), 記得要改成正確的名稱,另外要注意的是使用kbdgen 時,它用到XP的Keyboard layout DLL 要從 \windows\system32 複製到執行目錄下。


Run kbdgen log

%WINCEROOT%PLATFORMMYDEVICEsrcdevlayout>kbdgen kbdfr.dll -o 040C
kbdgen for Windows CE (Release) (Built on Dec 30 2003 15:22:20)
Warning - Generating desktop VK to CE VK conversions for the Input Language:
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF
Warning - Generating VKeyToXTScanCodeTable:
Warning -   The following duplicate entries have been ignored
Warning -   Virtual key VK_CLEAR             (0x0C) - Scan code 0x59
Warning -   Virtual key VK_TAB               (0x09) - Scan code 0x7C
Warning -   Virtual key VK_RETURN            (0x0D) - Scan code 0xE01C
Warning - Generating desktop VK to CE VK conversions for the Device Layout:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF
Warning -   Desktop VK_OEM_WSCTRL    no CE match
Warning -   Desktop VK_OEM_FINISH    assigned to CE VK_DBE_KATAKANA
Warning -   Desktop VK_OEM_JUMP      no CE match
Warning -   Desktop VK_OEM_BACKTAB   assigned to CE VK_DBE_ROMAN
Warning -   Desktop VK_OEM_AUTO      assigned to CE VK_DBE_SBCSCHAR
Warning -   Desktop VK_OEM_PA3       no CE match
Warning -   Desktop VK_OEM_RESET     no CE match
Warning -   Desktop VK_ABNT_C1       no CE match
Warning -   Desktop VK_OEM_PA1       no CE match
Warning -   Desktop VK_ABNT_C2       no CE match
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF

%WINCEROOT%PLATFORMMYDEVICEsrcdevlayout>kbdgen kbdgr.dll -o 0407
kbdgen for Windows CE (Release) (Built on Dec 30 2003 15:22:20)
Warning - Generating desktop VK to CE VK conversions for the Input Language:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_MINUS     assigned to CE VK_HYPHEN
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning - Generating VKeyToXTScanCodeTable:
Warning -   The following duplicate entries have been ignored
Warning -   Virtual key VK_CLEAR             (0x0C) - Scan code 0x59
Warning -   Virtual key VK_TAB               (0x09) - Scan code 0x7C
Warning -   Virtual key VK_RETURN            (0x0D) - Scan code 0xE01C
Warning - Generating desktop VK to CE VK conversions for the Device Layout:
Warning -   Desktop VK_OEM_4         assigned to CE VK_LBRACKET
Warning -   Desktop VK_OEM_6         assigned to CE VK_RBRACKET
Warning -   Desktop VK_OEM_1         assigned to CE VK_SEMICOLON
Warning -   Desktop VK_OEM_PLUS      assigned to CE VK_EQUAL
Warning -   Desktop VK_OEM_3         assigned to CE VK_BACKQUOTE
Warning -   Desktop VK_OEM_7         assigned to CE VK_APOSTROPHE
Warning -   Desktop VK_OEM_5         assigned to CE VK_BACKSLASH
Warning -   Desktop VK_OEM_2         assigned to CE VK_SLASH
Warning -   Desktop VK_OEM_COMMA     assigned to CE VK_COMMA
Warning -   Desktop VK_OEM_PERIOD    assigned to CE VK_PERIOD
Warning -   Desktop VK_OEM_MINUS     assigned to CE VK_HYPHEN
Warning -   Desktop VK_OEM_WSCTRL    no CE match
Warning -   Desktop VK_OEM_FINISH    assigned to CE VK_DBE_KATAKANA
Warning -   Desktop VK_OEM_JUMP      no CE match
Warning -   Desktop VK_OEM_BACKTAB   assigned to CE VK_DBE_ROMAN
Warning -   Desktop VK_OEM_AUTO      assigned to CE VK_DBE_SBCSCHAR
Warning -   Desktop VK_OEM_PA3       no CE match
Warning -   Desktop VK_OEM_RESET     no CE match
Warning -   Desktop VK_ABNT_C1       no CE match
Warning -   Desktop VK_OEM_PA1       no CE match
Warning -   Desktop VK_ABNT_C2       no CE match
Warning -   Desktop VK_OEM_8         assigned to CE VK_OFF

然後放在自己Driver 的source directory,還要改 .def 去 EXPORT 出正確的介面 

例如本來只有

IL_00000409
BuiltInKeypad_00000409
PS2_AT_00000409
改成
IL_00000409
IL_0000040C
IL_00000407

BuiltInKeypad_00000409
BuiltInKeypad_0000040C
BuiltInKeypad_00000407

PS2_AT_00000409
PS2_AT_0000040C
PS2_AT_00000407

Source 的 Link Lib. 也要加入, 這是目前改的有support 0409(En-US)/040C(FRA)/0407(GER)

SOURCELIBS=
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_BuiltInKeypad_0409_Layout.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_pddList.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)mainstoneii_keypad.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)InputLang_0409.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)InputLang_040C.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)InputLang_0407.lib

$(_COMMONOAKROOT)lib$(_CPUINDPATH)kbdus_lib.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)kbdfr_lib.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)kbdgr_lib.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)Nop_KbdCommon.lib
$(_TARGETPLATROOT)lib$(_CPUINDPATH)LayoutManager.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)KeybdIst.lib
$(_COMMONOAKROOT)lib$(_CPUINDPATH)NumPadRmp.lib


下面是個人目前工作平台上的一個 keyboard driver log, 可以看出LayoutManager 載入040C的相關 Layout 過程


Layout Manager : DLL_PROCESS_ATTACH
+KeybdDriverInitializeEx()
Lyg.p: Initialized PDD 0 – PS/2 NOP (Mask 4)
+KeyPad_Entry(), uiPddId: 0x1
KeyPad_Entry: Initialize Keypad_Entry ID 1

+KeyPad::Initialize()
+AllocKeyPadRegs()
-AllocKeyPadRegs(), Return: TRUE
+-KeyPad::KeyPadPowerOn()
Lyg.p: Received KBD1: notification
-KeyPad::Initialize()
+-KeyPad::IsrThreadStart()
+-KeyPad::KeyPadPowerOn()
-KeyPad_Entry(), KeyPad_Entry: Initialization complete
Lyg.p: Initialized PDD 1 – Keypad (Mask 16)
+GetDefaultInputMethodName(), pszName: “"
+GetPreloadUnNamedValue(), pszName :
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadUnNamedValue(), pszName : 0000040C, fRet : TRUE
+GetPreloadInputMethodName(), PreloadIndex : 1, pszName :
+GetPreloadInputMethodKey(), uiPreloadIndex : 1
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
+-KeyPadIsrThread()
-GetPreloadInputMethodKey(), szKeyBuf:"1″, fRet : TRUE
+KeyPad::IsrThreadProc()
+KeypadPdd_GetEventEx2()
+KeyPad::KeyPadDataRead(), pui8Data: 0xA3EFDBC
-KeyPad::KeyPadDataRead(), Return: FALSE
KeyPress happens: 0xff
-KeypadPdd_GetEventEx2(), event count = 1-GetPreloadInputMethodName(), pszName : e0010409, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : e0010409, szTempDefaultInputMethodName : 0000040C
+GetPreloadInputMethodName(), PreloadIndex : 2, pszName : e0010409
+GetPreloadInputMethodKey(), uiPreloadIndex : 2
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadInputMethodKey(), szKeyBuf:"2″, fRet : TRUE
-GetPreloadInputMethodName(), pszName : 00000409, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : 00000409, szTempDefaultInputMethodName : 0000040C
+GetPreloadInputMethodName(), PreloadIndex : 3, pszName : 00000409
+GetPreloadInputMethodKey(), uiPreloadIndex : 3
+-OpenPreloadKey(), pszRegPreload : Keyboard LayoutPreload
-GetPreloadInputMethodKey(), szKeyBuf:"3″, fRet : TRUE
-GetPreloadInputMethodName(), pszName : 0000040C, fRet : TRUE
=== to called GetPreloadInputMethodName(), szTempInputMethodName : 0000040C, szTempDefaultInputMethodName : 0000040C
-GetDefaultInputMethodName(), pszName: 0000040C, fRet : TRUE
Lyg.p: Found default input method 0000040C
+SetInputLanguage()
Lyg.p: Changing from input language 0x00000000 to 0x0000040c
+GetInputMethodInfo(), pszInputMethod : 0000040C
-GetInputMethodInfo(), pszFileValue : Layout File, pili->szDll : mainstoneii_keypad_Us.dll, fRet : TRUE

*** First(szProcName : ethod 000004
),2nd(szProcName : IL_, g_szProcPrefix : IL_)
*** Final : szProcName : IL_0000040C, iliNew.szName : 0000040C

+IL_0000040C(), French Keyboard
-IL_0000040C(), French Keyboard
-SetInputLanguage(), fRet : TRUE
+SetDeviceLayout(), uiPdd : 0x00000000
+SelectDeviceLayout() : pszHkl:(0000040C), pszDll:(),
pszProcName(), cchProcName(0x00000028)
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13F694
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13F694
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)
Lyg.p: Could not get the address of BuiltInKeypad from mainstoneii_keypad_Us.dll
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x00000000), pfnDLEntry(0x03B259C4)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B25D8C)), fRet : TRUE
+PS2_AT_0000040C(), French Keyboard
-PS2_AT_0000040C(), French Keyboard
Lyg.p: Found device layout match for PS/2 NOP and 0x0000040C: PS2_AT – mainstoneii_keypad_Us.dll
-SelectDeviceLayout(), fRet : TRUE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x00000000), pfnDLEntry(0x00000000)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(PS2_AT_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B25D8C)), fRet : TRUE
+PS2_AT_0000040C(), French Keyboard
-PS2_AT_0000040C(), French Keyboard
+ATRemapVKey()
-SetDeviceLayout(), fRet : TRUE
+SetDeviceLayout(), uiPdd : 0x00000001
+SelectDeviceLayout() : pszHkl:(0000040C), pszDll:(), pszProcName(), cchProcName(0x00000028)
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)
Lyg.p: Failed loading device layout DLL 0000040C
-GetDeviceLayoutEntry(pszDll(0000040C), pszProcName(Keyboard Layout), hDll(0x00000000), pfnDLEntry(0x20000010)), fRet : FALSE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x20000010)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13F694
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13F694
Lyg.p: Found device layout match for Keypad and 0x0000040C: BuiltInKeypad – mainstoneii_keypad_Us.dll
-SelectDeviceLayout(), fRet : TRUE
+GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x00000000), pfnDLEntry(0x03B25D8C)
-GetDeviceLayoutEntry(pszDll(mainstoneii_keypad_Us.dll), pszProcName(BuiltInKeypad_0000040C), hDll(0x8786DED8), pfnDLEntry(0x03B259C4)), fRet : TRUE
+BuiltInKeypad_0000040C(), pDeviceLayout: 0xA13FC58
-BuiltInKeypad_0000040C(), SetBuiltInKeypad pDeviceLayout: 0xA13FC58
+BuiltInKeypad_RemapVKey: cKbdEvents = 2
-SetDeviceLayout(), fRet : TRUE
Lyg.p: Layout Manager successfully initialized to  2
Lyg.p: keybd 1 scan code 0x000000ff Up
Lyg.p: PDD 1: Using device layout 0x0000040c with mask 0x0010
+ScanCodeToVKey(uiScanCode(0x000000FF), ScanCodeToVKeyData(0x01FBE110), cpscvk(2), puiVKey(0x0A38FE6C)
-ScanCodeToVKey(uiScanCode(0x000000FF), *puiVKey(0x00000000), fRet : FALSE
-KeybdDriverInitializeEx()
+Lyg.p
-Lyg.p

Technorati tags: , ,
廣告