1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Makes the Macintosh a mouse machine, and makes mouse machines detectable.

This commit is contained in:
Thomas Harte 2019-06-11 18:21:56 -04:00
parent a0321aa6ff
commit 124c7bcbb0
9 changed files with 42 additions and 11 deletions

View File

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

View File

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

View File

@ -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 <Analyser::Static::Macintosh::Target::Model model> 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 <Analyser::Static::Macintosh::Target::Model model> 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 <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
}
private:
Inputs::Mouse *get_mouse() override {
return &mouse_;
}
struct IWM {
IWM(int clock_rate) : iwm(clock_rate) {}
@ -384,7 +393,6 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
b2b0: 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 <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
int phase_ = 1;
SonyDrive drives_[2];
Inputs::QuadratureMouse mouse_;
uint32_t ram_mask_ = 0;
uint32_t rom_mask_ = 0;

View File

@ -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;
/*!

View File

@ -15,7 +15,7 @@ namespace MouseMachine {
class Machine {
public:
virtual Mouse *get_mouse() = 0;
virtual Inputs::Mouse *get_mouse() = 0;
};
}

View File

@ -45,6 +45,10 @@ template<typename T> class TypedDynamicMachine: public ::Machine::DynamicMachine
return get<KeyboardMachine::Machine>();
}
MouseMachine::Machine *mouse_machine() override {
return get<MouseMachine::Machine>();
}
Configurable::Device *configurable_device() override {
return get<Configurable::Device>();
}

View File

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

View File

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

View File

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