summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-08-29 08:20:04 +0000
committerbjarni <bjarni@openttd.org>2007-08-29 08:20:04 +0000
commit97135f2b7e46e730bbac53572ec37b68d562ede2 (patch)
treed7fa5d349c7dc964b9c846e0b70a567357147c3b /src/video
parent5e5d36d6b4c0d86abc9f8c346bda5254b7f8ba35 (diff)
downloadopenttd-97135f2b7e46e730bbac53572ec37b68d562ede2.tar.xz
(svn r10996) -Feature: [OSX] added more options for right click emulation (controlled from the interface tab in the patch window)
This only works with the cocoa drivers (you will use the cocoa drivers unless you manually switched to SDL and compiled yourself) Note: if control-click is selected, then the ingame control-click (like presignals and such) will be command-click Requested and tested by ln- (so he should be blamed if this goes wrong :P )
Diffstat (limited to 'src/video')
-rw-r--r--src/video/cocoa_v.mm26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/video/cocoa_v.mm b/src/video/cocoa_v.mm
index e410ca0f2..0b9ec1786 100644
--- a/src/video/cocoa_v.mm
+++ b/src/video/cocoa_v.mm
@@ -79,6 +79,14 @@ extern "C" void HideMenuBar();
#undef Point
#undef Rect
+/* Right Mouse Button Emulation enum */
+enum {
+ RMBE_COMMAND,
+ RMBE_CONTROL,
+ RMBE_OFF,
+};
+
+
/* Subclass of NSWindow to fix genie effect and support resize events */
@interface OTTD_QuartzWindow : NSWindow
- (void)miniaturize:(id)sender;
@@ -359,9 +367,9 @@ static uint32 QZ_MapKey(unsigned short sym)
}
if (_cocoa_video_data.current_mods & NSShiftKeyMask) key |= WKC_SHIFT;
- if (_cocoa_video_data.current_mods & NSControlKeyMask) key |= WKC_CTRL;
+ if (_cocoa_video_data.current_mods & NSControlKeyMask) key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META);
if (_cocoa_video_data.current_mods & NSAlternateKeyMask) key |= WKC_ALT;
- if (_cocoa_video_data.current_mods & NSCommandKeyMask) key |= WKC_META;
+ if (_cocoa_video_data.current_mods & NSCommandKeyMask) key |= (_patches.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_META : WKC_CTRL);
return key << 16;
}
@@ -544,8 +552,14 @@ static bool QZ_PollEvent()
break;
case NSLeftMouseDown:
+ {
+ uint32 keymask = 0;
+ if (_patches.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSCommandKeyMask;
+ if (_patches.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSControlKeyMask;
+
pt = QZ_GetMouseLocation(event);
- if (!([ event modifierFlags ] & NSCommandKeyMask) ||
+
+ if (!([ event modifierFlags ] & keymask) ||
!QZ_MouseIsInsideView(&pt)) {
[NSApp sendEvent:event];
}
@@ -559,14 +573,14 @@ static bool QZ_PollEvent()
QZ_MouseMovedEvent((int)pt.x, (int)pt.y);
/* Right mouse button emulation */
- if ([ event modifierFlags ] & NSCommandKeyMask) {
+ if ([ event modifierFlags ] & keymask) {
_cocoa_video_data.emulating_right_button = true;
QZ_MouseButtonEvent(1, YES);
} else {
QZ_MouseButtonEvent(0, YES);
}
break;
-
+ }
case NSLeftMouseUp:
[NSApp sendEvent:event];
@@ -750,7 +764,7 @@ static void QZ_GameLoop()
last_cur_ticks = cur_ticks;
next_tick = cur_ticks + 30;
- _ctrl_pressed = !!(_cocoa_video_data.current_mods & NSControlKeyMask);
+ _ctrl_pressed = !!(_cocoa_video_data.current_mods & ( _patches.right_mouse_btn_emulation != RMBE_CONTROL ? NSControlKeyMask : NSCommandKeyMask));
_shift_pressed = !!(_cocoa_video_data.current_mods & NSShiftKeyMask);
GameLoop();