case CHK_MODIFIER:
// Modifiers format: controlnum bOffset bAxisID bBtnType bModType fToggle fStatus dwSpecific
if ( dwSection == CHK_MODIFIERS || pController )
{
int controlnum = 0;
MODIFIER modWorking;
ZeroMemory(&modWorking, sizeof(modWorking));
unsigned int tOffset, tAxisID, tBtnType, tModType, tToggle, tStatus, tSpecific;
if (sscanf(pszLine, "%u %x %u %u %u %u %u %x", &controlnum, &tOffset, &tAxisID,
&tBtnType, &tModType, &tToggle, &tStatus, &tSpecific) != 8)
return false;
// done to overcome issues with sscanf and "small" data blocks
modWorking.btnButton.bOffset = tOffset;
modWorking.btnButton.bAxisID = tAxisID;
modWorking.btnButton.bBtnType = tBtnType;
modWorking.bModType = tModType;
modWorking.fToggle = tToggle;
modWorking.fStatus = tStatus;
modWorking.dwSpecific = tSpecific; // looks stupid, but unsigned int might not always be DWORD32
// Now we need to assign parentdevice. If we have a valid gGUID, we'll use that...
int found = FindDeviceinList(gGUID);
if (found != -1)
modWorking.btnButton.parentDevice = &g_devList[found];
else
{
// ... otherwise, we do the following in order:
// 1. If bBtnType is of type DT_MOUSEBUTTON or DT_MOUSEAXE, set gGUID to that of g_sysMouse (ignoring the given name and number)
if ( modWorking.btnButton.bBtnType == DT_MOUSEBUTTON || modWorking.btnButton.bBtnType == DT_MOUSEAXE )
{
modWorking.btnButton.parentDevice = &g_sysMouse;
}
// 2. If bBtnType is of type DT_KEYBUTTON, set gGUID to that of SysKeyboard
else if ( modWorking.btnButton.bBtnType == DT_KEYBUTTON )
{
gGUID = GUID_SysKeyboard;
int found = FindDeviceinList(gGUID);
if (found != -1)
modWorking.btnButton.parentDevice = &g_devList[found];
else
modWorking.btnButton.parentDevice = NULL;
}
// 3. otherwise, look up the name and number using FindDeviceinList, and set gGUID to that
else
{
found = FindDeviceinList(pszDeviceName, bDeviceNr, true);
if (found != -1)
{
gGUID = g_devList[found].guidInstance;
modWorking.btnButton.parentDevice = &g_devList[found];
}
else
{
DebugWrite(_T("ProcessKey: couldn't find a device in g_devList for %s %d\n"), pszDeviceName, bDeviceNr);
gGUID = GUID_NULL;
modWorking.btnButton.parentDevice = NULL;
return false;
}
}
}