mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-13 07:30:21 +00:00
Starts adding a keyboard.
This commit is contained in:
parent
c284b34003
commit
17e9305282
@ -21,8 +21,10 @@ void Bus::set_device_output(size_t device_id, bool output) {
|
||||
// Modify the all-devices bus state.
|
||||
bus_state_[device_id] = output;
|
||||
|
||||
// React to signal edges only.
|
||||
const bool data_level = get_state();
|
||||
// React to signal edges only; don't use get_state here to avoid
|
||||
// endless recursion should any reactive devices set new output
|
||||
// during the various calls made below.
|
||||
const bool data_level = bus_state_.all();
|
||||
if(data_level_ != data_level) {
|
||||
data_level_ = data_level;
|
||||
|
||||
|
53
Machines/Apple/ADB/Keyboard.cpp
Normal file
53
Machines/Apple/ADB/Keyboard.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
//
|
||||
// Keyboard.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 13/02/2021.
|
||||
// Copyright © 2021 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "Keyboard.hpp"
|
||||
|
||||
using namespace Apple::ADB;
|
||||
|
||||
Keyboard::Keyboard(Bus &bus) : ReactiveDevice(bus, 2) {}
|
||||
|
||||
void Keyboard::perform_command(const Command &command) {
|
||||
if(command.type == Command::Type::Talk) {
|
||||
switch(command.reg) {
|
||||
case 0:
|
||||
// Post up to two key events, or nothing if there are
|
||||
// no events pending.
|
||||
// post_response({0x00, 0x00});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
/*
|
||||
In all cases below: 0 = pressed/on; 1 = released/off.
|
||||
|
||||
b15: None (reserved)
|
||||
b14: Delete
|
||||
b13: Caps lock
|
||||
b12: Reset
|
||||
b11: Control
|
||||
b10: Shift
|
||||
b9: Option
|
||||
b8: Command
|
||||
|
||||
-- From here onwards, available only on the extended keyboard.
|
||||
|
||||
b7: Num lock/clear
|
||||
b6: Scroll lock
|
||||
b5–3: None (reserved)
|
||||
b2: Scroll Lock LED
|
||||
b1: Caps Lock LED
|
||||
b0: Num Lock LED
|
||||
*/
|
||||
post_response({0xff, 0xff});
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
28
Machines/Apple/ADB/Keyboard.hpp
Normal file
28
Machines/Apple/ADB/Keyboard.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
//
|
||||
// Keyboard.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 13/02/2021.
|
||||
// Copyright © 2021 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Keyboard_hpp
|
||||
#define Keyboard_hpp
|
||||
|
||||
#include "ReactiveDevice.hpp"
|
||||
|
||||
namespace Apple {
|
||||
namespace ADB {
|
||||
|
||||
class Keyboard: public ReactiveDevice {
|
||||
public:
|
||||
Keyboard(Bus &);
|
||||
|
||||
private:
|
||||
void perform_command(const Command &command) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* Keyboard_hpp */
|
@ -18,6 +18,7 @@ class Mouse: public ReactiveDevice {
|
||||
public:
|
||||
Mouse(Bus &);
|
||||
|
||||
private:
|
||||
void perform_command(const Command &command) override;
|
||||
};
|
||||
|
||||
|
@ -42,8 +42,9 @@ void ReactiveDevice::advance_state(double microseconds) {
|
||||
}
|
||||
|
||||
// Advance the implied number of bits.
|
||||
bit_offset_ += int(microseconds_at_bit_ / 100);
|
||||
microseconds_at_bit_ -= double(bit_offset_ * 100.0);
|
||||
const int step = int(microseconds_at_bit_ / 100);
|
||||
bit_offset_ += step;
|
||||
microseconds_at_bit_ -= double(step * 100.0);
|
||||
|
||||
// Check for end-of-transmission.
|
||||
if(bit_offset_ >= int(response_.size() * 10)) {
|
||||
|
@ -39,7 +39,12 @@ enum class MicrocontrollerFlags: uint8_t {
|
||||
|
||||
}
|
||||
|
||||
GLU::GLU() : executor_(*this), bus_(HalfCycles(1'789'772)), controller_id_(bus_.add_device()), mouse_(bus_) {}
|
||||
GLU::GLU() :
|
||||
executor_(*this),
|
||||
bus_(HalfCycles(1'789'772)),
|
||||
controller_id_(bus_.add_device()),
|
||||
mouse_(bus_),
|
||||
keyboard_(bus_) {}
|
||||
|
||||
// MARK: - External interface.
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "../ADB/Bus.hpp"
|
||||
#include "../ADB/Mouse.hpp"
|
||||
#include "../ADB/Keyboard.hpp"
|
||||
|
||||
namespace Apple {
|
||||
namespace IIgs {
|
||||
@ -58,8 +59,9 @@ class GLU: public InstructionSet::M50740::PortHandler {
|
||||
Apple::ADB::Bus bus_;
|
||||
size_t controller_id_;
|
||||
|
||||
// TODO: add some other devices, and attach them to the ADB bus.
|
||||
// For now, attach only a keyboard and mouse.
|
||||
Apple::ADB::Mouse mouse_;
|
||||
Apple::ADB::Keyboard keyboard_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -176,6 +176,9 @@
|
||||
4B2E86B825D7490E0024F1E9 /* ReactiveDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E86B525D7490E0024F1E9 /* ReactiveDevice.cpp */; };
|
||||
4B2E86BE25D74F160024F1E9 /* Mouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E86BC25D74F160024F1E9 /* Mouse.cpp */; };
|
||||
4B2E86BF25D74F160024F1E9 /* Mouse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E86BC25D74F160024F1E9 /* Mouse.cpp */; };
|
||||
4B2E86C925D892EF0024F1E9 /* DAT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BE8EB6425C750B50040BC40 /* DAT.cpp */; };
|
||||
4B2E86CF25D8D8C70024F1E9 /* Keyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E86CD25D8D8C70024F1E9 /* Keyboard.cpp */; };
|
||||
4B2E86D025D8D8C70024F1E9 /* Keyboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2E86CD25D8D8C70024F1E9 /* Keyboard.cpp */; };
|
||||
4B302184208A550100773308 /* DiskII.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B302183208A550100773308 /* DiskII.cpp */; };
|
||||
4B302185208A550100773308 /* DiskII.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B302183208A550100773308 /* DiskII.cpp */; };
|
||||
4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B30512B1D989E2200B4FED8 /* Drive.cpp */; };
|
||||
@ -1124,6 +1127,8 @@
|
||||
4B2E86B625D7490E0024F1E9 /* ReactiveDevice.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ReactiveDevice.hpp; sourceTree = "<group>"; };
|
||||
4B2E86BC25D74F160024F1E9 /* Mouse.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Mouse.cpp; sourceTree = "<group>"; };
|
||||
4B2E86BD25D74F160024F1E9 /* Mouse.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Mouse.hpp; sourceTree = "<group>"; };
|
||||
4B2E86CD25D8D8C70024F1E9 /* Keyboard.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Keyboard.cpp; sourceTree = "<group>"; };
|
||||
4B2E86CE25D8D8C70024F1E9 /* Keyboard.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = Keyboard.hpp; sourceTree = "<group>"; };
|
||||
4B302182208A550100773308 /* DiskII.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiskII.hpp; sourceTree = "<group>"; };
|
||||
4B302183208A550100773308 /* DiskII.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiskII.cpp; sourceTree = "<group>"; };
|
||||
4B30512B1D989E2200B4FED8 /* Drive.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Drive.cpp; sourceTree = "<group>"; };
|
||||
@ -4196,11 +4201,13 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4BCE1DEF25D4C3FA00AE7A2B /* Bus.cpp */,
|
||||
4BCE1DF025D4C3FA00AE7A2B /* Bus.hpp */,
|
||||
4B2E86B525D7490E0024F1E9 /* ReactiveDevice.cpp */,
|
||||
4B2E86B625D7490E0024F1E9 /* ReactiveDevice.hpp */,
|
||||
4B2E86CD25D8D8C70024F1E9 /* Keyboard.cpp */,
|
||||
4B2E86BC25D74F160024F1E9 /* Mouse.cpp */,
|
||||
4B2E86B525D7490E0024F1E9 /* ReactiveDevice.cpp */,
|
||||
4BCE1DF025D4C3FA00AE7A2B /* Bus.hpp */,
|
||||
4B2E86CE25D8D8C70024F1E9 /* Keyboard.hpp */,
|
||||
4B2E86BD25D74F160024F1E9 /* Mouse.hpp */,
|
||||
4B2E86B625D7490E0024F1E9 /* ReactiveDevice.hpp */,
|
||||
);
|
||||
path = ADB;
|
||||
sourceTree = "<group>";
|
||||
@ -5037,6 +5044,7 @@
|
||||
4B2E86BF25D74F160024F1E9 /* Mouse.cpp in Sources */,
|
||||
4B6ED2F1208E2F8A0047B343 /* WOZ.cpp in Sources */,
|
||||
4B055AD81FAE9B180060FFFF /* Video.cpp in Sources */,
|
||||
4B2E86D025D8D8C70024F1E9 /* Keyboard.cpp in Sources */,
|
||||
4B89452F201967B4007DE474 /* StaticAnalyser.cpp in Sources */,
|
||||
4B894531201967B4007DE474 /* StaticAnalyser.cpp in Sources */,
|
||||
4B0ACC2D23775819008902D0 /* IntelligentKeyboard.cpp in Sources */,
|
||||
@ -5092,6 +5100,7 @@
|
||||
4B055AED1FAE9BA20060FFFF /* Z80Storage.cpp in Sources */,
|
||||
4B1B88BC202E2EC100B67DFF /* MultiKeyboardMachine.cpp in Sources */,
|
||||
4BC890D4230F86020025A55A /* DirectAccessDevice.cpp in Sources */,
|
||||
4B2E86C925D892EF0024F1E9 /* DAT.cpp in Sources */,
|
||||
4B6AAEAE230E40250078E864 /* Target.cpp in Sources */,
|
||||
4BF437EF209D0F7E008CBD6B /* SegmentParser.cpp in Sources */,
|
||||
4B055AD11FAE9B030060FFFF /* Video.cpp in Sources */,
|
||||
@ -5366,6 +5375,7 @@
|
||||
4B4518841F75E91A00926311 /* UnformattedTrack.cpp in Sources */,
|
||||
4B65086022F4CF8D009C1100 /* Keyboard.cpp in Sources */,
|
||||
4B894528201967B4007DE474 /* Disk.cpp in Sources */,
|
||||
4B2E86CF25D8D8C70024F1E9 /* Keyboard.cpp in Sources */,
|
||||
4BBB70A4202011C2002FE009 /* MultiMediaTarget.cpp in Sources */,
|
||||
4B0ACC02237756ED008902D0 /* Line.cpp in Sources */,
|
||||
4B89453A201967B4007DE474 /* StaticAnalyser.cpp in Sources */,
|
||||
|
@ -62,7 +62,7 @@
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "/Users/thomasharte/Library/Mobile\ Documents/com\~apple\~CloudDocs/Desktop/Soft/Apple\ II/Keplermatik.dsk"
|
||||
isEnabled = "YES">
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "/Users/thomasharte/Library/Mobile\ Documents/com\~apple\~CloudDocs/Desktop/Soft/Apple\ II/WOZs/Prince\ of\ Persia\ side\ A.woz"
|
||||
@ -106,11 +106,11 @@
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--rompath=/Users/thomasharte/Projects/CLK/ROMImages"
|
||||
isEnabled = "YES">
|
||||
isEnabled = "NO">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--help"
|
||||
isEnabled = "NO">
|
||||
isEnabled = "YES">
|
||||
</CommandLineArgument>
|
||||
<CommandLineArgument
|
||||
argument = "--model=cpc6128"
|
||||
|
Loading…
x
Reference in New Issue
Block a user