Updated CSFML and SFML.Net to the new input classes

This commit is contained in:
Laurent Gomila 2011-07-05 23:04:03 +02:00 committed by Marco Antognini
parent 3cd3e88e0e
commit 7d2fa550c0
54 changed files with 1503 additions and 955 deletions

View file

@ -257,16 +257,6 @@ CSFML_API void sfRenderWindow_RestoreGLStates(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
CSFML_API void sfRenderWindow_Display(sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Get the input manager of a window
///
/// \param renderWindow : Renderwindow object
///
/// \return Reference to the input
///
////////////////////////////////////////////////////////////
CSFML_API const sfInput* sfRenderWindow_GetInput(const sfRenderWindow* renderWindow);
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
///

View file

@ -32,7 +32,9 @@
#include <SFML/System.h>
#include <SFML/Window/Context.h>
#include <SFML/Window/Event.h>
#include <SFML/Window/Input.h>
#include <SFML/Window/Joystick.h>
#include <SFML/Window/Keyboard.h>
#include <SFML/Window/Mouse.h>
#include <SFML/Window/VideoMode.h>
#include <SFML/Window/Window.h>

View file

@ -28,145 +28,9 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// Definition of key codes for keyboard events
////////////////////////////////////////////////////////////
typedef enum
{
sfKeyA = 'a',
sfKeyB = 'b',
sfKeyC = 'c',
sfKeyD = 'd',
sfKeyE = 'e',
sfKeyF = 'f',
sfKeyG = 'g',
sfKeyH = 'h',
sfKeyI = 'i',
sfKeyJ = 'j',
sfKeyK = 'k',
sfKeyL = 'l',
sfKeyM = 'm',
sfKeyN = 'n',
sfKeyO = 'o',
sfKeyP = 'p',
sfKeyQ = 'q',
sfKeyR = 'r',
sfKeyS = 's',
sfKeyT = 't',
sfKeyU = 'u',
sfKeyV = 'v',
sfKeyW = 'w',
sfKeyX = 'x',
sfKeyY = 'y',
sfKeyZ = 'z',
sfKeyNum0 = '0',
sfKeyNum1 = '1',
sfKeyNum2 = '2',
sfKeyNum3 = '3',
sfKeyNum4 = '4',
sfKeyNum5 = '5',
sfKeyNum6 = '6',
sfKeyNum7 = '7',
sfKeyNum8 = '8',
sfKeyNum9 = '9',
sfKeyEscape = 256,
sfKeyLControl,
sfKeyLShift,
sfKeyLAlt,
sfKeyLSystem, ///< OS specific key (left side) : windows (Win and Linux), apple (MacOS), ...
sfKeyRControl,
sfKeyRShift,
sfKeyRAlt,
sfKeyRSystem, ///< OS specific key (right side) : windows (Win and Linux), apple (MacOS), ...
sfKeyMenu,
sfKeyLBracket, ///< [
sfKeyRBracket, ///< ]
sfKeySemiColon, ///< ;
sfKeyComma, ///< ,
sfKeyPeriod, ///< .
sfKeyQuote, ///< '
sfKeySlash, ///< /
sfKeyBackSlash,
sfKeyTilde, ///< ~
sfKeyEqual, ///< =
sfKeyDash, ///< -
sfKeySpace,
sfKeyReturn,
sfKeyBack,
sfKeyTab,
sfKeyPageUp,
sfKeyPageDown,
sfKeyEnd,
sfKeyHome,
sfKeyInsert,
sfKeyDelete,
sfKeyAdd, ///< +
sfKeySubtract, ///< -
sfKeyMultiply, ///< *
sfKeyDivide, ///< /
sfKeyLeft, ///< Left arrow
sfKeyRight, ///< Right arrow
sfKeyUp, ///< Up arrow
sfKeyDown, ///< Down arrow
sfKeyNumpad0,
sfKeyNumpad1,
sfKeyNumpad2,
sfKeyNumpad3,
sfKeyNumpad4,
sfKeyNumpad5,
sfKeyNumpad6,
sfKeyNumpad7,
sfKeyNumpad8,
sfKeyNumpad9,
sfKeyF1,
sfKeyF2,
sfKeyF3,
sfKeyF4,
sfKeyF5,
sfKeyF6,
sfKeyF7,
sfKeyF8,
sfKeyF9,
sfKeyF10,
sfKeyF11,
sfKeyF12,
sfKeyF13,
sfKeyF14,
sfKeyF15,
sfKeyPause,
sfKeyCount // For internal use
} sfKeyCode;
////////////////////////////////////////////////////////////
/// Definition of button codes for mouse events
////////////////////////////////////////////////////////////
typedef enum
{
sfButtonLeft,
sfButtonRight,
sfButtonMiddle,
sfButtonX1,
sfButtonX2
} sfMouseButton;
////////////////////////////////////////////////////////////
/// Definition of joystick axis for joystick events
////////////////////////////////////////////////////////////
typedef enum
{
sfJoyAxisX,
sfJoyAxisY,
sfJoyAxisZ,
sfJoyAxisR,
sfJoyAxisU,
sfJoyAxisV,
sfJoyAxisPOV
} sfJoyAxis;
#include <SFML/Window/Joystick.h>
#include <SFML/Window/Keyboard.h>
#include <SFML/Window/Mouse.h>
////////////////////////////////////////////////////////////
@ -187,9 +51,11 @@ typedef enum
sfEvtMouseMoved,
sfEvtMouseEntered,
sfEvtMouseLeft,
sfEvtJoyButtonPressed,
sfEvtJoyButtonReleased,
sfEvtJoyMoved
sfEvtJoystickButtonPressed,
sfEvtJoystickButtonReleased,
sfEvtJoystickMoved,
sfEvtJoystickConnected,
sfEvtJoystickDisconnected
} sfEventType;
@ -250,24 +116,33 @@ struct sfMouseWheelEvent
////////////////////////////////////////////////////////////
/// Joystick axis move event parameters
////////////////////////////////////////////////////////////
struct sfJoyMoveEvent
struct sfJoystickMoveEvent
{
sfEventType Type;
unsigned int JoystickId;
sfJoyAxis Axis;
float Position;
sfEventType Type;
unsigned int JoystickId;
sfJoystickAxis Axis;
float Position;
};
////////////////////////////////////////////////////////////
/// Joystick buttons events parameters
////////////////////////////////////////////////////////////
struct sfJoyButtonEvent
struct sfJoystickButtonEvent
{
sfEventType Type;
unsigned int JoystickId;
unsigned int Button;
};
////////////////////////////////////////////////////////////
/// Joystick connection/disconnection event parameters
////////////////////////////////////////////////////////////
struct sfJoystickConnectEvent
{
sfEventType Type;
unsigned int JoystickId;
};
////////////////////////////////////////////////////////////
/// Size events parameters
////////////////////////////////////////////////////////////
@ -287,15 +162,16 @@ typedef union
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
sfEventType Type; ///< Type of the event
struct sfKeyEvent Key;
struct sfTextEvent Text;
struct sfMouseMoveEvent MouseMove;
struct sfMouseButtonEvent MouseButton;
struct sfMouseWheelEvent MouseWheel;
struct sfJoyMoveEvent JoyMove;
struct sfJoyButtonEvent JoyButton;
struct sfSizeEvent Size;
sfEventType Type; ///< Type of the event
struct sfSizeEvent Size;
struct sfKeyEvent Key;
struct sfTextEvent Text;
struct sfMouseMoveEvent MouseMove;
struct sfMouseButtonEvent MouseButton;
struct sfMouseWheelEvent MouseWheel;
struct sfJoystickMoveEvent JoystickMove;
struct sfJoystickButtonEvent JoystickButton;
struct sfJoystickConnectEvent JoystickConnect;
} sfEvent;

