diff --git a/bindings/c/include/SFML/Graphics/RenderWindow.h b/bindings/c/include/SFML/Graphics/RenderWindow.h index 775fa5a6c..489a62793 100644 --- a/bindings/c/include/SFML/Graphics/RenderWindow.h +++ b/bindings/c/include/SFML/Graphics/RenderWindow.h @@ -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 /// diff --git a/bindings/c/include/SFML/Window.h b/bindings/c/include/SFML/Window.h index 0dc211bf5..5b002c78f 100644 --- a/bindings/c/include/SFML/Window.h +++ b/bindings/c/include/SFML/Window.h @@ -32,7 +32,9 @@ #include #include #include -#include +#include +#include +#include #include #include diff --git a/bindings/c/include/SFML/Window/Event.h b/bindings/c/include/SFML/Window/Event.h index 9782e2b7f..279b67cc0 100644 --- a/bindings/c/include/SFML/Window/Event.h +++ b/bindings/c/include/SFML/Window/Event.h @@ -28,145 +28,9 @@ // Headers //////////////////////////////////////////////////////////// #include - - -//////////////////////////////////////////////////////////// -/// 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 +#include +#include //////////////////////////////////////////////////////////// @@ -187,9 +51,11 @@ typedef enum sfEvtMouseMoved, sfEvtMouseEntered, sfEvtMouseLeft, - sfEvtJoyButtonPressed, - sfEvtJoyButtonReleased, - sfEvtJoyMoved + sfEvtJoystickButtonPressed, + sfEvtJoystickButtonReleased, + sfEvtJoystickMoved, + sfEvtJoystickConnected, + sfEvtJoystickDisconnected } sfEventType; @@ -250,24 +116,33 @@ struct sfMouseWheelEvent //////////////////////////////////////////////////////////// /// Joystick axis move event parameters //////////////////////////////////////////////////////////// -struct sfJoyMoveEvent +struct sfJoystickMoveEvent { - sfEventType Type; - unsigned int JoystickId; - sfJoyAxis Axis; - float Position; + sfEventType Type; + unsigned int JoystickId; + sfJoystickAxis Axis; + float Position; }; //////////////////////////////////////////////////////////// /// Joystick buttons events parameters //////////////////////////////////////////////////////////// -struct sfJoyButtonEvent +struct sfJoystickButtonEvent { sfEventType Type; unsigned int JoystickId; unsigned int Button; }; +//////////////////////////////////////////////////////////// +/// Joystick connection/disconnection event parameters +//////////////////////////////////////////////////////////// +struct sfJoystickConnectEvent +{ + sfEventType Type; + unsigned int JoystickId; +}; + //////////////////////////////////////////////////////////// /// Size events parameters //////////////////////////////////////////////////////////// @@ -287,15 +162,16 @@ typedef union //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - sfEventType Type; ///< Type of the event - struct sfKeyEvent Key; - struct sfTextEvent Text; - struct sfMouseMoveEvent MouseMove; - struct sfMouseButtonEvent MouseButton; - struct sfMouseWheelEvent MouseWheel; - struct sfJoyMoveEvent JoyMove; - struct sfJoyButtonEvent JoyButton; - struct sfSizeEvent Size; + sfEventType Type; ///< Type of the event + struct sfSizeEvent Size; + struct sfKeyEvent Key; + struct sfTextEvent Text; + struct sfMouseMoveEvent MouseMove; + struct sfMouseButtonEvent MouseButton; + struct sfMouseWheelEvent MouseWheel; + struct sfJoystickMoveEvent JoystickMove; + struct sfJoystickButtonEvent JoystickButton; + struct sfJoystickConnectEvent JoystickConnect; } sfEvent; diff --git a/bindings/c/include/SFML/Window/Joystick.h b/bindings/c/include/SFML/Window/Joystick.h new file mode 100644 index 000000000..197a6a2b4 --- /dev/null +++ b/bindings/c/include/SFML/Window/Joystick.h @@ -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 + + +//////////////////////////////////////////////////////////// +/// \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 diff --git a/bindings/c/include/SFML/Window/Keyboard.h b/bindings/c/include/SFML/Window/Keyboard.h new file mode 100644 index 000000000..1901a236f --- /dev/null +++ b/bindings/c/include/SFML/Window/Keyboard.h @@ -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 + + +//////////////////////////////////////////////////////////// +/// \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 diff --git a/bindings/c/include/SFML/Window/Mouse.h b/bindings/c/include/SFML/Window/Mouse.h new file mode 100644 index 000000000..3fb895efd --- /dev/null +++ b/bindings/c/include/SFML/Window/Mouse.h @@ -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 + + +//////////////////////////////////////////////////////////// +/// \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 diff --git a/bindings/c/include/SFML/Window/Types.h b/bindings/c/include/SFML/Window/Types.h index f91fdabcd..65a488d95 100644 --- a/bindings/c/include/SFML/Window/Types.h +++ b/bindings/c/include/SFML/Window/Types.h @@ -27,7 +27,6 @@ typedef struct sfContext sfContext; -typedef struct sfInput sfInput; typedef struct sfWindow sfWindow; diff --git a/bindings/c/include/SFML/Window/Window.h b/bindings/c/include/SFML/Window/Window.h index a3754eabf..dbf3e6364 100644 --- a/bindings/c/include/SFML/Window/Window.h +++ b/bindings/c/include/SFML/Window/Window.h @@ -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 /// diff --git a/bindings/c/src/SFML/ConvertEvent.h b/bindings/c/src/SFML/ConvertEvent.h index 18b5e6d95..a248b3771 100644 --- a/bindings/c/src/SFML/ConvertEvent.h +++ b/bindings/c/src/SFML/ConvertEvent.h @@ -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(SFMLEvent.JoyMove.Axis); - event->JoyMove.Position = SFMLEvent.JoyMove.Position; + case sfEvtJoystickMoved : + event->JoystickMove.JoystickId = SFMLEvent.JoystickMove.JoystickId; + event->JoystickMove.Axis = static_cast(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 : diff --git a/bindings/c/src/SFML/Graphics/RenderImageStruct.h b/bindings/c/src/SFML/Graphics/RenderImageStruct.h index 97bffe48c..452c52122 100644 --- a/bindings/c/src/SFML/Graphics/RenderImageStruct.h +++ b/bindings/c/src/SFML/Graphics/RenderImageStruct.h @@ -31,7 +31,6 @@ #include #include #include -#include //////////////////////////////////////////////////////////// diff --git a/bindings/c/src/SFML/Graphics/RenderWindow.cpp b/bindings/c/src/SFML/Graphics/RenderWindow.cpp index e76a0cc0a..6c266ee32 100644 --- a/bindings/c/src/SFML/Graphics/RenderWindow.cpp +++ b/bindings/c/src/SFML/Graphics/RenderWindow.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/bindings/c/src/SFML/Graphics/RenderWindowStruct.h b/bindings/c/src/SFML/Graphics/RenderWindowStruct.h index 0610fcd22..2498b2344 100644 --- a/bindings/c/src/SFML/Graphics/RenderWindowStruct.h +++ b/bindings/c/src/SFML/Graphics/RenderWindowStruct.h @@ -30,7 +30,6 @@ //////////////////////////////////////////////////////////// #include #include -#include //////////////////////////////////////////////////////////// @@ -39,7 +38,6 @@ struct sfRenderWindow { sf::RenderWindow This; - sfInput Input; sfView DefaultView; sfView CurrentView; }; diff --git a/bindings/c/src/SFML/Window/CMakeLists.txt b/bindings/c/src/SFML/Window/CMakeLists.txt index 87cd539ab..1e8595ec6 100644 --- a/bindings/c/src/SFML/Window/CMakeLists.txt +++ b/bindings/c/src/SFML/Window/CMakeLists.txt @@ -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 diff --git a/bindings/c/src/SFML/Window/Input.cpp b/bindings/c/src/SFML/Window/Joystick.cpp similarity index 62% rename from bindings/c/src/SFML/Window/Input.cpp rename to bindings/c/src/SFML/Window/Joystick.cpp index 0d5099bc5..cc60c4c4a 100644 --- a/bindings/c/src/SFML/Window/Input.cpp +++ b/bindings/c/src/SFML/Window/Joystick.cpp @@ -1,83 +1,84 @@ -//////////////////////////////////////////////////////////// -// -// 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 -#include -#include - - -//////////////////////////////////////////////////////////// -/// Get the state of a key -//////////////////////////////////////////////////////////// -sfBool sfInput_IsKeyDown(const sfInput* input, sfKeyCode code) -{ - CSFML_CALL_PTR_RETURN(input, IsKeyDown((sf::Key::Code)code), sfFalse); -} - - -//////////////////////////////////////////////////////////// -/// Get the state of a mouse button -//////////////////////////////////////////////////////////// -sfBool sfInput_IsMouseButtonDown(const sfInput* input, sfMouseButton button) -{ - CSFML_CALL_PTR_RETURN(input, IsMouseButtonDown((sf::Mouse::Button)button), sfFalse); -} - - -//////////////////////////////////////////////////////////// -/// Get the state of a joystick button -//////////////////////////////////////////////////////////// -sfBool sfInput_IsJoystickButtonDown(const sfInput* input, unsigned int joyId, unsigned int button) -{ - CSFML_CALL_PTR_RETURN(input, IsJoystickButtonDown(joyId, button), sfFalse); -} - - -//////////////////////////////////////////////////////////// -/// Get the mouse X position -//////////////////////////////////////////////////////////// -int sfInput_GetMouseX(const sfInput* input) -{ - CSFML_CALL_PTR_RETURN(input, GetMouseX(), 0); -} - - -//////////////////////////////////////////////////////////// -/// Get the mouse Y position -//////////////////////////////////////////////////////////// -int sfInput_GetMouseY(const sfInput* input) -{ - CSFML_CALL_PTR_RETURN(input, GetMouseY(), 0); -} - -//////////////////////////////////////////////////////////// -/// Get the joystick position on a given axis -//////////////////////////////////////////////////////////// -float sfInput_GetJoystickAxis(const sfInput* input, unsigned int joyId, sfJoyAxis axis) -{ - CSFML_CALL_PTR_RETURN(input, GetJoystickAxis(joyId, (sf::Joy::Axis)axis), 0.f); -} +//////////////////////////////////////////////////////////// +// +// 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 +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a joystick is connected +//////////////////////////////////////////////////////////// +sfBool sfJoystick_IsConnected(unsigned int joystick) +{ + return sf::Joystick::IsConnected(joystick) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Return the number of buttons supported by a joystick +//////////////////////////////////////////////////////////// +unsigned int sfJoystick_GetButtonCount(unsigned int joystick) +{ + return sf::Joystick::GetButtonCount(joystick); +} + + +//////////////////////////////////////////////////////////// +/// Check if a joystick supports a given axis +//////////////////////////////////////////////////////////// +sfBool sfJoystick_HasAxis(unsigned int joystick, sfJoystickAxis axis) +{ + return sf::Joystick::HasAxis(joystick, static_cast(axis)) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Check if a joystick button is pressed +//////////////////////////////////////////////////////////// +sfBool sfJoystick_IsButtonPressed(unsigned int joystick, unsigned int button) +{ + return sf::Joystick::IsButtonPressed(joystick, button) ? sfTrue : sfFalse; +} + + +//////////////////////////////////////////////////////////// +/// Get the current position of a joystick axis +//////////////////////////////////////////////////////////// +float sfJoystick_GetAxisPosition(unsigned int joystick, sfJoystickAxis axis) +{ + return sf::Joystick::GetAxisPosition(joystick, static_cast(axis)); +} + + +//////////////////////////////////////////////////////////// +/// Update the states of all joysticks +//////////////////////////////////////////////////////////// +void sfJoystick_Update(void) +{ + sf::Joystick::Update(); +} diff --git a/bindings/c/src/SFML/Window/InputStruct.h b/bindings/c/src/SFML/Window/Keyboard.cpp similarity index 84% rename from bindings/c/src/SFML/Window/InputStruct.h rename to bindings/c/src/SFML/Window/Keyboard.cpp index 127e459ea..190c118ea 100644 --- a/bindings/c/src/SFML/Window/InputStruct.h +++ b/bindings/c/src/SFML/Window/Keyboard.cpp @@ -1,43 +1,39 @@ -//////////////////////////////////////////////////////////// -// -// 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_INPUTSTRUCT_H -#define SFML_INPUTSTRUCT_H - -//////////////////////////////////////////////////////////// -// Headers -//////////////////////////////////////////////////////////// -#include - - -//////////////////////////////////////////////////////////// -// Internal structure of sfInput -//////////////////////////////////////////////////////////// -struct sfInput -{ - const sf::Input* This; -}; - - -#endif // SFML_INPUTSTRUCT_H +//////////////////////////////////////////////////////////// +// +// 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 +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a key is pressed +//////////////////////////////////////////////////////////// +sfBool sfKeyboard_IsKeyPressed(sfKeyCode key) +{ + return sf::Keyboard::IsKeyPressed(static_cast(key)); +} diff --git a/bindings/c/src/SFML/Window/Mouse.cpp b/bindings/c/src/SFML/Window/Mouse.cpp new file mode 100644 index 000000000..ac0a2663a --- /dev/null +++ b/bindings/c/src/SFML/Window/Mouse.cpp @@ -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 +#include +#include + + +//////////////////////////////////////////////////////////// +/// Check if a mouse button is pressed +//////////////////////////////////////////////////////////// +sfBool sfMouse_IsButtonPressed(sfMouseButton button) +{ + return sf::Mouse::IsButtonPressed(static_cast(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; +} diff --git a/bindings/c/src/SFML/Window/Window.cpp b/bindings/c/src/SFML/Window/Window.cpp index d3e9fe4e3..ea12c5008 100644 --- a/bindings/c/src/SFML/Window/Window.cpp +++ b/bindings/c/src/SFML/Window/Window.cpp @@ -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 //////////////////////////////////////////////////////////// diff --git a/bindings/c/src/SFML/Window/WindowStruct.h b/bindings/c/src/SFML/Window/WindowStruct.h index 0429f1539..1f0eaddec 100644 --- a/bindings/c/src/SFML/Window/WindowStruct.h +++ b/bindings/c/src/SFML/Window/WindowStruct.h @@ -29,7 +29,6 @@ // Headers //////////////////////////////////////////////////////////// #include -#include //////////////////////////////////////////////////////////// @@ -38,7 +37,6 @@ struct sfWindow { sf::Window This; - sfInput Input; }; diff --git a/bindings/dotnet/examples/opengl/OpenGL.cs b/bindings/dotnet/examples/opengl/OpenGL.cs index 7167a45b3..4eadc92a6 100644 --- a/bindings/dotnet/examples/opengl/OpenGL.cs +++ b/bindings/dotnet/examples/opengl/OpenGL.cs @@ -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(); } diff --git a/bindings/dotnet/examples/shader/Shader.cs b/bindings/dotnet/examples/shader/Shader.cs index 6d62ab803..646e1a806 100644 --- a/bindings/dotnet/examples/shader/Shader.cs +++ b/bindings/dotnet/examples/shader/Shader.cs @@ -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 diff --git a/bindings/dotnet/examples/window/Window.cs b/bindings/dotnet/examples/window/Window.cs index eece87eb1..1fc64416f 100644 --- a/bindings/dotnet/examples/window/Window.cs +++ b/bindings/dotnet/examples/window/Window.cs @@ -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(); } diff --git a/bindings/dotnet/extlibs/x64/csfml-audio-2.dll b/bindings/dotnet/extlibs/x64/csfml-audio-2.dll index e40d615f7..031d001d5 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-audio-2.dll and b/bindings/dotnet/extlibs/x64/csfml-audio-2.dll differ diff --git a/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll b/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll index caaf5c43c..aeafa0c52 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll and b/bindings/dotnet/extlibs/x64/csfml-graphics-2.dll differ diff --git a/bindings/dotnet/extlibs/x64/csfml-window-2.dll b/bindings/dotnet/extlibs/x64/csfml-window-2.dll index 3f82d4f8e..5041692d7 100644 Binary files a/bindings/dotnet/extlibs/x64/csfml-window-2.dll and b/bindings/dotnet/extlibs/x64/csfml-window-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-audio-2.dll b/bindings/dotnet/extlibs/x86/csfml-audio-2.dll index b36224e34..50c974b32 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-audio-2.dll and b/bindings/dotnet/extlibs/x86/csfml-audio-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll b/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll index 42ec9953a..e067e5c8c 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll and b/bindings/dotnet/extlibs/x86/csfml-graphics-2.dll differ diff --git a/bindings/dotnet/extlibs/x86/csfml-window-2.dll b/bindings/dotnet/extlibs/x86/csfml-window-2.dll index 5df7ff826..b74998260 100644 Binary files a/bindings/dotnet/extlibs/x86/csfml-window-2.dll and b/bindings/dotnet/extlibs/x86/csfml-window-2.dll differ diff --git a/bindings/dotnet/src/Audio/Listener.cs b/bindings/dotnet/src/Audio/Listener.cs index f3179329f..a47830a7a 100644 --- a/bindings/dotnet/src/Audio/Listener.cs +++ b/bindings/dotnet/src/Audio/Listener.cs @@ -31,9 +31,9 @@ namespace SFML /// 3D position of the listener (default is (0, 0, 0)) /// //////////////////////////////////////////////////////////// - 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)) /// //////////////////////////////////////////////////////////// - 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);} } diff --git a/bindings/dotnet/src/Audio/Music.cs b/bindings/dotnet/src/Audio/Music.cs index b7e4b6712..6aac0ef4a 100644 --- a/bindings/dotnet/src/Audio/Music.cs +++ b/bindings/dotnet/src/Audio/Music.cs @@ -159,9 +159,9 @@ namespace SFML /// 3D position of the music. Default value is (0, 0, 0) /// //////////////////////////////////////////////////////////// - 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);} } diff --git a/bindings/dotnet/src/Audio/Sound.cs b/bindings/dotnet/src/Audio/Sound.cs index f42f41969..69b390778 100644 --- a/bindings/dotnet/src/Audio/Sound.cs +++ b/bindings/dotnet/src/Audio/Sound.cs @@ -165,9 +165,9 @@ namespace SFML /// 3D position of the sound. Default value is (0, 0, 0) /// //////////////////////////////////////////////////////////// - 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);} } diff --git a/bindings/dotnet/src/Audio/SoundStream.cs b/bindings/dotnet/src/Audio/SoundStream.cs index 999ad1435..c44c13b89 100644 --- a/bindings/dotnet/src/Audio/SoundStream.cs +++ b/bindings/dotnet/src/Audio/SoundStream.cs @@ -124,9 +124,9 @@ namespace SFML /// 3D position of the sound stream. Default value is (0, 0, 0) /// //////////////////////////////////////////////////////////// - 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);} } diff --git a/bindings/dotnet/src/Audio/Vector3.cs b/bindings/dotnet/src/Audio/Vector3.cs index 5cf10be5c..611e1968e 100644 --- a/bindings/dotnet/src/Audio/Vector3.cs +++ b/bindings/dotnet/src/Audio/Vector3.cs @@ -7,12 +7,12 @@ namespace SFML { //////////////////////////////////////////////////////////// /// - /// Vector3 is an utility class for manipulating 3 dimensional + /// Vector3f is an utility class for manipulating 3 dimensional /// vectors with float components /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] - public struct Vector3 + public struct Vector3f { //////////////////////////////////////////////////////////// /// @@ -22,7 +22,7 @@ namespace SFML /// Y coordinate /// Z coordinate //////////////////////////////////////////////////////////// - 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 /// Vector to negate /// -v //////////////////////////////////////////////////////////// - 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 /// Second vector /// v1 - v2 //////////////////////////////////////////////////////////// - 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 /// Second vector /// v1 + v2 //////////////////////////////////////////////////////////// - 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 /// Scalar value /// v * x //////////////////////////////////////////////////////////// - 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 /// Vector /// x * v //////////////////////////////////////////////////////////// - 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 /// Scalar value /// v / x //////////////////////////////////////////////////////////// - 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 + ")"; diff --git a/bindings/dotnet/src/Graphics/Drawable.cs b/bindings/dotnet/src/Graphics/Drawable.cs index e85c13ec8..09e11a5ef 100644 --- a/bindings/dotnet/src/Graphics/Drawable.cs +++ b/bindings/dotnet/src/Graphics/Drawable.cs @@ -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 /// //////////////////////////////////////////////////////////// - public abstract Vector2 Position {get; set;} + public abstract Vector2f Position { get; set; } //////////////////////////////////////////////////////////// /// @@ -52,7 +53,7 @@ namespace SFML /// Vertical and horizontal scale of the object /// //////////////////////////////////////////////////////////// - public abstract Vector2 Scale {get; set;} + public abstract Vector2f Scale { get; set; } //////////////////////////////////////////////////////////// /// @@ -60,7 +61,7 @@ namespace SFML /// (center of translation, rotation and scale) /// //////////////////////////////////////////////////////////// - public abstract Vector2 Origin {get; set;} + public abstract Vector2f Origin { get; set; } //////////////////////////////////////////////////////////// /// @@ -84,7 +85,7 @@ namespace SFML /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - public abstract Vector2 TransformToLocal(Vector2 point); + public abstract Vector2f TransformToLocal(Vector2f point); //////////////////////////////////////////////////////////// /// @@ -94,7 +95,7 @@ namespace SFML /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - public abstract Vector2 TransformToGlobal(Vector2 point); + public abstract Vector2f TransformToGlobal(Vector2f point); //////////////////////////////////////////////////////////// /// diff --git a/bindings/dotnet/src/Graphics/RenderImage.cs b/bindings/dotnet/src/Graphics/RenderImage.cs index 396725e4e..28bcde2ce 100644 --- a/bindings/dotnet/src/Graphics/RenderImage.cs +++ b/bindings/dotnet/src/Graphics/RenderImage.cs @@ -134,7 +134,7 @@ namespace SFML /// Converted point /// //////////////////////////////////////////////////////////// - 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 /// Converted point /// //////////////////////////////////////////////////////////// - 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; diff --git a/bindings/dotnet/src/Graphics/RenderTarget.cs b/bindings/dotnet/src/Graphics/RenderTarget.cs index 0961e4ccb..6319850da 100644 --- a/bindings/dotnet/src/Graphics/RenderTarget.cs +++ b/bindings/dotnet/src/Graphics/RenderTarget.cs @@ -69,7 +69,7 @@ namespace SFML /// Y coordinate of the point to convert, relative to the target /// Converted point //////////////////////////////////////////////////////////// - Vector2 ConvertCoords(uint x, uint y); + Vector2f ConvertCoords(uint x, uint y); //////////////////////////////////////////////////////////// /// @@ -81,7 +81,7 @@ namespace SFML /// Target view to convert the point to /// Converted point //////////////////////////////////////////////////////////// - Vector2 ConvertCoords(uint x, uint y, View view); + Vector2f ConvertCoords(uint x, uint y, View view); //////////////////////////////////////////////////////////// /// diff --git a/bindings/dotnet/src/Graphics/RenderWindow.cs b/bindings/dotnet/src/Graphics/RenderWindow.cs index 7e0a23aa6..ff757a2a2 100644 --- a/bindings/dotnet/src/Graphics/RenderWindow.cs +++ b/bindings/dotnet/src/Graphics/RenderWindow.cs @@ -369,7 +369,7 @@ namespace SFML /// Converted point /// //////////////////////////////////////////////////////////// - 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 /// Converted point /// //////////////////////////////////////////////////////////// - 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); diff --git a/bindings/dotnet/src/Graphics/Shader.cs b/bindings/dotnet/src/Graphics/Shader.cs index 7bbbc2784..7efb2782b 100644 --- a/bindings/dotnet/src/Graphics/Shader.cs +++ b/bindings/dotnet/src/Graphics/Shader.cs @@ -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 /// Name of the parameter in the shader /// Value of the parameter //////////////////////////////////////////////////////////// - public void SetParameter(string name, Vector2 v) + public void SetParameter(string name, Vector2f v) { SetParameter(name, v.X, v.Y); } diff --git a/bindings/dotnet/src/Graphics/Shape.cs b/bindings/dotnet/src/Graphics/Shape.cs index 3f807e2a6..79e52418e 100644 --- a/bindings/dotnet/src/Graphics/Shape.cs +++ b/bindings/dotnet/src/Graphics/Shape.cs @@ -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 /// //////////////////////////////////////////////////////////// - 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 /// //////////////////////////////////////////////////////////// - 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) /// //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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 /// Position of the point /// Color of the point //////////////////////////////////////////////////////////// - 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 /// Color of the point /// Outline color of the point //////////////////////////////////////////////////////////// - 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 /// Index of the point, in range [0, NbPoints - 1] /// New position of the index-th point //////////////////////////////////////////////////////////// - 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 /// Index of the point, in range [0, NbPoints - 1] /// Position of the index-th point //////////////////////////////////////////////////////////// - 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 /// Color used to draw the line /// New line shape built with the given parameters //////////////////////////////////////////////////////////// - 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 /// Color used to draw the outline /// New line shape built with the given parameters //////////////////////////////////////////////////////////// - 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 /// Color used to fill the circle /// New circle shape built with the given parameters //////////////////////////////////////////////////////////// - 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 /// Color used to draw the outline /// New circle shape built with the given parameters //////////////////////////////////////////////////////////// - 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); diff --git a/bindings/dotnet/src/Graphics/Sprite.cs b/bindings/dotnet/src/Graphics/Sprite.cs index ae171ed8c..2ab1ee810 100644 --- a/bindings/dotnet/src/Graphics/Sprite.cs +++ b/bindings/dotnet/src/Graphics/Sprite.cs @@ -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 /// //////////////////////////////////////////////////////////// - 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 /// //////////////////////////////////////////////////////////// - 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) /// //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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); diff --git a/bindings/dotnet/src/Graphics/Text.cs b/bindings/dotnet/src/Graphics/Text.cs index 1524e0e02..c0a6c816d 100644 --- a/bindings/dotnet/src/Graphics/Text.cs +++ b/bindings/dotnet/src/Graphics/Text.cs @@ -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 /// //////////////////////////////////////////////////////////// - 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 /// //////////////////////////////////////////////////////////// - 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) /// //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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 /// Point to transform /// Transformed point //////////////////////////////////////////////////////////// - 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 /// Index of the character /// Position of the Index-th character (end of text if Index is out of range) //////////////////////////////////////////////////////////// - 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); diff --git a/bindings/dotnet/src/Graphics/Vector2.cs b/bindings/dotnet/src/Graphics/Vector2.cs deleted file mode 100644 index 669cc3328..000000000 --- a/bindings/dotnet/src/Graphics/Vector2.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -namespace SFML -{ - namespace Graphics - { - //////////////////////////////////////////////////////////// - /// - /// Vector2 is an utility class for manipulating 2 dimensional - /// vectors with float components - /// - //////////////////////////////////////////////////////////// - [StructLayout(LayoutKind.Sequential)] - public struct Vector2 - { - //////////////////////////////////////////////////////////// - /// - /// Construct the vector from its coordinates - /// - /// X coordinate - /// Y coordinate - //////////////////////////////////////////////////////////// - public Vector2(float x, float y) - { - X = x; - Y = y; - } - - //////////////////////////////////////////////////////////// - /// - /// Operator - overload ; returns the opposite of a vector - /// - /// Vector to negate - /// -v - //////////////////////////////////////////////////////////// - public static Vector2 operator -(Vector2 v) - { - return new Vector2(-v.X, -v.Y); - } - - //////////////////////////////////////////////////////////// - /// - /// Operator - overload ; subtracts two vectors - /// - /// First vector - /// Second vector - /// v1 - v2 - //////////////////////////////////////////////////////////// - public static Vector2 operator -(Vector2 v1, Vector2 v2) - { - return new Vector2(v1.X - v2.X, v1.Y - v2.Y); - } - - //////////////////////////////////////////////////////////// - /// - /// Operator + overload ; add two vectors - /// - /// First vector - /// Second vector - /// v1 + v2 - //////////////////////////////////////////////////////////// - public static Vector2 operator +(Vector2 v1, Vector2 v2) - { - return new Vector2(v1.X + v2.X, v1.Y + v2.Y); - } - - //////////////////////////////////////////////////////////// - /// - /// Operator * overload ; multiply a vector by a scalar value - /// - /// Vector - /// Scalar value - /// v * x - //////////////////////////////////////////////////////////// - public static Vector2 operator *(Vector2 v, float x) - { - return new Vector2(v.X * x, v.Y * x); - } - - //////////////////////////////////////////////////////////// - /// - /// Operator * overload ; multiply a scalar value by a vector - /// - /// Scalar value - /// Vector - /// x * v - //////////////////////////////////////////////////////////// - public static Vector2 operator *(float x, Vector2 v) - { - return new Vector2(v.X * x, v.Y * x); - } - - //////////////////////////////////////////////////////////// - /// - /// Operator / overload ; divide a vector by a scalar value - /// - /// Vector - /// Scalar value - /// v / x - //////////////////////////////////////////////////////////// - public static Vector2 operator /(Vector2 v, float x) - { - return new Vector2(v.X / x, v.Y / x); - } - - //////////////////////////////////////////////////////////// - /// - /// Provide a string describing the object - /// - /// String description of the object - //////////////////////////////////////////////////////////// - public override string ToString() - { - return "[Vector2]" + - " X(" + X + ")" + - " Y(" + Y + ")"; - } - - /// X (horizontal) component of the vector - public float X; - - /// Y (vertical) component of the vector - public float Y; - } - } -} diff --git a/bindings/dotnet/src/Graphics/View.cs b/bindings/dotnet/src/Graphics/View.cs index 1b7ab5237..5968aead8 100644 --- a/bindings/dotnet/src/Graphics/View.cs +++ b/bindings/dotnet/src/Graphics/View.cs @@ -1,6 +1,7 @@ using System; using System.Runtime.InteropServices; using System.Security; +using SFML.Window; namespace SFML { @@ -42,7 +43,7 @@ namespace SFML /// Center of the view /// Size of the view //////////////////////////////////////////////////////////// - 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 /// //////////////////////////////////////////////////////////// - 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 /// //////////////////////////////////////////////////////////// - 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 /// /// Offset to move the view //////////////////////////////////////////////////////////// - public void Move(Vector2 offset) + public void Move(Vector2f offset) { sfView_Move(This, offset.X, offset.Y); } diff --git a/bindings/dotnet/src/Graphics/sfml-graphics.csproj b/bindings/dotnet/src/Graphics/sfml-graphics.csproj index 8b08a54b7..41fae5c1e 100644 --- a/bindings/dotnet/src/Graphics/sfml-graphics.csproj +++ b/bindings/dotnet/src/Graphics/sfml-graphics.csproj @@ -80,7 +80,6 @@ - diff --git a/bindings/dotnet/src/Window/Event.cs b/bindings/dotnet/src/Window/Event.cs index 9923f09b6..0408c4ac8 100644 --- a/bindings/dotnet/src/Window/Event.cs +++ b/bindings/dotnet/src/Window/Event.cs @@ -5,168 +5,6 @@ namespace SFML { namespace Window { - //////////////////////////////////////////////////////////// - /// - /// Definition of key codes for keyboard events - /// - //////////////////////////////////////////////////////////// - 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 - } - - //////////////////////////////////////////////////////////// - /// - /// Definition of button codes for mouse events - /// - //////////////////////////////////////////////////////////// - public enum MouseButton - { - /// Left mouse button - Left, - - /// Right mouse button - Right, - - /// Center (wheel) mouse button - Middle, - - /// First extra button - XButton1, - - /// Second extra button - XButton2 - } - - //////////////////////////////////////////////////////////// - /// - /// Definition of joystick axis for joystick events - /// - //////////////////////////////////////////////////////////// - public enum JoyAxis - { - /// X axis - AxisX, - - /// Y axis - AxisY, - - /// Z axis - AxisZ, - - /// R axis - AxisR, - - /// U axis - AxisU, - - /// V axis - AxisV, - - /// Point of view - AxisPOV - } - //////////////////////////////////////////////////////////// /// /// Enumeration of the different types of events @@ -214,13 +52,19 @@ namespace SFML MouseLeft, /// Event triggered when a joystick button is pressed - JoyButtonPressed, + JoystickButtonPressed, /// Event triggered when a joystick button is released - JoyButtonReleased, + JoystickButtonReleased, /// Event triggered when a joystick axis moves - JoyMoved + JoystickMoved, + + /// Event triggered when a joystick is connected + JoystickConnected, + + /// Event triggered when a joystick is disconnected + JoystickDisconnected } //////////////////////////////////////////////////////////// @@ -232,7 +76,7 @@ namespace SFML public struct KeyEvent { /// Code of the key (see KeyCode enum) - public KeyCode Code; + public Keyboard.Key Code; /// Is the Alt modifier pressed? public int Alt; @@ -283,7 +127,7 @@ namespace SFML public struct MouseButtonEvent { /// Code of the button (see MouseButton enum) - public MouseButton Button; + public Mouse.Button Button; /// X coordinate of the mouse cursor public int X; @@ -316,13 +160,13 @@ namespace SFML /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] - public struct JoyMoveEvent + public struct JoystickMoveEvent { /// Index of the joystick which triggered the event public uint JoystickId; /// Joystick axis (see JoyAxis enum) - public JoyAxis Axis; + public Joystick.Axis Axis; /// Current position of the axis public float Position; @@ -334,7 +178,7 @@ namespace SFML /// //////////////////////////////////////////////////////////// [StructLayout(LayoutKind.Sequential)] - public struct JoyButtonEvent + public struct JoystickButtonEvent { /// Index of the joystick which triggered the event public uint JoystickId; @@ -343,6 +187,18 @@ namespace SFML public uint Button; } + //////////////////////////////////////////////////////////// + /// + /// Joystick connect event parameters + /// + //////////////////////////////////////////////////////////// + [StructLayout(LayoutKind.Sequential)] + public struct JoystickConnectEvent + { + /// Index of the joystick which triggered the event + public uint JoystickId; + } + //////////////////////////////////////////////////////////// /// /// Size event parameters @@ -370,6 +226,10 @@ namespace SFML [FieldOffset(0)] public EventType Type; + /// Arguments for size events (Resized) + [FieldOffset(4)] + public SizeEvent Size; + /// Arguments for key events (KeyPressed, KeyReleased) [FieldOffset(4)] public KeyEvent Key; @@ -390,17 +250,17 @@ namespace SFML [FieldOffset(4)] public MouseWheelEvent MouseWheel; - /// Arguments for joystick axis events (JoyMoved) + /// Arguments for joystick axis events (JoystickMoved) [FieldOffset(4)] - public JoyMoveEvent JoyMove; + public JoystickMoveEvent JoystickMove; - /// Arguments for joystick button events (JoyButtonPressed, JoyButtonReleased) + /// Arguments for joystick button events (JoystickButtonPressed, JoystickButtonReleased) [FieldOffset(4)] - public JoyButtonEvent JoyButton; + public JoystickButtonEvent JoystickButton; - /// Arguments for size events (Resized) + /// Arguments for joystick connect events (JoystickConnected, JoystickDisconnected) [FieldOffset(4)] - public SizeEvent Size; + public JoystickConnectEvent JoystickConnect; } } } diff --git a/bindings/dotnet/src/Window/EventArgs.cs b/bindings/dotnet/src/Window/EventArgs.cs index 37c26d76a..8ecf8d3cd 100644 --- a/bindings/dotnet/src/Window/EventArgs.cs +++ b/bindings/dotnet/src/Window/EventArgs.cs @@ -43,7 +43,7 @@ namespace SFML } /// Code of the key (see KeyCode enum) - public KeyCode Code; + public Keyboard.Key Code; /// Is the Alt modifier pressed? public bool Alt; @@ -166,7 +166,7 @@ namespace SFML } /// Code of the button (see MouseButton enum) - public MouseButton Button; + public Mouse.Button Button; /// X coordinate of the mouse cursor public int X; @@ -224,7 +224,7 @@ namespace SFML /// Joystick axis move event parameters /// //////////////////////////////////////////////////////////// - public class JoyMoveEventArgs : EventArgs + public class JoystickMoveEventArgs : EventArgs { //////////////////////////////////////////////////////////// /// @@ -232,7 +232,7 @@ namespace SFML /// /// Joystick move event //////////////////////////////////////////////////////////// - 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; /// Joystick axis (see JoyAxis enum) - public JoyAxis Axis; + public Joystick.Axis Axis; /// Current position of the axis public float Position; @@ -268,7 +268,7 @@ namespace SFML /// Joystick buttons event parameters /// //////////////////////////////////////////////////////////// - public class JoyButtonEventArgs : EventArgs + public class JoystickButtonEventArgs : EventArgs { //////////////////////////////////////////////////////////// /// @@ -276,7 +276,7 @@ namespace SFML /// /// Joystick button event //////////////////////////////////////////////////////////// - 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; } + //////////////////////////////////////////////////////////// + /// + /// Joystick connection/disconnection event parameters + /// + //////////////////////////////////////////////////////////// + public class JoystickConnectEventArgs : EventArgs + { + //////////////////////////////////////////////////////////// + /// + /// Construct the joystick connect arguments from a joystick connect event + /// + /// Joystick button event + //////////////////////////////////////////////////////////// + public JoystickConnectEventArgs(JoystickConnectEvent e) + { + JoystickId = e.JoystickId; + } + + //////////////////////////////////////////////////////////// + /// + /// Provide a string describing the object + /// + /// String description of the object + //////////////////////////////////////////////////////////// + public override string ToString() + { + return "[JoystickConnectEventArgs]" + + " JoystickId(" + JoystickId + ")"; + } + + /// Index of the joystick which triggered the event + public uint JoystickId; + } + //////////////////////////////////////////////////////////// /// /// Size event parameters diff --git a/bindings/dotnet/src/Window/Input.cs b/bindings/dotnet/src/Window/Input.cs deleted file mode 100644 index eb086b6d2..000000000 --- a/bindings/dotnet/src/Window/Input.cs +++ /dev/null @@ -1,144 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Security; - -namespace SFML -{ - namespace Window - { - //////////////////////////////////////////////////////////// - /// - /// Input handles real-time input from keyboard and mouse. - /// Use it instead of events to handle continuous moves and more - /// game-friendly inputs - /// - //////////////////////////////////////////////////////////// - public class Input : ObjectBase - { - //////////////////////////////////////////////////////////// - /// - /// Get the state of a key - /// - /// Key to check - /// True if key is down, false if key is up - //////////////////////////////////////////////////////////// - public bool IsKeyDown(KeyCode key) - { - return sfInput_IsKeyDown(This, key); - } - - //////////////////////////////////////////////////////////// - /// - /// Get the state of a mouse button - /// - /// Button to check - /// True if button is down, false if button is up - //////////////////////////////////////////////////////////// - public bool IsMouseButtonDown(MouseButton button) - { - return sfInput_IsMouseButtonDown(This, button); - } - - //////////////////////////////////////////////////////////// - /// - /// Get the state of a joystick button - /// - /// Identifier of the joystick to check (0 or 1) - /// Button to check - /// True if button is down, false if button is up - //////////////////////////////////////////////////////////// - public bool IsJoystickButtonDown(uint joystickId, uint button) - { - return sfInput_IsJoystickButtonDown(This, joystickId, button); - } - - //////////////////////////////////////////////////////////// - /// - /// Get the mouse X position - /// - /// Current mouse left position, relative to owner window - //////////////////////////////////////////////////////////// - public int GetMouseX() - { - return sfInput_GetMouseX(This); - } - - //////////////////////////////////////////////////////////// - /// - /// Get the mouse Y position - /// - /// Current mouse top position, relative to owner window - //////////////////////////////////////////////////////////// - public int GetMouseY() - { - return sfInput_GetMouseY(This); - } - - //////////////////////////////////////////////////////////// - /// - /// Get a joystick axis position - /// - /// Identifier of the joystick to check (0 or 1) - /// Axis to get - /// Current axis position, in the range [-100, 100] (except for POV, which is [0, 360]) - //////////////////////////////////////////////////////////// - public float GetJoystickAxis(uint joystickId, JoyAxis axis) - { - return sfInput_GetJoystickAxis(This, joystickId, axis); - } - - //////////////////////////////////////////////////////////// - /// - /// For internal use only, construct the instance from a direct pointer to the internal object - /// - /// Internal pointer to the input object - //////////////////////////////////////////////////////////// - public Input(IntPtr thisPtr) : - base(thisPtr) - { - } - - //////////////////////////////////////////////////////////// - /// - /// Provide a string describing the object - /// - /// String description of the object - //////////////////////////////////////////////////////////// - public override string ToString() - { - return "[Input]"; - } - - //////////////////////////////////////////////////////////// - /// - /// Handle the destruction of the object - /// - /// Is the GC disposing the object, or is it an explicit call ? - //////////////////////////////////////////////////////////// - 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 - } - } -} diff --git a/bindings/dotnet/src/Window/Joystick.cs b/bindings/dotnet/src/Window/Joystick.cs new file mode 100644 index 000000000..6b1555664 --- /dev/null +++ b/bindings/dotnet/src/Window/Joystick.cs @@ -0,0 +1,159 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; + +namespace SFML +{ + namespace Window + { + //////////////////////////////////////////////////////////// + /// + /// Give access to the real-time state of the joysticks + /// + //////////////////////////////////////////////////////////// + public class Joystick + { + /// Maximum number of supported joysticks + public static readonly uint Count = 8; + + /// Maximum number of supported buttons + public static readonly uint ButtonCount = 32; + + /// Maximum number of supported axes + public static readonly uint AxisCount = 8; + + //////////////////////////////////////////////////////////// + /// + /// Axes supported by SFML joysticks + /// + //////////////////////////////////////////////////////////// + public enum Axis + { + /// The X axis + X, + + /// The Y axis + Y, + + /// The Z axis + Z, + + /// The R axis + R, + + /// The U axis + U, + + /// The V axis + V, + + /// The X axis of the point-of-view hat + PovX, + + /// TheY axis of the point-of-view hat + PovY + }; + + //////////////////////////////////////////////////////////// + /// + /// Check if a joystick is connected + /// + /// Index of the joystick to check + /// True if the joystick is connected, false otherwise + //////////////////////////////////////////////////////////// + public static bool IsConnected(uint joystick) + { + return sfJoystick_IsConnected(joystick); + } + + //////////////////////////////////////////////////////////// + /// + /// Return the number of buttons supported by a joystick + /// + /// If the joystick is not connected, this function returns 0. + /// Index of the joystick + /// Number of buttons supported by the joystick + //////////////////////////////////////////////////////////// + public static uint GetButtonCount(uint joystick) + { + return sfJoystick_GetButtonCount(joystick); + } + + //////////////////////////////////////////////////////////// + /// + /// Check if a joystick supports a given axis + /// + /// If the joystick is not connected, this function returns false. + /// Index of the joystick + /// Axis to check + /// True if the joystick supports the axis, false otherwise + //////////////////////////////////////////////////////////// + public static bool HasAxis(uint joystick, Axis axis) + { + return sfJoystick_HasAxis(joystick, axis); + } + + //////////////////////////////////////////////////////////// + /// + /// Check if a joystick button is pressed + /// + /// If the joystick is not connected, this function returns false. + /// Index of the joystick + /// Button to check + /// True if the button is pressed, false otherwise + //////////////////////////////////////////////////////////// + public static bool IsButtonPressed(uint joystick, uint button) + { + return sfJoystick_IsButtonPressed(joystick, button); + } + + //////////////////////////////////////////////////////////// + /// + /// Get the current position of a joystick axis + /// + /// If the joystick is not connected, this function returns 0. + /// Index of the joystick + /// Axis to check + /// Current position of the axis, in range [-100 .. 100] + //////////////////////////////////////////////////////////// + public static float GetAxisPosition(uint joystick, Axis axis) + { + return sfJoystick_GetAxisPosition(joystick, axis); + } + + //////////////////////////////////////////////////////////// + /// + /// 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. + //////////////////////////////////////////////////////////// + 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 + } + } +} diff --git a/bindings/dotnet/src/Window/Keyboard.cs b/bindings/dotnet/src/Window/Keyboard.cs new file mode 100644 index 000000000..3f36cf0e7 --- /dev/null +++ b/bindings/dotnet/src/Window/Keyboard.cs @@ -0,0 +1,146 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; + +namespace SFML +{ + namespace Window + { + //////////////////////////////////////////////////////////// + /// + /// Give access to the real-time state of the keyboard + /// + //////////////////////////////////////////////////////////// + public class Keyboard + { + //////////////////////////////////////////////////////////// + /// + /// Key codes + /// + //////////////////////////////////////////////////////////// + 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 + }; + + //////////////////////////////////////////////////////////// + /// + /// Check if a key is pressed + /// + /// Key to check + /// True if the key is pressed, false otherwise + //////////////////////////////////////////////////////////// + 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 + } + } +} diff --git a/bindings/dotnet/src/Window/Mouse.cs b/bindings/dotnet/src/Window/Mouse.cs new file mode 100644 index 000000000..3a79725d3 --- /dev/null +++ b/bindings/dotnet/src/Window/Mouse.cs @@ -0,0 +1,81 @@ +using System; +using System.Runtime.InteropServices; +using System.Security; + +namespace SFML +{ + namespace Window + { + //////////////////////////////////////////////////////////// + /// + /// Give access to the real-time state of the mouse + /// + //////////////////////////////////////////////////////////// + public class Mouse + { + //////////////////////////////////////////////////////////// + /// + /// Mouse buttons + /// + //////////////////////////////////////////////////////////// + public enum Button + { + /// The left mouse button + Left, + + /// The right mouse button + Right, + + /// The middle (wheel) mouse button + Middle, + + /// The first extra mouse button + XButton1, + + /// The second extra mouse button + XButton2, + + /// Keep last -- the total number of mouse buttons + ButtonCount + }; + + //////////////////////////////////////////////////////////// + /// + /// Check if a mouse button is pressed + /// + /// Button to check + /// True if the button is pressed, false otherwise + //////////////////////////////////////////////////////////// + public static bool IsButtonPressed(Button button) + { + return sfMouse_IsButtonPressed(button); + } + + //////////////////////////////////////////////////////////// + /// + /// 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. + /// Current position of the mouse + //////////////////////////////////////////////////////////// + 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 + } + } +} diff --git a/bindings/dotnet/src/Window/Vector2.cs b/bindings/dotnet/src/Window/Vector2.cs new file mode 100644 index 000000000..8a07669ac --- /dev/null +++ b/bindings/dotnet/src/Window/Vector2.cs @@ -0,0 +1,246 @@ +using System; +using System.Runtime.InteropServices; + +namespace SFML +{ + namespace Window + { + //////////////////////////////////////////////////////////// + /// + /// Vector2f is an utility class for manipulating 2 dimensional + /// vectors with float components + /// + //////////////////////////////////////////////////////////// + [StructLayout(LayoutKind.Sequential)] + public struct Vector2f + { + //////////////////////////////////////////////////////////// + /// + /// Construct the vector from its coordinates + /// + /// X coordinate + /// Y coordinate + //////////////////////////////////////////////////////////// + public Vector2f(float x, float y) + { + X = x; + Y = y; + } + + //////////////////////////////////////////////////////////// + /// + /// Operator - overload ; returns the opposite of a vector + /// + /// Vector to negate + /// -v + //////////////////////////////////////////////////////////// + public static Vector2f operator -(Vector2f v) + { + return new Vector2f(-v.X, -v.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator - overload ; subtracts two vectors + /// + /// First vector + /// Second vector + /// v1 - v2 + //////////////////////////////////////////////////////////// + public static Vector2f operator -(Vector2f v1, Vector2f v2) + { + return new Vector2f(v1.X - v2.X, v1.Y - v2.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator + overload ; add two vectors + /// + /// First vector + /// Second vector + /// v1 + v2 + //////////////////////////////////////////////////////////// + public static Vector2f operator +(Vector2f v1, Vector2f v2) + { + return new Vector2f(v1.X + v2.X, v1.Y + v2.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator * overload ; multiply a vector by a scalar value + /// + /// Vector + /// Scalar value + /// v * x + //////////////////////////////////////////////////////////// + public static Vector2f operator *(Vector2f v, float x) + { + return new Vector2f(v.X * x, v.Y * x); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator * overload ; multiply a scalar value by a vector + /// + /// Scalar value + /// Vector + /// x * v + //////////////////////////////////////////////////////////// + public static Vector2f operator *(float x, Vector2f v) + { + return new Vector2f(v.X * x, v.Y * x); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator / overload ; divide a vector by a scalar value + /// + /// Vector + /// Scalar value + /// v / x + //////////////////////////////////////////////////////////// + public static Vector2f operator /(Vector2f v, float x) + { + return new Vector2f(v.X / x, v.Y / x); + } + + //////////////////////////////////////////////////////////// + /// + /// Provide a string describing the object + /// + /// String description of the object + //////////////////////////////////////////////////////////// + public override string ToString() + { + return "[Vector2f]" + + " X(" + X + ")" + + " Y(" + Y + ")"; + } + + /// X (horizontal) component of the vector + public float X; + + /// Y (vertical) component of the vector + public float Y; + } + + //////////////////////////////////////////////////////////// + /// + /// Vector2i is an utility class for manipulating 2 dimensional + /// vectors with integer components + /// + //////////////////////////////////////////////////////////// + [StructLayout(LayoutKind.Sequential)] + public struct Vector2i + { + //////////////////////////////////////////////////////////// + /// + /// Construct the vector from its coordinates + /// + /// X coordinate + /// Y coordinate + //////////////////////////////////////////////////////////// + public Vector2i(int x, int y) + { + X = x; + Y = y; + } + + //////////////////////////////////////////////////////////// + /// + /// Operator - overload ; returns the opposite of a vector + /// + /// Vector to negate + /// -v + //////////////////////////////////////////////////////////// + public static Vector2i operator -(Vector2i v) + { + return new Vector2i(-v.X, -v.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator - overload ; subtracts two vectors + /// + /// First vector + /// Second vector + /// v1 - v2 + //////////////////////////////////////////////////////////// + public static Vector2i operator -(Vector2i v1, Vector2i v2) + { + return new Vector2i(v1.X - v2.X, v1.Y - v2.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator + overload ; add two vectors + /// + /// First vector + /// Second vector + /// v1 + v2 + //////////////////////////////////////////////////////////// + public static Vector2i operator +(Vector2i v1, Vector2i v2) + { + return new Vector2i(v1.X + v2.X, v1.Y + v2.Y); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator * overload ; multiply a vector by a scalar value + /// + /// Vector + /// Scalar value + /// v * x + //////////////////////////////////////////////////////////// + public static Vector2i operator *(Vector2i v, int x) + { + return new Vector2i(v.X * x, v.Y * x); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator * overload ; multiply a scalar value by a vector + /// + /// Scalar value + /// Vector + /// x * v + //////////////////////////////////////////////////////////// + public static Vector2i operator *(int x, Vector2i v) + { + return new Vector2i(v.X * x, v.Y * x); + } + + //////////////////////////////////////////////////////////// + /// + /// Operator / overload ; divide a vector by a scalar value + /// + /// Vector + /// Scalar value + /// v / x + //////////////////////////////////////////////////////////// + public static Vector2i operator /(Vector2i v, int x) + { + return new Vector2i(v.X / x, v.Y / x); + } + + //////////////////////////////////////////////////////////// + /// + /// Provide a string describing the object + /// + /// String description of the object + //////////////////////////////////////////////////////////// + public override string ToString() + { + return "[Vector2i]" + + " X(" + X + ")" + + " Y(" + Y + ")"; + } + + /// X (horizontal) component of the vector + public int X; + + /// Y (vertical) component of the vector + public int Y; + } + } +} diff --git a/bindings/dotnet/src/Window/Window.cs b/bindings/dotnet/src/Window/Window.cs index e430eaf08..1a99e017c 100644 --- a/bindings/dotnet/src/Window/Window.cs +++ b/bindings/dotnet/src/Window/Window.cs @@ -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)); - } - - //////////////////////////////////////////////////////////// - /// - /// Input manager of the window - /// - //////////////////////////////////////////////////////////// - public Input Input - { - get {return myInput;} } //////////////////////////////////////////////////////////// @@ -215,6 +203,19 @@ namespace SFML sfWindow_SetCursorPosition(This, x, y); } + //////////////////////////////////////////////////////////// + /// + /// Get the position of the mouse cursor + /// + /// The current position of the mouse cursor, relative to the window + //////////////////////////////////////////////////////////// + public virtual Vector2i GetCursorPosition() + { + Vector2i position; + sfWindow_GetCursorPosition(This, out position.X, out position.Y); + return position; + } + //////////////////////////////////////////////////////////// /// /// 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 /// Event handler for the MouseLeft event public event EventHandler MouseLeft = null; - /// Event handler for the JoyButtonPressed event - public event EventHandler JoyButtonPressed = null; + /// Event handler for the JoystickButtonPressed event + public event EventHandler JoystickButtonPressed = null; - /// Event handler for the JoyButtonReleased event - public event EventHandler JoyButtonReleased = null; + /// Event handler for the JoystickButtonReleased event + public event EventHandler JoystickButtonReleased = null; - /// Event handler for the JoyMoved event - public event EventHandler JoyMoved = null; + /// Event handler for the JoystickMoved event + public event EventHandler JoystickMoved = null; - protected Input myInput = null; + /// Event handler for the JoystickConnected event + public event EventHandler JoystickConnected = null; + + /// Event handler for the JoystickDisconnected event + public event EventHandler 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); diff --git a/bindings/dotnet/src/Window/sfml-window.csproj b/bindings/dotnet/src/Window/sfml-window.csproj index a499dc513..6a2ead758 100644 --- a/bindings/dotnet/src/Window/sfml-window.csproj +++ b/bindings/dotnet/src/Window/sfml-window.csproj @@ -70,9 +70,12 @@ - + + + + diff --git a/include/SFML/Window/Joystick.hpp b/include/SFML/Window/Joystick.hpp index b059c2d88..d4ec1a963 100644 --- a/include/SFML/Window/Joystick.hpp +++ b/include/SFML/Window/Joystick.hpp @@ -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 diff --git a/src/SFML/Window/Joystick.cpp b/src/SFML/Window/Joystick.cpp index 95e292914..e3b4e0883 100644 --- a/src/SFML/Window/Joystick.cpp +++ b/src/SFML/Window/Joystick.cpp @@ -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]; }