update CMake file so that it will generate proper _WIN32_WINNT and WINVER definitions...
[freeglut] / src / mswin / fg_spaceball_mswin.c
index 09f6a96..84d848d 100644 (file)
  */
 
 /*
- * Modified by Jinrong Xie (stonexjr@gmail.com) 12/24/2014
+ * Modified by Jinrong Xie <stonexjr at gmail.com> 12/24/2014
  * for Space Navigator support on Windows.
  * This code is enhanced by at least supporting 3Dconnexion's 
  * six degree of freedom navigator.
  */
 
+#if(_WIN32_WINNT >= 0x0501)
+
 #include <GL/freeglut.h>
+#include <stdlib.h>
 #include "../fg_internal.h"
 
 enum {
@@ -121,7 +124,7 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
        if (res == -1)
                return;
 
-       rawInputBuffer = (BYTE*)malloc(size);
+       rawInputBuffer = malloc(size * sizeof *rawInputBuffer);
        pRawInput = (PRAWINPUT)rawInputBuffer;
 
        res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER));
@@ -189,3 +192,5 @@ void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
                }
        }
 }
+
+#endif
\ No newline at end of file