diff --git a/Analyser/Dynamic/MultiMachine/MultiMachine.cpp b/Analyser/Dynamic/MultiMachine/MultiMachine.cpp index ba6328b31..4f057c3cf 100644 --- a/Analyser/Dynamic/MultiMachine/MultiMachine.cpp +++ b/Analyser/Dynamic/MultiMachine/MultiMachine.cpp @@ -59,6 +59,11 @@ KeyboardMachine::Machine *MultiMachine::keyboard_machine() { } } +MouseMachine::Machine *MultiMachine::mouse_machine() { + // TODO. + return nullptr; +} + Configurable::Device *MultiMachine::configurable_device() { if(has_picked_) { return machines_.front()->configurable_device(); diff --git a/Analyser/Dynamic/MultiMachine/MultiMachine.hpp b/Analyser/Dynamic/MultiMachine/MultiMachine.hpp index e520c6fad..464c80b0d 100644 --- a/Analyser/Dynamic/MultiMachine/MultiMachine.hpp +++ b/Analyser/Dynamic/MultiMachine/MultiMachine.hpp @@ -54,6 +54,7 @@ class MultiMachine: public ::Machine::DynamicMachine, public MultiCRTMachine::De Configurable::Device *configurable_device() override; CRTMachine::Machine *crt_machine() override; JoystickMachine::Machine *joystick_machine() override; + MouseMachine::Machine *mouse_machine() override; KeyboardMachine::Machine *keyboard_machine() override; MediaTarget::Machine *media_target() override; void *raw_pointer() override; diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index e71cd4ec5..7b77edab9 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -19,8 +19,11 @@ #include "../../CRTMachine.hpp" #include "../../MediaTarget.hpp" +#include "../../MouseMachine.hpp" -#define LOG_TRACE +#include "../../../Inputs/QuadratureMouse/QuadratureMouse.hpp" + +//#define LOG_TRACE #include "../../../Components/6522/6522.hpp" #include "../../../Components/8530/z8530.hpp" @@ -44,6 +47,7 @@ template class ConcreteMachin public Machine, public CRTMachine::Machine, public MediaTarget::Machine, + public MouseMachine::Machine, public CPU::MC68000::BusHandler { public: using Target = Analyser::Static::Macintosh::Target; @@ -57,7 +61,8 @@ template class ConcreteMachin drives_{ {CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke}, {CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke} - } { + }, + mouse_(1) { // Select a ROM name and determine the proper ROM and RAM sizes // based on the machine model. @@ -348,6 +353,10 @@ template class ConcreteMachin } private: + Inputs::Mouse *get_mouse() override { + return &mouse_; + } + struct IWM { IWM(int clock_rate) : iwm(clock_rate) {} @@ -384,7 +393,6 @@ template class ConcreteMachin b2–b0: audio output volume */ iwm_.flush(); - printf("{SEL: %c} ", (value & 0x20) ? 't' : 'f'); iwm_.iwm.set_select(!!(value & 0x20)); machine_.set_use_alternate_buffers(!(value & 0x40), !(value&0x08)); @@ -487,6 +495,7 @@ template class ConcreteMachin int phase_ = 1; SonyDrive drives_[2]; + Inputs::QuadratureMouse mouse_; uint32_t ram_mask_ = 0; uint32_t rom_mask_ = 0; diff --git a/Machines/DynamicMachine.hpp b/Machines/DynamicMachine.hpp index bcc59b965..0f888b89e 100644 --- a/Machines/DynamicMachine.hpp +++ b/Machines/DynamicMachine.hpp @@ -11,10 +11,13 @@ #include "../Configurable/Configurable.hpp" #include "../Activity/Source.hpp" -#include "MediaTarget.hpp" + #include "CRTMachine.hpp" #include "JoystickMachine.hpp" #include "KeyboardMachine.hpp" +#include "MediaTarget.hpp" +#include "MouseMachine.hpp" + #include "Utility/Typer.hpp" namespace Machine { @@ -31,6 +34,7 @@ struct DynamicMachine { virtual CRTMachine::Machine *crt_machine() = 0; virtual JoystickMachine::Machine *joystick_machine() = 0; virtual KeyboardMachine::Machine *keyboard_machine() = 0; + virtual MouseMachine::Machine *mouse_machine() = 0; virtual MediaTarget::Machine *media_target() = 0; /*! diff --git a/Machines/MouseMachine.hpp b/Machines/MouseMachine.hpp index ef2029359..7b4ce9a9d 100644 --- a/Machines/MouseMachine.hpp +++ b/Machines/MouseMachine.hpp @@ -15,7 +15,7 @@ namespace MouseMachine { class Machine { public: - virtual Mouse *get_mouse() = 0; + virtual Inputs::Mouse *get_mouse() = 0; }; } diff --git a/Machines/Utility/TypedDynamicMachine.hpp b/Machines/Utility/TypedDynamicMachine.hpp index a559c94e0..e9f3382a2 100644 --- a/Machines/Utility/TypedDynamicMachine.hpp +++ b/Machines/Utility/TypedDynamicMachine.hpp @@ -45,6 +45,10 @@ template class TypedDynamicMachine: public ::Machine::DynamicMachine return get(); } + MouseMachine::Machine *mouse_machine() override { + return get(); + } + Configurable::Device *configurable_device() override { return get(); } diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 4d89fc503..0561eea8a 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -72,13 +72,13 @@ class MachineDocument: fileprivate func setupMachineOutput() { if let machine = self.machine, let openGLView = self.openGLView { - // establish the output aspect ratio and audio + // Establish the output aspect ratio and audio. let aspectRatio = self.aspectRatio() openGLView.perform(glContext: { machine.setView(openGLView, aspectRatio: Float(aspectRatio.width / aspectRatio.height)) }) - // attach an options panel if one is available + // Attach an options panel if one is available. if let optionsPanelNibName = self.optionsPanelNibName { Bundle.main.loadNibNamed(optionsPanelNibName, owner: self, topLevelObjects: nil) self.optionsPanel.machine = machine @@ -89,19 +89,22 @@ class MachineDocument: machine.delegate = self self.bestEffortUpdater = CSBestEffortUpdater() - // callbacks from the OpenGL may come on a different thread, immediately following the .delegate set; - // hence the full setup of the best-effort updater prior to setting self as a delegate + // Callbacks from the OpenGL may come on a different thread, immediately following the .delegate set; + // hence the full setup of the best-effort updater prior to setting self as a delegate. openGLView.delegate = self openGLView.responderDelegate = self + // If this machine has a mouse, enable mouse capture. + openGLView.shouldCaptureMouse = machine.hasMouse + setupAudioQueueClockRate() - // bring OpenGL view-holding window on top of the options panel and show the content + // Bring OpenGL view-holding window on top of the options panel and show the content. openGLView.isHidden = false openGLView.window!.makeKeyAndOrderFront(self) openGLView.window!.makeFirstResponder(openGLView) - // start accepting best effort updates + // Start accepting best effort updates. self.bestEffortUpdater!.delegate = self } } diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.h b/OSBindings/Mac/Clock Signal/Machine/CSMachine.h index ca824bbc3..f51f49cf6 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.h +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.h @@ -81,6 +81,7 @@ typedef NS_ENUM(NSInteger, CSMachineKeyboardInputMode) { // Input control. @property (nonatomic, readonly) BOOL hasExclusiveKeyboard; @property (nonatomic, readonly) BOOL hasJoystick; +@property (nonatomic, readonly) BOOL hasMouse; @property (nonatomic, assign) CSMachineKeyboardInputMode inputMode; @property (nonatomic, nullable) CSJoystickManager *joystickManager; diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index c43535b04..c65169366 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -540,6 +540,10 @@ struct ActivityObserver: public Activity::Observer { return !!_machine->joystick_machine(); } +- (BOOL)hasMouse { + return !!_machine->mouse_machine(); +} + - (BOOL)hasExclusiveKeyboard { return !!_machine->keyboard_machine() && _machine->keyboard_machine()->get_keyboard().is_exclusive(); }