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;
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
////////////////////////////////////////////////////////////
@ -288,14 +163,15 @@ typedef union
// Member data
////////////////////////////////////////////////////////////
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 sfJoyMoveEvent JoyMove;
struct sfJoyButtonEvent JoyButton;
struct sfSizeEvent Size;
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
///

View File

@ -79,16 +79,24 @@ inline void ConvertEvent(const sf::Event& SFMLEvent, sfEvent* event)
event->MouseMove.Y = SFMLEvent.MouseMove.Y;
break;
case sfEvtJoyButtonPressed :
case sfEvtJoyButtonReleased :
event->JoyButton.JoystickId = SFMLEvent.JoyButton.JoystickId;
event->JoyButton.Button = SFMLEvent.JoyButton.Button;
case sfEvtJoystickButtonPressed :
case sfEvtJoystickButtonReleased :
event->JoystickButton.JoystickId = SFMLEvent.JoystickButton.JoystickId;
event->JoystickButton.Button = SFMLEvent.JoystickButton.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;
case sfEvtJoystickMoved :
event->JoystickMove.JoystickId = SFMLEvent.JoystickMove.JoystickId;
event->JoystickMove.Axis = static_cast<sfJoystickAxis>(SFMLEvent.JoystickMove.Axis);
event->JoystickMove.Position = SFMLEvent.JoystickMove.Position;
break;
case sfEvtJoystickConnected :
event->JoystickConnect.JoystickId = SFMLEvent.JoystickConnect.JoystickId;
break;
case sfEvtJoystickDisconnected :
event->JoystickConnect.JoystickId = SFMLEvent.JoystickConnect.JoystickId;
break;
default :

View File

@ -31,7 +31,6 @@
#include <SFML/Graphics/RenderImage.hpp>
#include <SFML/Graphics/ImageStruct.h>
#include <SFML/Graphics/ViewStruct.h>
#include <SFML/Window/InputStruct.h>
////////////////////////////////////////////////////////////

View File

@ -58,7 +58,6 @@ sfRenderWindow* sfRenderWindow_Create(sfVideoMode mode, const char* title, unsig
// Create the window
sfRenderWindow* renderWindow = new sfRenderWindow;
renderWindow->This.Create(videoMode, title, style, params);
renderWindow->Input.This = &renderWindow->This.GetInput();
renderWindow->DefaultView.This = renderWindow->This.GetDefaultView();
renderWindow->CurrentView.This = renderWindow->This.GetView();
@ -85,7 +84,6 @@ sfRenderWindow* sfRenderWindow_CreateFromHandle(sfWindowHandle handle, const sfC
// Create the window
sfRenderWindow* renderWindow = new sfRenderWindow;
renderWindow->This.Create(handle, params);
renderWindow->Input.This = &renderWindow->This.GetInput();
renderWindow->DefaultView.This = renderWindow->This.GetDefaultView();
renderWindow->CurrentView.This = renderWindow->This.GetView();
@ -320,17 +318,6 @@ void sfRenderWindow_Display(sfRenderWindow* renderWindow)
}
////////////////////////////////////////////////////////////
/// Get the input manager of a window
////////////////////////////////////////////////////////////
const sfInput* sfRenderWindow_GetInput(const sfRenderWindow* renderWindow)
{
CSFML_CHECK_RETURN(renderWindow, NULL);
return &renderWindow->Input;
}
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
////////////////////////////////////////////////////////////

View File

@ -30,7 +30,6 @@
////////////////////////////////////////////////////////////
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/ViewStruct.h>
#include <SFML/Window/InputStruct.h>
////////////////////////////////////////////////////////////
@ -39,7 +38,6 @@
struct sfRenderWindow
{
sf::RenderWindow This;
sfInput Input;
sfView DefaultView;
sfView CurrentView;
};

View File

@ -8,9 +8,12 @@ set(SRC
${SRCROOT}/ContextStruct.h
${INCROOT}/Context.h
${INCROOT}/Event.h
${SRCROOT}/Input.cpp
${SRCROOT}/InputStruct.h
${INCROOT}/Input.h
${SRCROOT}/Joystick.cpp
${SRCROOT}/Keyboard.cpp
${SRCROOT}/Mouse.cpp
${INCROOT}/Joystick.h
${INCROOT}/Keyboard.h
${INCROOT}/Mouse.h
${INCROOT}/Types.h
${SRCROOT}/VideoMode.cpp
${INCROOT}/VideoMode.h

View File

@ -25,59 +25,60 @@
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Input.h>
#include <SFML/Window/InputStruct.h>
#include <SFML/Window/Joystick.h>
#include <SFML/Window/Joystick.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Get the state of a key
/// Check if a joystick is connected
////////////////////////////////////////////////////////////
sfBool sfInput_IsKeyDown(const sfInput* input, sfKeyCode code)
sfBool sfJoystick_IsConnected(unsigned int joystick)
{
CSFML_CALL_PTR_RETURN(input, IsKeyDown((sf::Key::Code)code), sfFalse);
return sf::Joystick::IsConnected(joystick) ? sfTrue : sfFalse;
}
////////////////////////////////////////////////////////////
/// Get the state of a mouse button
/// Return the number of buttons supported by a joystick
////////////////////////////////////////////////////////////
sfBool sfInput_IsMouseButtonDown(const sfInput* input, sfMouseButton button)
unsigned int sfJoystick_GetButtonCount(unsigned int joystick)
{
CSFML_CALL_PTR_RETURN(input, IsMouseButtonDown((sf::Mouse::Button)button), sfFalse);
return sf::Joystick::GetButtonCount(joystick);
}
////////////////////////////////////////////////////////////
/// Get the state of a joystick button
/// Check if a joystick supports a given axis
////////////////////////////////////////////////////////////
sfBool sfInput_IsJoystickButtonDown(const sfInput* input, unsigned int joyId, unsigned int button)
sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis)
{
CSFML_CALL_PTR_RETURN(input, IsJoystickButtonDown(joyId, button), sfFalse);
return sf::Joystick::HasAxis(joystick, static_cast<sf::Joystick::Axis>(axis)) ? sfTrue : sfFalse;
}
////////////////////////////////////////////////////////////
/// Get the mouse X position
/// Check if a joystick button is pressed
////////////////////////////////////////////////////////////
int sfInput_GetMouseX(const sfInput* input)
sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button)
{
CSFML_CALL_PTR_RETURN(input, GetMouseX(), 0);
return sf::Joystick::IsButtonPressed(joystick, button) ? sfTrue : sfFalse;
}
////////////////////////////////////////////////////////////
/// Get the mouse Y position
/// Get the current position of a joystick axis
////////////////////////////////////////////////////////////
int sfInput_GetMouseY(const sfInput* input)
float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis)
{
CSFML_CALL_PTR_RETURN(input, GetMouseY(), 0);
return sf::Joystick::GetAxisPosition(joystick, static_cast<sf::Joystick::Axis>(axis));
}
////////////////////////////////////////////////////////////
/// Get the joystick position on a given axis
/// Update the states of all joysticks
////////////////////////////////////////////////////////////
float sfInput_GetJoystickAxis(const sfInput* input, unsigned int joyId, sfJoyAxis axis)
void sfJoystick_Update(void)
{
CSFML_CALL_PTR_RETURN(input, GetJoystickAxis(joyId, (sf::Joy::Axis)axis), 0.f);
sf::Joystick::Update();
}

View File

@ -22,22 +22,18 @@
//
////////////////////////////////////////////////////////////
#ifndef SFML_INPUTSTRUCT_H
#define SFML_INPUTSTRUCT_H
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Input.hpp>
#include <SFML/Window/Keyboard.h>
#include <SFML/Window/Keyboard.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
// Internal structure of sfInput
/// Check if a key is pressed
////////////////////////////////////////////////////////////
struct sfInput
sfBool sfKeyboard_IsKeyPressed(sfKeyCode key)
{
const sf::Input* This;
};
#endif // SFML_INPUTSTRUCT_H
return sf::Keyboard::IsKeyPressed(static_cast<sf::Keyboard::Key>(key));
}

View File

@ -0,0 +1,53 @@
////////////////////////////////////////////////////////////
//
// 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.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Mouse.h>
#include <SFML/Window/Mouse.hpp>
#include <SFML/Internal.h>
////////////////////////////////////////////////////////////
/// Check if a mouse button is pressed
////////////////////////////////////////////////////////////
sfBool sfMouse_IsButtonPressed(sfMouseButton button)
{
return sf::Mouse::IsButtonPressed(static_cast<sf::Mouse::Button>(button)) ? sfTrue : sfFalse;
}
////////////////////////////////////////////////////////////
/// Get the current position of the mouse
////////////////////////////////////////////////////////////
void sfMouse_GetPosition(int* x, int* y)
{
sf::Vector2i position = sf::Mouse::GetPosition();
if (x)
*x = position.x;
if (y)
*y = position.y;
}

