cleaning up mixed tabs and spaces

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1840 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2018-03-26 20:32:31 +00:00
parent a2fef0a9bb
commit b8a9827c5b
16 changed files with 218 additions and 218 deletions

View File

@ -286,7 +286,7 @@ GLint getAttribOrUniformLocation(const char* name, GLuint program, GLboolean isA
fprintf(stderr, "Warning: Could not bind attrib %s\n", name); fprintf(stderr, "Warning: Could not bind attrib %s\n", name);
} }
checkError ("getAttribOrUniformLocation"); checkError ("getAttribOrUniformLocation");
return attrib; return attrib;
} }
else else
@ -297,7 +297,7 @@ GLint getAttribOrUniformLocation(const char* name, GLuint program, GLboolean isA
fprintf(stderr, "Warning: Could not bind uniform %s\n", name); fprintf(stderr, "Warning: Could not bind uniform %s\n", name);
} }
checkError ("getAttribOrUniformLocation"); checkError ("getAttribOrUniformLocation");
return uniform; return uniform;
} }
} }

View File

@ -39,11 +39,11 @@
/* What supports variadic macros based off Wikipedia article on it (GCC-like must support C99 or higher to use variadic macros) */ /* What supports variadic macros based off Wikipedia article on it (GCC-like must support C99 or higher to use variadic macros) */
#if (((defined(__GNUC__) && (__GNUC__ >= 3)) || \ #if (((defined(__GNUC__) && (__GNUC__ >= 3)) || \
(defined(__clang__))) && \ (defined(__clang__))) && \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) || \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) || \
(defined(_MSC_VER) && (_MSC_VER >= 1400)) || \ (defined(_MSC_VER) && (_MSC_VER >= 1400)) || \
(defined(__BORLANDC__) && (__BORLANDC__ >= 0x570)) || \ (defined(__BORLANDC__) && (__BORLANDC__ >= 0x570)) || \
(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x530)) (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x530))
#define FG_COMPILER_SUPPORTS_VA_ARGS 1 #define FG_COMPILER_SUPPORTS_VA_ARGS 1
#else #else
#define FG_COMPILER_SUPPORTS_VA_ARGS 0 #define FG_COMPILER_SUPPORTS_VA_ARGS 0
@ -261,8 +261,8 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
} }
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b) \ #define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT_UCALL(a,b) \ IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT_UCALL(a,b) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
/* /*
* Combine _glut and _cb macros: * Combine _glut and _cb macros:
@ -276,20 +276,20 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b) IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0(a) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,a) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0_2NAME(a,b) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0_2NAME(a,b) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(a) \ #define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a) IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG1(a) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG1(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(a) \ #define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \
@ -300,12 +300,12 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b) IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2(a) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2_2NAME(a,b) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2_2NAME(a,b) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(a) \ #define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \
@ -316,12 +316,12 @@ void FGAPIENTRY glut##a##Func( FGCB##b callback ) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a) IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3(a) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3_2NAME(a,b) \ #define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3_2NAME(a,b) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) \
IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b) IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(a) \ #define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,a) \ IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,a) \

View File

@ -42,10 +42,10 @@ void FGAPIENTRY glutPostRedisplay( void )
{ {
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
if ( ! fgStructure.CurrentWindow ) if ( ! fgStructure.CurrentWindow )
{ {
fgError ( " ERROR: Function <%s> called" fgError ( " ERROR: Function <%s> called"
" with no current window defined.", "glutPostRedisplay" ) ; " with no current window defined.", "glutPostRedisplay" ) ;
} }
fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK; fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK;
} }

View File

@ -111,7 +111,7 @@ void fgInitialiseInputDevices ( void )
{ {
const char *dial_device=NULL; const char *dial_device=NULL;
dial_device = getenv ( "GLUT_DIALS_SERIAL" ); dial_device = getenv ( "GLUT_DIALS_SERIAL" );
fgPlatformRegisterDialDevice ( dial_device ); fgPlatformRegisterDialDevice ( dial_device );
if ( !dial_device ) return; if ( !dial_device ) return;
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return; if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;

View File

@ -392,7 +392,7 @@ struct tagSFG_State
int NumActiveJoysticks; /* Number of active joysticks (callback defined and positive pollrate) -- if zero, don't poll joysticks */ int NumActiveJoysticks; /* Number of active joysticks (callback defined and positive pollrate) -- if zero, don't poll joysticks */
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */ GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */ int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
int AuxiliaryBufferNumber;/* Number of auxiliary buffers */ int AuxiliaryBufferNumber;/* Number of auxiliary buffers */
int SampleNumber; /* Number of samples per pixel */ int SampleNumber; /* Number of samples per pixel */
@ -417,7 +417,7 @@ struct tagSFG_State
typedef struct tagSFG_Display SFG_Display; typedef struct tagSFG_Display SFG_Display;
struct tagSFG_Display struct tagSFG_Display
{ {
SFG_PlatformDisplay pDisplay; SFG_PlatformDisplay pDisplay;
int ScreenWidth; /* The screen's width in pixels */ int ScreenWidth; /* The screen's width in pixels */
int ScreenHeight; /* The screen's height in pixels */ int ScreenHeight; /* The screen's height in pixels */
@ -447,7 +447,7 @@ struct tagSFG_Context
SFG_WindowHandleType Handle; /* The window's handle */ SFG_WindowHandleType Handle; /* The window's handle */
SFG_WindowContextType Context; /* The window's OpenGL/WGL context */ SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */ SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
int DoubleBuffered; /* Treat the window as double-buffered */ int DoubleBuffered; /* Treat the window as double-buffered */
@ -536,7 +536,7 @@ struct tagSFG_WindowState /* as per notes above, sizes always refer to the cli
int DesiredZOrder; /* desired window Z Order position */ int DesiredZOrder; /* desired window Z Order position */
fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */ fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */
SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */ SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
long JoystickPollRate; /* The joystick polling rate */ long JoystickPollRate; /* The joystick polling rate */
fg_time_t JoystickLastPoll; /* When the last poll happened */ fg_time_t JoystickLastPoll; /* When the last poll happened */
@ -589,10 +589,10 @@ do \
(((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \ (((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \
(((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \ (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
} \ } \
else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \ else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \
{ \ { \
(((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \ (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
} \ } \
} while( 0 ) } while( 0 )
/* /*
@ -670,7 +670,7 @@ do \
FGCB ## cbname ## UC func = (FGCB ## cbname ## UC)(FETCH_WCB( window, cbname )); \ FGCB ## cbname ## UC func = (FGCB ## cbname ## UC)(FETCH_WCB( window, cbname )); \
FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \ FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \
fgSetWindow( &window ); \ fgSetWindow( &window ); \
func EXPAND_WCB( cbname )(( arg_list, userData )); \ func EXPAND_WCB( cbname )(( arg_list, userData )); \
} \ } \
} while( 0 ) } while( 0 )
@ -945,7 +945,7 @@ struct tagSFG_PlatformJoystick
typedef struct tagSFG_Joystick SFG_Joystick; typedef struct tagSFG_Joystick SFG_Joystick;
struct tagSFG_Joystick struct tagSFG_Joystick
{ {
SFG_PlatformJoystick pJoystick; SFG_PlatformJoystick pJoystick;
int id; int id;
GLboolean error; GLboolean error;

View File

@ -135,7 +135,7 @@ static void fghDeactivateSubMenu( SFG_MenuEntry *menuEntry )
static GLvoid fghGetVMaxExtent( SFG_Window* window, int* x, int* y ) static GLvoid fghGetVMaxExtent( SFG_Window* window, int* x, int* y )
{ {
if( fgStructure.GameModeWindow ) if( fgStructure.GameModeWindow )
fgPlatformGetGameModeVMaxExtent ( window, x, y ); fgPlatformGetGameModeVMaxExtent ( window, x, y );
else else
{ {
*x = fgDisplay.ScreenWidth; *x = fgDisplay.ScreenWidth;
@ -784,10 +784,10 @@ int FGAPIENTRY glutCreateMenuUcall( FGCBMenuUC callback, FGCBUserData userData )
{ {
/* The menu object creation code resides in fg_structure.c */ /* The menu object creation code resides in fg_structure.c */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenuUcall" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenuUcall" );
if (fgState.ActiveMenus) if (fgState.ActiveMenus)
{ {
fgError( "Menu manipulation not allowed while menus in use." ); fgError( "Menu manipulation not allowed while menus in use." );
} }
return fgCreateMenu( callback, userData )->ID; return fgCreateMenu( callback, userData )->ID;
} }

View File

@ -35,7 +35,7 @@ void fgInitialiseSpaceball(void)
void fgSpaceballClose(void) void fgSpaceballClose(void)
{ {
fgPlatformSpaceballClose(); fgPlatformSpaceballClose();
} }
int fgHasSpaceball(void) int fgHasSpaceball(void)
@ -88,12 +88,12 @@ void fgSpaceballClose(void)
int fgHasSpaceball(void) int fgHasSpaceball(void)
{ {
return 0; return 0;
} }
int fgSpaceballNumButtons(void) int fgSpaceballNumButtons(void)
{ {
return 0; return 0;
} }
void fgSpaceballSetWindow(SFG_Window *window) void fgSpaceballSetWindow(SFG_Window *window)

View File

@ -293,7 +293,7 @@ int FGAPIENTRY glutDeviceGet( GLenum eWhat )
return fgState.KeyRepeat; return fgState.KeyRepeat;
default: default:
return fgPlatformGlutDeviceGet ( eWhat ); return fgPlatformGlutDeviceGet ( eWhat );
} }
} }

View File

@ -83,7 +83,7 @@ SFG_Window* fgCreateWindow( SFG_Window* parent, const char* title,
fgError( "Out of memory. Could not create window." ); fgError( "Out of memory. Could not create window." );
} }
fgPlatformCreateWindow ( window ); fgPlatformCreateWindow ( window );
fghClearCallBacks( window ); fghClearCallBacks( window );
SET_WCB( *window, Reshape, fghDefaultReshape, NULL); SET_WCB( *window, Reshape, fghDefaultReshape, NULL);
@ -183,10 +183,10 @@ void fgAddToWindowDestroyList( SFG_Window* window )
SET_WCB( *window, Destroy, destroy, destroyData ); SET_WCB( *window, Destroy, destroy, destroyData );
} }
/* /*
* Similarly, clear all work set for the window, none of this has to be executed anymore * Similarly, clear all work set for the window, none of this has to be executed anymore
*/ */
window->State.WorkMask = 0; window->State.WorkMask = 0;
} }
/* /*

View File

@ -102,15 +102,15 @@ void fgPlatformInitialize( const char* displayName )
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0); HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
if( context ) if( context )
{ {
fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES ); fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES ); fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE ); fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE ); fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
DeleteDC(context); DeleteDC(context);
} }
else else
fgWarning("fgPlatformInitialize: " fgWarning("fgPlatformInitialize: "
"CreateDC failed, Screen size info may be incorrect\n" "CreateDC failed, Screen size info may be incorrect\n"
"This is quite likely caused by a bad '-display' parameter"); "This is quite likely caused by a bad '-display' parameter");
} }
@ -142,7 +142,7 @@ void fgPlatformInitialize( const char* displayName )
void fgPlatformDeinitialiseInputDevices ( void ) void fgPlatformDeinitialiseInputDevices ( void )
{ {
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
fghCloseInputDevices (); fghCloseInputDevices ();
#endif /* !defined(_WIN32_WCE) */ #endif /* !defined(_WIN32_WCE) */
fgState.JoysticksInitialised = GL_FALSE; fgState.JoysticksInitialised = GL_FALSE;
fgState.InputDevsInitialised = GL_FALSE; fgState.InputDevsInitialised = GL_FALSE;
@ -162,7 +162,7 @@ void fgPlatformCloseDisplay ( void )
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext ) void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
{ {
/* Do nothing -- this is required for X11 */ /* Do nothing -- this is required for X11 */
} }
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */ /* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */

View File

@ -108,6 +108,6 @@ int FGAPIENTRY __glutCreateMenuWithExit( void(* callback)( int ), void (__cdecl
int FGAPIENTRY __glutCreateMenuUcallWithExit(void(*callback)(int, void*), void(__cdecl *exit_function)(int), void* user_data) int FGAPIENTRY __glutCreateMenuUcallWithExit(void(*callback)(int, void*), void(__cdecl *exit_function)(int), void* user_data)
{ {
__glutExitFunc = exit_function; __glutExitFunc = exit_function;
return glutCreateMenuUcall(callback, user_data); return glutCreateMenuUcall(callback, user_data);
} }

View File

@ -55,145 +55,145 @@ RAWINPUTDEVICE __fgSpaceball = { 0x01, 0x08, 0x00, 0x00 };
void fgPlatformInitializeSpaceball(void) void fgPlatformInitializeSpaceball(void)
{ {
HWND hwnd; HWND hwnd;
sball_initialized = 1; sball_initialized = 1;
if (!fgStructure.CurrentWindow) if (!fgStructure.CurrentWindow)
{ {
sball_initialized = 0; sball_initialized = 0;
return; return;
} }
hwnd = fgStructure.CurrentWindow->Window.Handle; hwnd = fgStructure.CurrentWindow->Window.Handle;
{ {
BOOL ok; BOOL ok;
UINT cbSize = sizeof(__fgSpaceball); UINT cbSize = sizeof(__fgSpaceball);
__fgSpaceball.hwndTarget = hwnd; __fgSpaceball.hwndTarget = hwnd;
ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize); ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
if (!ok){ if (!ok){
__fgSpaceball.hwndTarget = NULL; __fgSpaceball.hwndTarget = NULL;
sball_initialized = 0; sball_initialized = 0;
} }
} }
} }
void fgPlatformSpaceballClose(void) void fgPlatformSpaceballClose(void)
{ {
return; return;
} }
int fgPlatformHasSpaceball(void) int fgPlatformHasSpaceball(void)
{ {
return __fgSpaceball.hwndTarget ? 1 : 0; return __fgSpaceball.hwndTarget ? 1 : 0;
} }
int fgPlatformSpaceballNumButtons(void) int fgPlatformSpaceballNumButtons(void)
{ {
return 0; return 0;
} }
void fgPlatformSpaceballSetWindow(SFG_Window *window) void fgPlatformSpaceballSetWindow(SFG_Window *window)
{ {
return; return;
} }
int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
return 0; return 0;
} }
void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam) void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
#define LOGITECH_VENDOR_ID 0x46d #define LOGITECH_VENDOR_ID 0x46d
HRAWINPUT hRawInput = (HRAWINPUT)lParam; HRAWINPUT hRawInput = (HRAWINPUT)lParam;
UINT inputCode = (UINT)wParam; UINT inputCode = (UINT)wParam;
UINT size; UINT size;
BYTE *rawInputBuffer; BYTE *rawInputBuffer;
PRAWINPUT pRawInput; PRAWINPUT pRawInput;
UINT res; UINT res;
RID_DEVICE_INFO sRidDeviceInfo; RID_DEVICE_INFO sRidDeviceInfo;
if (!sball_initialized) if (!sball_initialized)
{ {
fgPlatformInitializeSpaceball(); fgPlatformInitializeSpaceball();
if (!sball_initialized) if (!sball_initialized)
{ {
return; return;
} }
} }
res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER)); res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
if (res == -1) if (res == -1)
return; return;
rawInputBuffer = malloc(size * sizeof *rawInputBuffer); rawInputBuffer = malloc(size * sizeof *rawInputBuffer);
pRawInput = (PRAWINPUT)rawInputBuffer; pRawInput = (PRAWINPUT)rawInputBuffer;
res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER)); res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER));
if (res == -1) if (res == -1)
return; return;
if (pRawInput->header.dwType != RIM_TYPEHID) if (pRawInput->header.dwType != RIM_TYPEHID)
return; return;
sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO); sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO);
size = sizeof(RID_DEVICE_INFO); size = sizeof(RID_DEVICE_INFO);
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); SFG_Window* window = fgWindowByHandle(hwnd);
if ((window == NULL)) if ((window == NULL))
return; return;
if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID) if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
{ {
// Motion data comes in two parts: motion type and // Motion data comes in two parts: motion type and
// displacement/rotation along three axis. // displacement/rotation along three axis.
// Orientation is a right handed coordinate system with // Orientation is a right handed coordinate system with
// X goes right, Y goes up and Z goes towards viewer, e.g. // X goes right, Y goes up and Z goes towards viewer, e.g.
// the one used in OpenGL // the one used in OpenGL
if (pRawInput->data.hid.bRawData[0] == if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_TRANSLATION) SPNAV_EVENT_MOTION_TRANSLATION)
{ // Translation vector { // Translation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]); short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short X = pnData[0]; short X = pnData[0];
short Y = -pnData[2]; short Y = -pnData[2];
short Z = pnData[1]; short Z = pnData[1];
INVOKE_WCB(*window, SpaceMotion, (X, Y, Z)); INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
} }
else if (pRawInput->data.hid.bRawData[0] == else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_MOTION_ROTATION) SPNAV_EVENT_MOTION_ROTATION)
{ // Axis aligned rotation vector { // Axis aligned rotation vector
short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]); short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
short rX = pnData[0]; short rX = pnData[0];
short rY = -pnData[2]; short rY = -pnData[2];
short rZ = pnData[1]; short rZ = pnData[1];
INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ)); INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
} }
else if (pRawInput->data.hid.bRawData[0] == else if (pRawInput->data.hid.bRawData[0] ==
SPNAV_EVENT_BUTTON) SPNAV_EVENT_BUTTON)
{ // State of the keys { // State of the keys
unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]); unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
unsigned int state = GLUT_UP; unsigned int state = GLUT_UP;
if (FETCH_WCB(*window, SpaceButton)) if (FETCH_WCB(*window, SpaceButton))
{ {
int i; int i;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++)
{ {
unsigned long stateBefore = __fgSpaceKeystate&(1 << i); unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
unsigned long stateNow = dwKeystate&(1 << i); unsigned long stateNow = dwKeystate&(1 << i);
if (stateBefore && !stateNow) if (stateBefore && !stateNow)
INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP)); INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP));
if (!stateBefore && stateNow) if (!stateBefore && stateNow)
INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN)); INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN));
} }
} }
__fgSpaceKeystate = dwKeystate; __fgSpaceKeystate = dwKeystate;
} }
} }
} }
} }
#endif #endif

View File

@ -289,7 +289,7 @@ int fgPlatformGlutGet ( GLenum eWhat )
break; break;
} }
return -1; return -1;
} }

View File

@ -497,9 +497,9 @@ typedef struct
} m_proc_t; } m_proc_t;
static BOOL CALLBACK m_proc(HMONITOR mon, static BOOL CALLBACK m_proc(HMONITOR mon,
HDC hdc, HDC hdc,
LPRECT rect, LPRECT rect,
LPARAM data) LPARAM data)
{ {
m_proc_t *dp=(m_proc_t *)data; m_proc_t *dp=(m_proc_t *)data;
MONITORINFOEX info; MONITORINFOEX info;
@ -728,8 +728,8 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
/* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */ /* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */
#ifdef WM_TOUCH #ifdef WM_TOUCH
if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF) if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF)
fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow"); fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow");
if (fghRegisterTouchWindow) if (fghRegisterTouchWindow)
fghRegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM ); fghRegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM );
#endif #endif