Input: Expose mouse X1 and X2 buttons

This commit is contained in:
Amaryllis Kulla 2022-01-23 21:49:29 +01:00
parent 5d38b1f813
commit e156421b3b
4 changed files with 14 additions and 5 deletions

View File

@ -156,7 +156,9 @@ static buttonCodes[] =
{ "MOUSELEFT", Input::MouseLeft }, { "MOUSELEFT", Input::MouseLeft },
{ "MOUSEMIDDLE", Input::MouseMiddle }, { "MOUSEMIDDLE", Input::MouseMiddle },
{ "MOUSERIGHT", Input::MouseRight } { "MOUSERIGHT", Input::MouseRight },
{ "MOUSEX1", Input::MouseX1 },
{ "MOUSEX2", Input::MouseX2 }
}; };
static elementsN(buttonCodes); static elementsN(buttonCodes);

View File

@ -19,6 +19,10 @@ returns: Integer
Returns the cumulative amount of scroll events (negative if down, positive if up) inbetween the current and last `Input.update` call. Returns the cumulative amount of scroll events (negative if down, positive if up) inbetween the current and last `Input.update` call.
## Input::MOUSEX1 / ::MOUSEX2
These two constants representing two extra mouse buttons can be passed to the familiar #press?/#trigger?/#repeat? functions.
## MKXP.data_directory() ## MKXP.data_directory()
returns: String returns: String

View File

@ -34,7 +34,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#define BUTTON_CODE_COUNT 24 #define BUTTON_CODE_COUNT 26
struct ButtonState struct ButtonState
{ {
@ -237,7 +237,7 @@ static const int mapToIndex[] =
0, 0,
16, 17, 18, 19, 20, 16, 17, 18, 19, 20,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
21, 22, 23 21, 22, 23, 24, 25
}; };
static elementsN(mapToIndex); static elementsN(mapToIndex);
@ -465,12 +465,14 @@ struct InputPrivate
void initMsBindings() void initMsBindings()
{ {
msBindings.resize(3); msBindings.resize(5);
size_t i = 0; size_t i = 0;
msBindings[i++] = MsBinding(SDL_BUTTON_LEFT, Input::MouseLeft); msBindings[i++] = MsBinding(SDL_BUTTON_LEFT, Input::MouseLeft);
msBindings[i++] = MsBinding(SDL_BUTTON_MIDDLE, Input::MouseMiddle); msBindings[i++] = MsBinding(SDL_BUTTON_MIDDLE, Input::MouseMiddle);
msBindings[i++] = MsBinding(SDL_BUTTON_RIGHT, Input::MouseRight); msBindings[i++] = MsBinding(SDL_BUTTON_RIGHT, Input::MouseRight);
msBindings[i++] = MsBinding(SDL_BUTTON_X1, Input::MouseX1);
msBindings[i++] = MsBinding(SDL_BUTTON_X2, Input::MouseX2);
} }
void pollBindings(Input::ButtonCode &repeatCand) void pollBindings(Input::ButtonCode &repeatCand)

View File

@ -43,7 +43,8 @@ public:
F5 = 25, F6 = 26, F7 = 27, F8 = 28, F9 = 29, F5 = 25, F6 = 26, F7 = 27, F8 = 28, F9 = 29,
/* Non-standard extensions */ /* Non-standard extensions */
MouseLeft = 38, MouseMiddle = 39, MouseRight = 40 MouseLeft = 38, MouseMiddle = 39, MouseRight = 40,
MouseX1 = 41, MouseX2 = 42
}; };
void update(); void update();