View File

@ -53,7 +53,6 @@ sfWindow* sfWindow_Create(sfVideoMode mode, const char* title, unsigned long sty
// Create the window
sfWindow* window = new sfWindow;
window->This.Create(videoMode, title, style, params);
window->Input.This = &window->This.GetInput();
return window;
}
@ -78,7 +77,6 @@ sfWindow* sfWindow_CreateFromHandle(sfWindowHandle handle, const sfContextSettin
// Create the window
sfWindow* window = new sfWindow;
window->This.Create(handle, params);
window->Input.This = &window->This.GetInput();
return window;
}
@ -220,6 +218,21 @@ void sfWindow_SetCursorPosition(sfWindow* window, unsigned int left, unsigned in
}
////////////////////////////////////////////////////////////
/// Get the position of the mouse cursor on a window
////////////////////////////////////////////////////////////
void sfWindow_GetCursorPosition(sfWindow* window, int* left, int* top)
{
CSFML_CHECK(window);
sf::Vector2i position = window->This.GetCursorPosition();
if (left)
*left = position.x;
if (top)
*top = position.y;
}
////////////////////////////////////////////////////////////
/// Change the position of a window on screen.
/// Only works for top-level windows
@ -294,17 +307,6 @@ void sfWindow_Display(sfWindow* window)
}
////////////////////////////////////////////////////////////
/// Get the input manager of a window
////////////////////////////////////////////////////////////
const sfInput* sfWindow_GetInput(sfWindow* window)
{
CSFML_CHECK_RETURN(window, NULL);
return &window->Input;
}
////////////////////////////////////////////////////////////
/// Limit the framerate to a maximum fixed frequency for a window
////////////////////////////////////////////////////////////

View File

@ -29,7 +29,6 @@
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window/Window.hpp>
#include <SFML/Window/InputStruct.h>
////////////////////////////////////////////////////////////
@ -38,7 +37,6 @@
struct sfWindow
{
sf::Window This;
sfInput Input;
};

View File

@ -27,7 +27,7 @@ namespace opengl
// Create a text to display
Text text = new Text("SFML / OpenGL demo");
text.Position = new Vector2(250.0F, 450.0F);
text.Position = new Vector2f(250.0F, 450.0F);
text.Color = new Color(255, 255, 255, 170);
// Load an OpenGL texture.
@ -83,8 +83,8 @@ namespace opengl
Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT);
// We get the position of the mouse cursor, so that we can move the box accordingly
float x = window.Input.GetMouseX() * 200.0F / window.Width - 100.0F;
float y = -window.Input.GetMouseY() * 200.0F / window.Height + 100.0F;
float x = window.GetCursorPosition().X * 200.0F / window.Width - 100.0F;
float y = -window.GetCursorPosition().Y * 200.0F / window.Height + 100.0F;
// Apply some transformations
time += window.GetFrameTime() / 1000.0F;
@ -159,7 +159,7 @@ namespace opengl
static void OnKeyPressed(object sender, KeyEventArgs e)
{
RenderWindow window = (RenderWindow)sender;
if (e.Code == KeyCode.Escape)
if (e.Code == Keyboard.Key.Escape)
window.Close();
}

View File

