From f008a928eaa4b6f595b987d2f86f82a5cc3224e7 Mon Sep 17 00:00:00 2001 From: Jinrong Xie Date: Mon, 29 Jun 2015 10:09:06 +0000 Subject: [PATCH] minor update making code more compact. (cherry picked from commit 09f401761814677e37e750aeecb9ffee450bd989) (cherry picked from commit 09f401761814677e37e750aeecb9ffee450bd989) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1761 7f0cb862-5218-0410-a997-914c9d46530a --- src/mswin/fg_main_mswin.c | 10 ++++------ src/mswin/fg_spaceball_mswin.c | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mswin/fg_main_mswin.c b/src/mswin/fg_main_mswin.c index 97b8363..247312d 100644 --- a/src/mswin/fg_main_mswin.c +++ b/src/mswin/fg_main_mswin.c @@ -1545,13 +1545,11 @@ LRESULT CALLBACK fgPlatformWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPAR #endif //Added by Jinrong Xie (stonexjr@gmail.com) 12/24/2014 //for SpaceNavigator support on Windows. - /* - case WM_ACTIVATEAPP: - fgInitialiseSpaceball(); - break; - */ case WM_INPUT: - fgSpaceballHandleWinEvent(hWnd, wParam, lParam); + if (fgHasSpaceball()) + { + fgSpaceballHandleWinEvent(hWnd, wParam, lParam); + } break; default: /* Handle unhandled messages */ diff --git a/src/mswin/fg_spaceball_mswin.c b/src/mswin/fg_spaceball_mswin.c index 901954d..ba2ccf0 100644 --- a/src/mswin/fg_spaceball_mswin.c +++ b/src/mswin/fg_spaceball_mswin.c @@ -148,7 +148,7 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) // 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)//0x01) + SPNAV_EVENT_MOTION_TRANSLATION) { // Translation vector short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]); short X = pnData[0]; @@ -157,7 +157,7 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) INVOKE_WCB(*window, SpaceMotion, (X, Y, Z)); } else if (pRawInput->data.hid.bRawData[0] == - SPNAV_EVENT_MOTION_ROTATION)//0x02) + SPNAV_EVENT_MOTION_ROTATION) { // Axis aligned rotation vector short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]); short rX = pnData[0]; @@ -166,7 +166,7 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ)); } else if (pRawInput->data.hid.bRawData[0] == - SPNAV_EVENT_BUTTON)//0x03) + SPNAV_EVENT_BUTTON) { // State of the keys unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]); unsigned int state = GLUT_UP; -- 1.7.10.4