forked from bartvdbraak/blender
Indentation changes
This commit is contained in:
parent
08426ec2e7
commit
6bc101fa7e
@ -766,8 +766,7 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
|
|||||||
GHOST_TUns64 now = getMilliSeconds();
|
GHOST_TUns64 now = getMilliSeconds();
|
||||||
|
|
||||||
static bool firstEvent = true;
|
static bool firstEvent = true;
|
||||||
if (firstEvent)
|
if (firstEvent) { // determine exactly which device is plugged in
|
||||||
{ // determine exactly which device is plugged in
|
|
||||||
RID_DEVICE_INFO info;
|
RID_DEVICE_INFO info;
|
||||||
unsigned infoSize = sizeof(RID_DEVICE_INFO);
|
unsigned infoSize = sizeof(RID_DEVICE_INFO);
|
||||||
info.cbSize = infoSize;
|
info.cbSize = infoSize;
|
||||||
@ -776,23 +775,23 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
|
|||||||
if (info.dwType == RIM_TYPEHID)
|
if (info.dwType == RIM_TYPEHID)
|
||||||
m_ndofManager->setDevice(info.hid.dwVendorId, info.hid.dwProductId);
|
m_ndofManager->setDevice(info.hid.dwVendorId, info.hid.dwProductId);
|
||||||
else
|
else
|
||||||
puts("<!> not a HID device... mouse/kb perhaps?");
|
puts("<!> not a HID device... mouse/kb perhaps?");
|
||||||
|
|
||||||
firstEvent = false;
|
firstEvent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The NDOF manager sends button changes immediately, and *pretends* to
|
// The NDOF manager sends button changes immediately, and *pretends* to
|
||||||
// send motion. Mark as 'sent' so motion will always get dispatched.
|
// send motion. Mark as 'sent' so motion will always get dispatched.
|
||||||
eventSent = true;
|
eventSent = true;
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// using Microsoft compiler & header files
|
// using Microsoft compiler & header files
|
||||||
// they invented the RawInput API, so this version is (probably) correct
|
// they invented the RawInput API, so this version is (probably) correct
|
||||||
BYTE const* data = raw.data.hid.bRawData;
|
BYTE const* data = raw.data.hid.bRawData;
|
||||||
// struct RAWHID {
|
// struct RAWHID {
|
||||||
// DWORD dwSizeHid;
|
// DWORD dwSizeHid;
|
||||||
// DWORD dwCount;
|
// DWORD dwCount;
|
||||||
// BYTE bRawData[1];
|
// BYTE bRawData[1];
|
||||||
// };
|
// };
|
||||||
#else
|
#else
|
||||||
// MinGW's definition (below) doesn't agree, so we need a slight
|
// MinGW's definition (below) doesn't agree, so we need a slight
|
||||||
@ -807,46 +806,46 @@ bool GHOST_SystemWin32::processNDOF(RAWINPUT const& raw)
|
|||||||
|
|
||||||
BYTE packetType = data[0];
|
BYTE packetType = data[0];
|
||||||
switch (packetType)
|
switch (packetType)
|
||||||
{
|
{
|
||||||
case 1: // translation
|
case 1: // translation
|
||||||
{
|
{
|
||||||
short* axis = (short*)(data + 1);
|
short* axis = (short*)(data + 1);
|
||||||
short t[3] = {axis[0], -axis[2], axis[1]};
|
short t[3] = {axis[0], -axis[2], axis[1]};
|
||||||
m_ndofManager->updateTranslation(t, now);
|
m_ndofManager->updateTranslation(t, now);
|
||||||
|
|
||||||
if (raw.data.hid.dwSizeHid == 13)
|
if (raw.data.hid.dwSizeHid == 13)
|
||||||
{ // this report also includes rotation
|
{ // this report also includes rotation
|
||||||
short r[3] = {-axis[3], axis[5], -axis[4]};
|
short r[3] = {-axis[3], axis[5], -axis[4]};
|
||||||
m_ndofManager->updateRotation(r, now);
|
m_ndofManager->updateRotation(r, now);
|
||||||
|
|
||||||
// I've never gotten one of these, has anyone else?
|
// I've never gotten one of these, has anyone else?
|
||||||
puts("ndof: combined T + R");
|
puts("ndof: combined T + R");
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 2: // rotation
|
case 2: // rotation
|
||||||
{
|
{
|
||||||
short* axis = (short*)(data + 1);
|
short* axis = (short*)(data + 1);
|
||||||
short r[3] = {-axis[0], axis[2], -axis[1]};
|
short r[3] = {-axis[0], axis[2], -axis[1]};
|
||||||
m_ndofManager->updateRotation(r, now);
|
m_ndofManager->updateRotation(r, now);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: // buttons
|
case 3: // buttons
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
// I'm getting garbage bits -- examine whole report:
|
// I'm getting garbage bits -- examine whole report:
|
||||||
printf("ndof: HID report for buttons [");
|
printf("ndof: HID report for buttons [");
|
||||||
for (int i = 0; i < raw.data.hid.dwSizeHid; ++i)
|
for (int i = 0; i < raw.data.hid.dwSizeHid; ++i)
|
||||||
printf(" %02X", data[i]);
|
printf(" %02X", data[i]);
|
||||||
printf(" ]\n");
|
printf(" ]\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int button_bits;
|
int button_bits;
|
||||||
memcpy(&button_bits, data + 1, sizeof(button_bits));
|
memcpy(&button_bits, data + 1, sizeof(button_bits));
|
||||||
m_ndofManager->updateButtons(button_bits, now);
|
m_ndofManager->updateButtons(button_bits, now);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return eventSent;
|
return eventSent;
|
||||||
}
|
}
|
||||||
#endif // WITH_INPUT_NDOF
|
#endif // WITH_INPUT_NDOF
|
||||||
|
Loading…
Reference in New Issue
Block a user