mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Completes the wiring necessary for capture of the command key.
At least when coupled with mouse capture.
This commit is contained in:
parent
077c7d767f
commit
114f81941e
@ -209,8 +209,10 @@ class MachineDocument:
|
||||
openGLView.delegate = self
|
||||
openGLView.responderDelegate = self
|
||||
|
||||
// If this machine has a mouse, enable mouse capture.
|
||||
// If this machine has a mouse, enable mouse capture; also indicate whether usurption
|
||||
// of the command key is desired.
|
||||
openGLView.shouldCaptureMouse = machine.hasMouse
|
||||
openGLView.shouldUsurpCommand = machine.shouldUsurpCommand
|
||||
|
||||
setupAudioQueueClockRate()
|
||||
|
||||
|
@ -94,6 +94,7 @@ typedef NS_ENUM(NSInteger, CSMachineKeyboardInputMode) {
|
||||
|
||||
// Input control.
|
||||
@property (nonatomic, readonly) BOOL hasExclusiveKeyboard;
|
||||
@property (nonatomic, readonly) BOOL shouldUsurpCommand;
|
||||
@property (nonatomic, readonly) BOOL hasJoystick;
|
||||
@property (nonatomic, readonly) BOOL hasMouse;
|
||||
@property (nonatomic, assign) CSMachineKeyboardInputMode inputMode;
|
||||
|
@ -671,6 +671,14 @@ struct ActivityObserver: public Activity::Observer {
|
||||
return !!_machine->keyboard_machine() && _machine->keyboard_machine()->get_keyboard().is_exclusive();
|
||||
}
|
||||
|
||||
- (BOOL)shouldUsurpCommand {
|
||||
if(!_machine->keyboard_machine()) return NO;
|
||||
|
||||
const auto essential_modifiers = _machine->keyboard_machine()->get_keyboard().get_essential_modifiers();
|
||||
return essential_modifiers.find(Inputs::Keyboard::Key::LeftMeta) != essential_modifiers.end() ||
|
||||
essential_modifiers.find(Inputs::Keyboard::Key::RightMeta) != essential_modifiers.end();
|
||||
}
|
||||
|
||||
#pragma mark - Activity observation
|
||||
|
||||
- (void)addLED:(NSString *)led {
|
||||
|
@ -245,6 +245,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
[NSCursor unhide];
|
||||
[self.delegate openGLViewDidReleaseMouse:self];
|
||||
((CSApplication *)[NSApplication sharedApplication]).keyboardEventDelegate = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@ -304,6 +305,9 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
[NSCursor hide];
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
[self.delegate openGLViewDidCaptureMouse:self];
|
||||
if(self.shouldUsurpCommand) {
|
||||
((CSApplication *)[NSApplication sharedApplication]).keyboardEventDelegate = self;
|
||||
}
|
||||
|
||||
// Don't report the first click to the delegate; treat that as merely
|
||||
// an invitation to capture the cursor.
|
||||
|
Loading…
Reference in New Issue
Block a user