mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-09 05:25:01 +00:00
Roll formatting and const
tweaks into Inputs.
This commit is contained in:
@@ -115,6 +115,6 @@ void MultiConfigurable::set_options(const std::unique_ptr<Reflection::Struct> &s
|
||||
options->apply();
|
||||
}
|
||||
|
||||
std::unique_ptr<Reflection::Struct> MultiConfigurable::get_options() {
|
||||
std::unique_ptr<Reflection::Struct> MultiConfigurable::get_options() const {
|
||||
return std::make_unique<MultiStruct>(devices_);
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
// Below is the standard Configurable::Device interface; see there for documentation.
|
||||
void set_options(const std::unique_ptr<Reflection::Struct> &) final;
|
||||
std::unique_ptr<Reflection::Struct> get_options() final;
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final;
|
||||
|
||||
private:
|
||||
std::vector<Configurable::Device *> devices_;
|
||||
|
@@ -65,7 +65,7 @@ template <> struct TaskQueueStorage<void> {
|
||||
called once per action.
|
||||
*/
|
||||
template <bool perform_automatically, bool start_immediately = true, typename Performer = void> class AsyncTaskQueue: public TaskQueueStorage<Performer> {
|
||||
public:
|
||||
public:
|
||||
template <typename... Args> AsyncTaskQueue(Args&&... args) :
|
||||
TaskQueueStorage<Performer>(std::forward<Args>(args)...) {
|
||||
if constexpr (start_immediately) {
|
||||
@@ -171,7 +171,7 @@ template <bool perform_automatically, bool start_immediately = true, typename Pe
|
||||
stop();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
// The list of actions waiting be performed. These will be elided,
|
||||
// increasing their latency, if the emulation thread falls behind.
|
||||
using ActionVector = std::vector<std::function<void(void)>>;
|
||||
|
@@ -25,7 +25,7 @@ struct Device {
|
||||
virtual void set_options(const std::unique_ptr<Reflection::Struct> &options) = 0;
|
||||
|
||||
/// @returns An options object
|
||||
virtual std::unique_ptr<Reflection::Struct> get_options() = 0;
|
||||
virtual std::unique_ptr<Reflection::Struct> get_options() const = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@@ -26,11 +26,11 @@ ReflectableEnum(Display,
|
||||
//===
|
||||
|
||||
template <typename Owner> class DisplayOption {
|
||||
public:
|
||||
public:
|
||||
Configurable::Display output;
|
||||
DisplayOption(Configurable::Display output) : output(output) {}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void declare_display_option() {
|
||||
static_cast<Owner *>(this)->declare(&output, "output");
|
||||
AnnounceEnumNS(Configurable, Display);
|
||||
@@ -38,22 +38,22 @@ template <typename Owner> class DisplayOption {
|
||||
};
|
||||
|
||||
template <typename Owner> class QuickloadOption {
|
||||
public:
|
||||
public:
|
||||
bool quickload;
|
||||
QuickloadOption(bool quickload) : quickload(quickload) {}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void declare_quickload_option() {
|
||||
static_cast<Owner *>(this)->declare(&quickload, "quickload");
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Owner> class QuickbootOption {
|
||||
public:
|
||||
public:
|
||||
bool quickboot;
|
||||
QuickbootOption(bool quickboot) : quickboot(quickboot) {}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void declare_quickboot_option() {
|
||||
static_cast<Owner *>(this)->declare(&quickboot, "quickboot");
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ namespace Inputs {
|
||||
machine to toggle states, while an interested party either observes or polls.
|
||||
*/
|
||||
class Joystick {
|
||||
public:
|
||||
public:
|
||||
virtual ~Joystick() = default;
|
||||
|
||||
/*!
|
||||
@@ -82,11 +82,11 @@ class Joystick {
|
||||
Info info;
|
||||
// TODO: Find a way to make the above safely const; may mean not using a union.
|
||||
|
||||
Input(Type type, size_t index = 0) :
|
||||
Input(const Type type, const size_t index = 0) :
|
||||
type(type) {
|
||||
info.control.index = index;
|
||||
}
|
||||
Input(wchar_t symbol) : type(Key) {
|
||||
Input(const wchar_t symbol) : type(Key) {
|
||||
info.key.symbol = symbol;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class Joystick {
|
||||
return number_of_buttons_;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
int number_of_buttons_ = -1;
|
||||
};
|
||||
|
||||
@@ -157,7 +157,7 @@ class Joystick {
|
||||
promised analogue <-> digital mapping of Joystick.
|
||||
*/
|
||||
class ConcreteJoystick: public Joystick {
|
||||
public:
|
||||
public:
|
||||
ConcreteJoystick(const std::vector<Input> &inputs) : inputs_(inputs) {
|
||||
// Size and populate stick_types_, which is used for digital <-> analogue conversion.
|
||||
for(const auto &input: inputs_) {
|
||||
@@ -177,7 +177,7 @@ class ConcreteJoystick: public Joystick {
|
||||
return inputs_;
|
||||
}
|
||||
|
||||
void set_input(const Input &input, bool is_active) final {
|
||||
void set_input(const Input &input, const bool is_active) final {
|
||||
// If this is a digital setting to a digital property, just pass it along.
|
||||
if(input.is_button() || stick_types_[input.info.control.index] == StickType::Digital) {
|
||||
did_set_input(input, is_active);
|
||||
@@ -196,7 +196,7 @@ class ConcreteJoystick: public Joystick {
|
||||
}
|
||||
}
|
||||
|
||||
void set_input(const Input &input, float value) final {
|
||||
void set_input(const Input &input, const float value) final {
|
||||
// If this is an analogue setting to an analogue property, just pass it along.
|
||||
if(!input.is_button() && stick_types_[input.info.control.index] == StickType::Analogue) {
|
||||
did_set_input(input, value);
|
||||
@@ -218,11 +218,11 @@ class ConcreteJoystick: public Joystick {
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void did_set_input([[maybe_unused]] const Input &input, [[maybe_unused]] float value) {}
|
||||
virtual void did_set_input([[maybe_unused]] const Input &input, [[maybe_unused]] bool value) {}
|
||||
|
||||
private:
|
||||
private:
|
||||
const std::vector<Input> inputs_;
|
||||
|
||||
enum class StickType {
|
||||
|
@@ -21,7 +21,7 @@ Keyboard::Keyboard(const std::set<Key> &essential_modifiers) : essential_modifie
|
||||
Keyboard::Keyboard(const std::set<Key> &observed_keys, const std::set<Key> &essential_modifiers) :
|
||||
observed_keys_(observed_keys), essential_modifiers_(essential_modifiers), is_exclusive_(false) {}
|
||||
|
||||
bool Keyboard::set_key_pressed(Key key, char, bool is_pressed, bool) {
|
||||
bool Keyboard::set_key_pressed(const Key key, const char, const bool is_pressed, bool) {
|
||||
const size_t key_offset = size_t(key);
|
||||
if(key_offset >= key_states_.size()) {
|
||||
key_states_.resize(key_offset+1, false);
|
||||
@@ -41,7 +41,7 @@ void Keyboard::reset_all_keys() {
|
||||
if(delegate_) delegate_->reset_all_keys(this);
|
||||
}
|
||||
|
||||
void Keyboard::set_delegate(Delegate *delegate) {
|
||||
void Keyboard::set_delegate(Delegate *const delegate) {
|
||||
delegate_ = delegate;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,7 @@ namespace Inputs {
|
||||
machine to toggle states, while an interested party either observes or polls.
|
||||
*/
|
||||
class Keyboard {
|
||||
public:
|
||||
public:
|
||||
enum class Key {
|
||||
Escape, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PrintScreen, ScrollLock, Pause,
|
||||
BackTick, k1, k2, k3, k4, k5, k6, k7, k8, k9, k0, Hyphen, Equals, Backspace,
|
||||
@@ -76,10 +76,10 @@ class Keyboard {
|
||||
virtual bool keyboard_did_change_key(Keyboard *keyboard, Key key, bool is_pressed) = 0;
|
||||
virtual void reset_all_keys(Keyboard *keyboard) = 0;
|
||||
};
|
||||
void set_delegate(Delegate *delegate);
|
||||
bool get_key_state(Key key) const;
|
||||
void set_delegate(Delegate *);
|
||||
bool get_key_state(Key) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
std::set<Key> observed_keys_;
|
||||
const std::set<Key> essential_modifiers_;
|
||||
const bool is_exclusive_ = true;
|
||||
|
@@ -19,12 +19,12 @@ class Mouse {
|
||||
/*!
|
||||
Indicates a movement of the mouse.
|
||||
*/
|
||||
virtual void move([[maybe_unused]] int x, [[maybe_unused]] int y) {}
|
||||
virtual void move([[maybe_unused]] const int x, [[maybe_unused]] const int y) {}
|
||||
|
||||
/*!
|
||||
@returns the number of buttons on this mouse.
|
||||
*/
|
||||
virtual int get_number_of_buttons() {
|
||||
virtual int get_number_of_buttons() const {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class Mouse {
|
||||
The intention is that @c index be semantic, not positional:
|
||||
0 for the primary button, 1 for the secondary, 2 for the tertiary, etc.
|
||||
*/
|
||||
virtual void set_button_pressed([[maybe_unused]] int index, [[maybe_unused]] bool is_pressed) {}
|
||||
virtual void set_button_pressed([[maybe_unused]] const int index, [[maybe_unused]] const bool is_pressed) {}
|
||||
|
||||
/*!
|
||||
Releases all depressed buttons.
|
||||
|
@@ -26,24 +26,24 @@ namespace Inputs {
|
||||
channels below. This is intended to be fixed.
|
||||
*/
|
||||
class QuadratureMouse: public Mouse {
|
||||
public:
|
||||
QuadratureMouse(int number_of_buttons) :
|
||||
public:
|
||||
QuadratureMouse(const int number_of_buttons) :
|
||||
number_of_buttons_(number_of_buttons) {}
|
||||
|
||||
/*
|
||||
Inputs, to satisfy the Mouse interface.
|
||||
*/
|
||||
void move(int x, int y) final {
|
||||
void move(const int x, const int y) final {
|
||||
// Accumulate all provided motion.
|
||||
axes_[0] += x;
|
||||
axes_[1] += y;
|
||||
}
|
||||
|
||||
int get_number_of_buttons() final {
|
||||
int get_number_of_buttons() const final {
|
||||
return number_of_buttons_;
|
||||
}
|
||||
|
||||
void set_button_pressed(int index, bool is_pressed) final {
|
||||
void set_button_pressed(const int index, const bool is_pressed) final {
|
||||
if(is_pressed)
|
||||
button_flags_ |= (1 << index);
|
||||
else
|
||||
@@ -89,14 +89,14 @@ class QuadratureMouse: public Mouse {
|
||||
bit 1 is the 'secondary' (i.e. that which can be queried to
|
||||
observe direction).
|
||||
*/
|
||||
int get_channel(int axis) {
|
||||
int get_channel(int axis) const {
|
||||
return primaries_[axis] | (secondaries_[axis] << 1);
|
||||
}
|
||||
|
||||
/*!
|
||||
@returns a bit mask of the currently pressed buttons.
|
||||
*/
|
||||
int get_button_mask() {
|
||||
int get_button_mask() const {
|
||||
return button_flags_;
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@ class QuadratureMouse: public Mouse {
|
||||
@returns @c true if any mouse motion is waiting to be communicated;
|
||||
@c false otherwise.
|
||||
*/
|
||||
bool has_steps() {
|
||||
bool has_steps() const {
|
||||
return axes_[0] || axes_[1];
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
const int number_of_buttons_ = 0;
|
||||
std::atomic<int> button_flags_{0};
|
||||
std::atomic<int> axes_[2]{0, 0};
|
||||
|
@@ -507,7 +507,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->quickload = accelerate_loading_;
|
||||
return options;
|
||||
|
@@ -314,7 +314,7 @@ private:
|
||||
keyboard_.mouse_y_ += y;
|
||||
}
|
||||
|
||||
int get_number_of_buttons() override {
|
||||
int get_number_of_buttons() const override {
|
||||
return 3;
|
||||
}
|
||||
|
||||
|
@@ -589,7 +589,7 @@ template <bool has_scsi_bus> class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->quickload = allow_fast_tape_hack_;
|
||||
|
@@ -14,7 +14,7 @@ using namespace Amiga;
|
||||
|
||||
// MARK: - Mouse.
|
||||
|
||||
int Mouse::get_number_of_buttons() {
|
||||
int Mouse::get_number_of_buttons() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@@ -27,7 +27,7 @@ class Mouse: public Inputs::Mouse, public MouseJoystickInput {
|
||||
uint8_t get_cia_button() const final;
|
||||
|
||||
private:
|
||||
int get_number_of_buttons() final;
|
||||
int get_number_of_buttons() const final;
|
||||
void set_button_pressed(int, bool) final;
|
||||
void reset_all_buttons() final;
|
||||
void move(int, int) final;
|
||||
|
@@ -1187,7 +1187,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->quickload = allow_fast_tape_hack_;
|
||||
|
@@ -58,7 +58,7 @@ void Mouse::move(int x, int y) {
|
||||
post_service_request();
|
||||
}
|
||||
|
||||
int Mouse::get_number_of_buttons() {
|
||||
int Mouse::get_number_of_buttons() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@@ -21,7 +21,7 @@ class Mouse: public ReactiveDevice, public Inputs::Mouse {
|
||||
void perform_command(const Command &command) override;
|
||||
|
||||
void move(int x, int y) override;
|
||||
int get_number_of_buttons() override;
|
||||
int get_number_of_buttons() const override;
|
||||
void set_button_pressed(int index, bool is_pressed) override;
|
||||
void reset_all_buttons() override;
|
||||
|
||||
|
@@ -1043,7 +1043,7 @@ template <Analyser::Static::AppleII::Target::Model model, bool has_mockingboard>
|
||||
}
|
||||
|
||||
// MARK:: Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->use_square_pixels = video_.get_use_square_pixels();
|
||||
|
@@ -55,11 +55,10 @@ void VideoBase::set_use_square_pixels(bool use_square_pixels) {
|
||||
crt_.set_aspect_ratio(4.0f / 3.0f);
|
||||
}
|
||||
}
|
||||
bool VideoBase::get_use_square_pixels() {
|
||||
bool VideoBase::get_use_square_pixels() const {
|
||||
return use_square_pixels_;
|
||||
}
|
||||
|
||||
|
||||
void VideoBase::set_scan_target(Outputs::Display::ScanTarget *scan_target) {
|
||||
crt_.set_scan_target(scan_target);
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@ class VideoBase: public VideoSwitches<Cycles> {
|
||||
/// Sets whether the current CRT should be recalibrated away from normative NTSC
|
||||
/// to produce square pixels in 40-column text mode.
|
||||
void set_use_square_pixels(bool);
|
||||
bool get_use_square_pixels();
|
||||
bool get_use_square_pixels() const;
|
||||
|
||||
protected:
|
||||
Outputs::CRT::CRT crt_;
|
||||
|
@@ -502,7 +502,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->quickboot = quickboot_;
|
||||
return options;
|
||||
|
@@ -692,7 +692,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
|
@@ -427,7 +427,7 @@ void IntelligentKeyboard::move(int x, int y) {
|
||||
mouse_movement_[1] += y;
|
||||
}
|
||||
|
||||
int IntelligentKeyboard::get_number_of_buttons() {
|
||||
int IntelligentKeyboard::get_number_of_buttons() const {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
@@ -105,7 +105,7 @@ class IntelligentKeyboard:
|
||||
|
||||
// Inputs::Mouse.
|
||||
void move(int x, int y) final;
|
||||
int get_number_of_buttons() final;
|
||||
int get_number_of_buttons() const final;
|
||||
void set_button_pressed(int index, bool is_pressed) final;
|
||||
void reset_all_buttons() final;
|
||||
|
||||
|
@@ -357,7 +357,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
|
@@ -678,7 +678,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->quickload = allow_fast_tape_hack_;
|
||||
|
@@ -734,7 +734,7 @@ template <bool has_disk_controller, bool is_6mhz> class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
|
@@ -812,7 +812,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->quickload = allow_fast_tape_;
|
||||
|
@@ -421,7 +421,7 @@ template <Analyser::Static::Sega::Target::Model model> class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
|
@@ -677,7 +677,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface, CPU::MOS
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
options->quickload = use_fast_tape_hack_;
|
||||
|
@@ -1118,7 +1118,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Configuration options.
|
||||
std::unique_ptr<Reflection::Struct> get_options() override {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const override {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly);
|
||||
options->output = get_video_signal_configurable();
|
||||
return options;
|
||||
|
@@ -383,7 +383,7 @@ template<bool is_zx81> class ConcreteMachine:
|
||||
|
||||
// MARK: - Configuration options.
|
||||
|
||||
std::unique_ptr<Reflection::Struct> get_options() final {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const final {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly); // OptionsType is arbitrary, but not optional.
|
||||
options->automatic_tape_motor_control = use_automatic_tape_motor_control_;
|
||||
options->quickload = allow_fast_tape_hack_;
|
||||
|
@@ -721,7 +721,7 @@ template<Model model> class ConcreteMachine:
|
||||
|
||||
// MARK: - Configuration options.
|
||||
|
||||
std::unique_ptr<Reflection::Struct> get_options() override {
|
||||
std::unique_ptr<Reflection::Struct> get_options() const override {
|
||||
auto options = std::make_unique<Options>(Configurable::OptionsType::UserFriendly); // OptionsType is arbitrary, but not optional.
|
||||
options->automatic_tape_motor_control = use_automatic_tape_motor_control_;
|
||||
options->quickload = allow_fast_tape_hack_;
|
||||
|
Reference in New Issue
Block a user