mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Extends logic for when to fall back on standard keypress logic even in logical mode.
This commit is contained in:
parent
611182910a
commit
ed18092088
@ -36,6 +36,14 @@ void MultiKeyboardMachine::type_string(const std::string &string) {
|
||||
}
|
||||
}
|
||||
|
||||
bool MultiKeyboardMachine::can_type(char c) {
|
||||
bool can_type = true;
|
||||
for(const auto &machine: machines_) {
|
||||
can_type &= machine->can_type(c);
|
||||
}
|
||||
return can_type;
|
||||
}
|
||||
|
||||
Inputs::Keyboard &MultiKeyboardMachine::get_keyboard() {
|
||||
return keyboard_;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ class MultiKeyboardMachine: public KeyboardMachine::Machine {
|
||||
void clear_all_keys() final;
|
||||
void set_key_state(uint16_t key, bool is_pressed) final;
|
||||
void type_string(const std::string &) final;
|
||||
bool can_type(char c) final;
|
||||
Inputs::Keyboard &get_keyboard() final;
|
||||
};
|
||||
|
||||
|
@ -1082,6 +1082,10 @@ template <bool has_fdc> class ConcreteMachine:
|
||||
Utility::TypeRecipient<CharacterMapper>::add_typer(string);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
||||
}
|
||||
|
||||
HalfCycles get_typer_delay() final {
|
||||
return z80_.get_is_resetting() ? Cycles(3'400'000) : Cycles(0);
|
||||
}
|
||||
|
@ -858,6 +858,11 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
|
||||
string_serialiser_ = std::make_unique<Utility::StringSerialiser>(string, true);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
// Make an effort to type the entire printable ASCII range.
|
||||
return c >= 32 && c < 127;
|
||||
}
|
||||
|
||||
// MARK:: Configuration options.
|
||||
std::vector<std::unique_ptr<Configurable::Option>> get_options() final {
|
||||
return Apple::II::get_options();
|
||||
|
@ -648,6 +648,10 @@ class ConcreteMachine:
|
||||
Utility::TypeRecipient<CharacterMapper>::add_typer(string);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
||||
}
|
||||
|
||||
void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape) final {
|
||||
keyboard_via_.set_control_line_input(MOS::MOS6522::Port::A, MOS::MOS6522::Line::One, !tape->get_input());
|
||||
}
|
||||
|
@ -416,6 +416,10 @@ class ConcreteMachine:
|
||||
Utility::TypeRecipient<CharacterMapper>::add_typer(string);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
||||
}
|
||||
|
||||
KeyboardMapper *get_keyboard_mapper() final {
|
||||
return &keyboard_mapper_;
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ class Machine: public KeyActions {
|
||||
*/
|
||||
virtual void type_string(const std::string &);
|
||||
|
||||
/*!
|
||||
@returns @c true if this machine can type the character @c c as part of a @c type_string; @c false otherwise.
|
||||
*/
|
||||
virtual bool can_type(char c) { return false; }
|
||||
|
||||
/*!
|
||||
Provides a destination for keyboard input.
|
||||
*/
|
||||
|
@ -369,6 +369,11 @@ class ConcreteMachine:
|
||||
);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
// Make an effort to type the entire printable ASCII range.
|
||||
return c >= 32 && c < 127;
|
||||
}
|
||||
|
||||
// MARK: MSX::MemoryMap
|
||||
void map(int slot, std::size_t source_address, uint16_t destination_address, std::size_t length) final {
|
||||
assert(!(destination_address & 8191));
|
||||
|
@ -589,6 +589,11 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
|
||||
string_serialiser_ = std::make_unique<Utility::StringSerialiser>(string, true);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
// Make an effort to type the entire printable ASCII range.
|
||||
return c >= 32 && c < 127;
|
||||
}
|
||||
|
||||
// DiskController::Delegate
|
||||
void disk_controller_did_change_paged_item(DiskController *controller) final {
|
||||
switch(controller->get_paged_item()) {
|
||||
|
@ -140,3 +140,4 @@ uint16_t *CharacterMapper::table_lookup_sequence_for_character(KeySequence *sequ
|
||||
if(sequences[ucharacter][0] == KeyboardMachine::MappedMachine::KeyNotMapped) return nullptr;
|
||||
return sequences[ucharacter];
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,14 @@ class TypeRecipient: public Typer::Delegate {
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@returns @c true if the character mapper provides a mapping for @c c; @c false otherwise.
|
||||
*/
|
||||
bool can_type(char c) {
|
||||
const auto sequence = character_mapper.sequence_for_character(c);
|
||||
return sequence && sequence[0] != KeyboardMachine::MappedMachine::KeyNotMapped;
|
||||
}
|
||||
|
||||
/*!
|
||||
Provided in order to conform to that part of the Typer::Delegate interface that goes above and
|
||||
beyond KeyboardMachine::Machine; responds to the end of typing by clearing all keys.
|
||||
|
@ -344,6 +344,10 @@ template<bool is_zx81> class ConcreteMachine:
|
||||
Utility::TypeRecipient<CharacterMapper>::add_typer(string);
|
||||
}
|
||||
|
||||
bool can_type(char c) final {
|
||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
||||
}
|
||||
|
||||
// MARK: - Keyboard
|
||||
void set_key_state(uint16_t key, bool is_pressed) final {
|
||||
const auto line = key >> 8;
|
||||
|
@ -508,14 +508,14 @@ struct ActivityObserver: public Activity::Observer {
|
||||
// as something to type. If this isn't logical mode, or this key doesn't
|
||||
// map to a symbol, pass it along as a standard press.
|
||||
if(self.inputMode == CSMachineKeyboardInputModeKeyboardLogical) {
|
||||
if(pressedKey) {
|
||||
if(isPressed) {
|
||||
@synchronized(self) {
|
||||
@synchronized(self) {
|
||||
if(pressedKey && keyboard_machine->can_type(pressedKey)) {
|
||||
if(isPressed) {
|
||||
char string[2] = { pressedKey, 0 };
|
||||
keyboard_machine->type_string(string);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -899,7 +899,8 @@ int main(int argc, char *argv[]) {
|
||||
if(key_name[0] >= 0) key_value = key_name[0];
|
||||
|
||||
// If a logical mapping was selected and a symbol was found, type it.
|
||||
if(logical_keyboard && key_value != '\0') {
|
||||
if(logical_keyboard && key_value != '\0' && keyboard_machine->can_type(key_value)) {
|
||||
char string[] = { key_value, 0 };
|
||||
keyboard_machine->type_string(string);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user