Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AltGr support for USB Keyboard

0 views
Skip to first unread message

Jitendra Kataria

unread,
Aug 26, 2003, 7:19:02 AM8/26/03
to
Hi,
For Windows CE.NET 4.2.
Question:
How can I support the AltGr key used in the German
Keyboard for the USB driver which uses the NOP driver for
the keyboard.
I have observed that this works for the PS2 keyboards
which uses 8042 driver and signals the remapped
keybd_event in the layout manager.
But for the usb driver the keybd_events are signaled in
the USB keyboard driver so I cant remapp the event.


Thanks in Advance

Jeetu

Steve Schrock [MS]

unread,
Aug 26, 2003, 12:39:46 PM8/26/03
to
You could add something like the following to ProcessModifier() in
kbdhid.cpp:

// Handle AltGr
if (uiVk == VK_RMENU) {
// Also send a Right Control
const USAGE_TO_SCANCODE *pUsageToSc = FindUsageToSc(USAGE_RCONTROL);
DEBUGCHK(pUsageToSc);
GenerateKeyInfo(pUsageToSc, &uiVk, &uiSc, &dwFlags, hidpKeyEvent);

if (uiVk == VK_RCONTROL) {
UpdateKeyState(pKeyStateFlags, (UINT8) uiVk, hidpKeyEvent);
KeyboardEvent(uiVk, uiSc, dwFlags);
}
else {
RETAILMSG(1, (_T("Keyboard: AltGr processing failed. Returned
vkey 0x%02X\r\n"),
uiVk));
}
}

where GenerateKeyInfo is something like

// Expands a usage, scan code, and flags to a full scan code and virtual
key.
static
void
GenerateKeyInfo(
const USAGE_TO_SCANCODE *pUsageToSc,
PUINT puiVk,
PUINT puiSc,
PDWORD pdwFlags,
HIDP_KEYBOARD_DIRECTION hidpKeyEvent
)
{
DEBUGCHK(pUsageToSc);
DEBUGCHK(puiVk);
DEBUGCHK(puiSc);
DEBUGCHK(pdwFlags);

*puiSc = pUsageToSc->uiSc;
*pdwFlags = 0;

if (hidpKeyEvent == HidP_Keyboard_Break) {
*pdwFlags |= KEYEVENTF_KEYUP;
}

// Prepend extended bits
switch (GET_EB(pUsageToSc->uiFlags)) {
case EB_E0:
*puiSc |= SC_EXTENDED_BITS;
*pdwFlags |= KEYEVENTF_EXTENDEDKEY;
break;

case EB_E114:
*puiSc |= SC_E1_BITS;
break;

case EB_NONE:
break;

default:
// Why are you here?
DEBUGCHK(FALSE);
};

// Convert scan code to virtual key
DEBUGCHK(IsAPIReady(SH_WMGR) == TRUE); // Exception if FALSE
*puiVk = MapVirtualKey(*puiSc, MAP_SC_TO_VK);
}

This ProcessModifier() code will force all right alts to AltGr. This will be
fine if you only need to support AltGr keyboards.

If you wish to support both AltGr and non-AltGr keyboards, you will want the
Layout Manager to tell kbdhid if it should use AltGr or not for the current
keyboard layout. This information is stored in the Input Language's
fLocaleFlags. If fLocaleFlags includes KLLF_ALTGR, then AltGr should be
used. At boot and whenever the Input Language is changed, the Layout Manager
should send an IOCTL to each KBDx: driver to report the fLocaleFlags. This
should be done in a similar way to the reporting the auto repeat timings.
For example, something like the following could be added to
KbdNotificationThread() in laymgr.cpp:

// Set the keyboard's locale flags
if (g_ili.hkl != INVALID_HKL) {
DWORD dwLocaleFlags = g_ili.il.fLocaleFlags;
DeviceIoControl(hKbd, IOCTL_KBD_SET_LOCALE_FLAGS,
&dwLocaleFlags,
sizeof(dwLocaleFlags), NULL, 0, NULL, NULL);
}

Also, SetInputLanguage() should broadcast the new fLocaleFlags to all KBDx:
drivers.

--
Steve Schrock
Windows CE Device Drivers

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jitendra Kataria" <jeetu...@yahoo.com> wrote in message
news:0ba301c36bc3$da9f17c0$a401...@phx.gbl...

Jitendra Kataria

unread,
Aug 29, 2003, 8:45:15 AM8/29/03
to

Thanks Steve for helping me out from my problem.
I have changed the USB keyboard driver and the Layout
manager so that it work for both the PS2 keyboards and
the USB keyboards.

Best Wishes,,
Jeetu

>.
>

0 new messages