Skip to content

Commit 39f8d34

Browse files
authored
Merge pull request #297 from RobLoach/namespacing
Use namespaces for Keyboard/Mouse/Touch
2 parents f790a20 + 73ca3f7 commit 39f8d34

File tree

3 files changed

+42
-45
lines changed

3 files changed

+42
-45
lines changed

include/Keyboard.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,58 @@ namespace raylib {
77
/**
88
* Input-related functions: keyboard
99
*/
10-
class Keyboard {
11-
public:
10+
namespace Keyboard {
1211
/**
1312
* Detect if a key has been pressed once
1413
*/
15-
static bool IsKeyPressed(int key) {
14+
[[maybe_unused]] RLCPPAPI inline bool IsKeyPressed(int key) {
1615
return ::IsKeyPressed(key);
1716
}
1817

1918
/**
2019
* Detect if a key has been pressed again (Only PLATFORM_DESKTOP)
2120
*/
22-
static bool IsKeyPressedRepeat(int key) {
21+
[[maybe_unused]] RLCPPAPI inline bool IsKeyPressedRepeat(int key) {
2322
return ::IsKeyPressedRepeat(key);
2423
}
2524

2625
/**
2726
* Detect if a key is being pressed
2827
*/
29-
static bool IsKeyDown(int key) {
28+
[[maybe_unused]] RLCPPAPI inline bool IsKeyDown(int key) {
3029
return ::IsKeyDown(key);
3130
}
3231

3332
/**
3433
* Detect if a key has been released once
3534
*/
36-
static bool IsKeyReleased(int key) {
35+
[[maybe_unused]] RLCPPAPI inline bool IsKeyReleased(int key) {
3736
return ::IsKeyReleased(key);
3837
}
3938

4039
/**
4140
* Detect if a key is NOT being pressed
4241
*/
43-
static bool IsKeyUp(int key) {
42+
[[maybe_unused]] RLCPPAPI inline bool IsKeyUp(int key) {
4443
return ::IsKeyUp(key);
4544
}
4645

4746
/**
4847
* Get key pressed (keycode), call it multiple times for keys queued, returns 0 when the queue is empty
4948
*/
50-
static bool GetKeyPressed() {
49+
[[maybe_unused]] RLCPPAPI inline bool GetKeyPressed() {
5150
return ::GetKeyPressed();
5251
}
5352

5453
/**
5554
* Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
5655
*/
57-
static bool GetCharPressed() {
56+
[[maybe_unused]] RLCPPAPI inline bool GetCharPressed() {
5857
return ::GetCharPressed();
5958
}
6059
};
6160
} // namespace raylib
6261

63-
using RKeyboard = raylib::Keyboard;
62+
namespace RKeyboard = raylib::Keyboard;
6463

6564
#endif // RAYLIB_CPP_INCLUDE_KEYBOARD_HPP_

include/Mouse.hpp

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,87 @@ namespace raylib {
88
/**
99
* Input-related functions: mouse
1010
*/
11-
class Mouse {
12-
public:
11+
namespace Mouse {
1312
/**
1413
* Detect if a mouse button has been pressed once
1514
*/
16-
static bool IsButtonPressed(int button) {
15+
[[maybe_unused]] RLCPPAPI inline bool IsButtonPressed(int button) {
1716
return ::IsMouseButtonPressed(button);
1817
}
1918

2019
/**
2120
* Detect if a mouse button is being pressed
2221
*/
23-
static bool IsButtonDown(int button) {
22+
[[maybe_unused]] RLCPPAPI inline bool IsButtonDown(int button) {
2423
return ::IsMouseButtonDown(button);
2524
}
2625

2726
/**
2827
* Detect if a mouse button has been released once
2928
*/
30-
static bool IsButtonReleased(int button) {
29+
[[maybe_unused]] RLCPPAPI inline bool IsButtonReleased(int button) {
3130
return ::IsMouseButtonReleased(button);
3231
}
3332

34-
static bool IsButtonUp(int button) {
33+
[[maybe_unused]] RLCPPAPI inline bool IsButtonUp(int button) {
3534
return ::IsMouseButtonUp(button);
3635
}
3736

38-
static int GetX() {
37+
[[maybe_unused]] RLCPPAPI inline int GetX() {
3938
return ::GetMouseX();
4039
}
4140

42-
static int GetY() {
41+
[[maybe_unused]] RLCPPAPI inline int GetY() {
4342
return ::GetMouseY();
4443
}
4544

46-
static void SetX(int x) {
45+
[[maybe_unused]] RLCPPAPI inline void SetX(int x) {
4746
::SetMousePosition(x, GetY());
4847
}
4948

50-
static void SetY(int y) {
49+
[[maybe_unused]] RLCPPAPI inline void SetY(int y) {
5150
::SetMousePosition(GetX(), y);
5251
}
5352

54-
static Vector2 GetPosition() {
53+
[[maybe_unused]] RLCPPAPI inline Vector2 GetPosition() {
5554
return ::GetMousePosition();
5655
}
5756

58-
static void SetPosition(int x, int y) {
57+
[[maybe_unused]] RLCPPAPI inline void SetPosition(int x, int y) {
5958
::SetMousePosition(x, y);
6059
}
6160

62-
static void SetPosition(::Vector2 position) {
61+
[[maybe_unused]] RLCPPAPI inline void SetPosition(::Vector2 position) {
6362
::SetMousePosition(static_cast<int>(position.x), static_cast<int>(position.y));
6463
}
6564

6665
/**
6766
* Get mouse delta between frames
6867
*/
69-
static Vector2 GetDelta() {
68+
[[maybe_unused]] RLCPPAPI inline Vector2 GetDelta() {
7069
return ::GetMouseDelta();
7170
}
7271

73-
static void SetOffset(int offsetX = 0, int offsetY = 0) {
72+
[[maybe_unused]] RLCPPAPI inline void SetOffset(int offsetX = 0, int offsetY = 0) {
7473
::SetMouseOffset(offsetX, offsetY);
7574
}
7675

77-
static void SetOffset(::Vector2 offset) {
76+
[[maybe_unused]] RLCPPAPI inline void SetOffset(::Vector2 offset) {
7877
::SetMouseOffset(static_cast<int>(offset.x), static_cast<int>(offset.y));
7978
}
8079

81-
static void SetScale(float scaleX = 1.0f, float scaleY = 1.0f) {
80+
[[maybe_unused]] RLCPPAPI inline void SetScale(float scaleX = 1.0f, float scaleY = 1.0f) {
8281
::SetMouseScale(scaleX, scaleY);
8382
}
8483

85-
static void SetScale(::Vector2 scale) {
84+
[[maybe_unused]] RLCPPAPI inline void SetScale(::Vector2 scale) {
8685
::SetMouseScale(scale.x, scale.y);
8786
}
8887

8988
/**
9089
* Get mouse wheel movement for X or Y, whichever is larger
9190
*/
92-
static float GetWheelMove() {
91+
[[maybe_unused]] RLCPPAPI inline float GetWheelMove() {
9392
return ::GetMouseWheelMove();
9493
}
9594

@@ -98,7 +97,7 @@ class Mouse {
9897
*
9998
* @see ::GetMouseWheelMoveV()
10099
*/
101-
static Vector2 GetWheelMoveV() {
100+
[[maybe_unused]] RLCPPAPI inline Vector2 GetWheelMoveV() {
102101
return GetMouseWheelMoveV();
103102
}
104103

@@ -107,47 +106,47 @@ class Mouse {
107106
*
108107
* @see ::MouseCursor
109108
*/
110-
static void SetCursor(int cursor = MOUSE_CURSOR_DEFAULT) {
109+
[[maybe_unused]] RLCPPAPI inline void SetCursor(int cursor = MOUSE_CURSOR_DEFAULT) {
111110
::SetMouseCursor(cursor);
112111
}
113112

114113
/**
115114
* Get touch position X for touch point 0 (relative to screen size)
116115
*/
117-
static int GetTouchX() {
116+
[[maybe_unused]] RLCPPAPI inline int GetTouchX() {
118117
return ::GetTouchX();
119118
}
120119

121120
/**
122121
* Get touch position Y for touch point 0 (relative to screen size)
123122
*/
124-
static int GetTouchY() {
123+
[[maybe_unused]] RLCPPAPI inline int GetTouchY() {
125124
return ::GetTouchY();
126125
}
127126

128127
/**
129128
* Get touch position XY for a touch point index (relative to screen size)
130129
*/
131-
static Vector2 GetTouchPosition(int index) {
130+
[[maybe_unused]] RLCPPAPI inline Vector2 GetTouchPosition(int index) {
132131
return ::GetTouchPosition(index);
133132
}
134133

135134
/**
136135
* Get a ray trace from mouse position
137136
*/
138-
static Ray GetRay(::Vector2 mousePosition, const ::Camera& camera) {
137+
[[maybe_unused]] RLCPPAPI inline Ray GetRay(::Vector2 mousePosition, const ::Camera& camera) {
139138
return ::GetMouseRay(mousePosition, camera);
140139
}
141140

142141
/**
143142
* Get a ray trace from mouse position
144143
*/
145-
static Ray GetRay(const ::Camera& camera) {
144+
[[maybe_unused]] RLCPPAPI inline Ray GetRay(const ::Camera& camera) {
146145
return ::GetMouseRay(::GetMousePosition(), camera);
147146
}
148147
};
149148
} // namespace raylib
150149

151-
using RMouse = raylib::Mouse;
150+
namespace RMouse = raylib::Mouse;
152151

153152
#endif // RAYLIB_CPP_INCLUDE_MOUSE_HPP_

include/Touch.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,44 @@ namespace raylib {
77
/**
88
* Input-related functions: touch
99
*/
10-
class Touch {
11-
public:
10+
namespace Touch {
1211
/**
1312
* Get touch position X for touch point 0 (relative to screen size)
1413
*/
15-
static int GetX() {
14+
[[maybe_unused]] RLCPPAPI inline int GetX() {
1615
return ::GetTouchX();
1716
}
1817

1918
/**
2019
* Get touch position Y for touch point 0 (relative to screen size)
2120
*/
22-
static int GetY() {
21+
[[maybe_unused]] RLCPPAPI inline int GetY() {
2322
return ::GetTouchY();
2423
}
2524

2625
/**
2726
* Get touch position XY for a touch point index (relative to screen size)
2827
*/
29-
static Vector2 GetPosition(int index) {
28+
[[maybe_unused]] RLCPPAPI inline Vector2 GetPosition(int index) {
3029
return ::GetTouchPosition(index);
3130
}
3231

3332
/**
3433
* Get touch point identifier for given index
3534
*/
36-
static int GetPointId(int index) {
35+
[[maybe_unused]] RLCPPAPI inline int GetPointId(int index) {
3736
return ::GetTouchPointId(index);
3837
}
3938

4039
/**
4140
* Get number of touch points
4241
*/
43-
static int GetPointCount() {
42+
[[maybe_unused]] RLCPPAPI inline int GetPointCount() {
4443
return ::GetTouchPointCount();
4544
}
4645
};
4746
} // namespace raylib
4847

49-
using RTouch = raylib::Touch;
48+
namespace RTouch = raylib::Touch;
5049

5150
#endif // RAYLIB_CPP_INCLUDE_TOUCH_HPP_

0 commit comments

Comments
 (0)