1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Adds additional joystick commands to the dispatcher.

This commit is contained in:
Thomas Harte 2019-11-09 20:10:54 -05:00
parent 8e9428623e
commit 7ae0902103
2 changed files with 44 additions and 7 deletions

View File

@ -167,10 +167,30 @@ void IntelligentKeyboard::dispatch_command(uint8_t command) {
case 0x12: disable_mouse(); break;
case 0x13: pause(); break;
case 0x14: set_joystick_event_mode(); break;
case 0x15: set_joystick_interrogation_mode(); break;
case 0x16: interrogate_joysticks(); break;
case 0x1a: disable_joysticks(); break;
/* Joystick commands. */
case 0x14: set_joystick_event_mode(); break;
case 0x15: set_joystick_interrogation_mode(); break;
case 0x16: interrogate_joysticks(); break;
case 0x17:
if(command_sequence_.size() != 2) return;
set_joystick_monitoring_mode(command_sequence_[1]);
break;
case 0x18: set_joystick_fire_button_monitoring_mode(); break;
case 0x19: {
if(command_sequence_.size() != 7) return;
VelocityThreshold horizontal, vertical;
horizontal.threshold = command_sequence_[1];
horizontal.prior_rate = command_sequence_[3];
horizontal.post_rate = command_sequence_[5];
vertical.threshold = command_sequence_[2];
vertical.prior_rate = command_sequence_[4];
vertical.post_rate = command_sequence_[6];
set_joystick_keycode_mode(horizontal, vertical);
} break;
case 0x1a: disable_joysticks(); break;
}
// There was no premature exit, so a complete command sequence must have been satisfied.
@ -370,3 +390,12 @@ void IntelligentKeyboard::interrogate_joysticks() {
joystick2->get_state()
});
}
void IntelligentKeyboard::set_joystick_monitoring_mode(uint8_t rate) {
}
void IntelligentKeyboard::set_joystick_fire_button_monitoring_mode() {
}
void IntelligentKeyboard::set_joystick_keycode_mode(VelocityThreshold horizontal, VelocityThreshold vertical) {
}

View File

@ -130,6 +130,14 @@ class IntelligentKeyboard:
void disable_joysticks();
void set_joystick_event_mode();
void set_joystick_interrogation_mode();
void set_joystick_monitoring_mode(uint8_t rate);
void set_joystick_fire_button_monitoring_mode();
struct VelocityThreshold {
uint8_t threshold;
uint8_t prior_rate;
uint8_t post_rate;
};
void set_joystick_keycode_mode(VelocityThreshold horizontal, VelocityThreshold vertical);
void interrogate_joysticks();
enum class JoystickMode {
@ -158,7 +166,7 @@ class IntelligentKeyboard:
case Input::Fire: mask = 0x80; break;
}
if(is_active) state_ &= ~mask; else state_ |= mask;
if(is_active) state_ |= mask; else state_ &= ~mask;
}
uint8_t get_state() {
@ -171,8 +179,8 @@ class IntelligentKeyboard:
}
private:
uint8_t state_ = 0x8f;
uint8_t returned_state_ = 0x8f;
uint8_t state_ = 0x00;
uint8_t returned_state_ = 0x00;
};
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
};