Fixed C2275 compiler error in fg_spaceball_mswin.c

- Known to only affect Visual Studio 2010. Visual Studio 2013 and up may have relaxed the error.

(cherry picked from commit 6b8552edbd)

(cherry picked from commit 6b8552edbd)

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1779 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2015-12-14 16:22:44 +00:00
parent f812349a8f
commit 012736d296

View File

@ -64,14 +64,16 @@ void fgPlatformInitializeSpaceball(void)
} }
hwnd = fgStructure.CurrentWindow->Window.Handle; hwnd = fgStructure.CurrentWindow->Window.Handle;
BOOL ok; {
UINT cbSize = sizeof(__fgSpaceball); BOOL ok;
__fgSpaceball.hwndTarget = hwnd; UINT cbSize = sizeof(__fgSpaceball);
ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize); __fgSpaceball.hwndTarget = hwnd;
ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
if (!ok){ if (!ok){
__fgSpaceball.hwndTarget = NULL; __fgSpaceball.hwndTarget = NULL;
sball_initialized = 0; sball_initialized = 0;
}
} }
} }
@ -138,57 +140,58 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size); res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size);
if (res == -1) if (res == -1)
return; return;
SFG_Window* window = fgWindowByHandle(hwnd);
if ((window == NULL))
return;
if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
{ {
// Motion data comes in two parts: motion type and SFG_Window* window = fgWindowByHandle(hwnd);
// displacement/rotation along three axis. if ((window == NULL))
// Orientation is a right handed coordinate system with return;
// X goes right, Y goes up and Z goes towards viewer, e.g.
// the one used in OpenGL
if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_TRANSLATION)
{ // Translation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short X = pnData[0];
short Y = -pnData[2];
short Z = pnData[1];
INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_ROTATION)
{ // Axis aligned rotation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short rX = pnData[0];
short rY = -pnData[2];
short rZ = pnData[1];
INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_BUTTON)
{ // State of the keys
unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
unsigned int state = GLUT_UP;
if (FETCH_WCB(*window, SpaceButton))
{
int i;
for (i = 0; i < 32; i++)
{
unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
unsigned long stateNow = dwKeystate&(1 << i);
if (stateBefore && !stateNow) if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_DOWN)); {
if (!stateBefore && stateNow) // Motion data comes in two parts: motion type and
INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_UP)); // displacement/rotation along three axis.
// Orientation is a right handed coordinate system with
} // X goes right, Y goes up and Z goes towards viewer, e.g.
// the one used in OpenGL
if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_TRANSLATION)
{ // Translation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short X = pnData[0];
short Y = -pnData[2];
short Z = pnData[1];
INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_ROTATION)
{ // Axis aligned rotation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short rX = pnData[0];
short rY = -pnData[2];
short rZ = pnData[1];
INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
}
else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_BUTTON)
{ // State of the keys
unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
unsigned int state = GLUT_UP;
if (FETCH_WCB(*window, SpaceButton))
{
int i;
for (i = 0; i < 32; i++)
{
unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
unsigned long stateNow = dwKeystate&(1 << i);
if (stateBefore && !stateNow)
INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_DOWN));
if (!stateBefore && stateNow)
INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_UP));
}
}
__fgSpaceKeystate = dwKeystate;
} }
__fgSpaceKeystate = dwKeystate;
} }
} }
} }