From 9fb9d9243781652a75ad066dde81aa8a4606302a Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 5 Nov 2016 14:47:09 -0400 Subject: [PATCH 1/4] Made the typer much more able to help out, and thereby tidied and separated the Oric's typer. --- Machines/Commodore/Vic-20/Vic20.cpp | 2 +- Machines/Commodore/Vic-20/Vic20.hpp | 4 +- Machines/Electron/Electron.cpp | 2 +- Machines/Electron/Electron.hpp | 2 +- Machines/KeyboardMachine.hpp | 22 +++++ Machines/Oric/Oric.cpp | 87 +------------------ Machines/Oric/Oric.hpp | 10 +-- Machines/Oric/Typer.cpp | 82 +++++++++++++++++ Machines/Typer.cpp | 44 +++++++++- Machines/Typer.hpp | 18 +++- .../Clock Signal.xcodeproj/project.pbxproj | 6 ++ 11 files changed, 178 insertions(+), 101 deletions(-) create mode 100644 Machines/KeyboardMachine.hpp create mode 100644 Machines/Oric/Typer.cpp diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index ea221d001..5f11246d5 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -535,7 +535,7 @@ KeyboardVIA::KeyboardVIA() : _portB(0xff) clear_all_keys(); } -void KeyboardVIA::set_key_state(Key key, bool isPressed) +void KeyboardVIA::set_key_state(uint16_t key, bool isPressed) { if(isPressed) _columns[key & 7] &= ~(key >> 3); diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 8ee08f753..9d1b06110 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -98,7 +98,7 @@ class KeyboardVIA: public MOS::MOS6522, public MOS::MOS6522IRQDeleg KeyboardVIA(); using MOS6522IRQDelegate::set_interrupt_status; - void set_key_state(Key key, bool isPressed); + void set_key_state(uint16_t key, bool isPressed); void clear_all_keys(); // to satisfy MOS::MOS6522 @@ -157,7 +157,7 @@ class Machine: // void set_tape(std::shared_ptr tape); // void set_disk(std::shared_ptr disk); - void set_key_state(Key key, bool isPressed) { _keyboardVIA->set_key_state(key, isPressed); } + void set_key_state(uint16_t key, bool isPressed) { _keyboardVIA->set_key_state(key, isPressed); } void clear_all_keys() { _keyboardVIA->clear_all_keys(); } void set_joystick_state(JoystickInput input, bool isPressed) { _userPortVIA->set_joystick_state(input, isPressed); diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 89f654eb9..8457a59b1 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -916,7 +916,7 @@ void Machine::clear_all_keys() memset(_key_states, 0, sizeof(_key_states)); } -void Machine::set_key_state(Key key, bool isPressed) +void Machine::set_key_state(uint16_t key, bool isPressed) { if(key == KeyBreak) { diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 12c8fbd24..b7b02cd61 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -149,7 +149,7 @@ class Machine: void set_rom(ROMSlot slot, std::vector data, bool is_writeable); - void set_key_state(Key key, bool isPressed); + void set_key_state(uint16_t key, bool isPressed); void clear_all_keys(); inline void set_use_fast_tape_hack(bool activate) { _use_fast_tape_hack = activate; } diff --git a/Machines/KeyboardMachine.hpp b/Machines/KeyboardMachine.hpp new file mode 100644 index 000000000..a5aa972b7 --- /dev/null +++ b/Machines/KeyboardMachine.hpp @@ -0,0 +1,22 @@ +// +// KeyboardMachine.h +// Clock Signal +// +// Created by Thomas Harte on 05/11/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#ifndef KeyboardMachine_h +#define KeyboardMachine_h + +namespace KeyboardMachine { + +class Machine { + public: + virtual void set_key_state(uint16_t key, bool isPressed) = 0; + virtual void clear_all_keys() = 0; +}; + +} + +#endif /* KeyboardMachine_h */ diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 13bf6b9c7..ac7c4a1e4 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -119,7 +119,7 @@ void Machine::mos6522_did_change_interrupt_status(void *mos6522) set_irq_line(_via.get_interrupt_line()); } -void Machine::set_key_state(Key key, bool isPressed) +void Machine::set_key_state(uint16_t key, bool isPressed) { if(key == KeyNMI) { @@ -165,91 +165,6 @@ void Machine::run_for_cycles(int number_of_cycles) CPU6502::Processor::run_for_cycles(number_of_cycles); } -#pragma mark - Automatic typing - -bool Machine::typer_set_next_character(::Utility::Typer *typer, char character, int phase) -{ - if(!phase) clear_all_keys(); - - // The following table is arranged in ASCII order - Key key_sequences[][3] = { - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {KeyDelete, TerminateSequence}, - {NotMapped}, - {KeyReturn, TerminateSequence}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - - {KeySpace, TerminateSequence}, // space - - {KeyLeftShift, Key1, TerminateSequence}, {KeyLeftShift, KeyQuote, TerminateSequence}, // !, " - {KeyLeftShift, Key3, TerminateSequence}, {KeyLeftShift, Key4, TerminateSequence}, // #, $ - {KeyLeftShift, Key5, TerminateSequence}, {KeyLeftShift, Key7, TerminateSequence}, // %, & - {KeyQuote, TerminateSequence}, {KeyLeftShift, Key9, TerminateSequence}, // ', ( - {KeyLeftShift, Key0, TerminateSequence}, {KeyLeftShift, Key8, TerminateSequence}, // ), * - {KeyLeftShift, KeyEquals, TerminateSequence}, {KeyComma, TerminateSequence}, // +, , - {KeyMinus, TerminateSequence}, {KeyFullStop, TerminateSequence}, // -, . - {KeyForwardSlash, TerminateSequence}, // / - - {Key0, TerminateSequence}, {Key1, TerminateSequence}, // 0, 1 - {Key2, TerminateSequence}, {Key3, TerminateSequence}, // 2, 3 - {Key4, TerminateSequence}, {Key5, TerminateSequence}, // 4, 5 - {Key6, TerminateSequence}, {Key7, TerminateSequence}, // 6, 7 - {Key8, TerminateSequence}, {Key9, TerminateSequence}, // 8, 9 - - {KeyLeftShift, KeySemiColon, TerminateSequence}, {KeySemiColon, TerminateSequence}, // :, ; - {KeyLeftShift, KeyComma, TerminateSequence}, {KeyEquals, TerminateSequence}, // <, = - {KeyLeftShift, KeyFullStop, TerminateSequence}, {KeyLeftShift, KeyForwardSlash, TerminateSequence}, // >, ? - {KeyLeftShift, Key2, TerminateSequence}, // @ - - {KeyLeftShift, KeyA, TerminateSequence}, {KeyLeftShift, KeyB, TerminateSequence}, {KeyLeftShift, KeyC, TerminateSequence}, {KeyLeftShift, KeyD, TerminateSequence}, // A, B, C, D - {KeyLeftShift, KeyE, TerminateSequence}, {KeyLeftShift, KeyF, TerminateSequence}, {KeyLeftShift, KeyG, TerminateSequence}, {KeyLeftShift, KeyH, TerminateSequence}, // E, F, G, H - {KeyLeftShift, KeyI, TerminateSequence}, {KeyLeftShift, KeyJ, TerminateSequence}, {KeyLeftShift, KeyK, TerminateSequence}, {KeyLeftShift, KeyL, TerminateSequence}, // I, J, K L - {KeyLeftShift, KeyM, TerminateSequence}, {KeyLeftShift, KeyN, TerminateSequence}, {KeyLeftShift, KeyO, TerminateSequence}, {KeyLeftShift, KeyP, TerminateSequence}, // M, N, O, P - {KeyLeftShift, KeyQ, TerminateSequence}, {KeyLeftShift, KeyR, TerminateSequence}, {KeyLeftShift, KeyS, TerminateSequence}, {KeyLeftShift, KeyT, TerminateSequence}, // Q, R, S, T - {KeyLeftShift, KeyU, TerminateSequence}, {KeyLeftShift, KeyV, TerminateSequence}, {KeyLeftShift, KeyW, TerminateSequence}, {KeyLeftShift, KeyX, TerminateSequence}, // U, V, W X - {KeyLeftShift, KeyY, TerminateSequence}, {KeyLeftShift, KeyZ, TerminateSequence}, // Y, Z - - {KeyOpenSquare, TerminateSequence}, {KeyBackSlash, TerminateSequence}, // [, '\' - {KeyCloseSquare, TerminateSequence}, {KeyLeftShift, Key6, TerminateSequence}, // ], ^ - {NotMapped}, {NotMapped}, // _, ` - - {KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D - {KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H - {KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L - {KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P - {KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T - {KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X - {KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z - - {KeyLeftShift, KeyOpenSquare, TerminateSequence}, {KeyLeftShift, KeyBackSlash, TerminateSequence}, // {, | - {KeyLeftShift, KeyCloseSquare, TerminateSequence}, // }, ~ - }; - Key *key_sequence = nullptr; - - character &= 0x7f; - if(character < sizeof(key_sequences) / sizeof(*key_sequences)) - { - key_sequence = key_sequences[character]; - - if(key_sequence[0] != NotMapped) - { - if(phase) - { - set_key_state(key_sequence[phase-1], true); - return key_sequence[phase] == TerminateSequence; - } - else - return false; - } - } - - return true; -} - #pragma mark - The 6522 Machine::VIA::VIA() : MOS::MOS6522(), _cycles_since_ay_update(0) {} diff --git a/Machines/Oric/Oric.hpp b/Machines/Oric/Oric.hpp index 697dfe706..d020dd3c6 100644 --- a/Machines/Oric/Oric.hpp +++ b/Machines/Oric/Oric.hpp @@ -45,9 +45,9 @@ enum Key: uint16_t { KeyEquals = 0x0700 | 0x80, KeyReturn = 0x0700 | 0x20, KeyRightShift = 0x0700 | 0x10, KeyForwardSlash = 0x0700 | 0x08, Key0 = 0x0700 | 0x04, KeyL = 0x0700 | 0x02, Key8 = 0x0700 | 0x01, - KeyNMI = 0xffff, + KeyNMI = 0xfffd, - TerminateSequence = 0xfffe, NotMapped = 0xfffc + TerminateSequence = 0xffff, NotMapped = 0xfffe }; class Machine: @@ -62,7 +62,7 @@ class Machine: Machine(); void set_rom(std::vector data); - void set_key_state(Key key, bool isPressed); + void set_key_state(uint16_t key, bool isPressed); void clear_all_keys(); void set_use_fast_tape_hack(bool activate); @@ -87,8 +87,8 @@ class Machine: // to satisfy Storage::Tape::BinaryTapePlayer::Delegate void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player); - // for Utility::TypeRecipient - virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase); + // for Utility::TypeRecipient::Delegate + uint16_t *sequence_for_character(Utility::Typer *typer, char character); private: // RAM and ROM diff --git a/Machines/Oric/Typer.cpp b/Machines/Oric/Typer.cpp new file mode 100644 index 000000000..492068880 --- /dev/null +++ b/Machines/Oric/Typer.cpp @@ -0,0 +1,82 @@ +#include "Oric.hpp" + +uint16_t *Oric::Machine::sequence_for_character(Utility::Typer *typer, char character) +{ +#define KEYS(...) {__VA_ARGS__, TerminateSequence} +#define SHIFT(...) {KeyLeftShift, __VA_ARGS__, TerminateSequence} +#define X {NotMapped} + + // The following table is arranged in ASCII order + static Key key_sequences[][3] = { + /* NUL */ X, /* SOH */ X, + /* STX */ X, /* ETX */ X, + /* EOT */ X, /* ENQ */ X, + /* ACK */ X, /* BEL */ X, + /* BS */ KEYS(KeyDelete), /* HT */ X, + /* LF */ KEYS(KeyReturn), /* VT */ X, + /* FF */ X, /* CR */ X, + /* SO */ X, /* SI */ X, + /* DLE */ X, /* DC1 */ X, + /* DC2 */ X, /* DC3 */ X, + /* DC4 */ X, /* NAK */ X, + /* SYN */ X, /* ETB */ X, + /* CAN */ X, /* EM */ X, + /* SUB */ X, /* ESC */ X, + /* FS */ X, /* GS */ X, + /* RS */ X, /* US */ X, + /* space */ KEYS(KeySpace), /* ! */ SHIFT(Key1), + /* " */ SHIFT(KeyQuote), /* # */ SHIFT(Key3), + /* $ */ SHIFT(Key4), /* % */ SHIFT(Key5), + /* & */ SHIFT(Key7), /* ' */ KEYS(KeyQuote), + /* ( */ SHIFT(Key9), /* ) */ SHIFT(Key0), + /* * */ SHIFT(Key8), /* + */ SHIFT(KeyEquals), + /* , */ KEYS(KeyComma), /* - */ KEYS(KeyMinus), + /* . */ KEYS(KeyFullStop), /* / */ KEYS(KeyForwardSlash), + /* 0 */ KEYS(Key0), /* 1 */ KEYS(Key1), + /* 2 */ KEYS(Key2), /* 3 */ KEYS(Key3), + /* 4 */ KEYS(Key4), /* 5 */ KEYS(Key5), + /* 6 */ KEYS(Key6), /* 7 */ KEYS(Key7), + /* 8 */ KEYS(Key8), /* 9 */ KEYS(Key9), + /* : */ SHIFT(KeySemiColon), /* ; */ KEYS(KeySemiColon), + /* < */ SHIFT(KeyComma), /* = */ KEYS(KeyEquals), + /* > */ SHIFT(KeyFullStop), /* ? */ SHIFT(KeyForwardSlash), + /* @ */ SHIFT(Key2), /* A */ SHIFT(KeyA), + /* B */ SHIFT(KeyB), /* C */ SHIFT(KeyC), + /* D */ SHIFT(KeyD), /* E */ SHIFT(KeyE), + /* F */ SHIFT(KeyF), /* G */ SHIFT(KeyG), + /* H */ SHIFT(KeyH), /* I */ SHIFT(KeyI), + /* J */ SHIFT(KeyJ), /* K */ SHIFT(KeyK), + /* L */ SHIFT(KeyL), /* M */ SHIFT(KeyM), + /* N */ SHIFT(KeyN), /* O */ SHIFT(KeyO), + /* P */ SHIFT(KeyP), /* Q */ SHIFT(KeyQ), + /* R */ SHIFT(KeyR), /* S */ SHIFT(KeyS), + /* T */ SHIFT(KeyT), /* U */ SHIFT(KeyU), + /* V */ SHIFT(KeyV), /* W */ SHIFT(KeyW), + /* X */ SHIFT(KeyX), /* Y */ SHIFT(KeyY), + /* Z */ SHIFT(KeyZ), /* [ */ KEYS(KeyOpenSquare), + /* \ */ KEYS(KeyBackSlash), /* ] */ KEYS(KeyCloseSquare), + /* ^ */ SHIFT(Key6), /* _ */ X, + /* ` */ X, /* a */ KEYS(KeyA), + /* b */ KEYS(KeyB), /* c */ KEYS(KeyC), + /* d */ KEYS(KeyD), /* e */ KEYS(KeyE), + /* f */ KEYS(KeyF), /* g */ KEYS(KeyG), + /* h */ KEYS(KeyH), /* i */ KEYS(KeyI), + /* j */ KEYS(KeyJ), /* k */ KEYS(KeyK), + /* l */ KEYS(KeyL), /* m */ KEYS(KeyM), + /* n */ KEYS(KeyN), /* o */ KEYS(KeyO), + /* p */ KEYS(KeyP), /* q */ KEYS(KeyQ), + /* r */ KEYS(KeyR), /* s */ KEYS(KeyS), + /* t */ KEYS(KeyT), /* u */ KEYS(KeyU), + /* v */ KEYS(KeyV), /* w */ KEYS(KeyW), + /* x */ KEYS(KeyX), /* y */ KEYS(KeyY), + /* z */ KEYS(KeyZ), /* { */ SHIFT(KeyOpenSquare), + /* | */ SHIFT(KeyBackSlash), /* } */ SHIFT(KeyCloseSquare), + }; +#undef KEYS +#undef SHIFT +#undef X + + if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; + if(key_sequences[character][0] == NotMapped) return nullptr; + return (uint16_t *)key_sequences[character]; +} diff --git a/Machines/Typer.cpp b/Machines/Typer.cpp index a17935280..ac074240e 100644 --- a/Machines/Typer.cpp +++ b/Machines/Typer.cpp @@ -12,7 +12,12 @@ using namespace Utility; Typer::Typer(const char *string, int delay, int frequency, Delegate *delegate) : - _counter(-delay), _frequency(frequency), _string(strdup(string)), _string_pointer(0), _delegate(delegate), _phase(0) {} + _counter(-delay), _frequency(frequency), _string_pointer(0), _delegate(delegate), _phase(0) +{ + size_t string_size = strlen(string) + 3; + _string = (char *)malloc(string_size); + snprintf(_string, strlen(string) + 3, "%c%s%c", Typer::BeginString, string, Typer::EndString); +} void Typer::update(int duration) { @@ -20,14 +25,20 @@ void Typer::update(int duration) { if(_counter < 0 && _counter + duration >= 0) { - type_next_character(); + if(!type_next_character()) + { + _delegate->typer_reset(this); + } } _counter += duration; while(_string && _counter > _frequency) { _counter -= _frequency; - type_next_character(); + if(!type_next_character()) + { + _delegate->typer_reset(this); + } } } } @@ -60,3 +71,30 @@ Typer::~Typer() { free(_string); } + +#pragma mark - Delegate + +bool Typer::Delegate::typer_set_next_character(Utility::Typer *typer, char character, int phase) +{ + uint16_t *sequence = sequence_for_character(typer, character); + if(!sequence) return true; + + if(!phase) clear_all_keys(); + else + { + set_key_state(sequence[phase - 1], true); + return sequence[phase] == Typer::Delegate::EndSequence; + } + + return false; +} + +void Typer::Delegate::typer_reset(Typer *typer) +{ + clear_all_keys(); +} + +uint16_t *Typer::Delegate::sequence_for_character(Typer *typer, char character) +{ + return nullptr; +} diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index 229c5dd05..e6b172e15 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -10,14 +10,20 @@ #define Typer_hpp #include +#include "KeyboardMachine.hpp" namespace Utility { class Typer { public: - class Delegate { + class Delegate: public KeyboardMachine::Machine { public: - virtual bool typer_set_next_character(Typer *typer, char character, int phase) = 0; + virtual bool typer_set_next_character(Typer *typer, char character, int phase); + virtual void typer_reset(Typer *typer); + + virtual uint16_t *sequence_for_character(Typer *typer, char character); + + const uint16_t EndSequence = 0xffff; }; Typer(const char *string, int delay, int frequency, Delegate *delegate); @@ -25,6 +31,9 @@ class Typer { void update(int duration); bool type_next_character(); + const char BeginString = 0x02; // i.e. ASCII start of text + const char EndString = 0x03; // i.e. ASCII end of text + private: char *_string; int _frequency; @@ -41,6 +50,11 @@ class TypeRecipient: public Typer::Delegate { _typer.reset(new Typer(string, get_typer_delay(), get_typer_frequency(), this)); } + void typer_reset(Typer *typer) + { + _typer.reset(); + } + protected: virtual int get_typer_delay() { return 0; } virtual int get_typer_frequency() { return 0; } diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 0a212894a..e3918bc36 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -357,6 +357,7 @@ 4BC76E691C98E31700E6EF73 /* FIRFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC76E671C98E31700E6EF73 /* FIRFilter.cpp */; }; 4BC76E6B1C98F43700E6EF73 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */; }; 4BC830D11D6E7C690000A26F /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC830CF1D6E7C690000A26F /* Tape.cpp */; }; + 4BC8A62A1DCE4F2700DAC693 /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */; }; 4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC91B811D1F160E00884B76 /* CommodoreTAP.cpp */; }; 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; }; 4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; }; @@ -494,6 +495,7 @@ 4B69FB451C4D950F00B5F0AA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 4B6C73BB1D387AE500AFCFCA /* DiskController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DiskController.cpp; sourceTree = ""; }; 4B6C73BC1D387AE500AFCFCA /* DiskController.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DiskController.hpp; sourceTree = ""; }; + 4B8E4ECD1DCE483D003716C3 /* KeyboardMachine.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = KeyboardMachine.hpp; sourceTree = ""; }; 4B8FE2141DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/Atari2600Options.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE2161DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/MachineDocument.xib"; sourceTree = SOURCE_ROOT; }; 4B8FE2181DA19D5F0090D3CE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = "Clock Signal/Base.lproj/ElectronOptions.xib"; sourceTree = SOURCE_ROOT; }; @@ -830,6 +832,7 @@ 4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; }; 4BC830CF1D6E7C690000A26F /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Commodore/Tape.cpp; sourceTree = ""; }; 4BC830D01D6E7C690000A26F /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Commodore/Tape.hpp; sourceTree = ""; }; + 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Typer.cpp; path = Oric/Typer.cpp; sourceTree = ""; }; 4BC91B811D1F160E00884B76 /* CommodoreTAP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommodoreTAP.cpp; sourceTree = ""; }; 4BC91B821D1F160E00884B76 /* CommodoreTAP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CommodoreTAP.hpp; sourceTree = ""; }; 4BC9DF441D044FCA00F44158 /* ROMImages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ROMImages; path = ../../../../ROMImages; sourceTree = ""; }; @@ -1607,6 +1610,7 @@ 4B1E85731D170228001EF87D /* Typer.cpp */, 4BA9C3CF1D8164A9002DDB61 /* ConfigurationTarget.hpp */, 4B046DC31CFE651500E9E45E /* CRTMachine.hpp */, + 4B8E4ECD1DCE483D003716C3 /* KeyboardMachine.hpp */, 4B2A33291DB8544D002876E3 /* MemoryFuzzer.hpp */, 4B1E85741D170228001EF87D /* Typer.hpp */, 4B2E2D961C3A06EC00138695 /* Atari2600 */, @@ -1720,6 +1724,7 @@ 4BCF1FA31DADC3DD0039D2E7 /* Oric.hpp */, 4B2BFDB01DAEF5FF001A68B8 /* Video.cpp */, 4B2BFDB11DAEF5FF001A68B8 /* Video.hpp */, + 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */, ); name = Oric; sourceTree = ""; @@ -2270,6 +2275,7 @@ 4B1E85751D170228001EF87D /* Typer.cpp in Sources */, 4BF829631D8F536B001BAE39 /* SSD.cpp in Sources */, 4B2E2D9D1C3A070400138695 /* Electron.cpp in Sources */, + 4BC8A62A1DCE4F2700DAC693 /* Typer.cpp in Sources */, 4B3940E71DA83C8300427841 /* AsyncTaskQueue.cpp in Sources */, 4BAB62B81D3302CA00DF5BA0 /* PCMTrack.cpp in Sources */, 4B69FB3D1C4D908A00B5F0AA /* Tape.cpp in Sources */, From 338904fffe334a09a5bf44586020231078a9c9f7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 5 Nov 2016 15:07:57 -0400 Subject: [PATCH 2/4] Made similar cleanings of the Electron and Vic. --- Machines/Commodore/Vic-20/Typer.cpp | 87 ++++++++++++++ Machines/Commodore/Vic-20/Vic20.cpp | 106 ------------------ Machines/Commodore/Vic-20/Vic20.hpp | 4 +- Machines/Electron/Electron.cpp | 95 ---------------- Machines/Electron/Electron.hpp | 6 +- Machines/Electron/Typer.cpp | 100 +++++++++++++++++ Machines/Oric/Typer.cpp | 2 - .../Clock Signal.xcodeproj/project.pbxproj | 8 ++ 8 files changed, 199 insertions(+), 209 deletions(-) create mode 100644 Machines/Commodore/Vic-20/Typer.cpp create mode 100644 Machines/Electron/Typer.cpp diff --git a/Machines/Commodore/Vic-20/Typer.cpp b/Machines/Commodore/Vic-20/Typer.cpp new file mode 100644 index 000000000..efcfbca00 --- /dev/null +++ b/Machines/Commodore/Vic-20/Typer.cpp @@ -0,0 +1,87 @@ +// +// Typer.cpp +// Clock Signal +// +// Created by Thomas Harte on 05/11/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#include "Vic20.hpp" + +uint16_t *Commodore::Vic20::Machine::sequence_for_character(Utility::Typer *typer, char character) +{ +#define KEYS(...) {__VA_ARGS__, TerminateSequence} +#define SHIFT(...) {KeyLShift, __VA_ARGS__, TerminateSequence} +#define X {NotMapped} + static Key key_sequences[][3] = { + /* NUL */ X, /* SOH */ X, + /* STX */ X, /* ETX */ X, + /* EOT */ X, /* ENQ */ X, + /* ACK */ X, /* BEL */ X, + /* BS */ KEYS(KeyDelete), /* HT */ X, + /* LF */ KEYS(KeyReturn), /* VT */ X, + /* FF */ X, /* CR */ X, + /* SO */ X, /* SI */ X, + /* DLE */ X, /* DC1 */ X, + /* DC2 */ X, /* DC3 */ X, + /* DC4 */ X, /* NAK */ X, + /* SYN */ X, /* ETB */ X, + /* CAN */ X, /* EM */ X, + /* SUB */ X, /* ESC */ X, + /* FS */ X, /* GS */ X, + /* RS */ X, /* US */ X, + /* space */ KEYS(KeySpace), /* ! */ SHIFT(Key1), + /* " */ SHIFT(Key2), /* # */ SHIFT(Key3), + /* $ */ SHIFT(Key4), /* % */ SHIFT(Key5), + /* & */ SHIFT(Key6), /* ' */ SHIFT(Key7), + /* ( */ SHIFT(Key8), /* ) */ SHIFT(Key9), + /* * */ KEYS(KeyAsterisk), /* + */ KEYS(KeyPlus), + /* , */ KEYS(KeyComma), /* - */ KEYS(KeyDash), + /* . */ KEYS(KeyFullStop), /* / */ KEYS(KeySlash), + /* 0 */ KEYS(Key0), /* 1 */ KEYS(Key1), + /* 2 */ KEYS(Key2), /* 3 */ KEYS(Key3), + /* 4 */ KEYS(Key4), /* 5 */ KEYS(Key5), + /* 6 */ KEYS(Key6), /* 7 */ KEYS(Key7), + /* 8 */ KEYS(Key8), /* 9 */ KEYS(Key9), + /* : */ KEYS(KeyColon), /* ; */ KEYS(KeySemicolon), + /* < */ SHIFT(KeyComma), /* = */ KEYS(KeyEquals), + /* > */ SHIFT(KeyFullStop), /* ? */ SHIFT(KeySlash), + /* @ */ KEYS(KeyAt), /* A */ SHIFT(KeyA), + /* B */ SHIFT(KeyB), /* C */ SHIFT(KeyC), + /* D */ SHIFT(KeyD), /* E */ SHIFT(KeyE), + /* F */ SHIFT(KeyF), /* G */ SHIFT(KeyG), + /* H */ SHIFT(KeyH), /* I */ SHIFT(KeyI), + /* J */ SHIFT(KeyJ), /* K */ SHIFT(KeyK), + /* L */ SHIFT(KeyL), /* M */ SHIFT(KeyM), + /* N */ SHIFT(KeyN), /* O */ SHIFT(KeyO), + /* P */ SHIFT(KeyP), /* Q */ SHIFT(KeyQ), + /* R */ SHIFT(KeyR), /* S */ SHIFT(KeyS), + /* T */ SHIFT(KeyT), /* U */ SHIFT(KeyU), + /* V */ SHIFT(KeyV), /* W */ SHIFT(KeyW), + /* X */ SHIFT(KeyX), /* Y */ SHIFT(KeyY), + /* Z */ SHIFT(KeyZ), /* [ */ SHIFT(KeyColon), + /* \ */ X, /* ] */ SHIFT(KeyFullStop), + /* ^ */ X, /* _ */ X, + /* ` */ X, /* a */ KEYS(KeyA), + /* b */ KEYS(KeyB), /* c */ KEYS(KeyC), + /* d */ KEYS(KeyD), /* e */ KEYS(KeyE), + /* f */ KEYS(KeyF), /* g */ KEYS(KeyG), + /* h */ KEYS(KeyH), /* i */ KEYS(KeyI), + /* j */ KEYS(KeyJ), /* k */ KEYS(KeyK), + /* l */ KEYS(KeyL), /* m */ KEYS(KeyM), + /* n */ KEYS(KeyN), /* o */ KEYS(KeyO), + /* p */ KEYS(KeyP), /* q */ KEYS(KeyQ), + /* r */ KEYS(KeyR), /* s */ KEYS(KeyS), + /* t */ KEYS(KeyT), /* u */ KEYS(KeyU), + /* v */ KEYS(KeyV), /* w */ KEYS(KeyW), + /* x */ KEYS(KeyX), /* y */ KEYS(KeyY), + /* z */ KEYS(KeyZ) + }; +#undef KEYS +#undef SHIFT +#undef X + + if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; + if(key_sequences[character][0] == NotMapped) return nullptr; + return (uint16_t *)key_sequences[character]; +} diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 5f11246d5..8b803c752 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -368,112 +368,6 @@ void Machine::install_disk_rom() } } -#pragma mark - Typer - -int Machine::get_typer_delay() -{ - return get_is_resetting() ? 1*263*60*65 : 0; // wait a second if resetting -} - -int Machine::get_typer_frequency() -{ - return 2*263*65; // accept a new character every two fields -} - -bool Machine::typer_set_next_character(::Utility::Typer *typer, char character, int phase) -{ - if(!phase) clear_all_keys(); - - // The following table is arranged in ASCII order - Key key_sequences[][3] = { - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {KeyDelete, TerminateSequence}, - {NotMapped}, - {KeyReturn, TerminateSequence}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - - {KeySpace, TerminateSequence}, // space - - {KeyLShift, Key1, TerminateSequence}, {KeyLShift, Key2, TerminateSequence}, // !, " - {KeyLShift, Key3, TerminateSequence}, {KeyLShift, Key4, TerminateSequence}, // #, $ - {KeyLShift, Key5, TerminateSequence}, {KeyLShift, Key6, TerminateSequence}, // %, & - {KeyLShift, Key7, TerminateSequence}, {KeyLShift, Key8, TerminateSequence}, // ', ( - {KeyLShift, Key9, TerminateSequence}, {KeyAsterisk, TerminateSequence}, // ), * - {KeyPlus, TerminateSequence}, {KeyComma, TerminateSequence}, // +, , - {KeyDash, TerminateSequence}, {KeyFullStop, TerminateSequence}, // -, . - {KeySlash, TerminateSequence}, // / - - {Key0, TerminateSequence}, {Key1, TerminateSequence}, // 0, 1 - {Key2, TerminateSequence}, {Key3, TerminateSequence}, // 2, 3 - {Key4, TerminateSequence}, {Key5, TerminateSequence}, // 4, 5 - {Key6, TerminateSequence}, {Key7, TerminateSequence}, // 6, 7 - {Key8, TerminateSequence}, {Key9, TerminateSequence}, // 8, 9 - - {KeyColon, TerminateSequence}, {KeySemicolon, TerminateSequence}, // :, ; - {KeyLShift, KeyComma, TerminateSequence}, {KeyEquals, TerminateSequence}, // <, = - {KeyLShift, KeyFullStop, TerminateSequence}, {KeyLShift, KeySlash, TerminateSequence}, // >, ? - {KeyAt, TerminateSequence}, // @ - - {KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D - {KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H - {KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L - {KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P - {KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T - {KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X - {KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z - - {KeyLShift, KeyColon, TerminateSequence}, {NotMapped}, // [, '\' - {KeyLShift, KeyFullStop, TerminateSequence}, {NotMapped}, // ], ^ - {NotMapped}, {NotMapped}, // _, ` - - {KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D - {KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H - {KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L - {KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P - {KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T - {KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X - {KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z -// {KeyLShift, KeyA, TerminateSequence}, {KeyLShift, KeyB, TerminateSequence}, // a, b -// {KeyLShift, KeyC, TerminateSequence}, {KeyLShift, KeyD, TerminateSequence}, // c, d -// {KeyLShift, KeyE, TerminateSequence}, {KeyLShift, KeyF, TerminateSequence}, // e, f -// {KeyLShift, KeyG, TerminateSequence}, {KeyLShift, KeyH, TerminateSequence}, // g, h -// {KeyLShift, KeyI, TerminateSequence}, {KeyLShift, KeyJ, TerminateSequence}, // i, j -// {KeyLShift, KeyK, TerminateSequence}, {KeyLShift, KeyL, TerminateSequence}, // k, l -// {KeyLShift, KeyM, TerminateSequence}, {KeyLShift, KeyN, TerminateSequence}, // m, n -// {KeyLShift, KeyO, TerminateSequence}, {KeyLShift, KeyP, TerminateSequence}, // o, p -// {KeyLShift, KeyQ, TerminateSequence}, {KeyLShift, KeyR, TerminateSequence}, // q, r -// {KeyLShift, KeyS, TerminateSequence}, {KeyLShift, KeyT, TerminateSequence}, // s, t -// {KeyLShift, KeyU, TerminateSequence}, {KeyLShift, KeyV, TerminateSequence}, // u, v -// {KeyLShift, KeyW, TerminateSequence}, {KeyLShift, KeyX, TerminateSequence}, // w, x -// {KeyLShift, KeyY, TerminateSequence}, {KeyLShift, KeyZ, TerminateSequence}, // y, z - - }; - Key *key_sequence = nullptr; - - character &= 0x7f; - if(character < sizeof(key_sequences) / sizeof(*key_sequences)) - { - key_sequence = key_sequences[character]; - - if(key_sequence[0] != NotMapped) - { - if(phase > 0) - { - set_key_state(key_sequence[phase-1], true); - return key_sequence[phase] == TerminateSequence; - } - else - return false; - } - } - - return true; -} - #pragma mark - UserPortVIA uint8_t UserPortVIA::get_port_input(Port port) diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 9d1b06110..0c0b1b187 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -186,9 +186,7 @@ class Machine: virtual void mos6522_did_change_interrupt_status(void *mos6522); // for Utility::TypeRecipient - virtual int get_typer_delay(); - virtual int get_typer_frequency(); - virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase); + uint16_t *sequence_for_character(Utility::Typer *typer, char character); // for Tape::Delegate virtual void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape); diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 8457a59b1..805700752 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -1099,98 +1099,3 @@ inline void Tape::run_for_cycles(unsigned int number_of_cycles) } } } - -#pragma mark - Typer - -int Machine::get_typer_delay() -{ - return get_is_resetting() ? 625*25*128 : 0; // wait one second if resetting -} - -int Machine::get_typer_frequency() -{ - return 625*128; // accept a new character every frame -} - -bool Machine::typer_set_next_character(::Utility::Typer *typer, char character, int phase) -{ - if(!phase) clear_all_keys(); - - // The following table is arranged in ASCII order - Key key_sequences[][3] = { - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {KeyDelete, TerminateSequence}, - {NotMapped}, - {KeyReturn, TerminateSequence}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - {NotMapped}, {NotMapped}, {NotMapped}, {NotMapped}, - - {KeySpace, TerminateSequence}, // space - - {KeyShift, Key1, TerminateSequence}, {KeyShift, Key2, TerminateSequence}, // !, " - {KeyShift, Key3, TerminateSequence}, {KeyShift, Key4, TerminateSequence}, // #, $ - {KeyShift, Key5, TerminateSequence}, {KeyShift, Key6, TerminateSequence}, // %, & - {KeyShift, Key7, TerminateSequence}, {KeyShift, Key8, TerminateSequence}, // ', ( - {KeyShift, Key9, TerminateSequence}, {KeyShift, KeyColon, TerminateSequence}, // ), * - {KeyShift, KeySemiColon, TerminateSequence}, {KeyComma, TerminateSequence}, // +, , - {KeyMinus, TerminateSequence}, {KeyFullStop, TerminateSequence}, // -, . - {KeySlash, TerminateSequence}, // / - - {Key0, TerminateSequence}, {Key1, TerminateSequence}, // 0, 1 - {Key2, TerminateSequence}, {Key3, TerminateSequence}, // 2, 3 - {Key4, TerminateSequence}, {Key5, TerminateSequence}, // 4, 5 - {Key6, TerminateSequence}, {Key7, TerminateSequence}, // 6, 7 - {Key8, TerminateSequence}, {Key9, TerminateSequence}, // 8, 9 - - {KeyColon, TerminateSequence}, {KeySemiColon, TerminateSequence}, // :, ; - {KeyShift, KeyComma, TerminateSequence}, {KeyShift, KeyMinus, TerminateSequence}, // <, = - {KeyShift, KeyFullStop, TerminateSequence}, {KeyShift, KeySlash, TerminateSequence}, // >, ? - {KeyShift, Key0, TerminateSequence}, // @ - - {KeyA, TerminateSequence}, {KeyB, TerminateSequence}, {KeyC, TerminateSequence}, {KeyD, TerminateSequence}, // A, B, C, D - {KeyE, TerminateSequence}, {KeyF, TerminateSequence}, {KeyG, TerminateSequence}, {KeyH, TerminateSequence}, // E, F, G, H - {KeyI, TerminateSequence}, {KeyJ, TerminateSequence}, {KeyK, TerminateSequence}, {KeyL, TerminateSequence}, // I, J, K L - {KeyM, TerminateSequence}, {KeyN, TerminateSequence}, {KeyO, TerminateSequence}, {KeyP, TerminateSequence}, // M, N, O, P - {KeyQ, TerminateSequence}, {KeyR, TerminateSequence}, {KeyS, TerminateSequence}, {KeyT, TerminateSequence}, // Q, R, S, T - {KeyU, TerminateSequence}, {KeyV, TerminateSequence}, {KeyW, TerminateSequence}, {KeyX, TerminateSequence}, // U, V, W X - {KeyY, TerminateSequence}, {KeyZ, TerminateSequence}, // Y, Z - - {KeyShift, KeyCopy, TerminateSequence}, {KeyControl, KeyRight, TerminateSequence}, // [, '\' - {KeyControl, KeyCopy, TerminateSequence}, {KeyShift, KeyLeft, TerminateSequence}, // ], ^ - {KeyShift, KeyDown, TerminateSequence}, {NotMapped}, // _, ` - - {KeyShift, KeyA, TerminateSequence}, {KeyShift, KeyB, TerminateSequence}, {KeyShift, KeyC, TerminateSequence}, {KeyShift, KeyD, TerminateSequence}, // a, b, c, d - {KeyShift, KeyE, TerminateSequence}, {KeyShift, KeyF, TerminateSequence}, {KeyShift, KeyG, TerminateSequence}, {KeyShift, KeyH, TerminateSequence}, // e, f, g, h - {KeyShift, KeyI, TerminateSequence}, {KeyShift, KeyJ, TerminateSequence}, {KeyShift, KeyK, TerminateSequence}, {KeyShift, KeyL, TerminateSequence}, // i, j, k, l - {KeyShift, KeyM, TerminateSequence}, {KeyShift, KeyN, TerminateSequence}, {KeyShift, KeyO, TerminateSequence}, {KeyShift, KeyP, TerminateSequence}, // m, n, o, p - {KeyShift, KeyQ, TerminateSequence}, {KeyShift, KeyR, TerminateSequence}, {KeyShift, KeyS, TerminateSequence}, {KeyShift, KeyT, TerminateSequence}, // q, r, s, t - {KeyShift, KeyU, TerminateSequence}, {KeyShift, KeyV, TerminateSequence}, {KeyShift, KeyW, TerminateSequence}, {KeyShift, KeyX, TerminateSequence}, // u, v, w, x - {KeyShift, KeyY, TerminateSequence}, {KeyShift, KeyZ, TerminateSequence}, // y, z - - {KeyControl, KeyUp, TerminateSequence}, {KeyShift, KeyRight, TerminateSequence}, // {, | - {KeyControl, KeyDown, TerminateSequence}, {KeyControl, KeyLeft, TerminateSequence}, // }, ~ - }; - Key *key_sequence = nullptr; - - character &= 0x7f; - if(character < sizeof(key_sequences) / sizeof(*key_sequences)) - { - key_sequence = key_sequences[character]; - - if(key_sequence[0] != NotMapped) - { - if(phase > 0) - { - set_key_state(key_sequence[phase-1], true); - return key_sequence[phase] == TerminateSequence; - } - else - return false; - } - } - - return true; -} diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index b7b02cd61..15c6b7dfc 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -60,9 +60,9 @@ enum Key: uint16_t { KeyZ = 0x00c0 | 0x08, KeyA = 0x00c0 | 0x04, KeyQ = 0x00c0 | 0x02, Key1 = 0x00c0 | 0x01, KeyShift = 0x00d0 | 0x08, KeyControl = 0x00d0 | 0x04, KeyFunc = 0x00d0 | 0x02, KeyEscape = 0x00d0 | 0x01, - KeyBreak = 0xffff, + KeyBreak = 0xfffd, - TerminateSequence = 0, NotMapped = 0xfffe, + TerminateSequence = 0xffff, NotMapped = 0xfffe, }; class Tape: public Storage::Tape::TapePlayer { @@ -174,7 +174,7 @@ class Machine: // for Utility::TypeRecipient virtual int get_typer_delay(); virtual int get_typer_frequency(); - virtual bool typer_set_next_character(Utility::Typer *typer, char character, int phase); + uint16_t *sequence_for_character(Utility::Typer *typer, char character); private: diff --git a/Machines/Electron/Typer.cpp b/Machines/Electron/Typer.cpp new file mode 100644 index 000000000..6a01c77dc --- /dev/null +++ b/Machines/Electron/Typer.cpp @@ -0,0 +1,100 @@ +// +// Typer.cpp +// Clock Signal +// +// Created by Thomas Harte on 05/11/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#include "Electron.hpp" + +int Electron::Machine::get_typer_delay() +{ + return get_is_resetting() ? 625*25*128 : 0; // wait one second if resetting +} + +int Electron::Machine::get_typer_frequency() +{ + return 625*128; // accept a new character every frame +} + +uint16_t *Electron::Machine::sequence_for_character(Utility::Typer *typer, char character) +{ +#define KEYS(...) {__VA_ARGS__, TerminateSequence} +#define SHIFT(...) {KeyShift, __VA_ARGS__, TerminateSequence} +#define CTRL(...) {KeyControl, __VA_ARGS__, TerminateSequence} +#define X {NotMapped} + static Key key_sequences[][3] = { + /* NUL */ X, /* SOH */ X, + /* STX */ X, /* ETX */ X, + /* EOT */ X, /* ENQ */ X, + /* ACK */ X, /* BEL */ X, + /* BS */ KEYS(KeyDelete), /* HT */ X, + /* LF */ KEYS(KeyReturn), /* VT */ X, + /* FF */ X, /* CR */ X, + /* SO */ X, /* SI */ X, + /* DLE */ X, /* DC1 */ X, + /* DC2 */ X, /* DC3 */ X, + /* DC4 */ X, /* NAK */ X, + /* SYN */ X, /* ETB */ X, + /* CAN */ X, /* EM */ X, + /* SUB */ X, /* ESC */ X, + /* FS */ X, /* GS */ X, + /* RS */ X, /* US */ X, + /* space */ KEYS(KeySpace), /* ! */ SHIFT(Key1), + /* " */ SHIFT(Key2), /* # */ SHIFT(Key3), + /* $ */ SHIFT(Key4), /* % */ SHIFT(Key5), + /* & */ SHIFT(Key6), /* ' */ SHIFT(Key7), + /* ( */ SHIFT(Key8), /* ) */ SHIFT(Key9), + /* * */ SHIFT(KeyColon), /* + */ SHIFT(KeySemiColon), + /* , */ KEYS(KeyComma), /* - */ KEYS(KeyMinus), + /* . */ KEYS(KeyFullStop), /* / */ KEYS(KeySlash), + /* 0 */ KEYS(Key0), /* 1 */ KEYS(Key1), + /* 2 */ KEYS(Key2), /* 3 */ KEYS(Key3), + /* 4 */ KEYS(Key4), /* 5 */ KEYS(Key5), + /* 6 */ KEYS(Key6), /* 7 */ KEYS(Key7), + /* 8 */ KEYS(Key8), /* 9 */ KEYS(Key9), + /* : */ KEYS(KeyColon), /* ; */ KEYS(KeySemiColon), + /* < */ SHIFT(KeyComma), /* = */ SHIFT(KeyMinus), + /* > */ SHIFT(KeyFullStop), /* ? */ SHIFT(KeySlash), + /* @ */ SHIFT(Key0), /* A */ KEYS(KeyA), + /* B */ KEYS(KeyB), /* C */ KEYS(KeyC), + /* D */ KEYS(KeyD), /* E */ KEYS(KeyE), + /* F */ KEYS(KeyF), /* G */ KEYS(KeyG), + /* H */ KEYS(KeyH), /* I */ KEYS(KeyI), + /* J */ KEYS(KeyJ), /* K */ KEYS(KeyK), + /* L */ KEYS(KeyL), /* M */ KEYS(KeyM), + /* N */ KEYS(KeyN), /* O */ KEYS(KeyO), + /* P */ KEYS(KeyP), /* Q */ KEYS(KeyQ), + /* R */ KEYS(KeyR), /* S */ KEYS(KeyS), + /* T */ KEYS(KeyT), /* U */ KEYS(KeyU), + /* V */ KEYS(KeyV), /* W */ KEYS(KeyW), + /* X */ KEYS(KeyX), /* Y */ KEYS(KeyY), + /* Z */ KEYS(KeyZ), /* [ */ SHIFT(KeyCopy), + /* \ */ CTRL(KeyRight), /* ] */ CTRL(KeyCopy), + /* ^ */ SHIFT(KeyLeft), /* _ */ SHIFT(KeyDown), + /* ` */ X, /* a */ SHIFT(KeyA), + /* b */ SHIFT(KeyB), /* c */ SHIFT(KeyC), + /* d */ SHIFT(KeyD), /* e */ SHIFT(KeyE), + /* f */ SHIFT(KeyF), /* g */ SHIFT(KeyG), + /* h */ SHIFT(KeyH), /* i */ SHIFT(KeyI), + /* j */ SHIFT(KeyJ), /* k */ SHIFT(KeyK), + /* l */ SHIFT(KeyL), /* m */ SHIFT(KeyM), + /* n */ SHIFT(KeyN), /* o */ SHIFT(KeyO), + /* p */ SHIFT(KeyP), /* q */ SHIFT(KeyQ), + /* r */ SHIFT(KeyR), /* s */ SHIFT(KeyS), + /* t */ SHIFT(KeyT), /* u */ SHIFT(KeyU), + /* v */ SHIFT(KeyV), /* w */ SHIFT(KeyW), + /* x */ SHIFT(KeyX), /* y */ SHIFT(KeyY), + /* z */ SHIFT(KeyZ), /* { */ CTRL(KeyUp), + /* | */ SHIFT(KeyRight), /* } */ CTRL(KeyDown), + /* ~ */ CTRL(KeyLeft) + }; +#undef KEYS +#undef SHIFT +#undef X + + if(character > sizeof(key_sequences) / sizeof(*key_sequences)) return nullptr; + if(key_sequences[character][0] == NotMapped) return nullptr; + return (uint16_t *)key_sequences[character]; +} diff --git a/Machines/Oric/Typer.cpp b/Machines/Oric/Typer.cpp index 492068880..bcd1361a9 100644 --- a/Machines/Oric/Typer.cpp +++ b/Machines/Oric/Typer.cpp @@ -5,8 +5,6 @@ uint16_t *Oric::Machine::sequence_for_character(Utility::Typer *typer, char char #define KEYS(...) {__VA_ARGS__, TerminateSequence} #define SHIFT(...) {KeyLeftShift, __VA_ARGS__, TerminateSequence} #define X {NotMapped} - - // The following table is arranged in ASCII order static Key key_sequences[][3] = { /* NUL */ X, /* SOH */ X, /* STX */ X, /* ETX */ X, diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index e3918bc36..02cee0d91 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -358,6 +358,8 @@ 4BC76E6B1C98F43700E6EF73 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BC76E6A1C98F43700E6EF73 /* Accelerate.framework */; }; 4BC830D11D6E7C690000A26F /* Tape.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC830CF1D6E7C690000A26F /* Tape.cpp */; }; 4BC8A62A1DCE4F2700DAC693 /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */; }; + 4BC8A62D1DCE60E000DAC693 /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC8A62B1DCE60E000DAC693 /* Typer.cpp */; }; + 4BC8A62F1DCE63CA00DAC693 /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC8A62E1DCE63CA00DAC693 /* Typer.cpp */; }; 4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC91B811D1F160E00884B76 /* CommodoreTAP.cpp */; }; 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; }; 4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; }; @@ -833,6 +835,8 @@ 4BC830CF1D6E7C690000A26F /* Tape.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Tape.cpp; path = ../../StaticAnalyser/Commodore/Tape.cpp; sourceTree = ""; }; 4BC830D01D6E7C690000A26F /* Tape.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Tape.hpp; path = ../../StaticAnalyser/Commodore/Tape.hpp; sourceTree = ""; }; 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Typer.cpp; path = Oric/Typer.cpp; sourceTree = ""; }; + 4BC8A62B1DCE60E000DAC693 /* Typer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Typer.cpp; path = Electron/Typer.cpp; sourceTree = ""; }; + 4BC8A62E1DCE63CA00DAC693 /* Typer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Typer.cpp; sourceTree = ""; }; 4BC91B811D1F160E00884B76 /* CommodoreTAP.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommodoreTAP.cpp; sourceTree = ""; }; 4BC91B821D1F160E00884B76 /* CommodoreTAP.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CommodoreTAP.hpp; sourceTree = ""; }; 4BC9DF441D044FCA00F44158 /* ROMImages */ = {isa = PBXFileReference; lastKnownFileType = folder; name = ROMImages; path = ../../../../ROMImages; sourceTree = ""; }; @@ -1022,6 +1026,7 @@ 4B2E2D9C1C3A070400138695 /* Electron.hpp */, 4B30512E1D98ACC600B4FED8 /* Plus3.cpp */, 4B30512F1D98ACC600B4FED8 /* Plus3.hpp */, + 4BC8A62B1DCE60E000DAC693 /* Typer.cpp */, ); name = Electron; sourceTree = ""; @@ -1088,6 +1093,7 @@ children = ( 4B4DC81F1D2C2425003C5BF8 /* Vic20.cpp */, 4B4DC8201D2C2425003C5BF8 /* Vic20.hpp */, + 4BC8A62E1DCE63CA00DAC693 /* Typer.cpp */, ); path = "Vic-20"; sourceTree = ""; @@ -2237,6 +2243,7 @@ 4BBF99151C8FBA6F0075DAFB /* CRTOpenGL.cpp in Sources */, 4B0CCC451C62D0B3001CAC5F /* CRT.cpp in Sources */, 4BCF1FA41DADC3DD0039D2E7 /* Oric.cpp in Sources */, + 4BC8A62D1DCE60E000DAC693 /* Typer.cpp in Sources */, 4B643F3F1D77B88000D431D6 /* DocumentController.swift in Sources */, 4BA799951D8B656E0045123D /* StaticAnalyser.cpp in Sources */, 4BF829601D8F3C87001BAE39 /* CRC.cpp in Sources */, @@ -2304,6 +2311,7 @@ 4BCF1FAB1DADD41B0039D2E7 /* StaticAnalyser.cpp in Sources */, 4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */, 4B37EE821D7345A6006A09A4 /* BinaryDump.cpp in Sources */, + 4BC8A62F1DCE63CA00DAC693 /* Typer.cpp in Sources */, 4BB73EA21B587A5100552FC2 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; From c21bef42830a5e052b85d8644cc71761c663a046 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 5 Nov 2016 15:08:22 -0400 Subject: [PATCH 3/4] Project cleaning. --- OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 02cee0d91..e0a7e563f 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -1091,9 +1091,9 @@ 4B4DC81E1D2C2425003C5BF8 /* Vic-20 */ = { isa = PBXGroup; children = ( + 4BC8A62E1DCE63CA00DAC693 /* Typer.cpp */, 4B4DC81F1D2C2425003C5BF8 /* Vic20.cpp */, 4B4DC8201D2C2425003C5BF8 /* Vic20.hpp */, - 4BC8A62E1DCE63CA00DAC693 /* Typer.cpp */, ); path = "Vic-20"; sourceTree = ""; @@ -1728,9 +1728,9 @@ children = ( 4BCF1FA21DADC3DD0039D2E7 /* Oric.cpp */, 4BCF1FA31DADC3DD0039D2E7 /* Oric.hpp */, + 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */, 4B2BFDB01DAEF5FF001A68B8 /* Video.cpp */, 4B2BFDB11DAEF5FF001A68B8 /* Video.hpp */, - 4BC8A6291DCE4F2700DAC693 /* Typer.cpp */, ); name = Oric; sourceTree = ""; From 45b169f341aca39f728bc49a2b4a851388197033 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 5 Nov 2016 15:28:03 -0400 Subject: [PATCH 4/4] Made a few mapping fixes, clarified where the default reset code lives, ensured the Oric and Vic clear their keys when the typer ends. --- Machines/Commodore/Vic-20/Typer.cpp | 30 ++++++++++++++--------------- Machines/Commodore/Vic-20/Vic20.cpp | 3 +++ Machines/Commodore/Vic-20/Vic20.hpp | 2 +- Machines/Electron/Typer.cpp | 2 +- Machines/Oric/Oric.cpp | 6 +++++- Machines/Typer.cpp | 5 ----- Machines/Typer.hpp | 3 ++- 7 files changed, 27 insertions(+), 24 deletions(-) diff --git a/Machines/Commodore/Vic-20/Typer.cpp b/Machines/Commodore/Vic-20/Typer.cpp index efcfbca00..9cf018e4f 100644 --- a/Machines/Commodore/Vic-20/Typer.cpp +++ b/Machines/Commodore/Vic-20/Typer.cpp @@ -46,21 +46,21 @@ uint16_t *Commodore::Vic20::Machine::sequence_for_character(Utility::Typer *type /* : */ KEYS(KeyColon), /* ; */ KEYS(KeySemicolon), /* < */ SHIFT(KeyComma), /* = */ KEYS(KeyEquals), /* > */ SHIFT(KeyFullStop), /* ? */ SHIFT(KeySlash), - /* @ */ KEYS(KeyAt), /* A */ SHIFT(KeyA), - /* B */ SHIFT(KeyB), /* C */ SHIFT(KeyC), - /* D */ SHIFT(KeyD), /* E */ SHIFT(KeyE), - /* F */ SHIFT(KeyF), /* G */ SHIFT(KeyG), - /* H */ SHIFT(KeyH), /* I */ SHIFT(KeyI), - /* J */ SHIFT(KeyJ), /* K */ SHIFT(KeyK), - /* L */ SHIFT(KeyL), /* M */ SHIFT(KeyM), - /* N */ SHIFT(KeyN), /* O */ SHIFT(KeyO), - /* P */ SHIFT(KeyP), /* Q */ SHIFT(KeyQ), - /* R */ SHIFT(KeyR), /* S */ SHIFT(KeyS), - /* T */ SHIFT(KeyT), /* U */ SHIFT(KeyU), - /* V */ SHIFT(KeyV), /* W */ SHIFT(KeyW), - /* X */ SHIFT(KeyX), /* Y */ SHIFT(KeyY), - /* Z */ SHIFT(KeyZ), /* [ */ SHIFT(KeyColon), - /* \ */ X, /* ] */ SHIFT(KeyFullStop), + /* @ */ KEYS(KeyAt), /* A */ KEYS(KeyA), + /* B */ KEYS(KeyB), /* C */ KEYS(KeyC), + /* D */ KEYS(KeyD), /* E */ KEYS(KeyE), + /* F */ KEYS(KeyF), /* G */ KEYS(KeyG), + /* H */ KEYS(KeyH), /* I */ KEYS(KeyI), + /* J */ KEYS(KeyJ), /* K */ KEYS(KeyK), + /* L */ KEYS(KeyL), /* M */ KEYS(KeyM), + /* N */ KEYS(KeyN), /* O */ KEYS(KeyO), + /* P */ KEYS(KeyP), /* Q */ KEYS(KeyQ), + /* R */ KEYS(KeyR), /* S */ KEYS(KeyS), + /* T */ KEYS(KeyT), /* U */ KEYS(KeyU), + /* V */ KEYS(KeyV), /* W */ KEYS(KeyW), + /* X */ KEYS(KeyX), /* Y */ KEYS(KeyY), + /* Z */ KEYS(KeyZ), /* [ */ SHIFT(KeyColon), + /* \ */ X, /* ] */ SHIFT(KeySemicolon), /* ^ */ X, /* _ */ X, /* ` */ X, /* a */ KEYS(KeyA), /* b */ KEYS(KeyB), /* c */ KEYS(KeyC), diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 8b803c752..48617d124 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -162,7 +162,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E) { if(!_typer->type_next_character()) + { + clear_all_keys(); _typer.reset(); + } } _tape.run_for_cycles(1); if(_c1540) _c1540->run_for_cycles(1); diff --git a/Machines/Commodore/Vic-20/Vic20.hpp b/Machines/Commodore/Vic-20/Vic20.hpp index 0c0b1b187..61d3c62e7 100644 --- a/Machines/Commodore/Vic-20/Vic20.hpp +++ b/Machines/Commodore/Vic-20/Vic20.hpp @@ -64,7 +64,7 @@ enum Key: uint16_t { Key1 = key(0, 0x01), Key3 = key(0, 0x02), Key5 = key(0, 0x04), Key7 = key(0, 0x08), Key9 = key(0, 0x10), KeyPlus = key(0, 0x20), KeyGBP = key(0, 0x40), KeyDelete = key(0, 0x80), - TerminateSequence = 0, NotMapped = 0xffff + TerminateSequence = 0xffff, NotMapped = 0xfffe }; enum JoystickInput { diff --git a/Machines/Electron/Typer.cpp b/Machines/Electron/Typer.cpp index 6a01c77dc..31bc92f3e 100644 --- a/Machines/Electron/Typer.cpp +++ b/Machines/Electron/Typer.cpp @@ -15,7 +15,7 @@ int Electron::Machine::get_typer_delay() int Electron::Machine::get_typer_frequency() { - return 625*128; // accept a new character every frame + return 625*128*2; // accept a new character every two frames } uint16_t *Electron::Machine::sequence_for_character(Utility::Typer *typer, char character) diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index ac7c4a1e4..64f53df89 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -81,7 +81,11 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xF495) { - if(!_typer->type_next_character()) _typer.reset(); + if(!_typer->type_next_character()) + { + clear_all_keys(); + _typer.reset(); + } } _via.run_for_cycles(1); diff --git a/Machines/Typer.cpp b/Machines/Typer.cpp index ac074240e..43a527b0d 100644 --- a/Machines/Typer.cpp +++ b/Machines/Typer.cpp @@ -89,11 +89,6 @@ bool Typer::Delegate::typer_set_next_character(Utility::Typer *typer, char chara return false; } -void Typer::Delegate::typer_reset(Typer *typer) -{ - clear_all_keys(); -} - uint16_t *Typer::Delegate::sequence_for_character(Typer *typer, char character) { return nullptr; diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index e6b172e15..4a5958414 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -19,7 +19,7 @@ class Typer { class Delegate: public KeyboardMachine::Machine { public: virtual bool typer_set_next_character(Typer *typer, char character, int phase); - virtual void typer_reset(Typer *typer); + virtual void typer_reset(Typer *typer) = 0; virtual uint16_t *sequence_for_character(Typer *typer, char character); @@ -52,6 +52,7 @@ class TypeRecipient: public Typer::Delegate { void typer_reset(Typer *typer) { + clear_all_keys(); _typer.reset(); }