diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index a153b8144..b85797814 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -814,6 +814,11 @@ inline void Machine::update_display() } } +void Machine::clear_all_keys() +{ + memset(_key_states, 0, sizeof(_key_states)); +} + void Machine::set_key_state(Key key, bool isPressed) { if(key == KeyBreak) diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index dfd8818ac..34db2abe4 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -154,6 +154,7 @@ class Machine: public CPU6502::Processor, Tape::Delegate { void set_tape(std::shared_ptr tape); void set_key_state(Key key, bool isPressed); + void clear_all_keys(); void setup_output(float aspect_ratio); Outputs::CRT::CRT *get_crt() { return _crt.get(); } diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/MainMenu.xib b/OSBindings/Mac/Clock Signal/Base.lproj/MainMenu.xib index ab625aa30..012c3874d 100644 --- a/OSBindings/Mac/Clock Signal/Base.lproj/MainMenu.xib +++ b/OSBindings/Mac/Clock Signal/Base.lproj/MainMenu.xib @@ -342,268 +342,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - Default - - - - - - - Left to Right - - - - - - - Right to Left - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift index bed4fa3d1..4d08e603a 100644 --- a/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/ElectronDocument.swift @@ -117,6 +117,11 @@ class ElectronDocument: MachineDocument { } } + // MARK: NSWindowDelegate + func windowDidResignKey(notification: NSNotification) { + electron.clearAllKeys() + } + // MARK: CSOpenGLViewResponderDelegate override func keyDown(event: NSEvent) { electron.setKey(event.keyCode, isPressed: true) diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index f35970b48..4801f6c86 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -9,7 +9,7 @@ import Cocoa import AudioToolbox -class MachineDocument: NSDocument, CSOpenGLViewDelegate, CSOpenGLViewResponderDelegate { +class MachineDocument: NSDocument, CSOpenGLViewDelegate, CSOpenGLViewResponderDelegate, NSWindowDelegate { @IBOutlet weak var openGLView: CSOpenGLView! { didSet { diff --git a/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.h b/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.h index 8e9f5530f..3b4d45ff3 100644 --- a/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.h +++ b/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.h @@ -17,6 +17,7 @@ - (BOOL)openUEFAtURL:(nonnull NSURL *)URL; - (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed; +- (void)clearAllKeys; - (void)drawViewForPixelSize:(CGSize)pixelSize onlyIfDirty:(BOOL)onlyIfDirty; diff --git a/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.mm b/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.mm index 3943dc360..52607f738 100644 --- a/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.mm +++ b/OSBindings/Mac/Clock Signal/Wrappers/CSElectron.mm @@ -66,6 +66,12 @@ } } +- (void)clearAllKeys { + @synchronized(self) { + _electron.clear_all_keys(); + } +} + - (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed { @synchronized(self) { switch(key) @@ -134,6 +140,7 @@ case VK_Shift: _electron.set_key_state(Electron::Key::KeyShift, isPressed); break; case VK_Control: _electron.set_key_state(Electron::Key::KeyControl, isPressed); break; + case VK_Command: case VK_Option: _electron.set_key_state(Electron::Key::KeyFunc, isPressed); break; case VK_F12: _electron.set_key_state(Electron::Key::KeyBreak, isPressed); break;