mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-20 02:08:14 +00:00
Added support for additional mouse buttons (#1753)
* Added support for additional mouse buttons * Renamed mouse button enum Co-authored-by: Lambert Wang <lambert.ww@gmail.com>
This commit is contained in:
26
src/core.c
26
src/core.c
@@ -438,12 +438,12 @@ typedef struct CoreData {
|
||||
bool cursorHidden; // Track if cursor is hidden
|
||||
bool cursorOnScreen; // Tracks if cursor is inside client area
|
||||
|
||||
char currentButtonState[3]; // Registers current mouse button state
|
||||
char previousButtonState[3]; // Registers previous mouse button state
|
||||
char currentButtonState[MOUSE_BUTTON_MAX]; // Registers current mouse button state
|
||||
char previousButtonState[MOUSE_BUTTON_MAX]; // Registers previous mouse button state
|
||||
float currentWheelMove; // Registers current mouse wheel variation
|
||||
float previousWheelMove; // Registers previous mouse wheel variation
|
||||
#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
|
||||
} Mouse;
|
||||
struct {
|
||||
@@ -5351,11 +5351,11 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||
|
||||
if (flags == AMOTION_EVENT_ACTION_DOWN || flags == AMOTION_EVENT_ACTION_MOVE)
|
||||
{
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_LEFT_BUTTON] = 1;
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 1;
|
||||
}
|
||||
else if (flags == AMOTION_EVENT_ACTION_UP)
|
||||
{
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_LEFT_BUTTON] = 0;
|
||||
CORE.Input.Touch.currentTouchState[MOUSE_BUTTON_LEFT] = 0;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
@@ -6068,11 +6068,11 @@ static void *EventThread(void *arg)
|
||||
// Touchscreen tap
|
||||
if (event.code == ABS_PRESSURE)
|
||||
{
|
||||
int previousMouseLeftButtonState = CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON];
|
||||
int previousMouseLeftButtonState = CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT];
|
||||
|
||||
if (!event.value && previousMouseLeftButtonState)
|
||||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 0;
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 0;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_UP;
|
||||
@@ -6082,7 +6082,7 @@ static void *EventThread(void *arg)
|
||||
|
||||
if (event.value && !previousMouseLeftButtonState)
|
||||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 1;
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = 1;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
touchAction = TOUCH_DOWN;
|
||||
@@ -6099,7 +6099,7 @@ static void *EventThread(void *arg)
|
||||
// Mouse button parsing
|
||||
if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT))
|
||||
{
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = event.value;
|
||||
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_LEFT] = event.value;
|
||||
|
||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||
if (event.value > 0) touchAction = TOUCH_DOWN;
|
||||
@@ -6108,8 +6108,12 @@ static void *EventThread(void *arg)
|
||||
#endif
|
||||
}
|
||||
|
||||
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_RIGHT) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_RIGHT] = event.value;
|
||||
if (event.code == BTN_MIDDLE) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_MIDDLE] = event.value;
|
||||
if (event.code == BTN_SIDE) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_SIDE] = event.value;
|
||||
if (event.code == BTN_EXTRA) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_EXTRA] = event.value;
|
||||
if (event.code == BTN_FORWARD) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_FORWARD] = event.value;
|
||||
if (event.code == BTN_BACK) CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_BUTTON_BACK] = event.value;
|
||||
}
|
||||
|
||||
// Screen confinement
|
||||
|
Reference in New Issue
Block a user