View file

@ -0,0 +1,135 @@
////////////////////////////////////////////////////////////
//
// 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_JOYSTICK_H
#define SFML_JOYSTICK_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Global joysticks capabilities
///
////////////////////////////////////////////////////////////
enum
{
sfJoystickCount = 8, ///< Maximum number of supported joysticks
sfJoystickButtonCount = 32, ///< Maximum number of supported buttons
sfJoystickAxisCount = 8 ///< Maximum number of supported axes
};
////////////////////////////////////////////////////////////
/// \brief Axes supported by SFML joysticks
///
////////////////////////////////////////////////////////////
typedef enum
{
sfJoystickX, ///< The X axis
sfJoystickY, ///< The Y axis
sfJoystickZ, ///< The Z axis
sfJoystickR, ///< The R axis
sfJoystickU, ///< The U axis
sfJoystickV, ///< The V axis
sfJoystickPovX, ///< The X axis of the point-of-view hat
sfJoystickPovY ///< The Y axis of the point-of-view hat
} sfJoystickAxis;
////////////////////////////////////////////////////////////
/// \brief Check if a joystick is connected
///
/// \param joystick Index of the joystick to check
///
/// \return sfTrue if the joystick is connected, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_IsConnected(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Return the number of buttons supported by a joystick
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
///
/// \return Number of buttons supported by the joystick
///
////////////////////////////////////////////////////////////
CSFML_API unsigned int sfJoystick_GetButtonCount(unsigned int joystick);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick supports a given axis
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return sfTrue if the joystick supports the axis, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis);
////////////////////////////////////////////////////////////
/// \brief Check if a joystick button is pressed
///
/// If the joystick is not connected, this function returns false.
///
/// \param joystick Index of the joystick
/// \param button Button to check
///
/// \return sfTrue if the button is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of a joystick axis
///
/// If the joystick is not connected, this function returns 0.
///
/// \param joystick Index of the joystick
/// \param axis Axis to check
///
/// \return Current position of the axis, in range [-100 .. 100]
///
////////////////////////////////////////////////////////////
CSFML_API float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis);
////////////////////////////////////////////////////////////
/// \brief Update the states of all joysticks
///
/// This function is used internally by SFML, so you normally
/// don't have to call it explicitely. However, you may need to
/// call it if you have no window yet (or no window at all):
/// in this case the joysticks states are not updated automatically.
///
////////////////////////////////////////////////////////////
CSFML_API void sfJoystick_Update(void);
#endif // SFML_JOYSTICK_H

