mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
macOS: Add XBUTTON1/2 mouse button support
This commit is contained in:
parent
3bbe889177
commit
59b70501fa
@ -243,6 +243,16 @@ static OSStatus Window_ProcessWindowEvent(EventRef inEvent) {
|
||||
return eventNotHandledErr;
|
||||
}
|
||||
|
||||
static int MapNativeMouse(EventMouseButton button) {
|
||||
if (button == kEventMouseButtonPrimary) return KEY_LMOUSE;
|
||||
if (button == kEventMouseButtonSecondary) return KEY_RMOUSE;
|
||||
if (button == kEventMouseButtonTertiary) return KEY_MMOUSE;
|
||||
|
||||
if (button == 4) return KEY_XBUTTON1;
|
||||
if (button == 5) return KEY_XBUTTON2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
||||
int mouseX, mouseY;
|
||||
HIPoint pt, raw;
|
||||
@ -251,6 +261,7 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
||||
EventMouseButton button;
|
||||
SInt32 delta;
|
||||
OSStatus res;
|
||||
int btn;
|
||||
|
||||
res = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint,
|
||||
NULL, sizeof(HIPoint), NULL, &pt);
|
||||
@ -287,14 +298,9 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
||||
NULL, sizeof(EventMouseButton), NULL, &button);
|
||||
if (res) Logger_Abort2(res, "Getting mouse button");
|
||||
|
||||
switch (button) {
|
||||
case kEventMouseButtonPrimary:
|
||||
Input_Set(KEY_LMOUSE, down); break;
|
||||
case kEventMouseButtonSecondary:
|
||||
Input_Set(KEY_RMOUSE, down); break;
|
||||
case kEventMouseButtonTertiary:
|
||||
Input_Set(KEY_MMOUSE, down); break;
|
||||
}
|
||||
btn = MapNativeMouse(button);
|
||||
if (btn) Input_Set(btn, down); break;
|
||||
|
||||
return eventNotHandledErr;
|
||||
|
||||
case kEventMouseWheelMoved:
|
||||
|
@ -356,6 +356,8 @@ static int MapNativeMouse(int button) {
|
||||
if (button == 0) return KEY_LMOUSE;
|
||||
if (button == 1) return KEY_RMOUSE;
|
||||
if (button == 2) return KEY_MMOUSE;
|
||||
if (button == 3) return KEY_XBUTTON1;
|
||||
if (button == 4) return KEY_XBUTTON2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user