mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
FS#65 - Add a blocking WaitEvent function
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1247 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
fd91756a9e
commit
a68ff5713b
@ -193,6 +193,7 @@ EXPORTS
|
|||||||
sfRenderWindow_GetHeight
|
sfRenderWindow_GetHeight
|
||||||
sfRenderWindow_GetSettings
|
sfRenderWindow_GetSettings
|
||||||
sfRenderWindow_GetEvent
|
sfRenderWindow_GetEvent
|
||||||
|
sfRenderWindow_WaitEvent
|
||||||
sfRenderWindow_UseVerticalSync
|
sfRenderWindow_UseVerticalSync
|
||||||
sfRenderWindow_ShowMouseCursor
|
sfRenderWindow_ShowMouseCursor
|
||||||
sfRenderWindow_SetCursorPosition
|
sfRenderWindow_SetCursorPosition
|
||||||
|
@ -194,6 +194,7 @@ EXPORTS
|
|||||||
sfRenderWindow_GetHeight
|
sfRenderWindow_GetHeight
|
||||||
sfRenderWindow_GetSettings
|
sfRenderWindow_GetSettings
|
||||||
sfRenderWindow_GetEvent
|
sfRenderWindow_GetEvent
|
||||||
|
sfRenderWindow_WaitEvent
|
||||||
sfRenderWindow_UseVerticalSync
|
sfRenderWindow_UseVerticalSync
|
||||||
sfRenderWindow_ShowMouseCursor
|
sfRenderWindow_ShowMouseCursor
|
||||||
sfRenderWindow_SetCursorPosition
|
sfRenderWindow_SetCursorPosition
|
||||||
|
@ -19,6 +19,7 @@ EXPORTS
|
|||||||
sfWindow_GetHeight
|
sfWindow_GetHeight
|
||||||
sfWindow_GetSettings
|
sfWindow_GetSettings
|
||||||
sfWindow_GetEvent
|
sfWindow_GetEvent
|
||||||
|
sfWindow_WaitEvent
|
||||||
sfWindow_UseVerticalSync
|
sfWindow_UseVerticalSync
|
||||||
sfWindow_ShowMouseCursor
|
sfWindow_ShowMouseCursor
|
||||||
sfWindow_SetCursorPosition
|
sfWindow_SetCursorPosition
|
||||||
|
@ -19,6 +19,7 @@ EXPORTS
|
|||||||
sfWindow_GetHeight
|
sfWindow_GetHeight
|
||||||
sfWindow_GetSettings
|
sfWindow_GetSettings
|
||||||
sfWindow_GetEvent
|
sfWindow_GetEvent
|
||||||
|
sfWindow_WaitEvent
|
||||||
sfWindow_UseVerticalSync
|
sfWindow_UseVerticalSync
|
||||||
sfWindow_ShowMouseCursor
|
sfWindow_ShowMouseCursor
|
||||||
sfWindow_SetCursorPosition
|
sfWindow_SetCursorPosition
|
||||||
|
@ -193,6 +193,7 @@ EXPORTS
|
|||||||
sfRenderWindow_GetHeight
|
sfRenderWindow_GetHeight
|
||||||
sfRenderWindow_GetSettings
|
sfRenderWindow_GetSettings
|
||||||
sfRenderWindow_GetEvent
|
sfRenderWindow_GetEvent
|
||||||
|
sfRenderWindow_WaitEvent
|
||||||
sfRenderWindow_UseVerticalSync
|
sfRenderWindow_UseVerticalSync
|
||||||
sfRenderWindow_ShowMouseCursor
|
sfRenderWindow_ShowMouseCursor
|
||||||
sfRenderWindow_SetCursorPosition
|
sfRenderWindow_SetCursorPosition
|
||||||
|
@ -194,6 +194,7 @@ EXPORTS
|
|||||||
sfRenderWindow_GetHeight
|
sfRenderWindow_GetHeight
|
||||||
sfRenderWindow_GetSettings
|
sfRenderWindow_GetSettings
|
||||||
sfRenderWindow_GetEvent
|
sfRenderWindow_GetEvent
|
||||||
|
sfRenderWindow_WaitEvent
|
||||||
sfRenderWindow_UseVerticalSync
|
sfRenderWindow_UseVerticalSync
|
||||||
sfRenderWindow_ShowMouseCursor
|
sfRenderWindow_ShowMouseCursor
|
||||||
sfRenderWindow_SetCursorPosition
|
sfRenderWindow_SetCursorPosition
|
||||||
|
@ -19,6 +19,7 @@ EXPORTS
|
|||||||
sfWindow_GetHeight
|
sfWindow_GetHeight
|
||||||
sfWindow_GetSettings
|
sfWindow_GetSettings
|
||||||
sfWindow_GetEvent
|
sfWindow_GetEvent
|
||||||
|
sfWindow_WaitEvent
|
||||||
sfWindow_UseVerticalSync
|
sfWindow_UseVerticalSync
|
||||||
sfWindow_ShowMouseCursor
|
sfWindow_ShowMouseCursor
|
||||||
sfWindow_SetCursorPosition
|
sfWindow_SetCursorPosition
|
||||||
|
@ -19,6 +19,7 @@ EXPORTS
|
|||||||
sfWindow_GetHeight
|
sfWindow_GetHeight
|
||||||
sfWindow_GetSettings
|
sfWindow_GetSettings
|
||||||
sfWindow_GetEvent
|
sfWindow_GetEvent
|
||||||
|
sfWindow_WaitEvent
|
||||||
sfWindow_UseVerticalSync
|
sfWindow_UseVerticalSync
|
||||||
sfWindow_ShowMouseCursor
|
sfWindow_ShowMouseCursor
|
||||||
sfWindow_SetCursorPosition
|
sfWindow_SetCursorPosition
|
||||||
|
@ -123,6 +123,17 @@ CSFML_API sfContextSettings sfRenderWindow_GetSettings(sfRenderWindow* renderWin
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API sfBool sfRenderWindow_GetEvent(sfRenderWindow* renderWindow, sfEvent* event);
|
CSFML_API sfBool sfRenderWindow_GetEvent(sfRenderWindow* renderWindow, sfEvent* event);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Wait for an event and return it
|
||||||
|
///
|
||||||
|
/// \param renderWindow : Renderwindow object
|
||||||
|
/// \param event : Event to fill
|
||||||
|
///
|
||||||
|
/// \return sfFalse if an error occured
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_API sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Enable / disable vertical synchronization on a window
|
/// Enable / disable vertical synchronization on a window
|
||||||
///
|
///
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef SFML_Shape_H
|
#ifndef SFML_SHAPE_H
|
||||||
#define SFML_Shape_H
|
#define SFML_SHAPE_H
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
@ -451,4 +451,4 @@ CSFML_API void sfShape_SetPointColor(sfShape* shape, unsigned int index, sfColor
|
|||||||
CSFML_API void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color);
|
CSFML_API void sfShape_SetPointOutlineColor(sfShape* shape, unsigned int index, sfColor color);
|
||||||
|
|
||||||
|
|
||||||
#endif // SFML_Shape_H
|
#endif // SFML_SHAPE_H
|
||||||
|
@ -145,6 +145,17 @@ CSFML_API sfContextSettings sfWindow_GetSettings(sfWindow* window);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API sfBool sfWindow_GetEvent(sfWindow* window, sfEvent* event);
|
CSFML_API sfBool sfWindow_GetEvent(sfWindow* window, sfEvent* event);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Wait for an event and return it
|
||||||
|
///
|
||||||
|
/// \param window : Window object
|
||||||
|
/// \param event : Event to fill
|
||||||
|
///
|
||||||
|
/// \return sfFalse if an error occured
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_API sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Enable / disable vertical synchronization on a window
|
/// Enable / disable vertical synchronization on a window
|
||||||
///
|
///
|
||||||
|
96
CSFML/src/SFML/ConvertEvent.h
Normal file
96
CSFML/src/SFML/ConvertEvent.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SFML - Simple and Fast Multimedia Library
|
||||||
|
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
// subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented;
|
||||||
|
// you must not claim that you wrote the original software.
|
||||||
|
// If you use this software in a product, an acknowledgment
|
||||||
|
// in the product documentation would be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such,
|
||||||
|
// and must not be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SFML_CONVERTEVENT_H
|
||||||
|
#define SFML_CONVERTEVENT_H
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Headers
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
#include <SFML/Window/Event.hpp>
|
||||||
|
#include <SFML/Window/Event.h>
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Define a function to convert a sf::Event ot a sfEvent
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event)
|
||||||
|
{
|
||||||
|
// Convert its type
|
||||||
|
event->Type = static_cast<sfEventType>(SFMLEvent.Type);
|
||||||
|
|
||||||
|
// Fill its fields
|
||||||
|
switch (event->Type)
|
||||||
|
{
|
||||||
|
case sfEvtResized :
|
||||||
|
event->Size.Width = SFMLEvent.Size.Width;
|
||||||
|
event->Size.Height = SFMLEvent.Size.Height;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtTextEntered :
|
||||||
|
event->Text.Unicode = SFMLEvent.Text.Unicode;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtKeyReleased :
|
||||||
|
case sfEvtKeyPressed :
|
||||||
|
event->Key.Code = static_cast<sfKeyCode>(SFMLEvent.Key.Code);
|
||||||
|
event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse;
|
||||||
|
event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse;
|
||||||
|
event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtMouseWheelMoved :
|
||||||
|
event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtMouseButtonPressed :
|
||||||
|
case sfEvtMouseButtonReleased :
|
||||||
|
event->MouseButton.Button = static_cast<sfMouseButton>(SFMLEvent.MouseButton.Button);
|
||||||
|
event->MouseButton.X = SFMLEvent.MouseButton.X;
|
||||||
|
event->MouseButton.Y = SFMLEvent.MouseButton.Y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtMouseMoved :
|
||||||
|
event->MouseMove.X = SFMLEvent.MouseMove.X;
|
||||||
|
event->MouseMove.Y = SFMLEvent.MouseMove.Y;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtJoyButtonPressed :
|
||||||
|
case sfEvtJoyButtonReleased :
|
||||||
|
event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId;
|
||||||
|
event->JoyButton.Button = SFMLEvent.JoyButton.Button;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sfEvtJoyMoved :
|
||||||
|
event->JoyMove.JoystickId = SFMLEvent.JoyMove.JoystickId;
|
||||||
|
event->JoyMove.Axis = static_cast<sfJoyAxis>(SFMLEvent.JoyMove.Axis);
|
||||||
|
event->JoyMove.Position = SFMLEvent.JoyMove.Position;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default :
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SFML_CONVERTEVENT_H
|
@ -33,6 +33,7 @@
|
|||||||
#include <SFML/Graphics/SpriteStruct.h>
|
#include <SFML/Graphics/SpriteStruct.h>
|
||||||
#include <SFML/Graphics/StringStruct.h>
|
#include <SFML/Graphics/StringStruct.h>
|
||||||
#include <SFML/Internal.h>
|
#include <SFML/Internal.h>
|
||||||
|
#include <SFML/ConvertEvent.h>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -150,60 +151,31 @@ sfBool sfRenderWindow_GetEvent(sfRenderWindow* renderWindow, sfEvent* event)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return sfFalse;
|
return sfFalse;
|
||||||
|
|
||||||
// Convert its type
|
// Convert the sf::Event event to a sfEvent
|
||||||
event->Type = static_cast<sfEventType>(SFMLEvent.Type);
|
ConvertEvent(SFMLEvent, event);
|
||||||
|
|
||||||
// Fill its fields
|
return sfTrue;
|
||||||
switch (event->Type)
|
}
|
||||||
{
|
|
||||||
case sfEvtResized :
|
|
||||||
event->Size.Width = SFMLEvent.Size.Width;
|
|
||||||
event->Size.Height = SFMLEvent.Size.Height;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtTextEntered :
|
|
||||||
event->Text.Unicode = SFMLEvent.Text.Unicode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtKeyReleased :
|
////////////////////////////////////////////////////////////
|
||||||
case sfEvtKeyPressed :
|
/// Wait for an event and return it
|
||||||
event->Key.Code = static_cast<sfKeyCode>(SFMLEvent.Key.Code);
|
////////////////////////////////////////////////////////////
|
||||||
event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse;
|
sfBool sfRenderWindow_WaitEvent(sfRenderWindow* renderWindow, sfEvent* event)
|
||||||
event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse;
|
{
|
||||||
event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse;
|
CSFML_CHECK_RETURN(renderWindow, sfFalse);
|
||||||
break;
|
CSFML_CHECK_RETURN(event, sfFalse);
|
||||||
|
|
||||||
case sfEvtMouseWheelMoved :
|
// Get the event
|
||||||
event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta;
|
sf::Event SFMLEvent;
|
||||||
break;
|
sfBool ret = renderWindow->This.WaitEvent(SFMLEvent);
|
||||||
|
|
||||||
case sfEvtMouseButtonPressed :
|
// Error, return
|
||||||
case sfEvtMouseButtonReleased :
|
if (!ret)
|
||||||
event->MouseButton.Button = static_cast<sfMouseButton>(SFMLEvent.MouseButton.Button);
|
return sfFalse;
|
||||||
event->MouseButton.X = SFMLEvent.MouseButton.X;
|
|
||||||
event->MouseButton.Y = SFMLEvent.MouseButton.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtMouseMoved :
|
// Convert the sf::Event event to a sfEvent
|
||||||
event->MouseMove.X = SFMLEvent.MouseMove.X;
|
ConvertEvent(SFMLEvent, event);
|
||||||
event->MouseMove.Y = SFMLEvent.MouseMove.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtJoyButtonPressed :
|
|
||||||
case sfEvtJoyButtonReleased :
|
|
||||||
event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId;
|
|
||||||
event->JoyButton.Button = SFMLEvent.JoyButton.Button;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtJoyMoved :
|
|
||||||
event->JoyMove.JoystickId = SFMLEvent.JoyMove.JoystickId;
|
|
||||||
event->JoyMove.Axis = static_cast<sfJoyAxis>(SFMLEvent.JoyMove.Axis);
|
|
||||||
event->JoyMove.Position = SFMLEvent.JoyMove.Position;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sfTrue;
|
return sfTrue;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// SFML - Simple and Fast Multimedia Library
|
// SFML - Simple and Fast Multimedia Library
|
||||||
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
|
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
|
||||||
//
|
//
|
||||||
// This software is provided 'as-is', without any express or implied warranty.
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
@ -22,6 +22,8 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SFML_INTERNAL_H
|
||||||
|
#define SFML_INTERNAL_H
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Define macros to check the validity of CSFML objects
|
// Define macros to check the validity of CSFML objects
|
||||||
@ -102,3 +104,5 @@
|
|||||||
#define CSFML_CALL_PTR_RETURN(Object, Function, Default) (void)Default; return (Object->This->Function);
|
#define CSFML_CALL_PTR_RETURN(Object, Function, Default) (void)Default; return (Object->This->Function);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // SFML_INTERNAL_H
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <SFML/Window/Window.h>
|
#include <SFML/Window/Window.h>
|
||||||
#include <SFML/Window/WindowStruct.h>
|
#include <SFML/Window/WindowStruct.h>
|
||||||
#include <SFML/Internal.h>
|
#include <SFML/Internal.h>
|
||||||
|
#include <SFML/ConvertEvent.h>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -139,60 +140,31 @@ sfBool sfWindow_GetEvent(sfWindow* window, sfEvent* event)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return sfFalse;
|
return sfFalse;
|
||||||
|
|
||||||
// Convert its type
|
// Convert the sf::Event event to a sfEvent
|
||||||
event->Type = static_cast<sfEventType>(SFMLEvent.Type);
|
ConvertEvent(SFMLEvent, event);
|
||||||
|
|
||||||
// Fill its fields
|
return sfTrue;
|
||||||
switch (event->Type)
|
}
|
||||||
{
|
|
||||||
case sfEvtResized :
|
|
||||||
event->Size.Width = SFMLEvent.Size.Width;
|
|
||||||
event->Size.Height = SFMLEvent.Size.Height;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtTextEntered :
|
|
||||||
event->Text.Unicode = SFMLEvent.Text.Unicode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtKeyReleased :
|
////////////////////////////////////////////////////////////
|
||||||
case sfEvtKeyPressed :
|
/// Wait for an event and return it
|
||||||
event->Key.Code = static_cast<sfKeyCode>(SFMLEvent.Key.Code);
|
////////////////////////////////////////////////////////////
|
||||||
event->Key.Alt = SFMLEvent.Key.Alt ? sfTrue : sfFalse;
|
sfBool sfWindow_WaitEvent(sfWindow* window, sfEvent* event)
|
||||||
event->Key.Control = SFMLEvent.Key.Control ? sfTrue : sfFalse;
|
{
|
||||||
event->Key.Shift = SFMLEvent.Key.Shift ? sfTrue : sfFalse;
|
CSFML_CHECK_RETURN(window, sfFalse);
|
||||||
break;
|
CSFML_CHECK_RETURN(event, sfFalse);
|
||||||
|
|
||||||
case sfEvtMouseWheelMoved :
|
// Get the event
|
||||||
event->MouseWheel.Delta = SFMLEvent.MouseWheel.Delta;
|
sf::Event SFMLEvent;
|
||||||
break;
|
sfBool ret = window->This.WaitEvent(SFMLEvent);
|
||||||
|
|
||||||
case sfEvtMouseButtonPressed :
|
// Error, return
|
||||||
case sfEvtMouseButtonReleased :
|
if (!ret)
|
||||||
event->MouseButton.Button = static_cast<sfMouseButton>(SFMLEvent.MouseButton.Button);
|
return sfFalse;
|
||||||
event->MouseButton.X = SFMLEvent.MouseButton.X;
|
|
||||||
event->MouseButton.Y = SFMLEvent.MouseButton.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtMouseMoved :
|
// Convert the sf::Event event to a sfEvent
|
||||||
event->MouseMove.X = SFMLEvent.MouseMove.X;
|
ConvertEvent(SFMLEvent, event);
|
||||||
event->MouseMove.Y = SFMLEvent.MouseMove.Y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtJoyButtonPressed :
|
|
||||||
case sfEvtJoyButtonReleased :
|
|
||||||
event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId;
|
|
||||||
event->JoyButton.Button = SFMLEvent.JoyButton.Button;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case sfEvtJoyMoved :
|
|
||||||
event->JoyMove.JoystickId = SFMLEvent.JoyMove.JoystickId;
|
|
||||||
event->JoyMove.Axis = static_cast<sfJoyAxis>(SFMLEvent.JoyMove.Axis);
|
|
||||||
event->JoyMove.Position = SFMLEvent.JoyMove.Position;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sfTrue;
|
return sfTrue;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -436,6 +436,18 @@ namespace SFML
|
|||||||
return sfRenderWindow_GetEvent(This, out eventToFill);
|
return sfRenderWindow_GetEvent(This, out eventToFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Internal function to get the next event (blocking)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
|
||||||
|
/// <returns>False if any error occured</returns>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
protected override bool WaitEvent(out Event eventToFill)
|
||||||
|
{
|
||||||
|
return sfRenderWindow_WaitEvent(This, out eventToFill);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the destruction of the object
|
/// Handle the destruction of the object
|
||||||
@ -487,6 +499,9 @@ namespace SFML
|
|||||||
|
|
||||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern bool sfRenderWindow_GetEvent(IntPtr This, out Event Evt);
|
static extern bool sfRenderWindow_GetEvent(IntPtr This, out Event Evt);
|
||||||
|
|
||||||
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
|
static extern bool sfRenderWindow_WaitEvent(IntPtr This, out Event Evt);
|
||||||
|
|
||||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfRenderWindow_Clear(IntPtr This, Color ClearColor);
|
static extern void sfRenderWindow_Clear(IntPtr This, Color ClearColor);
|
||||||
|
@ -340,97 +340,27 @@ namespace SFML
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call the event handlers for each pending event.
|
/// Wait for a new event and dispatch it to the corresponding
|
||||||
|
/// event handler
|
||||||
|
/// </summary>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
public void WaitAndDispatchEvents()
|
||||||
|
{
|
||||||
|
Event e;
|
||||||
|
if (WaitEvent(out e))
|
||||||
|
CallEventHandler(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Call the event handlers for each pending event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
public void DispatchEvents()
|
public void DispatchEvents()
|
||||||
{
|
{
|
||||||
Event e;
|
Event e;
|
||||||
while (GetEvent(out e))
|
while (GetEvent(out e))
|
||||||
{
|
CallEventHandler(e);
|
||||||
switch (e.Type)
|
|
||||||
{
|
|
||||||
case EventType.Closed :
|
|
||||||
if (Closed != null)
|
|
||||||
Closed(this, EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.GainedFocus :
|
|
||||||
if (GainedFocus != null)
|
|
||||||
GainedFocus(this, EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.JoyButtonPressed :
|
|
||||||
if (JoyButtonPressed != null)
|
|
||||||
JoyButtonPressed(this, new JoyButtonEventArgs(e.JoyButton));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.JoyButtonReleased :
|
|
||||||
if (JoyButtonReleased != null)
|
|
||||||
JoyButtonReleased(this, new JoyButtonEventArgs(e.JoyButton));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.JoyMoved :
|
|
||||||
if (JoyMoved != null)
|
|
||||||
JoyMoved(this, new JoyMoveEventArgs(e.JoyMove));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.KeyPressed :
|
|
||||||
if (KeyPressed != null)
|
|
||||||
KeyPressed(this, new KeyEventArgs(e.Key));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.KeyReleased :
|
|
||||||
if (KeyReleased != null)
|
|
||||||
KeyReleased(this, new KeyEventArgs(e.Key));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.LostFocus :
|
|
||||||
if (LostFocus != null)
|
|
||||||
LostFocus(this, EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseButtonPressed :
|
|
||||||
if (MouseButtonPressed != null)
|
|
||||||
MouseButtonPressed(this, new MouseButtonEventArgs(e.MouseButton));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseButtonReleased :
|
|
||||||
if (MouseButtonReleased != null)
|
|
||||||
MouseButtonReleased(this, new MouseButtonEventArgs(e.MouseButton));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseEntered :
|
|
||||||
if (MouseEntered != null)
|
|
||||||
MouseEntered(this, EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseLeft :
|
|
||||||
if (MouseLeft != null)
|
|
||||||
MouseLeft(this, EventArgs.Empty);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseMoved :
|
|
||||||
if (MouseMoved != null)
|
|
||||||
MouseMoved(this, new MouseMoveEventArgs(e.MouseMove));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.MouseWheelMoved :
|
|
||||||
if (MouseWheelMoved != null)
|
|
||||||
MouseWheelMoved(this, new MouseWheelEventArgs(e.MouseWheel));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.Resized :
|
|
||||||
if (Resized != null)
|
|
||||||
Resized(this, new SizeEventArgs(e.Size));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EventType.TextEntered :
|
|
||||||
if (TextEntered != null)
|
|
||||||
TextEntered(this, new TextEventArgs(e.Text));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -448,7 +378,7 @@ namespace SFML
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Internal function to get the next event
|
/// Internal function to get the next event (non-blocking)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
|
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
|
||||||
/// <returns>True if there was an event, false otherwise</returns>
|
/// <returns>True if there was an event, false otherwise</returns>
|
||||||
@ -458,6 +388,18 @@ namespace SFML
|
|||||||
return sfWindow_GetEvent(This, out eventToFill);
|
return sfWindow_GetEvent(This, out eventToFill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Internal function to get the next event (blocking)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="eventToFill">Variable to fill with the raw pointer to the event structure</param>
|
||||||
|
/// <returns>False if any error occured</returns>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
protected virtual bool WaitEvent(out Event eventToFill)
|
||||||
|
{
|
||||||
|
return sfWindow_WaitEvent(This, out eventToFill);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle the destruction of the object
|
/// Handle the destruction of the object
|
||||||
@ -469,6 +411,98 @@ namespace SFML
|
|||||||
sfWindow_Destroy(This);
|
sfWindow_Destroy(This);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Call the event handler for the given event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">Event to dispatch</param>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
private void CallEventHandler(Event e)
|
||||||
|
{
|
||||||
|
switch (e.Type)
|
||||||
|
{
|
||||||
|
case EventType.Closed :
|
||||||
|
if (Closed != null)
|
||||||
|
Closed(this, EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.GainedFocus :
|
||||||
|
if (GainedFocus != null)
|
||||||
|
GainedFocus(this, EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.JoyButtonPressed :
|
||||||
|
if (JoyButtonPressed != null)
|
||||||
|
JoyButtonPressed(this, new JoyButtonEventArgs(e.JoyButton));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.JoyButtonReleased :
|
||||||
|
if (JoyButtonReleased != null)
|
||||||
|
JoyButtonReleased(this, new JoyButtonEventArgs(e.JoyButton));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.JoyMoved :
|
||||||
|
if (JoyMoved != null)
|
||||||
|
JoyMoved(this, new JoyMoveEventArgs(e.JoyMove));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.KeyPressed :
|
||||||
|
if (KeyPressed != null)
|
||||||
|
KeyPressed(this, new KeyEventArgs(e.Key));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.KeyReleased :
|
||||||
|
if (KeyReleased != null)
|
||||||
|
KeyReleased(this, new KeyEventArgs(e.Key));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.LostFocus :
|
||||||
|
if (LostFocus != null)
|
||||||
|
LostFocus(this, EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseButtonPressed :
|
||||||
|
if (MouseButtonPressed != null)
|
||||||
|
MouseButtonPressed(this, new MouseButtonEventArgs(e.MouseButton));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseButtonReleased :
|
||||||
|
if (MouseButtonReleased != null)
|
||||||
|
MouseButtonReleased(this, new MouseButtonEventArgs(e.MouseButton));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseEntered :
|
||||||
|
if (MouseEntered != null)
|
||||||
|
MouseEntered(this, EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseLeft :
|
||||||
|
if (MouseLeft != null)
|
||||||
|
MouseLeft(this, EventArgs.Empty);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseMoved :
|
||||||
|
if (MouseMoved != null)
|
||||||
|
MouseMoved(this, new MouseMoveEventArgs(e.MouseMove));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.MouseWheelMoved :
|
||||||
|
if (MouseWheelMoved != null)
|
||||||
|
MouseWheelMoved(this, new MouseWheelEventArgs(e.MouseWheel));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.Resized :
|
||||||
|
if (Resized != null)
|
||||||
|
Resized(this, new SizeEventArgs(e.Size));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventType.TextEntered :
|
||||||
|
if (TextEntered != null)
|
||||||
|
TextEntered(this, new TextEventArgs(e.Text));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Event handler for the Closed event</summary>
|
/// <summary>Event handler for the Closed event</summary>
|
||||||
public event EventHandler Closed = null;
|
public event EventHandler Closed = null;
|
||||||
|
|
||||||
@ -541,6 +575,9 @@ namespace SFML
|
|||||||
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern bool sfWindow_GetEvent(IntPtr This, out Event Evt);
|
static extern bool sfWindow_GetEvent(IntPtr This, out Event Evt);
|
||||||
|
|
||||||
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||||
|
static extern bool sfWindow_WaitEvent(IntPtr This, out Event Evt);
|
||||||
|
|
||||||
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-window"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfWindow_Display(IntPtr This);
|
static extern void sfWindow_Display(IntPtr This);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Pop the event on top of events stack, if any, and return it
|
/// \brief Pop the event on top of events stack, if any, and return it
|
||||||
///
|
///
|
||||||
/// This function is not blocking, if there's no pending event then
|
/// This function is not blocking: if there's no pending event then
|
||||||
/// it will return false and leave \a event unmodified.
|
/// it will return false and leave \a event unmodified.
|
||||||
/// Note that more than event may be present in the events stack,
|
/// Note that more than event may be present in the events stack,
|
||||||
/// thus you should always call this function in a loop
|
/// thus you should always call this function in a loop
|
||||||
@ -212,6 +212,31 @@ public :
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
bool GetEvent(Event& event);
|
bool GetEvent(Event& event);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Wait for an event and return it
|
||||||
|
///
|
||||||
|
/// This function is blocking: if there's no pending event then
|
||||||
|
/// it will wait until an event is received.
|
||||||
|
/// After this function returns (and no error occured),
|
||||||
|
/// the \a event object is always valid and filled properly.
|
||||||
|
/// This function is typically used when you have a thread that
|
||||||
|
/// is dedicated to events handling: you want to make this thread
|
||||||
|
/// sleep as long as no new event is received.
|
||||||
|
/// \code
|
||||||
|
/// sf::Event event;
|
||||||
|
/// if (window.WaitEvent(event))
|
||||||
|
/// {
|
||||||
|
/// // process event...
|
||||||
|
/// }
|
||||||
|
/// \endcode
|
||||||
|
///
|
||||||
|
/// \param event Event to be returned
|
||||||
|
///
|
||||||
|
/// \return False if any error occured
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
bool WaitEvent(Event& event);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Enable or disable vertical synchronization
|
/// \brief Enable or disable vertical synchronization
|
||||||
///
|
///
|
||||||
|
@ -280,7 +280,7 @@ WindowHandle WindowImplX11::GetHandle() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::ProcessEvents()
|
void WindowImplX11::ProcessEvents(bool block)
|
||||||
{
|
{
|
||||||
// This function implements a workaround to properly discard
|
// This function implements a workaround to properly discard
|
||||||
// repeated key events when necessary. The problem is that the
|
// repeated key events when necessary. The problem is that the
|
||||||
|
@ -82,81 +82,83 @@ public :
|
|||||||
::Display* GetDisplay() const;
|
::Display* GetDisplay() const;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the OS-specific handle of the window
|
/// \brief Get the OS-specific handle of the window
|
||||||
///
|
///
|
||||||
/// \return Handle of the window
|
/// \return Handle of the window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual WindowHandle GetHandle() const;
|
virtual WindowHandle GetHandle() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from operating system
|
/// \brief Process incoming events from the operating system
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
/// \param block Use true to block the thread until an event arrives
|
||||||
virtual void ProcessEvents();
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void ProcessEvents(bool block);
|
||||||
/// \brief Show or hide the mouse cursor
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param show True to show, false to hide
|
/// \brief Show or hide the mouse cursor
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
/// \param show True to show, false to hide
|
||||||
virtual void ShowMouseCursor(bool show);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void ShowMouseCursor(bool show);
|
||||||
/// \brief Change the position of the mouse cursor
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param left Left coordinate of the cursor, relative to the window
|
/// \brief Change the position of the mouse cursor
|
||||||
/// \param top Top coordinate of the cursor, relative to the window
|
///
|
||||||
///
|
/// \param left Left coordinate of the cursor, relative to the window
|
||||||
////////////////////////////////////////////////////////////
|
/// \param top Top coordinate of the cursor, relative to the window
|
||||||
virtual void SetCursorPosition(unsigned int left, unsigned int top);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void SetCursorPosition(unsigned int left, unsigned int top);
|
||||||
/// \brief Change the position of the window on screen
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param left Left position
|
/// \brief Change the position of the window on screen
|
||||||
/// \param top Top position
|
///
|
||||||
///
|
/// \param left Left position
|
||||||
////////////////////////////////////////////////////////////
|
/// \param top Top position
|
||||||
virtual void SetPosition(int left, int top);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void SetPosition(int left, int top);
|
||||||
/// \brief Change the size of the rendering region of the window
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param width New width
|
/// \brief Change the size of the rendering region of the window
|
||||||
/// \param height New height
|
///
|
||||||
///
|
/// \param width New width
|
||||||
////////////////////////////////////////////////////////////
|
/// \param height New height
|
||||||
virtual void SetSize(unsigned int width, unsigned int height);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void SetSize(unsigned int width, unsigned int height);
|
||||||
/// \brief Show or hide the window
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param show True to show, false to hide
|
/// \brief Show or hide the window
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
/// \param show True to show, false to hide
|
||||||
virtual void Show(bool show);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void Show(bool show);
|
||||||
/// \brief Enable or disable automatic key-repeat
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param enabled True to enable, false to disable
|
/// \brief Enable or disable automatic key-repeat
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
/// \param enabled True to enable, false to disable
|
||||||
virtual void EnableKeyRepeat(bool enabled);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
virtual void EnableKeyRepeat(bool enabled);
|
||||||
/// \brief Change the window's icon
|
|
||||||
///
|
////////////////////////////////////////////////////////////
|
||||||
/// \param width Icon's width, in pixels
|
/// \brief Change the window's icon
|
||||||
/// \param height Icon's height, in pixels
|
///
|
||||||
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
/// \param width Icon's width, in pixels
|
||||||
///
|
/// \param height Icon's height, in pixels
|
||||||
////////////////////////////////////////////////////////////
|
/// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits
|
||||||
virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels);
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
virtual void SetIcon(unsigned int width, unsigned int height, const Uint8* pixels);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Switch to fullscreen mode
|
/// \brief Switch to fullscreen mode
|
||||||
|
@ -202,11 +202,14 @@ WindowHandle WindowImplWin32::GetHandle() const
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplWin32::ProcessEvents()
|
void WindowImplWin32::ProcessEvents(bool block)
|
||||||
{
|
{
|
||||||
// We update the window only if we own it
|
// We process the window events only if we own it
|
||||||
if (!myCallback)
|
if (!myCallback)
|
||||||
{
|
{
|
||||||
|
if (block)
|
||||||
|
WaitMessage();
|
||||||
|
|
||||||
MSG message;
|
MSG message;
|
||||||
while (PeekMessage(&message, myHandle, 0, 0, PM_REMOVE))
|
while (PeekMessage(&message, myHandle, 0, 0, PM_REMOVE))
|
||||||
{
|
{
|
||||||
|
@ -81,10 +81,12 @@ private :
|
|||||||
virtual WindowHandle GetHandle() const;
|
virtual WindowHandle GetHandle() const;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from operating system
|
/// \brief Process incoming events from the operating system
|
||||||
|
///
|
||||||
|
/// \param block Use true to block the thread until an event arrives
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual void ProcessEvents();
|
virtual void ProcessEvents(bool block);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Show or hide the mouse cursor
|
/// \brief Show or hide the mouse cursor
|
||||||
|
@ -211,9 +211,29 @@ bool Window::GetEvent(Event& event)
|
|||||||
{
|
{
|
||||||
// Let the window implementation process incoming events if the events queue is empty
|
// Let the window implementation process incoming events if the events queue is empty
|
||||||
if (myWindow && myEvents.empty())
|
if (myWindow && myEvents.empty())
|
||||||
myWindow->DoEvents();
|
myWindow->DoEvents(false);
|
||||||
|
|
||||||
// Pop first event of queue, if not empty
|
// Pop the first event of the queue, if it is not empty
|
||||||
|
if (!myEvents.empty())
|
||||||
|
{
|
||||||
|
event = myEvents.front();
|
||||||
|
myEvents.pop();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
bool Window::WaitEvent(Event& event)
|
||||||
|
{
|
||||||
|
// Let the window implementation process incoming events if the events queue is empty
|
||||||
|
if (myWindow && myEvents.empty())
|
||||||
|
myWindow->DoEvents(true);
|
||||||
|
|
||||||
|
// Pop the first event of the queue, if it is not empty
|
||||||
if (!myEvents.empty())
|
if (!myEvents.empty())
|
||||||
{
|
{
|
||||||
event = myEvents.front();
|
event = myEvents.front();
|
||||||
|
@ -126,13 +126,13 @@ void WindowImpl::SetJoystickThreshold(float threshold)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImpl::DoEvents()
|
void WindowImpl::DoEvents(bool block)
|
||||||
{
|
{
|
||||||
// Read the joysticks state and generate the appropriate events
|
// Read the joysticks state and generate the appropriate events
|
||||||
ProcessJoystickEvents();
|
ProcessJoystickEvents();
|
||||||
|
|
||||||
// Let the derived class process other events
|
// Let the derived class process other events
|
||||||
ProcessEvents();
|
ProcessEvents(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,10 +124,12 @@ public :
|
|||||||
void SetJoystickThreshold(float threshold);
|
void SetJoystickThreshold(float threshold);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from operating system
|
/// \brief Process incoming events from the operating system
|
||||||
|
///
|
||||||
|
/// \param block Use true to block the thread until an event arrives
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void DoEvents();
|
void DoEvents(bool block);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get the OS-specific handle of the window
|
/// \brief Get the OS-specific handle of the window
|
||||||
@ -229,10 +231,12 @@ private :
|
|||||||
void ProcessJoystickEvents();
|
void ProcessJoystickEvents();
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Process incoming events from operating system
|
/// \brief Process incoming events from the operating system
|
||||||
|
///
|
||||||
|
/// \param block Use true to block the thread until an event arrives
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
virtual void ProcessEvents() = 0;
|
virtual void ProcessEvents(bool block) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Total number of joysticks supported
|
// Total number of joysticks supported
|
||||||
|
Loading…
Reference in New Issue
Block a user