View file

@ -0,0 +1,156 @@
////////////////////////////////////////////////////////////
//
// 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_KEYBOARD_H
#define SFML_KEYBOARD_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Key codes
///
////////////////////////////////////////////////////////////
typedef enum
{
sfKeyA, ///< The A key
sfKeyB, ///< The B key
sfKeyC, ///< The C key
sfKeyD, ///< The D key
sfKeyE, ///< The E key
sfKeyF, ///< The F key
sfKeyG, ///< The G key
sfKeyH, ///< The H key
sfKeyI, ///< The I key
sfKeyJ, ///< The J key
sfKeyK, ///< The K key
sfKeyL, ///< The L key
sfKeyM, ///< The M key
sfKeyN, ///< The N key
sfKeyO, ///< The O key
sfKeyP, ///< The P key
sfKeyQ, ///< The Q key
sfKeyR, ///< The R key
sfKeyS, ///< The S key
sfKeyT, ///< The T key
sfKeyU, ///< The U key
sfKeyV, ///< The V key
sfKeyW, ///< The W key
sfKeyX, ///< The X key
sfKeyY, ///< The Y key
sfKeyZ, ///< The Z key
sfKeyNum0, ///< The 0 key
sfKeyNum1, ///< The 1 key
sfKeyNum2, ///< The 2 key
sfKeyNum3, ///< The 3 key
sfKeyNum4, ///< The 4 key
sfKeyNum5, ///< The 5 key
sfKeyNum6, ///< The 6 key
sfKeyNum7, ///< The 7 key
sfKeyNum8, ///< The 8 key
sfKeyNum9, ///< The 9 key
sfKeyEscape, ///< The Escape key
sfKeyLControl, ///< The left Control key
sfKeyLShift, ///< The left Shift key
sfKeyLAlt, ///< The left Alt key
sfKeyLSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
sfKeyRControl, ///< The right Control key
sfKeyRShift, ///< The right Shift key
sfKeyRAlt, ///< The right Alt key
sfKeyRSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
sfKeyMenu, ///< The Menu key
sfKeyLBracket, ///< The [ key
sfKeyRBracket, ///< The ] key
sfKeySemiColon, ///< The ; key
sfKeyComma, ///< The , key
sfKeyPeriod, ///< The . key
sfKeyQuote, ///< The ' key
sfKeySlash, ///< The / key
sfKeyBackSlash, ///< The \ key
sfKeyTilde, ///< The ~ key
sfKeyEqual, ///< The = key
sfKeyDash, ///< The - key
sfKeySpace, ///< The Space key
sfKeyReturn, ///< The Return key
sfKeyBack, ///< The Backspace key
sfKeyTab, ///< The Tabulation key
sfKeyPageUp, ///< The Page up key
sfKeyPageDown, ///< The Page down key
sfKeyEnd, ///< The End key
sfKeyHome, ///< The Home key
sfKeyInsert, ///< The Insert key
sfKeyDelete, ///< The Delete key
sfKeyAdd, ///< +
sfKeySubtract, ///< -
sfKeyMultiply, ///< *
sfKeyDivide, ///< /
sfKeyLeft, ///< Left arrow
sfKeyRight, ///< Right arrow
sfKeyUp, ///< Up arrow
sfKeyDown, ///< Down arrow
sfKeyNumpad0, ///< The numpad 0 key
sfKeyNumpad1, ///< The numpad 1 key
sfKeyNumpad2, ///< The numpad 2 key
sfKeyNumpad3, ///< The numpad 3 key
sfKeyNumpad4, ///< The numpad 4 key
sfKeyNumpad5, ///< The numpad 5 key
sfKeyNumpad6, ///< The numpad 6 key
sfKeyNumpad7, ///< The numpad 7 key
sfKeyNumpad8, ///< The numpad 8 key
sfKeyNumpad9, ///< The numpad 9 key
sfKeyF1, ///< The F1 key
sfKeyF2, ///< The F2 key
sfKeyF3, ///< The F3 key
sfKeyF4, ///< The F4 key
sfKeyF5, ///< The F5 key
sfKeyF6, ///< The F6 key
sfKeyF7, ///< The F7 key
sfKeyF8, ///< The F8 key
sfKeyF9, ///< The F8 key
sfKeyF10, ///< The F10 key
sfKeyF11, ///< The F11 key
sfKeyF12, ///< The F12 key
sfKeyF13, ///< The F13 key
sfKeyF14, ///< The F14 key
sfKeyF15, ///< The F15 key
sfKeyPause, ///< The Pause key
sfKeyCount ///< Keep last -- the total number of keyboard keys
} sfKeyCode;
////////////////////////////////////////////////////////////
/// \brief Check if a key is pressed
///
/// \param key Key to check
///
/// \return sfTrue if the key is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfKeyboard_IsKeyPressed(sfKeyCode key);
#endif // SFML_KEYBOARD_H

