diff options
author | bjarni <bjarni@openttd.org> | 2007-08-29 08:20:04 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2007-08-29 08:20:04 +0000 |
commit | 97135f2b7e46e730bbac53572ec37b68d562ede2 (patch) | |
tree | d7fa5d349c7dc964b9c846e0b70a567357147c3b | |
parent | 5e5d36d6b4c0d86abc9f8c346bda5254b7f8ba35 (diff) | |
download | openttd-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 )
-rw-r--r-- | src/lang/english.txt | 6 | ||||
-rw-r--r-- | src/settings.cpp | 4 | ||||
-rw-r--r-- | src/settings_gui.cpp | 4 | ||||
-rw-r--r-- | src/variables.h | 2 | ||||
-rw-r--r-- | src/video/cocoa_v.mm | 26 |
5 files changed, 36 insertions, 6 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt index abe97466a..57a13f4ec 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1103,6 +1103,12 @@ STR_CONFIG_PATCHES_SCROLLWHEEL_ZOOM :Zoom map STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLL :Scroll map STR_CONFIG_PATCHES_SCROLLWHEEL_OFF :Off STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER :{LTBLUE}Map scrollwheel speed: {ORANGE}{STRING1} + +STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU :{LTBLUE}Right-click emulation: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND :Command-click +STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL :Control-click +STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF :Off + STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING1} STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING1} STR_CONFIG_PATCHES_LOADING_INDICATORS :{LTBLUE}Use loading indicators: {ORANGE}{STRING1} diff --git a/src/settings.cpp b/src/settings.cpp index 1a64381bc..7a61d2404 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1348,6 +1348,10 @@ const SettingDesc _patch_settings[] = { SDT_BOOL(Patches, prefer_teamchat, S, 0, false, STR_CONFIG_PATCHES_PREFER_TEAMCHAT, NULL), SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL), SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5, 1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL), +#ifdef __APPLE__ + /* We might need to emulate a right mouse button on mac */ + SDT_VAR(Patches,right_mouse_btn_emulation,SLE_UINT8,S,MS,0, 0, 2, 0, STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU, NULL), +#endif SDT_BOOL(Patches, pause_on_newgame, S, 0, false, STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME, NULL), SDT_BOOL(Patches, advanced_vehicle_list, S, 0, true, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS, NULL), SDT_BOOL(Patches, timetable_in_ticks, S, 0, false, STR_CONFIG_PATCHES_TIMETABLE_IN_TICKS, NULL), diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 1802e2739..72066c7aa 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -650,6 +650,10 @@ static const char *_patches_ui[] = { * Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */ "scrollwheel_scrolling", "scrollwheel_multiplier", +#ifdef __APPLE__ + /* We might need to emulate a right mouse button on mac */ + "right_mouse_btn_emulation", +#endif "pause_on_newgame", "advanced_vehicle_list", "loading_indicators", diff --git a/src/variables.h b/src/variables.h index 1d3acfb1a..83b991574 100644 --- a/src/variables.h +++ b/src/variables.h @@ -225,6 +225,8 @@ struct Patches { /** YAPF settings */ YapfSettings yapf; + uint8 right_mouse_btn_emulation; + uint8 scrollwheel_scrolling; uint8 scrollwheel_multiplier; 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(); |