Skip to content

Commit

Permalink
MacOS: Detect Control key in addition to Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Deltafire committed Apr 7, 2024
1 parent fd29dae commit d3259da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/MilkyTracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ <h2><a id="shortcuts">5. Keyboard shortcuts</a></h2>
By user request, MilkyTracker features two edit modes. You can switch between these in the Config screen (Misc. tab). To learn about the differences and which might better suit you, read the appropriate sections below. There are a couple of shortcuts that are the same for both modes so let's clear those out of the way first:
</p>
<p>
<em>Please note that under Mac OS X the Command key is used instead of the Ctrl key.</em>
<em>Please note that under Mac OS X the Command key can be used in addition to the Ctrl key.</em>
</p>
<table>
<tr >
Expand Down
6 changes: 4 additions & 2 deletions src/tracker/cocoa/MTKeyTranslator.mm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ + (pp_uint16)toVK:(unsigned short) keyCode
case kVK_ANSI_KeypadEnter: return VK_DECIMAL;

// Modifier keys
case kVK_Command: return VK_CONTROL;
case kVK_Command:
case kVK_Control:
case kVK_RightControl: return VK_CONTROL;
case kVK_Option: return VK_ALT;
case kVK_RightCommand: return VK_RMENU; // MilkyTracker uses VK_RMENU for Play Pattern
case kVK_RightOption: return VK_RCONTROL; // and VK_RCONTROL for Play Song
Expand Down Expand Up @@ -208,4 +210,4 @@ + (pp_uint16)toSC:(unsigned short) keyCode
}
}

@end
@end
11 changes: 10 additions & 1 deletion src/tracker/cocoa/MTTrackerView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,16 @@ - (void)flagsChanged:(NSEvent*)theEvent
case kVK_RightCommand:
keyDown = flags & NSCommandKeyMask ? YES : NO;
break;


// Control could RightControl if mapped to an alternative key (ie, Caps-Lock)
case kVK_Control:
case kVK_RightControl:
if (flags & NSEventModifierFlagControl)
setKeyModifier(KeyModifierCTRL);
else
clearKeyModifier(KeyModifierCTRL);
break;

// Only Left Option is used as a modifier
case kVK_Option:
if (flags & NSAlternateKeyMask)
Expand Down

0 comments on commit d3259da

Please sign in to comment.