raylib-cpp
C++ object-oriented wrapper library for raylib.
Mouse.hpp
1 /*
2 * LICENSE: zlib/libpng
3 *
4 * raylib-cpp is licensed under an unmodified zlib/libpng license, which is an OSI-certified,
5 * BSD-like license that allows static linking with closed source software:
6 *
7 * Copyright (c) 2020 Rob Loach (@RobLoach)
8 *
9 * This software is provided "as-is", without any express or implied warranty. In no event
10 * will the authors be held liable for any damages arising from the use of this software.
11 *
12 * Permission is granted to anyone to use this software for any purpose, including commercial
13 * applications, and to alter it and redistribute it freely, subject to the following restrictions:
14 *
15 * 1. The origin of this software must not be misrepresented; you must not claim that you
16 * wrote the original software. If you use this software in a product, an acknowledgment
17 * in the product documentation would be appreciated but is not required.
18 *
19 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented
20 * as being the original software.
21 *
22 * 3. This notice may not be removed or altered from any source distribution.
23 */
24 
25 #ifndef RAYLIB_CPP_INCLUDE_MOUSE_HPP_
26 #define RAYLIB_CPP_INCLUDE_MOUSE_HPP_
27 
28 #include "./raylib.hpp"
29 
30 #include "./Vector2.hpp"
31 
32 namespace raylib {
36 class Mouse {
37  public:
41  static inline bool IsButtonPressed(int button) {
42  return ::IsMouseButtonPressed(button);
43  }
44 
48  static inline bool IsButtonDown(int button) {
49  return ::IsMouseButtonDown(button);
50  }
51 
55  static inline bool IsButtonReleased(int button) {
56  return ::IsMouseButtonReleased(button);
57  }
58 
59  static inline bool IsButtonUp(int button) {
60  return ::IsMouseButtonUp(button);
61  }
62 
63  static inline int GetX() {
64  return ::GetMouseX();
65  }
66 
67  static inline int GetY() {
68  return ::GetMouseY();
69  }
70 
71  static inline void SetX(int x) {
72  ::SetMousePosition(x, GetY());
73  }
74 
75  static inline void SetY(int y) {
76  ::SetMousePosition(GetX(), y);
77  }
78 
79  static inline Vector2 GetPosition() {
80  return ::GetMousePosition();
81  }
82 
83  static inline void SetPosition(int x, int y) {
84  ::SetMousePosition(x, y);
85  }
86 
87  static inline void SetOffset(int offsetX, int offsetY) {
88  ::SetMouseOffset(offsetX, offsetY);
89  }
90 
91  static inline void SetScale(float scaleX, float scaleY) {
92  ::SetMouseScale(scaleX, scaleY);
93  }
94 
95  static inline float GetWheelMove() {
96  return ::GetMouseWheelMove();
97  }
98 
99  static inline int GetCursor() {
100  return ::GetMouseCursor();
101  }
102 
103  static inline void SetCursor(int cursor) {
104  ::SetMouseCursor(cursor);
105  }
106 
107  static inline int GetTouchX() {
108  return ::GetTouchX();
109  }
110 
111  static inline int GetTouchY() {
112  return ::GetTouchY();
113  }
114 
115  static inline Vector2 GetTouchPosition(int index) {
116  return ::GetTouchPosition(index);
117  }
118 };
119 } // namespace raylib
120 
121 #endif // RAYLIB_CPP_INCLUDE_MOUSE_HPP_
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:31
raylib::Mouse
Input-related functions: mouse.
Definition: Mouse.hpp:36
raylib::Mouse::SetCursor
static void SetCursor(int cursor)
Definition: Mouse.hpp:103
raylib::Mouse::GetX
static int GetX()
Definition: Mouse.hpp:63
raylib::Mouse::SetOffset
static void SetOffset(int offsetX, int offsetY)
Definition: Mouse.hpp:87
raylib::Mouse::IsButtonDown
static bool IsButtonDown(int button)
Detect if a mouse button is being pressed.
Definition: Mouse.hpp:48
raylib::Mouse::IsButtonPressed
static bool IsButtonPressed(int button)
Detect if a mouse button has been pressed once.
Definition: Mouse.hpp:41
raylib::Mouse::GetTouchPosition
static Vector2 GetTouchPosition(int index)
Definition: Mouse.hpp:115
raylib::Mouse::SetScale
static void SetScale(float scaleX, float scaleY)
Definition: Mouse.hpp:91
raylib::Mouse::GetPosition
static Vector2 GetPosition()
Definition: Mouse.hpp:79
raylib::Mouse::GetY
static int GetY()
Definition: Mouse.hpp:67
raylib::Mouse::GetTouchX
static int GetTouchX()
Definition: Mouse.hpp:107
raylib::Vector2
Definition: Vector2.hpp:37
raylib::Mouse::GetTouchY
static int GetTouchY()
Definition: Mouse.hpp:111
raylib::Mouse::SetX
static void SetX(int x)
Definition: Mouse.hpp:71
raylib::Mouse::GetWheelMove
static float GetWheelMove()
Definition: Mouse.hpp:95
raylib::Mouse::IsButtonReleased
static bool IsButtonReleased(int button)
Detect if a mouse button has been released once.
Definition: Mouse.hpp:55
raylib::Mouse::IsButtonUp
static bool IsButtonUp(int button)
Definition: Mouse.hpp:59
raylib::Mouse::SetPosition
static void SetPosition(int x, int y)
Definition: Mouse.hpp:83
raylib::Mouse::GetCursor
static int GetCursor()
Definition: Mouse.hpp:99
raylib::Mouse::SetY
static void SetY(int y)
Definition: Mouse.hpp:75