📄 builtinkeypad_0409.cpp
字号:
0 , // 0x0D
0 , // 0x0E
0 , // 0x0F
'A' , // 0x10
'B' , // 0x11
'C' , // 0x12
'D' , // 0x13
'E' , // 0x14
'F' , // 0x15
'G' , // 0x16
'H' , // 0x17
'I' , // 0x18
'J' , // 0x19
'K' , // 0x1A
'L' , // 0x1B
'M' , // 0x1C
'N' , // 0x1D
'O' , // 0x1E
'P' , // 0x1F
'Q' , // 0x20
'R' , // 0x21
'S' , // 0x22
'T' , // 0x23
'U' , // 0x24
'V' , // 0x25
'W' , // 0x26
'X' , // 0x27
'Y' , // 0x28
'Z' , // 0x29
0 , // 0x2A
0 , // 0x2B
0 , // 0x2C
0 , // 0x2D
0 , // 0x2E
0 , // 0x2F
0 , // 0x30
VK_BACK , // 0x31
VK_CAPITAL , // 0x32
VK_CONTROL , // 0x33
VK_TRIGHT , // 0x34
VK_SPACE , // 0x35
VK_RETURN , // 0x36
VK_BACK , // 0x37
VK_DOWN , // 0x38
VK_END , // 0x39
VK_HOME , // 0x3A
VK_LEFT , // 0x3B
0 , // 0x3C
VK_LWIN , // 0x3D
VK_RWIN , // 0x3E
VK_MULTIPLY , // 0x3F
VK_EXECUTE , // 0x40
VK_UP , // 0x41
VK_DOWN , // 0x42
VK_UP , // 0x43
}; // MainScanCodeToVKeyTable[]
const UINT8 UniqueKeyScanCodeToVKeyTable[UNIQUE_KEY_SCAN_CODE_TABLE_SIZE] =
{
0x80, // '.' ,'<'
0x81, // '@' ,'>'
0x82, // '/' ,'{'
0x83, // '\\' ,'}'
0x84, // '!' ,'~'
0x85, // '?' ,'|'
0x86, // '$' ,'^'
0x87, // '&' ,'_'
0x88, // ':' ,'+'
0x89, // ';' ,'-'
0x8A, // ',' ,'%'
0x8B, // '\t' ,'='
0x8C, // '(' ,'['
0x8D, // ')' ,']'
// Unlike the language (real keyboard), we treat caps lock
// as shift for the quotes key. So it needs special handling
0x8E, // ''' ,'"'
0x8F, // # for PPC
}; // UniqueKeyScanCodeToVKeyTable[]
// src: vk unshifted shifted
// transform: vk shifted? vk shifted?
static const MARKER_VK_MAP markerVkMapping[] = {
{ 0x80, {VK_PERIOD, XLLP_FALSE}, {VK_COMMA, XLLP_TRUE} }, // '.' ,'<'
{ 0x81, {'2', XLLP_TRUE}, {VK_PERIOD, XLLP_TRUE} }, // '@' ,'>'
{ 0x82, {VK_SLASH, XLLP_FALSE}, {VK_LBRACKET, XLLP_TRUE} }, // '/' ,'{'
{ 0x83, {VK_BACKSLASH, XLLP_FALSE}, {VK_RBRACKET, XLLP_TRUE} }, // '\\' ,'}'
{ 0x84, {'1', XLLP_TRUE}, {VK_BACKQUOTE, XLLP_TRUE} }, // '!' ,'~'
{ 0x85, {VK_SLASH, XLLP_TRUE}, {VK_BACKSLASH, XLLP_TRUE} }, // '?' ,'|'
{ 0x86, {'4', XLLP_TRUE}, {'6', XLLP_TRUE} }, // '$' ,'^'
{ 0x87, {'7', XLLP_TRUE}, {VK_HYPHEN, XLLP_TRUE} }, // '&' ,'_'
{ 0x88, {VK_SEMICOLON, XLLP_TRUE}, {VK_ADD, XLLP_FALSE} }, // ':' ,'+'
{ 0x89, {VK_SEMICOLON, XLLP_FALSE}, {VK_HYPHEN, XLLP_FALSE} }, // ';' ,'-'
{ 0x8A, {VK_COMMA, XLLP_FALSE}, {'5', XLLP_TRUE} }, // ',' ,'%'
{ 0x8B, {VK_TAB, XLLP_FALSE}, {VK_EQUAL, XLLP_FALSE} }, // '\t' ,'='
{ 0x8C, {'9', XLLP_TRUE}, {VK_LBRACKET, XLLP_FALSE} }, // '(' ,'['
{ 0x8D, {'0', XLLP_TRUE}, {VK_RBRACKET, XLLP_FALSE} }, // ')' ,']'
{ 0x8E, {VK_APOSTROPHE,XLLP_FALSE}, {VK_APOSTROPHE,XLLP_TRUE} }, // ''' ,'"'
{ 0x8F, {'3' ,XLLP_TRUE}, {'3' ,XLLP_TRUE}, }, // # for PPC
}; // markerVkMapping[]
static ScanCodeToVKeyData MainScanCodeToVKeyTableInfo =
{
0,
MainScanCodeTableFirst,
MainScanCodeTableLast,
(UINT8 *) &MainScanCodeToVKeyTable[0]
};
static ScanCodeToVKeyData UniqueKeyScanCodeToVKeyTableInfo =
{
UNIQUE_KEY_SC_PREPEND_MSK,
UniqueKeyScanCodeTableFirst,
UniqueKeyScanCodeTableLast,
(UINT8 *) &UniqueKeyScanCodeToVKeyTable[0]
};
static ScanCodeToVKeyData *rgscvkBuiltInKeypad_Tables[] =
{ &MainScanCodeToVKeyTableInfo, &UniqueKeyScanCodeToVKeyTableInfo };
// Find a virtual key mapping in the given array.
static const MARKER_VK_MAP * FindMarkerVK (UINT32 uiVK)
{
// For now, our only remapping is to get the non-alphanumeric
// characters from the keypad into a form that will be re-
// transformed by the 409 locale input language to become
// what we really wanted in the first place. That transform
// is based on an AT style standard keyboard.
const MARKER_VK_MAP *seeker = &markerVkMapping[0];
int i = sizeof (markerVkMapping) / sizeof (MARKER_VK_MAP);
while ((uiVK != seeker->markerVK) && i--)
{
seeker++;
}
if (-1==i)
{
seeker = NULL;
}
// NKDbgPrintfW(TEXT("FindMarkerVK: uiVK= 0x%X;i=%d; seeker = 0x%Xr\n"),uiVK,i,seeker);
return(seeker);
} // FindMarkerVK()
#define KEY_STATE_ALL_SHIFTS_MSK (KeyShiftAnyShiftFlag | KeyShiftCapitalFlag |\
KeyShiftLeftShiftFlag | KeyShiftRightShiftFlag)
static
UINT
WINAPI
BuiltInKeypad_RemapVKey(
const KEYBD_EVENT *pKbdEvents,
UINT cKbdEvents,
KEYBD_EVENT *pRmpKbdEvents,
UINT cMaxRmpKbdEvents
)
{
SETFNAME(_T("BuiltInKeypad_RemapVKey"));
const MARKER_VK_MAP * markerVK_p = NULL;
const MARKER_VK_TRANSFORM * transformedVkInfo_p;
UINT totalRemappedEvents = 0;
UINT32 uiVkTmp;
KEYBD_EVENT * localRmp_p = pRmpKbdEvents;
const KEYBD_EVENT * localOrigEvts_p = pKbdEvents;
DEBUGMSG(ZONE_FUNCTION, (TEXT("+BuiltInKeypad_RemapVKey: cKbdEvents = %d\r\n"), cKbdEvents));
if (pRmpKbdEvents == NULL)
// In case this works like NumPadRemapVKey():
// "The Layout manager calls this the first time that the Device Layout
// is loaded. We will set up our global state here."
// But we're not keeping a global state yet
{
// One use of this null call is for client to size buffers.
// Theoretically, we could have 3:1 expansion the same as
// NumPadRemapVKey()
totalRemappedEvents = cKbdEvents * 3; // 1 to 3 mapping
}
else
{
for (UINT ui = 0; ui < cKbdEvents; ++ui)
{
if (UNIQUE_KEY_SC_PREPEND_MSK == (UNIQUE_KEY_SC_PREPEND_MSK & localOrigEvts_p->uiSc))
{
uiVkTmp = localOrigEvts_p->uiVk & ~UNIQUE_KEY_SC_PREPEND_MSK;
// One of our unique keys. Special handling
// We should have a marker VK: transform it into the
// VK and shift state that will be correctly interpreted
// by the input language.
markerVK_p = FindMarkerVK (uiVkTmp);
if (markerVK_p)
{
if (localOrigEvts_p->KeyStateFlags & KeyShiftCapitalFlag)
{
transformedVkInfo_p = &markerVK_p->shiftedInputTransform;
}
else
{
transformedVkInfo_p = &markerVK_p->unShiftedInputTransform;
}
// for testing, ignore other sources of shift key.
// If this works, will have to become a bit more complex.
if (XLLP_TRUE == transformedVkInfo_p->reportStateAsShifted)
{
// localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags | KeyShiftAnyShiftFlag;
// Force the shifted state. No access to instantaneous one-key shift state change.
localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags | KeyStateDownFlag;
localRmp_p->uiVk = VK_SHIFT; // set shift state to true
localRmp_p->uiSc = 0x4D; // invent a scan code
localRmp_p++;
totalRemappedEvents++;
localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags;
localRmp_p->uiVk = transformedVkInfo_p->outputVK;
localRmp_p->uiSc = localOrigEvts_p->uiSc;
localRmp_p++;
totalRemappedEvents++;
localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags & ~KeyStateDownFlag;
localRmp_p->uiVk = VK_SHIFT; // set shift state to true
localRmp_p->uiSc = 0x4D; // invent a scan code
}
else
{
localRmp_p->uiVk = transformedVkInfo_p->outputVK;
localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags & (~KEY_STATE_ALL_SHIFTS_MSK);
localRmp_p->uiSc = localOrigEvts_p->uiSc;
}
}
else
{
DEBUGMSG(ZONE_ERROR, (TEXT("Error - false detection of unique key\r\n")));
}
} // End of unique key processing
else
{
// Standard key. Normal processing.
localRmp_p->KeyStateFlags = localOrigEvts_p->KeyStateFlags;
localRmp_p->uiVk = localOrigEvts_p->uiVk;
localRmp_p->uiSc = localOrigEvts_p->uiSc;
}
localRmp_p++;
localOrigEvts_p++;
totalRemappedEvents++;
}
}
DEBUGMSG(ZONE_FUNCTION, (TEXT("-BuiltInKeypad_RemapVKey\r\n")));
return totalRemappedEvents;
} // BuiltInKeypad_RemapVKey()
static DEVICE_LAYOUT dlBuiltInKeypad =
{
sizeof(DEVICE_LAYOUT),
KEYPAD_PDD_ID,
rgscvkBuiltInKeypad_Tables,
dim(rgscvkBuiltInKeypad_Tables),
BuiltInKeypad_RemapVKey,
};
// suffix _00000409 is required for layouts that support
// locale 0409 (US English)
extern "C"
BOOL
BuiltInKeypad_00000409(
//BuiltInKeypad(
PDEVICE_LAYOUT pDeviceLayout
)
{
DEBUGCHK(pDeviceLayout != NULL);
BOOL fRet = FALSE;
if (pDeviceLayout->dwSize != sizeof(DEVICE_LAYOUT)) {
RETAILMSG(1, (_T("BuiltInKeypad_00000409: data structure size mismatch\r\n")));
goto leave;
}
// Make sure that the Sc->Vk tables are the sizes that we expect
DEBUGCHK(dim(MainScanCodeToVKeyTable) == (1 + MainScanCodeTableLast - MainScanCodeTableFirst));
*pDeviceLayout = dlBuiltInKeypad;
DEBUGMSG(1, (TEXT("\r\nKeyPad: Set dlBuiltInKeypad as Layout\r\n")));
fRet = TRUE;
leave:
return fRet;
}
#ifdef DEBUG
// Verify function declaration against the typedef.
static PFN_DEVICE_LAYOUT_ENTRY v_pfnDeviceLayout = BuiltInKeypad_00000409;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -