static void fghcbCheckJoystickPolls( SFG_Window *window,
SFG_Enumerator *enumerator )
{
static void fghcbCheckJoystickPolls( SFG_Window *window,
SFG_Enumerator *enumerator )
{
return;
socket = ConnectionNumber( fgDisplay.Display );
FD_ZERO( &fdset );
FD_SET( socket, &fdset );
return;
socket = ConnectionNumber( fgDisplay.Display );
FD_ZERO( &fdset );
FD_SET( socket, &fdset );
- fgSetWindow ( window ) ;
- window->Callbacks.Passive( event.xmotion.x, event.xmotion.y );
+ if( window->Callbacks.Passive )
+ {
+ fgSetWindow( window );
+ window->Callbacks.Passive( event.xmotion.x,
+ event.xmotion.y );
+ }
- if( ( button >= 4 ) && window->Callbacks.MouseWheel )
- {
- /*
- * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
- * " 6 and 7 " " one; ...
- *
- * XXX This *should* be behind some variables/macros,
- * XXX since the order and numbering isn't certain
- * XXX See XFree86 configuration docs (even back in the
- * XXX 3.x days, and especially with 4.x).
- */
- int wheel_number = (button - 4) / 2;
- int direction = (button & 1)*2 - 1;
-
- if( ButtonPress )
- fgStructure.Window->Callbacks.MouseWheel(
- wheel_number,
- direction,
- event.xbutton.x,
- event.xbutton.y
- );
- }
+ /*
+ * Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
+ * " 6 and 7 " " one; ...
+ *
+ * XXX This *should* be behind some variables/macros,
+ * XXX since the order and numbering isn't certain
+ * XXX See XFree86 configuration docs (even back in the
+ * XXX 3.x days, and especially with 4.x).
+ */
+ int wheel_number = (button - 4) / 2;
+ int direction = (button & 1)*2 - 1;
+
+ if( pressed )
+ fgStructure.Window->Callbacks.MouseWheel(
+ wheel_number,
+ direction,
+ event.xbutton.x,
+ event.xbutton.y
+ );
+
+#if TARGET_HOST_WIN32
+/*
+ * Determine a GLUT modifer mask based on MS-WINDOWS system info.
+ */
+int fgGetWin32Modifiers (void)
+{
+ return
+ ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
+ ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
+ ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
+ ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
+ ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
+ ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+}
+
LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam,
LPARAM lParam )
{
- unsigned int current_DisplayMode = fgState.DisplayMode;
- fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
- fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
- fgState.DisplayMode = current_DisplayMode;
-
- if( fgStructure.MenuContext )
- wglMakeCurrent( window->Window.Device,
- fgStructure.MenuContext->Context ) ;
- else
- {
- fgStructure.MenuContext =
- (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
- fgStructure.MenuContext->Context =
- wglCreateContext( window->Window.Device );
- }
-
- /* window->Window.Context = wglGetCurrentContext () ; */
- window->Window.Context = wglCreateContext( window->Window.Device );
+ unsigned int current_DisplayMode = fgState.DisplayMode;
+ fgState.DisplayMode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH;
+ fgSetupPixelFormat( window, FALSE, PFD_MAIN_PLANE );
+ fgState.DisplayMode = current_DisplayMode;
+
+ if( fgStructure.MenuContext )
+ wglMakeCurrent( window->Window.Device,
+ fgStructure.MenuContext->Context ) ;
+ else
+ {
+ fgStructure.MenuContext =
+ (SFG_MenuContext *)malloc( sizeof(SFG_MenuContext) );
+ fgStructure.MenuContext->Context =
+ wglCreateContext( window->Window.Device );
+ }
+
+ /* window->Window.Context = wglGetCurrentContext () ; */
+ window->Window.Context = wglCreateContext( window->Window.Device );
/* glutSetCursor( fgStructure.Window->State.Cursor ); */
printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
window->State.Cursor );
/* glutSetCursor( fgStructure.Window->State.Cursor ); */
printf("WM_ACTIVATE: glutSetCursor( %p, %d)\n", window,
window->State.Cursor );
-# define MAP_CURSOR(a,b) case a: SetCursor( LoadCursor( NULL, b ) ); \
- break;
+#define MAP_CURSOR(a,b) \
+ case a: \
+ SetCursor( LoadCursor( NULL, b ) ); \
+ break;
+
- switch( window->State.Cursor )
- {
- MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
- MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
- MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
- MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
- MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
- MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
- MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
- MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
- MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
- MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
- /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
- ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
-
- default:
- MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
- }
+ switch( window->State.Cursor )
+ {
+ MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, IDC_ARROW );
+ MAP_CURSOR( GLUT_CURSOR_LEFT_ARROW, IDC_ARROW );
+ MAP_CURSOR( GLUT_CURSOR_INFO, IDC_HELP );
+ MAP_CURSOR( GLUT_CURSOR_DESTROY, IDC_CROSS );
+ MAP_CURSOR( GLUT_CURSOR_HELP, IDC_HELP );
+ MAP_CURSOR( GLUT_CURSOR_CYCLE, IDC_SIZEALL );
+ MAP_CURSOR( GLUT_CURSOR_SPRAY, IDC_CROSS );
+ MAP_CURSOR( GLUT_CURSOR_WAIT, IDC_WAIT );
+ MAP_CURSOR( GLUT_CURSOR_TEXT, IDC_UPARROW );
+ MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
+ /* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
+ ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
+
+ default:
+ MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
+ }
#endif
else
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
#endif
else
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
- window->State.Redisplay = TRUE ;
-
- /*
- * Since the window is a menu, make the parent window current
- */
- fgSetWindow ( window->ActiveMenu->ParentWindow ) ;
-
+ window->State.Redisplay = TRUE;
+ fgSetWindow ( window->ActiveMenu->ParentWindow );
- window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+ window->State.Modifiers = fgGetWin32Modifiers( );
-
- fgStructure.Window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+ fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
- fgStructure.Window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+ fgStructure.Window->State.Modifiers = fgGetWin32Modifiers( );
- window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+ window->State.Modifiers = fgGetWin32Modifiers( );
GetCursorPos( &mouse_pos );
ScreenToClient( window->Window.Handle, &mouse_pos );
GetCursorPos( &mouse_pos );
ScreenToClient( window->Window.Handle, &mouse_pos );
- window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
+ window->State.Modifiers = fgGetWin32Modifiers( );
GetCursorPos( &mouse_pos );
ScreenToClient( window->Window.Handle, &mouse_pos );
GetCursorPos( &mouse_pos );
ScreenToClient( window->Window.Handle, &mouse_pos );
- window->State.Modifiers =
- ( ( ( GetKeyState( VK_LSHIFT ) < 0 ) ||
- ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
- ( ( ( GetKeyState( VK_LCONTROL ) < 0 ) ||
- ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
- ( ( ( GetKeyState( VK_LMENU ) < 0 ) ||
- ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
-
+ window->State.Modifiers = fgGetWin32Modifiers( );
window->Callbacks.Keyboard( (char)wParam, window->State.MouseX,
window->State.MouseY );
window->State.Modifiers = 0xffffffff;
window->Callbacks.Keyboard( (char)wParam, window->State.MouseX,
window->State.MouseY );
window->State.Modifiers = 0xffffffff;