View file

@ -0,0 +1,74 @@
////////////////////////////////////////////////////////////
//
// 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_MOUSE_H
#define SFML_MOUSE_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Config.h>
////////////////////////////////////////////////////////////
/// \brief Mouse buttons
///
////////////////////////////////////////////////////////////
typedef enum
{
sfMouseLeft, ///< The left mouse button
sfMouseRight, ///< The right mouse button
sfMouseMiddle, ///< The middle (wheel) mouse button
sfMouseXButton1, ///< The first extra mouse button
sfMouseXButton2, ///< The second extra mouse button
sfMouseButtonCount ///< Keep last -- the total number of mouse buttons
} sfMouseButton;
////////////////////////////////////////////////////////////
/// \brief Check if a mouse button is pressed
///
/// \param button Button to check
///
/// \return sfTrue if the button is pressed, sfFalse otherwise
///
////////////////////////////////////////////////////////////
CSFML_API sfBool sfMouse_IsButtonPressed(sfMouseButton button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of the mouse
///
/// This function returns the current position of the mouse
/// cursor.
/// If the cursor is over a SFML window, the returned position
/// is relative to this window. Otherwise, the returned position
/// is in desktop coordinates.
///
/// \return Current position of the mouse
///
////////////////////////////////////////////////////////////
CSFML_API void sfMouse_GetPosition(int* x, int* y);
#endif // SFML_MOUSE_H

View file

@ -27,7 +27,6 @@
typedef struct sfContext sfContext;
typedef struct sfInput sfInput;
typedef struct sfWindow sfWindow;

View file

@ -185,7 +185,17 @@ CSFML_API void sfWindow_ShowMouseCursor(sfWindow* window, sfBool show);
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int Top);
CSFML_API void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned int top);
////////////////////////////////////////////////////////////
/// Get the position of the mouse cursor on a window
///
/// \param window : Window object
/// \param left : Left coordinate of the cursor, relative to the window
/// \param top : Top coordinate of the cursor, relative to the window
///
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top);
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
@ -266,16 +276,6 @@ CSFML_API sfBool sfWindow_SetActive(sfWindow* window, sfBool active);
////////////////////////////////////////////////////////////
CSFML_API void sfWindow_Display(sfWindow* window);
////////////////////////////////////////////////////////////
/// Get the input manager of a window
///
/// \param window : Window object
///
/// \return Reference to the input
///
////////////////////////////////////////////////////////////
CSFML_API const sfInput* sfWindow_GetInput(sfWindow* window);
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
///