mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 16:45:48 -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;
|
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) {
|
static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
||||||
int mouseX, mouseY;
|
int mouseX, mouseY;
|
||||||
HIPoint pt, raw;
|
HIPoint pt, raw;
|
||||||
@ -251,6 +261,7 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
|||||||
EventMouseButton button;
|
EventMouseButton button;
|
||||||
SInt32 delta;
|
SInt32 delta;
|
||||||
OSStatus res;
|
OSStatus res;
|
||||||
|
int btn;
|
||||||
|
|
||||||
res = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint,
|
res = GetEventParameter(inEvent, kEventParamMouseLocation, typeHIPoint,
|
||||||
NULL, sizeof(HIPoint), NULL, &pt);
|
NULL, sizeof(HIPoint), NULL, &pt);
|
||||||
@ -287,14 +298,9 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
|||||||
NULL, sizeof(EventMouseButton), NULL, &button);
|
NULL, sizeof(EventMouseButton), NULL, &button);
|
||||||
if (res) Logger_Abort2(res, "Getting mouse button");
|
if (res) Logger_Abort2(res, "Getting mouse button");
|
||||||
|
|
||||||
switch (button) {
|
btn = MapNativeMouse(button);
|
||||||
case kEventMouseButtonPrimary:
|
if (btn) Input_Set(btn, down); break;
|
||||||
Input_Set(KEY_LMOUSE, down); break;
|
|
||||||
case kEventMouseButtonSecondary:
|
|
||||||
Input_Set(KEY_RMOUSE, down); break;
|
|
||||||
case kEventMouseButtonTertiary:
|
|
||||||
Input_Set(KEY_MMOUSE, down); break;
|
|
||||||
}
|
|
||||||
return eventNotHandledErr;
|
return eventNotHandledErr;
|
||||||
|
|
||||||
case kEventMouseWheelMoved:
|
case kEventMouseWheelMoved:
|
||||||
|
@ -356,6 +356,8 @@ static int MapNativeMouse(int button) {
|
|||||||
if (button == 0) return KEY_LMOUSE;
|
if (button == 0) return KEY_LMOUSE;
|
||||||
if (button == 1) return KEY_RMOUSE;
|
if (button == 1) return KEY_RMOUSE;
|
||||||
if (button == 2) return KEY_MMOUSE;
|
if (button == 2) return KEY_MMOUSE;
|
||||||
|
if (button == 3) return KEY_XBUTTON1;
|
||||||
|
if (button == 4) return KEY_XBUTTON2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user