Added support for additional mouse buttons
This commit is contained in:
parent
1269ce8a6f
commit
23bc3e9c16
|
|
@ -36,6 +36,10 @@ int main(void)
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) ballColor = MAROON;
|
||||||
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
else if (IsMouseButtonPressed(MOUSE_MIDDLE_BUTTON)) ballColor = LIME;
|
||||||
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
else if (IsMouseButtonPressed(MOUSE_RIGHT_BUTTON)) ballColor = DARKBLUE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_SIDE_BUTTON)) ballColor = PURPLE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_EXTRA_BUTTON)) ballColor = YELLOW;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_FORWARD_BUTTON)) ballColor = ORANGE;
|
||||||
|
else if (IsMouseButtonPressed(MOUSE_BACK_BUTTON)) ballColor = BEIGE;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|
|
||||||
10
src/core.c
10
src/core.c
|
|
@ -438,12 +438,12 @@ typedef struct CoreData {
|
||||||
bool cursorHidden; // Track if cursor is hidden
|
bool cursorHidden; // Track if cursor is hidden
|
||||||
bool cursorOnScreen; // Tracks if cursor is inside client area
|
bool cursorOnScreen; // Tracks if cursor is inside client area
|
||||||
|
|
||||||
char currentButtonState[3]; // Registers current mouse button state
|
char currentButtonState[MOUSE_BUTTON_MAX]; // Registers current mouse button state
|
||||||
char previousButtonState[3]; // Registers previous mouse button state
|
char previousButtonState[MOUSE_BUTTON_MAX]; // Registers previous mouse button state
|
||||||
float currentWheelMove; // Registers current mouse wheel variation
|
float currentWheelMove; // Registers current mouse wheel variation
|
||||||
float previousWheelMove; // Registers previous mouse wheel variation
|
float previousWheelMove; // Registers previous mouse wheel variation
|
||||||
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
|
#if defined(PLATFORM_RPI) || defined(PLATFORM_DRM)
|
||||||
char currentButtonStateEvdev[3]; // Holds the new mouse state for the next polling event to grab (Can't be written directly due to multithreading, app could miss the update)
|
char currentButtonStateEvdev[MOUSE_BUTTON_MAX]; // Holds the new mouse state for the next polling event to grab (Can't be written directly due to multithreading, app could miss the update)
|
||||||
#endif
|
#endif
|
||||||
} Mouse;
|
} Mouse;
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -6104,6 +6104,10 @@ static void *EventThread(void *arg)
|
||||||
|
|
||||||
if (event.code == BTN_RIGHT) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_RIGHT_BUTTON] = event.value;
|
if (event.code == BTN_RIGHT) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_RIGHT_BUTTON] = event.value;
|
||||||
if (event.code == BTN_MIDDLE) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_MIDDLE_BUTTON] = event.value;
|
if (event.code == BTN_MIDDLE) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_MIDDLE_BUTTON] = event.value;
|
||||||
|
if (event.code == BTN_SIDE) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_SIDE_BUTTON] = event.value;
|
||||||
|
if (event.code == BTN_EXTRA) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_EXTRA_BUTTON] = event.value;
|
||||||
|
if (event.code == BTN_FORWARD) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_FORWARD_BUTTON] = event.value;
|
||||||
|
if (event.code == BTN_BACK) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BACK_BUTTON] = event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screen confinement
|
// Screen confinement
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,12 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MOUSE_LEFT_BUTTON = 0,
|
MOUSE_LEFT_BUTTON = 0,
|
||||||
MOUSE_RIGHT_BUTTON = 1,
|
MOUSE_RIGHT_BUTTON = 1,
|
||||||
MOUSE_MIDDLE_BUTTON = 2
|
MOUSE_MIDDLE_BUTTON = 2,
|
||||||
|
MOUSE_SIDE_BUTTON = 3,
|
||||||
|
MOUSE_EXTRA_BUTTON = 4,
|
||||||
|
MOUSE_FORWARD_BUTTON = 5,
|
||||||
|
MOUSE_BACK_BUTTON = 6,
|
||||||
|
MOUSE_BUTTON_MAX = 7
|
||||||
} MouseButton;
|
} MouseButton;
|
||||||
|
|
||||||
// Mouse cursor
|
// Mouse cursor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user