@ -125,7 +125,7 @@ namespace shader
shaderText = new Text();
shaderText.Font = font;
shaderText.CharacterSize = 20;
shaderText.Position = new Vector2(5.0F, 0.0F);
shaderText.Position = new Vector2f(5.0F, 0.0F);
shaderText.Color = new Color(250, 100, 30);
shaderText.DisplayedString = "Background shader: \"" + backgroundShader.Name + "\"\n" +
"Flower shader: \"" + entityShader.Name + "\"\n" +
@ -135,7 +135,7 @@ namespace shader
Text infoText = new Text();
infoText.Font = font;
infoText.CharacterSize = 20;
infoText.Position = new Vector2(5.0F, 500.0F);
infoText.Position = new Vector2f(5.0F, 500.0F);
infoText.Color = new Color(250, 100, 30);
infoText.DisplayedString = "Move your mouse to change the shaders' parameters\n" +
"Press numpad 1 to change the background shader\n" +
@ -149,12 +149,9 @@ namespace shader
// Process events
window.DispatchEvents();
// TOFIX -- using window.Input together with image.Draw apparently causes a memory corruption
// Get the mouse position in the range [0, 1]
//float x = window.Input.GetMouseX() / (float)window.Width;
//float y = window.Input.GetMouseY() / (float)window.Height;
float x = (float)(Math.Cos(time * 1.3) + 1) * 0.5F;
float y = (float)(Math.Sin(time * 0.8) + 1) * 0.5F;
float x = window.GetCursorPosition().X / (float)window.Width;
float y = window.GetCursorPosition().Y / (float)window.Height;
// Update the shaders
backgroundShader.Update(x, y);
@ -162,10 +159,10 @@ namespace shader
globalShader.Update(x, y);
// Animate the sprite
time += window.GetFrameTime();
time += window.GetFrameTime() / 1000.0F;
float entityX = (float)(Math.Cos(time * 1.3) + 1.2) * 300;
float entityY = (float)(Math.Cos(time * 0.8) + 1.2) * 200;
entity.Position = new Vector2(entityX, entityY);
entity.Position = new Vector2f(entityX, entityY);
entity.Rotation = time * 100;
// Draw the background and the moving entity to the render image
@ -193,7 +190,7 @@ namespace shader
{
// Define a string for displaying the error message
Text error = new Text("Sorry, your system doesn't support shaders");
error.Position = new Vector2(100.0F, 250.0F);
error.Position = new Vector2f(100.0F, 250.0F);
error.Color = new Color(200, 100, 150);
// Start the game loop
@ -230,15 +227,15 @@ namespace shader
RenderWindow window = (RenderWindow)sender;
// Escape key : exit
if (e.Code == KeyCode.Escape)
if (e.Code == Keyboard.Key.Escape)
window.Close();
// Numpad : switch effect
switch (e.Code)
{
case KeyCode.Numpad1 : backgroundShader.GotoNext(); break;
case KeyCode.Numpad2 : entityShader.GotoNext(); break;
case KeyCode.Numpad3 : globalShader.GotoNext(); break;
case Keyboard.Key.Numpad1: backgroundShader.GotoNext(); break;
case Keyboard.Key.Numpad2: entityShader.GotoNext(); break;
case Keyboard.Key.Numpad3: globalShader.GotoNext(); break;
}
// Update the text

View File

@ -119,7 +119,7 @@ namespace window
static void OnKeyPressed(object sender, KeyEventArgs e)
{
Window window = (Window)sender;
if (e.Code == KeyCode.Escape)
if (e.Code == Keyboard.Key.Escape)
window.Close();
}

View File

@ -31,9 +31,9 @@ namespace SFML
/// 3D position of the listener (default is (0, 0, 0))
/// </summary>
////////////////////////////////////////////////////////////
public static Vector3 Position
public static Vector3f Position
{
get {Vector3 v; sfListener_GetPosition(out v.X, out v.Y, out v.Z); return v;}
get {Vector3f v; sfListener_GetPosition(out v.X, out v.Y, out v.Z); return v;}
set {sfListener_SetPosition(value.X, value.Y, value.Z);}
}
@ -42,9 +42,9 @@ namespace SFML
/// 3D direction of the listener (default is (0, 0, -1))
/// </summary>
////////////////////////////////////////////////////////////
public static Vector3 Direction
public static Vector3f Direction
{
get {Vector3 v; sfListener_GetDirection(out v.X, out v.Y, out v.Z); return v;}
get {Vector3f v; sfListener_GetDirection(out v.X, out v.Y, out v.Z); return v;}
set {sfListener_SetDirection(value.X, value.Y, value.Z);}
}

View File

@ -159,9 +159,9 @@ namespace SFML
/// 3D position of the music. Default value is (0, 0, 0)
/// </summary>
////////////////////////////////////////////////////////////
public Vector3 Position
public Vector3f Position
{
get {Vector3 v; sfMusic_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
get {Vector3f v; sfMusic_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
set {sfMusic_SetPosition(This, value.X, value.Y, value.Z);}
}

View File

@ -165,9 +165,9 @@ namespace SFML
/// 3D position of the sound. Default value is (0, 0, 0)
/// </summary>
////////////////////////////////////////////////////////////
public Vector3 Position
public Vector3f Position
{
get {Vector3 v; sfSound_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
get {Vector3f v; sfSound_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
set {sfSound_SetPosition(This, value.X, value.Y, value.Z);}
}

View File

@ -124,9 +124,9 @@ namespace SFML
/// 3D position of the sound stream. Default value is (0, 0, 0)
/// </summary>
////////////////////////////////////////////////////////////
public Vector3 Position
public Vector3f Position
{
get {Vector3 v; sfSoundStream_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
get {Vector3f v; sfSoundStream_GetPosition(This, out v.X, out v.Y, out v.Z); return v;}
set {sfSoundStream_SetPosition(This, value.X, value.Y, value.Z);}
}

View File

@ -7,12 +7,12 @@ namespace SFML
{
////////////////////////////////////////////////////////////
/// <summary>
/// Vector3 is an utility class for manipulating 3 dimensional
/// Vector3f is an utility class for manipulating 3 dimensional
/// vectors with float components
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Vector3
public struct Vector3f
{
////////////////////////////////////////////////////////////
/// <summary>
@ -22,7 +22,7 @@ namespace SFML
/// <param name="y">Y coordinate</param>
/// <param name="z">Z coordinate</param>
////////////////////////////////////////////////////////////
public Vector3(float x, float y, float z)
public Vector3f(float x, float y, float z)
{
X = x;
Y = y;
@ -36,9 +36,9 @@ namespace SFML
/// <param name="v">Vector to negate</param>
/// <returns>-v</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator -(Vector3 v)
public static Vector3f operator -(Vector3f v)
{
return new Vector3(-v.X, -v.Y, -v.Z);
return new Vector3f(-v.X, -v.Y, -v.Z);
}
////////////////////////////////////////////////////////////
@ -49,9 +49,9 @@ namespace SFML
/// <param name="v2">Second vector</param>
/// <returns>v1 - v2</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator -(Vector3 v1, Vector3 v2)
public static Vector3f operator -(Vector3f v1, Vector3f v2)
{
return new Vector3(v1.X - v2.X, v1.Y - v2.X, v1.Z - v2.Z);
return new Vector3f(v1.X - v2.X, v1.Y - v2.X, v1.Z - v2.Z);
}
////////////////////////////////////////////////////////////
@ -62,9 +62,9 @@ namespace SFML
/// <param name="v2">Second vector</param>
/// <returns>v1 + v2</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator +(Vector3 v1, Vector3 v2)
public static Vector3f operator +(Vector3f v1, Vector3f v2)
{
return new Vector3(v1.X + v2.X, v1.Y + v2.X, v1.Z + v2.Z);
return new Vector3f(v1.X + v2.X, v1.Y + v2.X, v1.Z + v2.Z);
}
////////////////////////////////////////////////////////////
@ -75,9 +75,9 @@ namespace SFML
/// <param name="x">Scalar value</param>
/// <returns>v * x</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator *(Vector3 v, float x)
public static Vector3f operator *(Vector3f v, float x)
{
return new Vector3(v.X * x, v.Y * x, v.Z * x);
return new Vector3f(v.X * x, v.Y * x, v.Z * x);
}
////////////////////////////////////////////////////////////
@ -88,9 +88,9 @@ namespace SFML
/// <param name="v">Vector</param>
/// <returns>x * v</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator *(float x, Vector3 v)
public static Vector3f operator *(float x, Vector3f v)
{
return new Vector3(v.X * x, v.Y * x, v.Z * x);
return new Vector3f(v.X * x, v.Y * x, v.Z * x);
}
////////////////////////////////////////////////////////////
@ -101,9 +101,9 @@ namespace SFML
/// <param name="x">Scalar value</param>
/// <returns>v / x</returns>
////////////////////////////////////////////////////////////
public static Vector3 operator /(Vector3 v, float x)
public static Vector3f operator /(Vector3f v, float x)
{
return new Vector3(v.X / x, v.Y / x, v.Z / x);
return new Vector3f(v.X / x, v.Y / x, v.Z / x);
}
////////////////////////////////////////////////////////////
@ -114,7 +114,7 @@ namespace SFML
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Vector3]" +
return "[Vector3f]" +
" X(" + X + ")" +
" Y(" + Y + ")" +
" Z(" + Z + ")";

View File

@ -1,5 +1,6 @@
using System;
using System.Runtime.InteropServices;
using SFML.Window;
namespace SFML
{
@ -38,7 +39,7 @@ namespace SFML
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Position {get; set;}
public abstract Vector2f Position { get; set; }
////////////////////////////////////////////////////////////
/// <summary>
@ -52,7 +53,7 @@ namespace SFML
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Scale {get; set;}
public abstract Vector2f Scale { get; set; }
////////////////////////////////////////////////////////////
/// <summary>
@ -60,7 +61,7 @@ namespace SFML
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public abstract Vector2 Origin {get; set;}
public abstract Vector2f Origin { get; set; }
////////////////////////////////////////////////////////////
/// <summary>
@ -84,7 +85,7 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public abstract Vector2 TransformToLocal(Vector2 point);
public abstract Vector2f TransformToLocal(Vector2f point);
////////////////////////////////////////////////////////////
/// <summary>
@ -94,7 +95,7 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public abstract Vector2 TransformToGlobal(Vector2 point);
public abstract Vector2f TransformToGlobal(Vector2f point);
////////////////////////////////////////////////////////////
/// <summary>

View File

@ -134,7 +134,7 @@ namespace SFML
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y)
public Vector2f ConvertCoords(uint x, uint y)
{
return ConvertCoords(x, y, GetView());
}
@ -150,9 +150,9 @@ namespace SFML
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y, View view)
public Vector2f ConvertCoords(uint x, uint y, View view)
{
Vector2 point;
Vector2f point;
sfRenderImage_ConvertCoords(This, x, y, out point.X, out point.Y, view.This);
return point;

View File

@ -69,7 +69,7 @@ namespace SFML
/// <param name="y">Y coordinate of the point to convert, relative to the target</param>
/// <returns>Converted point</returns>
////////////////////////////////////////////////////////////
Vector2 ConvertCoords(uint x, uint y);
Vector2f ConvertCoords(uint x, uint y);
////////////////////////////////////////////////////////////
/// <summary>
@ -81,7 +81,7 @@ namespace SFML
/// <param name="view">Target view to convert the point to</param>
/// <returns>Converted point</returns>
////////////////////////////////////////////////////////////
Vector2 ConvertCoords(uint x, uint y, View view);
Vector2f ConvertCoords(uint x, uint y, View view);
////////////////////////////////////////////////////////////
/// <summary>

View File

@ -369,7 +369,7 @@ namespace SFML
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y)
public Vector2f ConvertCoords(uint x, uint y)
{
return ConvertCoords(x, y, GetView());
}
@ -385,9 +385,9 @@ namespace SFML
/// <returns>Converted point</returns>
///
////////////////////////////////////////////////////////////
public Vector2 ConvertCoords(uint x, uint y, View view)
public Vector2f ConvertCoords(uint x, uint y, View view)
{
Vector2 point;
Vector2f point;
sfRenderWindow_ConvertCoords(This, x, y, out point.X, out point.Y, view.This);
return point;
@ -518,7 +518,6 @@ namespace SFML
////////////////////////////////////////////////////////////
private void Initialize()
{
myInput = new Input(sfRenderWindow_GetInput(This));
myDefaultView = new View(sfRenderWindow_GetDefaultView(This));
GC.SuppressFinalize(myDefaultView);
}
@ -535,9 +534,6 @@ namespace SFML
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_Destroy(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfRenderWindow_GetInput(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfRenderWindow_IsOpened(IntPtr This);

View File

@ -2,6 +2,7 @@ using System;
using System.Runtime.InteropServices;
using System.Security;
using System.Collections.Generic;
using SFML.Window;
namespace SFML
{
@ -64,7 +65,7 @@ namespace SFML
/// <param name="name">Name of the parameter in the shader</param>
/// <param name="v">Value of the parameter</param>
////////////////////////////////////////////////////////////
public void SetParameter(string name, Vector2 v)
public void SetParameter(string name, Vector2f v)
{
SetParameter(name, v.X, v.Y);
}

View File

@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using SFML.Window;
namespace SFML
{
@ -41,9 +42,9 @@ namespace SFML
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
public override Vector2f Position
{
get { return new Vector2(sfShape_GetX(This), sfShape_GetY(This)); }
get { return new Vector2f(sfShape_GetX(This), sfShape_GetY(This)); }
set { sfShape_SetPosition(This, value.X, value.Y); }
}
@ -63,9 +64,9 @@ namespace SFML
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
public override Vector2f Scale
{
get { return new Vector2(sfShape_GetScaleX(This), sfShape_GetScaleY(This)); }
get { return new Vector2f(sfShape_GetScaleX(This), sfShape_GetScaleY(This)); }
set { sfShape_SetScale(This, value.X, value.Y); }
}
@ -75,9 +76,9 @@ namespace SFML
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
public override Vector2f Origin
{
get { return new Vector2(sfShape_GetOriginX(This), sfShape_GetOriginY(This)); }
get { return new Vector2f(sfShape_GetOriginX(This), sfShape_GetOriginY(This)); }
set { sfShape_SetOrigin(This, value.X, value.Y); }
}
@ -111,9 +112,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
public override Vector2f TransformToLocal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfShape_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -127,9 +128,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
public override Vector2f TransformToGlobal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfShape_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -142,7 +143,7 @@ namespace SFML
/// <param name="position">Position of the point</param>
/// <param name="color">Color of the point</param>
////////////////////////////////////////////////////////////
public void AddPoint(Vector2 position, Color color)
public void AddPoint(Vector2f position, Color color)
{
AddPoint(position, color, Color.Black);
}
@ -155,7 +156,7 @@ namespace SFML
/// <param name="color">Color of the point</param>
/// <param name="outlineColor">Outline color of the point</param>
////////////////////////////////////////////////////////////
public void AddPoint(Vector2 position, Color color, Color outlineColor)
public void AddPoint(Vector2f position, Color color, Color outlineColor)
{
sfShape_AddPoint(This, position.X, position.Y, color, outlineColor);
}
@ -212,7 +213,7 @@ namespace SFML
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <param name="position">New position of the index-th point</param>
////////////////////////////////////////////////////////////
public void SetPointPosition(uint index, Vector2 position)
public void SetPointPosition(uint index, Vector2f position)
{
sfShape_SetPointPosition(This, index, position.X, position.Y);
}
@ -224,9 +225,9 @@ namespace SFML
/// <param name="index">Index of the point, in range [0, NbPoints - 1]</param>
/// <returns>Position of the index-th point</returns>
////////////////////////////////////////////////////////////
public Vector2 GetPointPosition(uint index)
public Vector2f GetPointPosition(uint index)
{
Vector2 Pos;
Vector2f Pos;
sfShape_GetPointPosition(This, index, out Pos.X, out Pos.Y);
return Pos;
@ -290,7 +291,7 @@ namespace SFML
/// <param name="color">Color used to draw the line</param>
/// <returns>New line shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Line(Vector2 p1, Vector2 p2, float thickness, Color color)
public static Shape Line(Vector2f p1, Vector2f p2, float thickness, Color color)
{
return Line(p1, p2, thickness, color, 0, Color.White);
}
@ -307,7 +308,7 @@ namespace SFML
/// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New line shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Line(Vector2 p1, Vector2 p2, float thickness, Color color, float outline, Color outlineColor)
public static Shape Line(Vector2f p1, Vector2f p2, float thickness, Color color, float outline, Color outlineColor)
{
return new Shape(sfShape_CreateLine(p1.X, p1.Y, p2.X, p2.Y, thickness, color, outline, outlineColor));
}
@ -349,7 +350,7 @@ namespace SFML
/// <param name="color">Color used to fill the circle</param>
/// <returns>New circle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Circle(Vector2 center, float radius, Color color)
public static Shape Circle(Vector2f center, float radius, Color color)
{
return Circle(center, radius, color, 0, Color.White);
}
@ -365,7 +366,7 @@ namespace SFML
/// <param name="outlineColor">Color used to draw the outline</param>
/// <returns>New circle shape built with the given parameters</returns>
////////////////////////////////////////////////////////////
public static Shape Circle(Vector2 center, float radius, Color color, float outline, Color outlineColor)
public static Shape Circle(Vector2f center, float radius, Color color, float outline, Color outlineColor)
{
return new Shape(sfShape_CreateCircle(center.X, center.Y, radius, color, outline, outlineColor));
}
@ -497,10 +498,10 @@ namespace SFML
static extern BlendMode sfShape_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfShape_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern void sfShape_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfShape_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern void sfShape_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawShape(IntPtr This, IntPtr Shape);

View File

@ -1,6 +1,7 @@
using System;
using System.Security;
using System.Runtime.InteropServices;
using SFML.Window;
namespace SFML
{
@ -53,9 +54,9 @@ namespace SFML
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
public override Vector2f Position
{
get { return new Vector2(sfSprite_GetX(This), sfSprite_GetY(This)); }
get { return new Vector2f(sfSprite_GetX(This), sfSprite_GetY(This)); }
set { sfSprite_SetPosition(This, value.X, value.Y); }
}
@ -75,9 +76,9 @@ namespace SFML
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
public override Vector2f Scale
{
get { return new Vector2(sfSprite_GetScaleX(This), sfSprite_GetScaleY(This)); }
get { return new Vector2f(sfSprite_GetScaleX(This), sfSprite_GetScaleY(This)); }
set { sfSprite_SetScale(This, value.X, value.Y); }
}
@ -87,9 +88,9 @@ namespace SFML
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
public override Vector2f Origin
{
get { return new Vector2(sfSprite_GetOriginX(This), sfSprite_GetOriginY(This)); }
get { return new Vector2f(sfSprite_GetOriginX(This), sfSprite_GetOriginY(This)); }
set { sfSprite_SetOrigin(This, value.X, value.Y); }
}
@ -123,9 +124,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
public override Vector2f TransformToLocal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfSprite_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -139,9 +140,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
public override Vector2f TransformToGlobal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfSprite_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -347,10 +348,10 @@ namespace SFML
static extern BlendMode sfSprite_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfSprite_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern Vector2f sfSprite_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfSprite_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern Vector2f sfSprite_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawSprite(IntPtr This, IntPtr Sprite);

View File

@ -1,6 +1,7 @@
using System;
using System.Security;
using System.Runtime.InteropServices;
using SFML.Window;
namespace SFML
{
@ -100,9 +101,9 @@ namespace SFML
/// Position of the object on screen
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Position
public override Vector2f Position
{
get { return new Vector2(sfText_GetX(This), sfText_GetY(This)); }
get { return new Vector2f(sfText_GetX(This), sfText_GetY(This)); }
set { sfText_SetPosition(This, value.X, value.Y); }
}
@ -122,9 +123,9 @@ namespace SFML
/// Vertical and horizontal scale of the object
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Scale
public override Vector2f Scale
{
get { return new Vector2(sfText_GetScaleX(This), sfText_GetScaleY(This)); }
get { return new Vector2f(sfText_GetScaleX(This), sfText_GetScaleY(This)); }
set { sfText_SetScale(This, value.X, value.Y); }
}
@ -134,9 +135,9 @@ namespace SFML
/// (center of translation, rotation and scale)
/// </summary>
////////////////////////////////////////////////////////////
public override Vector2 Origin
public override Vector2f Origin
{
get { return new Vector2(sfText_GetOriginX(This), sfText_GetOriginY(This)); }
get { return new Vector2f(sfText_GetOriginX(This), sfText_GetOriginY(This)); }
set { sfText_SetOrigin(This, value.X, value.Y); }
}
@ -170,9 +171,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToLocal(Vector2 point)
public override Vector2f TransformToLocal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfText_TransformToLocal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -186,9 +187,9 @@ namespace SFML
/// <param name="point">Point to transform</param>
/// <returns>Transformed point</returns>
////////////////////////////////////////////////////////////
public override Vector2 TransformToGlobal(Vector2 point)
public override Vector2f TransformToGlobal(Vector2f point)
{
Vector2 Transformed;
Vector2f Transformed;
sfText_TransformToGlobal(This, point.X, point.Y, out Transformed.X, out Transformed.Y);
return Transformed;
@ -282,9 +283,9 @@ namespace SFML
/// <param name="index">Index of the character</param>
/// <returns>Position of the Index-th character (end of text if Index is out of range)</returns>
////////////////////////////////////////////////////////////
public Vector2 GetCharacterPos(uint index)
public Vector2f GetCharacterPos(uint index)
{
Vector2 Pos;
Vector2f Pos;
sfText_GetCharacterPos(This, index, out Pos.X, out Pos.Y);
return Pos;
@ -411,10 +412,10 @@ namespace SFML
static extern BlendMode sfText_GetBlendMode(IntPtr This);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfText_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern Vector2f sfText_TransformToLocal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern Vector2 sfText_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
static extern Vector2f sfText_TransformToGlobal(IntPtr This, float PointX, float PointY, out float X, out float Y);
[DllImport("csfml-graphics-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfRenderWindow_DrawText(IntPtr This, IntPtr String);

View File

@ -1,127 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Graphics
{
////////////////////////////////////////////////////////////
/// <summary>
/// Vector2 is an utility class for manipulating 2 dimensional
/// vectors with float components
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Vector2
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the vector from its coordinates
/// </summary>
/// <param name="x">X coordinate</param>
/// <param name="y">Y coordinate</param>
////////////////////////////////////////////////////////////
public Vector2(float x, float y)
{
X = x;
Y = y;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; returns the opposite of a vector
/// </summary>
/// <param name="v">Vector to negate</param>
/// <returns>-v</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator -(Vector2 v)
{
return new Vector2(-v.X, -v.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; subtracts two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 - v2</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator -(Vector2 v1, Vector2 v2)
{
return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator + overload ; add two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 + v2</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator +(Vector2 v1, Vector2 v2)
{
return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v * x</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator *(Vector2 v, float x)
{
return new Vector2(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a scalar value by a vector
/// </summary>
/// <param name="x">Scalar value</param>
/// <param name="v">Vector</param>
/// <returns>x * v</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator *(float x, Vector2 v)
{
return new Vector2(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator / overload ; divide a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v / x</returns>
////////////////////////////////////////////////////////////
public static Vector2 operator /(Vector2 v, float x)
{
return new Vector2(v.X / x, v.Y / x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Vector2]" +
" X(" + X + ")" +
" Y(" + Y + ")";
}
/// <summary>X (horizontal) component of the vector</summary>
public float X;
/// <summary>Y (vertical) component of the vector</summary>
public float Y;
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
using SFML.Window;
namespace SFML
{
@ -42,7 +43,7 @@ namespace SFML
/// <param name="center">Center of the view</param>
/// <param name="size">Size of the view</param>
////////////////////////////////////////////////////////////
public View(Vector2 center, Vector2 size) :
public View(Vector2f center, Vector2f size) :
base(sfView_Create())
{
this.Center = center;
@ -65,9 +66,9 @@ namespace SFML
/// Center of the view
/// </summary>
////////////////////////////////////////////////////////////
public Vector2 Center
public Vector2f Center
{
get {return new Vector2(sfView_GetCenterX(This), sfView_GetCenterY(This));}
get {return new Vector2f(sfView_GetCenterX(This), sfView_GetCenterY(This));}
set {sfView_SetCenter(This, value.X, value.Y);}
}
@ -76,9 +77,9 @@ namespace SFML
/// Half-size of the view
/// </summary>
////////////////////////////////////////////////////////////
public Vector2 Size
public Vector2f Size
{
get {return new Vector2(sfView_GetWidth(This), sfView_GetHeight(This));}
get {return new Vector2f(sfView_GetWidth(This), sfView_GetHeight(This));}
set {sfView_SetSize(This, value.X, value.Y);}
}
@ -122,7 +123,7 @@ namespace SFML
/// </summary>
/// <param name="offset">Offset to move the view</param>
////////////////////////////////////////////////////////////
public void Move(Vector2 offset)
public void Move(Vector2f offset)
{
sfView_Move(This, offset.X, offset.Y);
}

View File

@ -80,7 +80,6 @@
<Compile Include="Shape.cs" />
<Compile Include="Sprite.cs" />
<Compile Include="Text.cs" />
<Compile Include="Vector2.cs" />
<Compile Include="View.cs" />
</ItemGroup>
<ItemGroup>

View File

@ -5,168 +5,6 @@ namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Definition of key codes for keyboard events
/// </summary>
////////////////////////////////////////////////////////////
public enum KeyCode
{
A = 'a',
B = 'b',
C = 'c',
D = 'd',
E = 'e',
F = 'f',
G = 'g',
H = 'h',
I = 'i',
J = 'j',
K = 'k',
L = 'l',
M = 'm',
N = 'n',
O = 'o',
P = 'p',
Q = 'q',
R = 'r',
S = 's',
T = 't',
U = 'u',
V = 'v',
W = 'w',
X = 'x',
Y = 'y',
Z = 'z',
Num0 = '0',
Num1 = '1',
Num2 = '2',
Num3 = '3',
Num4 = '4',
Num5 = '5',
Num6 = '6',
Num7 = '7',
Num8 = '8',
Num9 = '9',
Escape = 256,
LControl,
LShift,
LAlt,
LSystem, // OS specific key (left side) : windows (Win and Linux), apple (MacOS), ...
RControl,
RShift,
RAlt,
RSystem, // OS specific key (right side) : windows (Win and Linux), apple (MacOS), ...
Menu,
LBracket, // [
RBracket, // ]
SemiColon, // ;
Comma, // ,
Period, // .
Quote, // '
Slash, // /
BackSlash,
Tilde, // ~
Equal, // =
Dash, // -
Space,
Return,
Back,
Tab,
PageUp,
PageDown,
End,
Home,
Insert,
Delete,
Add, // +
Subtract, // -
Multiply, // *
Divide, // /
Left, // Left arrow
Right, // Right arrow
Up, // Up arrow
Down, // Down arrow
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
Pause
}
////////////////////////////////////////////////////////////
/// <summary>
/// Definition of button codes for mouse events
/// </summary>
////////////////////////////////////////////////////////////
public enum MouseButton
{
/// <summary>Left mouse button</summary>
Left,
/// <summary>Right mouse button</summary>
Right,
/// <summary>Center (wheel) mouse button</summary>
Middle,
/// <summary>First extra button</summary>
XButton1,
/// <summary>Second extra button</summary>
XButton2
}
////////////////////////////////////////////////////////////
/// <summary>
/// Definition of joystick axis for joystick events
/// </summary>
////////////////////////////////////////////////////////////
public enum JoyAxis
{
/// <summary>X axis</summary>
AxisX,
/// <summary>Y axis</summary>
AxisY,
/// <summary>Z axis</summary>
AxisZ,
/// <summary>R axis</summary>
AxisR,
/// <summary>U axis</summary>
AxisU,
/// <summary>V axis</summary>
AxisV,
/// <summary>Point of view</summary>
AxisPOV
}
////////////////////////////////////////////////////////////
/// <summary>
/// Enumeration of the different types of events
@ -214,13 +52,19 @@ namespace SFML
MouseLeft,
/// <summary>Event triggered when a joystick button is pressed</summary>
JoyButtonPressed,
JoystickButtonPressed,
/// <summary>Event triggered when a joystick button is released</summary>
JoyButtonReleased,
JoystickButtonReleased,
/// <summary>Event triggered when a joystick axis moves</summary>
JoyMoved
JoystickMoved,
/// <summary>Event triggered when a joystick is connected</summary>
JoystickConnected,
/// <summary>Event triggered when a joystick is disconnected</summary>
JoystickDisconnected
}
////////////////////////////////////////////////////////////
@ -232,7 +76,7 @@ namespace SFML
public struct KeyEvent
{
/// <summary>Code of the key (see KeyCode enum)</summary>
public KeyCode Code;
public Keyboard.Key Code;
/// <summary>Is the Alt modifier pressed?</summary>
public int Alt;
@ -283,7 +127,7 @@ namespace SFML
public struct MouseButtonEvent
{
/// <summary>Code of the button (see MouseButton enum)</summary>
public MouseButton Button;
public Mouse.Button Button;
/// <summary>X coordinate of the mouse cursor</summary>
public int X;
@ -316,13 +160,13 @@ namespace SFML
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct JoyMoveEvent
public struct JoystickMoveEvent
{
/// <summary>Index of the joystick which triggered the event</summary>
public uint JoystickId;
/// <summary>Joystick axis (see JoyAxis enum)</summary>
public JoyAxis Axis;
public Joystick.Axis Axis;
/// <summary>Current position of the axis</summary>
public float Position;
@ -334,7 +178,7 @@ namespace SFML
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct JoyButtonEvent
public struct JoystickButtonEvent
{
/// <summary>Index of the joystick which triggered the event</summary>
public uint JoystickId;
@ -343,6 +187,18 @@ namespace SFML
public uint Button;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Joystick connect event parameters
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct JoystickConnectEvent
{
/// <summary>Index of the joystick which triggered the event</summary>
public uint JoystickId;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Size event parameters
@ -370,6 +226,10 @@ namespace SFML
[FieldOffset(0)]
public EventType Type;
/// <summary>Arguments for size events (Resized)</summary>
[FieldOffset(4)]
public SizeEvent Size;
/// <summary>Arguments for key events (KeyPressed, KeyReleased)</summary>
[FieldOffset(4)]
public KeyEvent Key;
@ -390,17 +250,17 @@ namespace SFML
[FieldOffset(4)]
public MouseWheelEvent MouseWheel;
/// <summary>Arguments for joystick axis events (JoyMoved)</summary>
/// <summary>Arguments for joystick axis events (JoystickMoved)</summary>
[FieldOffset(4)]
public JoyMoveEvent JoyMove;
public JoystickMoveEvent JoystickMove;
/// <summary>Arguments for joystick button events (JoyButtonPressed, JoyButtonReleased)</summary>
/// <summary>Arguments for joystick button events (JoystickButtonPressed, JoystickButtonReleased)</summary>
[FieldOffset(4)]
public JoyButtonEvent JoyButton;
public JoystickButtonEvent JoystickButton;
/// <summary>Arguments for size events (Resized)</summary>
/// <summary>Arguments for joystick connect events (JoystickConnected, JoystickDisconnected)</summary>
[FieldOffset(4)]
public SizeEvent Size;
public JoystickConnectEvent JoystickConnect;
}
}
}

View File

@ -43,7 +43,7 @@ namespace SFML
}
/// <summary>Code of the key (see KeyCode enum)</summary>
public KeyCode Code;
public Keyboard.Key Code;
/// <summary>Is the Alt modifier pressed?</summary>
public bool Alt;
@ -166,7 +166,7 @@ namespace SFML
}
/// <summary>Code of the button (see MouseButton enum)</summary>
public MouseButton Button;
public Mouse.Button Button;
/// <summary>X coordinate of the mouse cursor</summary>
public int X;
@ -224,7 +224,7 @@ namespace SFML
/// Joystick axis move event parameters
/// </summary>
////////////////////////////////////////////////////////////
public class JoyMoveEventArgs : EventArgs
public class JoystickMoveEventArgs : EventArgs
{
////////////////////////////////////////////////////////////
/// <summary>
@ -232,7 +232,7 @@ namespace SFML
/// </summary>
/// <param name="e">Joystick move event</param>
////////////////////////////////////////////////////////////
public JoyMoveEventArgs(JoyMoveEvent e)
public JoystickMoveEventArgs(JoystickMoveEvent e)
{
JoystickId = e.JoystickId;
Axis = e.Axis;
@ -247,7 +247,7 @@ namespace SFML
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[JoyMoveEventArgs]" +
return "[JoystickMoveEventArgs]" +
" JoystickId(" + JoystickId + ")" +
" Axis(" + Axis + ")" +
" Position(" + Position + ")";
@ -257,7 +257,7 @@ namespace SFML
public uint JoystickId;
/// <summary>Joystick axis (see JoyAxis enum)</summary>
public JoyAxis Axis;
public Joystick.Axis Axis;
/// <summary>Current position of the axis</summary>
public float Position;
@ -268,7 +268,7 @@ namespace SFML
/// Joystick buttons event parameters
/// </summary>
////////////////////////////////////////////////////////////
public class JoyButtonEventArgs : EventArgs
public class JoystickButtonEventArgs : EventArgs
{
////////////////////////////////////////////////////////////
/// <summary>
@ -276,7 +276,7 @@ namespace SFML
/// </summary>
/// <param name="e">Joystick button event</param>
////////////////////////////////////////////////////////////
public JoyButtonEventArgs(JoyButtonEvent e)
public JoystickButtonEventArgs(JoystickButtonEvent e)
{
JoystickId = e.JoystickId;
Button = e.Button;
@ -290,7 +290,7 @@ namespace SFML
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[JoyButtonEventArgs]" +
return "[JoystickButtonEventArgs]" +
" JoystickId(" + JoystickId + ")" +
" Button(" + Button + ")";
}
@ -302,6 +302,40 @@ namespace SFML
public uint Button;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Joystick connection/disconnection event parameters
/// </summary>
////////////////////////////////////////////////////////////
public class JoystickConnectEventArgs : EventArgs
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the joystick connect arguments from a joystick connect event
/// </summary>
/// <param name="e">Joystick button event</param>
////////////////////////////////////////////////////////////
public JoystickConnectEventArgs(JoystickConnectEvent e)
{
JoystickId = e.JoystickId;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[JoystickConnectEventArgs]" +
" JoystickId(" + JoystickId + ")";
}
/// <summary>Index of the joystick which triggered the event</summary>
public uint JoystickId;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Size event parameters

View File

@ -1,144 +0,0 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Input handles real-time input from keyboard and mouse.
/// Use it instead of events to handle continuous moves and more
/// game-friendly inputs
/// </summary>
////////////////////////////////////////////////////////////
public class Input : ObjectBase
{
////////////////////////////////////////////////////////////
/// <summary>
/// Get the state of a key
/// </summary>
/// <param name="key">Key to check</param>
/// <returns>True if key is down, false if key is up</returns>
////////////////////////////////////////////////////////////
public bool IsKeyDown(KeyCode key)
{
return sfInput_IsKeyDown(This, key);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the state of a mouse button
/// </summary>
/// <param name="button">Button to check</param>
/// <returns>True if button is down, false if button is up</returns>
////////////////////////////////////////////////////////////
public bool IsMouseButtonDown(MouseButton button)
{
return sfInput_IsMouseButtonDown(This, button);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the state of a joystick button
/// </summary>
/// <param name="joystickId">Identifier of the joystick to check (0 or 1)</param>
/// <param name="button">Button to check</param>
/// <returns>True if button is down, false if button is up</returns>
////////////////////////////////////////////////////////////
public bool IsJoystickButtonDown(uint joystickId, uint button)
{
return sfInput_IsJoystickButtonDown(This, joystickId, button);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the mouse X position
/// </summary>
/// <returns>Current mouse left position, relative to owner window</returns>
////////////////////////////////////////////////////////////
public int GetMouseX()
{
return sfInput_GetMouseX(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the mouse Y position
/// </summary>
/// <returns>Current mouse top position, relative to owner window</returns>
////////////////////////////////////////////////////////////
public int GetMouseY()
{
return sfInput_GetMouseY(This);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get a joystick axis position
/// </summary>
/// <param name="joystickId">Identifier of the joystick to check (0 or 1)</param>
/// <param name="axis">Axis to get</param>
/// <returns>Current axis position, in the range [-100, 100] (except for POV, which is [0, 360])</returns>
////////////////////////////////////////////////////////////
public float GetJoystickAxis(uint joystickId, JoyAxis axis)
{
return sfInput_GetJoystickAxis(This, joystickId, axis);
}
////////////////////////////////////////////////////////////
/// <summary>
/// For internal use only, construct the instance from a direct pointer to the internal object
/// </summary>
/// <param name="thisPtr">Internal pointer to the input object</param>
////////////////////////////////////////////////////////////
public Input(IntPtr thisPtr) :
base(thisPtr)
{
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Input]";
}
////////////////////////////////////////////////////////////
/// <summary>
/// Handle the destruction of the object
/// </summary>
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
////////////////////////////////////////////////////////////
protected override void Destroy(bool disposing)
{
// Nothing to do here, Input instances are owned by the C library
}
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfInput_IsKeyDown(IntPtr This, KeyCode Key);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfInput_IsMouseButtonDown(IntPtr This, MouseButton Button);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfInput_IsJoystickButtonDown(IntPtr This, uint JoyId, uint Button);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern int sfInput_GetMouseX(IntPtr This);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern int sfInput_GetMouseY(IntPtr This);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfInput_GetJoystickAxis(IntPtr This, uint JoyId, JoyAxis Axis);
#endregion
}
}
}

View File

@ -0,0 +1,159 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Give access to the real-time state of the joysticks
/// </summary>
////////////////////////////////////////////////////////////
public class Joystick
{
/// <summary>Maximum number of supported joysticks</summary>
public static readonly uint Count = 8;
/// <summary>Maximum number of supported buttons</summary>
public static readonly uint ButtonCount = 32;
/// <summary>Maximum number of supported axes</summary>
public static readonly uint AxisCount = 8;
////////////////////////////////////////////////////////////
/// <summary>
/// Axes supported by SFML joysticks
/// </summary>
////////////////////////////////////////////////////////////
public enum Axis
{
/// <summary>The X axis</summary>
X,
/// <summary>The Y axis</summary>
Y,
/// <summary>The Z axis</summary>
Z,
/// <summary>The R axis</summary>
R,
/// <summary>The U axis</summary>
U,
/// <summary>The V axis</summary>
V,
/// <summary>The X axis of the point-of-view hat</summary>
PovX,
/// <summary>TheY axis of the point-of-view hat</summary>
PovY
};
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a joystick is connected
/// </summary>
/// <param name="joystick">Index of the joystick to check</param>
/// <returns>True if the joystick is connected, false otherwise</returns>
////////////////////////////////////////////////////////////
public static bool IsConnected(uint joystick)
{
return sfJoystick_IsConnected(joystick);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Return the number of buttons supported by a joystick
/// </summary>
/// If the joystick is not connected, this function returns 0.
/// <param name="joystick">Index of the joystick</param>
/// <returns>Number of buttons supported by the joystick</returns>
////////////////////////////////////////////////////////////
public static uint GetButtonCount(uint joystick)
{
return sfJoystick_GetButtonCount(joystick);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a joystick supports a given axis
/// </summary>
/// If the joystick is not connected, this function returns false.
/// <param name="joystick">Index of the joystick</param>
/// <param name="axis">Axis to check</param>
/// <returns>True if the joystick supports the axis, false otherwise</returns>
////////////////////////////////////////////////////////////
public static bool HasAxis(uint joystick, Axis axis)
{
return sfJoystick_HasAxis(joystick, axis);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a joystick button is pressed
/// </summary>
/// If the joystick is not connected, this function returns false.
/// <param name="joystick">Index of the joystick</param>
/// <param name="button">Button to check</param>
/// <returns>True if the button is pressed, false otherwise</returns>
////////////////////////////////////////////////////////////
public static bool IsButtonPressed(uint joystick, uint button)
{
return sfJoystick_IsButtonPressed(joystick, button);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the current position of a joystick axis
/// </summary>
/// If the joystick is not connected, this function returns 0.
/// <param name="joystick">Index of the joystick</param>
/// <param name="axis">Axis to check</param>
/// <returns>Current position of the axis, in range [-100 .. 100]</returns>
////////////////////////////////////////////////////////////
public static float GetAxisPosition(uint joystick, Axis axis)
{
return sfJoystick_GetAxisPosition(joystick, axis);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Update the states of all joysticks
/// </summary>
/// 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.
////////////////////////////////////////////////////////////
public static void Update()
{
sfJoystick_Update();
}
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfJoystick_IsConnected(uint joystick);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern uint sfJoystick_GetButtonCount(uint joystick);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfJoystick_HasAxis(uint joystick, Axis axis);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfJoystick_IsButtonPressed(uint joystick, uint button);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern float sfJoystick_GetAxisPosition(uint joystick, Axis axis);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfJoystick_Update();
#endregion
}
}
}

View File

@ -0,0 +1,146 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Give access to the real-time state of the keyboard
/// </summary>
////////////////////////////////////////////////////////////
public class Keyboard
{
////////////////////////////////////////////////////////////
/// <summary>
/// Key codes
/// </summary>
////////////////////////////////////////////////////////////
public enum Key
{
A, // The A key
B, // The B key
C, // The C key
D, // The D key
E, // The E key
F, // The F key
G, // The G key
H, // The H key
I, // The I key
J, // The J key
K, // The K key
L, // The L key
M, // The M key
N, // The N key
O, // The O key
P, // The P key
Q, // The Q key
R, // The R key
S, // The S key
T, // The T key
U, // The U key
V, // The V key
W, // The W key
X, // The X key
Y, // The Y key
Z, // The Z key
Num0, // The 0 key
Num1, // The 1 key
Num2, // The 2 key
Num3, // The 3 key
Num4, // The 4 key
Num5, // The 5 key
Num6, // The 6 key
Num7, // The 7 key
Num8, // The 8 key
Num9, // The 9 key
Escape, // The Escape key
LControl, // The left Control key
LShift, // The left Shift key
LAlt, // The left Alt key
LSystem, // The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
RControl, // The right Control key
RShift, // The right Shift key
RAlt, // The right Alt key
RSystem, // The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
Menu, // The Menu key
LBracket, // The [ key
RBracket, // The ] key
SemiColon, // The ; key
Comma, // The , key
Period, // The . key
Quote, // The ' key
Slash, // The / key
BackSlash, // The \ key
Tilde, // The ~ key
Equal, // The = key
Dash, // The - key
Space, // The Space key
Return, // The Return key
Back, // The Backspace key
Tab, // The Tabulation key
PageUp, // The Page up key
PageDown, // The Page down key
End, // The End key
Home, // The Home key
Insert, // The Insert key
Delete, // The Delete key
Add, // +
Subtract, // -
Multiply, // *
Divide, // /
Left, // Left arrow
Right, // Right arrow
Up, // Up arrow
Down, // Down arrow
Numpad0, // The numpad 0 key
Numpad1, // The numpad 1 key
Numpad2, // The numpad 2 key
Numpad3, // The numpad 3 key
Numpad4, // The numpad 4 key
Numpad5, // The numpad 5 key
Numpad6, // The numpad 6 key
Numpad7, // The numpad 7 key
Numpad8, // The numpad 8 key
Numpad9, // The numpad 9 key
F1, // The F1 key
F2, // The F2 key
F3, // The F3 key
F4, // The F4 key
F5, // The F5 key
F6, // The F6 key
F7, // The F7 key
F8, // The F8 key
F9, // The F8 key
F10, // The F10 key
F11, // The F11 key
F12, // The F12 key
F13, // The F13 key
F14, // The F14 key
F15, // The F15 key
Pause, // The Pause key
KeyCount // Keep last -- the total number of keyboard keys
};
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a key is pressed
/// </summary>
/// <param name="key">Key to check</param>
/// <returns>True if the key is pressed, false otherwise</returns>
////////////////////////////////////////////////////////////
public static bool IsKeyDown(Key key)
{
return sfKeyboard_IsKeyDown(key);
}
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfKeyboard_IsKeyDown(Key Key);
#endregion
}
}
}

View File

@ -0,0 +1,81 @@
using System;
using System.Runtime.InteropServices;
using System.Security;
namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Give access to the real-time state of the mouse
/// </summary>
////////////////////////////////////////////////////////////
public class Mouse
{
////////////////////////////////////////////////////////////
/// <summary>
/// Mouse buttons
/// </summary>
////////////////////////////////////////////////////////////
public enum Button
{
/// <summary>The left mouse button</summary>
Left,
/// <summary>The right mouse button</summary>
Right,
/// <summary>The middle (wheel) mouse button</summary>
Middle,
/// <summary>The first extra mouse button</summary>
XButton1,
/// <summary>The second extra mouse button</summary>
XButton2,
/// <summary>Keep last -- the total number of mouse buttons</summary>
ButtonCount
};
////////////////////////////////////////////////////////////
/// <summary>
/// Check if a mouse button is pressed
/// </summary>
/// <param name="button">Button to check</param>
/// <returns>True if the button is pressed, false otherwise</returns>
////////////////////////////////////////////////////////////
public static bool IsButtonPressed(Button button)
{
return sfMouse_IsButtonPressed(button);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the current position of the mouse
/// </summary>
/// 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.
/// <returns>Current position of the mouse</returns>
////////////////////////////////////////////////////////////
public static Vector2i GetPosition()
{
Vector2i position;
sfMouse_GetPosition(out position.X, out position.Y);
return position;
}
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfMouse_IsButtonPressed(Button button);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfMouse_GetPosition(out int x, out int y);
#endregion
}
}
}

View File

@ -0,0 +1,246 @@
using System;
using System.Runtime.InteropServices;
namespace SFML
{
namespace Window
{
////////////////////////////////////////////////////////////
/// <summary>
/// Vector2f is an utility class for manipulating 2 dimensional
/// vectors with float components
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Vector2f
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the vector from its coordinates
/// </summary>
/// <param name="x">X coordinate</param>
/// <param name="y">Y coordinate</param>
////////////////////////////////////////////////////////////
public Vector2f(float x, float y)
{
X = x;
Y = y;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; returns the opposite of a vector
/// </summary>
/// <param name="v">Vector to negate</param>
/// <returns>-v</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator -(Vector2f v)
{
return new Vector2f(-v.X, -v.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; subtracts two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 - v2</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator -(Vector2f v1, Vector2f v2)
{
return new Vector2f(v1.X - v2.X, v1.Y - v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator + overload ; add two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 + v2</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator +(Vector2f v1, Vector2f v2)
{
return new Vector2f(v1.X + v2.X, v1.Y + v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v * x</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator *(Vector2f v, float x)
{
return new Vector2f(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a scalar value by a vector
/// </summary>
/// <param name="x">Scalar value</param>
/// <param name="v">Vector</param>
/// <returns>x * v</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator *(float x, Vector2f v)
{
return new Vector2f(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator / overload ; divide a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v / x</returns>
////////////////////////////////////////////////////////////
public static Vector2f operator /(Vector2f v, float x)
{
return new Vector2f(v.X / x, v.Y / x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Vector2f]" +
" X(" + X + ")" +
" Y(" + Y + ")";
}
/// <summary>X (horizontal) component of the vector</summary>
public float X;
/// <summary>Y (vertical) component of the vector</summary>
public float Y;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Vector2i is an utility class for manipulating 2 dimensional
/// vectors with integer components
/// </summary>
////////////////////////////////////////////////////////////
[StructLayout(LayoutKind.Sequential)]
public struct Vector2i
{
////////////////////////////////////////////////////////////
/// <summary>
/// Construct the vector from its coordinates
/// </summary>
/// <param name="x">X coordinate</param>
/// <param name="y">Y coordinate</param>
////////////////////////////////////////////////////////////
public Vector2i(int x, int y)
{
X = x;
Y = y;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; returns the opposite of a vector
/// </summary>
/// <param name="v">Vector to negate</param>
/// <returns>-v</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator -(Vector2i v)
{
return new Vector2i(-v.X, -v.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator - overload ; subtracts two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 - v2</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator -(Vector2i v1, Vector2i v2)
{
return new Vector2i(v1.X - v2.X, v1.Y - v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator + overload ; add two vectors
/// </summary>
/// <param name="v1">First vector</param>
/// <param name="v2">Second vector</param>
/// <returns>v1 + v2</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator +(Vector2i v1, Vector2i v2)
{
return new Vector2i(v1.X + v2.X, v1.Y + v2.Y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v * x</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator *(Vector2i v, int x)
{
return new Vector2i(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator * overload ; multiply a scalar value by a vector
/// </summary>
/// <param name="x">Scalar value</param>
/// <param name="v">Vector</param>
/// <returns>x * v</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator *(int x, Vector2i v)
{
return new Vector2i(v.X * x, v.Y * x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Operator / overload ; divide a vector by a scalar value
/// </summary>
/// <param name="v">Vector</param>
/// <param name="x">Scalar value</param>
/// <returns>v / x</returns>
////////////////////////////////////////////////////////////
public static Vector2i operator /(Vector2i v, int x)
{
return new Vector2i(v.X / x, v.Y / x);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Provide a string describing the object
/// </summary>
/// <returns>String description of the object</returns>
////////////////////////////////////////////////////////////
public override string ToString()
{
return "[Vector2i]" +
" X(" + X + ")" +
" Y(" + Y + ")";
}
/// <summary>X (horizontal) component of the vector</summary>
public int X;
/// <summary>Y (vertical) component of the vector</summary>
public int Y;
}
}
}

View File

@ -79,7 +79,6 @@ namespace SFML
public Window(VideoMode mode, string title, Styles style, ContextSettings settings) :
base(sfWindow_Create(mode, title, style, ref settings))
{
myInput = new Input(sfWindow_GetInput(This));
}
////////////////////////////////////////////////////////////
@ -103,17 +102,6 @@ namespace SFML
public Window(IntPtr Handle, ContextSettings settings) :
base(sfWindow_CreateFromHandle(Handle, ref settings))
{
myInput = new Input(sfWindow_GetInput(This));
}
////////////////////////////////////////////////////////////
/// <summary>
/// Input manager of the window
/// </summary>
////////////////////////////////////////////////////////////
public Input Input
{
get {return myInput;}
}
////////////////////////////////////////////////////////////
@ -215,6 +203,19 @@ namespace SFML
sfWindow_SetCursorPosition(This, x, y);
}
////////////////////////////////////////////////////////////
/// <summary>
/// Get the position of the mouse cursor
/// </summary>
/// <returns>The current position of the mouse cursor, relative to the window</returns>
////////////////////////////////////////////////////////////
public virtual Vector2i GetCursorPosition()
{
Vector2i position;
sfWindow_GetCursorPosition(This, out position.X, out position.Y);
return position;
}
////////////////////////////////////////////////////////////
/// <summary>
/// Change the position of the window on screen.
@ -469,19 +470,29 @@ namespace SFML
GainedFocus(this, EventArgs.Empty);
break;
case EventType.JoyButtonPressed :
if (JoyButtonPressed != null)
JoyButtonPressed(this, new JoyButtonEventArgs(e.JoyButton));
case EventType.JoystickButtonPressed:
if (JoystickButtonPressed != null)
JoystickButtonPressed(this, new JoystickButtonEventArgs(e.JoystickButton));
break;
case EventType.JoyButtonReleased :
if (JoyButtonReleased != null)
JoyButtonReleased(this, new JoyButtonEventArgs(e.JoyButton));
case EventType.JoystickButtonReleased :
if (JoystickButtonReleased != null)
JoystickButtonReleased(this, new JoystickButtonEventArgs(e.JoystickButton));
break;
case EventType.JoyMoved :
if (JoyMoved != null)
JoyMoved(this, new JoyMoveEventArgs(e.JoyMove));
case EventType.JoystickMoved :
if (JoystickMoved != null)
JoystickMoved(this, new JoystickMoveEventArgs(e.JoystickMove));
break;
case EventType.JoystickConnected:
if (JoystickConnected != null)
JoystickConnected(this, new JoystickConnectEventArgs(e.JoystickConnect));
break;
case EventType.JoystickDisconnected:
if (JoystickDisconnected != null)
JoystickDisconnected(this, new JoystickConnectEventArgs(e.JoystickConnect));
break;
case EventType.KeyPressed :
@ -580,16 +591,20 @@ namespace SFML
/// <summary>Event handler for the MouseLeft event</summary>
public event EventHandler MouseLeft = null;
/// <summary>Event handler for the JoyButtonPressed event</summary>
public event EventHandler<JoyButtonEventArgs> JoyButtonPressed = null;
/// <summary>Event handler for the JoystickButtonPressed event</summary>
public event EventHandler<JoystickButtonEventArgs> JoystickButtonPressed = null;
/// <summary>Event handler for the JoyButtonReleased event</summary>
public event EventHandler<JoyButtonEventArgs> JoyButtonReleased = null;
/// <summary>Event handler for the JoystickButtonReleased event</summary>
public event EventHandler<JoystickButtonEventArgs> JoystickButtonReleased = null;
/// <summary>Event handler for the JoyMoved event</summary>
public event EventHandler<JoyMoveEventArgs> JoyMoved = null;
/// <summary>Event handler for the JoystickMoved event</summary>
public event EventHandler<JoystickMoveEventArgs> JoystickMoved = null;
protected Input myInput = null;
/// <summary>Event handler for the JoystickConnected event</summary>
public event EventHandler<JoystickConnectEventArgs> JoystickConnected = null;
/// <summary>Event handler for the JoystickDisconnected event</summary>
public event EventHandler<JoystickConnectEventArgs> JoystickDisconnected = null;
#region Imports
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
@ -601,9 +616,6 @@ namespace SFML
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfWindow_Destroy(IntPtr This);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern IntPtr sfWindow_GetInput(IntPtr This);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern bool sfWindow_IsOpened(IntPtr This);
@ -637,6 +649,9 @@ namespace SFML
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfWindow_SetCursorPosition(IntPtr This, uint X, uint Y);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfWindow_GetCursorPosition(IntPtr This, out int X, out int Y);
[DllImport("csfml-window-2", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
static extern void sfWindow_SetPosition(IntPtr This, int X, int Y);

View File

@ -70,9 +70,12 @@
<Compile Include="ContextSettings.cs" />
<Compile Include="Event.cs" />
<Compile Include="EventArgs.cs" />
<Compile Include="Input.cs" />
<Compile Include="Joystick.cs" />
<Compile Include="Keyboard.cs" />
<Compile Include="LoadingFailedException.cs" />
<Compile Include="Mouse.cs" />
<Compile Include="ObjectBase.cs" />
<Compile Include="Vector2.cs" />
<Compile Include="VideoMode.cs" />
<Compile Include="Window.cs" />
</ItemGroup>

View File

@ -114,7 +114,7 @@ public :
/// \return True if the button is pressed, false otherwise
///
////////////////////////////////////////////////////////////
static bool IsButtonPressed(unsigned int joystick, int button);
static bool IsButtonPressed(unsigned int joystick, unsigned int button);
////////////////////////////////////////////////////////////
/// \brief Get the current position of a joystick axis

View File

@ -53,7 +53,7 @@ bool Joystick::HasAxis(unsigned int joystick, Axis axis)
////////////////////////////////////////////////////////////
bool Joystick::IsButtonPressed(unsigned int joystick, int button)
bool Joystick::IsButtonPressed(unsigned int joystick, unsigned int button)
{
return priv::JoystickManager::GetInstance().GetState(joystick).Buttons[button];
}