(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 )
pull/155/head
bjarni 17 years ago
parent 5e5d36d6b4
commit 97135f2b7e

@ -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}

@ -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),

@ -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",

@ -225,6 +225,8 @@ struct Patches {
/** YAPF settings */
YapfSettings yapf;
uint8 right_mouse_btn_emulation;
uint8 scrollwheel_scrolling;
uint8 scrollwheel_multiplier;

@ -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();

Loading…
Cancel
Save