mirror of
https://github.com/TomHarte/CLK.git
synced 2025-03-25 21:34:05 +00:00
Fixes const correctness for joystick machines; the ST is now one such.
This commit is contained in:
parent
3741cba88c
commit
2c25135d8a
Analyser/Dynamic/MultiMachine/Implementation
Machines
OSBindings
@ -81,6 +81,6 @@ MultiJoystickMachine::MultiJoystickMachine(const std::vector<std::unique_ptr<::M
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &MultiJoystickMachine::get_joysticks() {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &MultiJoystickMachine::get_joysticks() {
|
||||
return joysticks_;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class MultiJoystickMachine: public JoystickMachine::Machine {
|
||||
MultiJoystickMachine(const std::vector<std::unique_ptr<::Machine::DynamicMachine>> &machines);
|
||||
|
||||
// Below is the standard JoystickMachine::Machine interface; see there for documentation.
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override;
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override;
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
|
||||
|
@ -604,7 +604,7 @@ class KeyboardState: public GI::AY38910::PortHandler {
|
||||
memset(rows_, 0xff, sizeof(rows_));
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
@ -1093,7 +1093,7 @@ template <bool has_fdc> class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Joysticks
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return key_state_.get_joysticks();
|
||||
}
|
||||
|
||||
|
@ -893,7 +893,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: JoystickMachine
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return joysticks_;
|
||||
}
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ class ConcreteMachine:
|
||||
joysticks_.emplace_back(new Joystick(bus_.get(), 4, 1));
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "AtariST.hpp"
|
||||
|
||||
#include "../../CRTMachine.hpp"
|
||||
#include "../../JoystickMachine.hpp"
|
||||
#include "../../KeyboardMachine.hpp"
|
||||
#include "../../MouseMachine.hpp"
|
||||
#include "../../MediaTarget.hpp"
|
||||
@ -49,6 +50,7 @@ class ConcreteMachine:
|
||||
public Motorola::MFP68901::MFP68901::InterruptDelegate,
|
||||
public DMAController::Delegate,
|
||||
public MouseMachine::Machine,
|
||||
public JoystickMachine::Machine,
|
||||
public KeyboardMachine::MappedMachine,
|
||||
public Activity::Source,
|
||||
public MediaTarget::Machine,
|
||||
@ -527,6 +529,11 @@ class ConcreteMachine:
|
||||
return &keyboard_mapper_;
|
||||
}
|
||||
|
||||
// MARK: - JoystickMachine
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final {
|
||||
return ikbd_.get_joysticks();
|
||||
}
|
||||
|
||||
// MARK: - AYPortHandler
|
||||
void set_port_output(bool port_b, uint8_t value) final {
|
||||
if(port_b) {
|
||||
|
@ -13,10 +13,13 @@
|
||||
#include "../../../Components/Serial/Line.hpp"
|
||||
#include "../../KeyboardMachine.hpp"
|
||||
|
||||
#include "../../../Inputs/Joystick.hpp"
|
||||
#include "../../../Inputs/Mouse.hpp"
|
||||
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Atari {
|
||||
namespace ST {
|
||||
@ -61,6 +64,10 @@ class IntelligentKeyboard:
|
||||
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) final;
|
||||
};
|
||||
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
private:
|
||||
// MARK: - Key queue.
|
||||
std::mutex key_queue_mutex_;
|
||||
@ -128,6 +135,7 @@ class IntelligentKeyboard:
|
||||
enum class JoystickMode {
|
||||
Disabled, Event, Interrogation
|
||||
} joystick_mode_ = JoystickMode::Event;
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class ConcreteMachine:
|
||||
audio_queue_.flush();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ class ConcreteMachine:
|
||||
keyboard_via_port_handler_->clear_all_keys();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ namespace JoystickMachine {
|
||||
|
||||
class Machine {
|
||||
public:
|
||||
virtual std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() = 0;
|
||||
virtual const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class AYPortHandler: public GI::AY38910::PortHandler {
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
@ -686,7 +686,7 @@ class ConcreteMachine:
|
||||
}
|
||||
|
||||
// MARK: - Joysticks
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return ay_port_handler_.get_joysticks();
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ class ConcreteMachine:
|
||||
audio_queue_.perform();
|
||||
}
|
||||
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
|
||||
return joysticks_;
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ struct ActivityObserver: public Activity::Observer {
|
||||
// Until then, apply a default mapping.
|
||||
|
||||
size_t c = 0;
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &machine_joysticks = _joystickMachine->get_joysticks();
|
||||
auto &machine_joysticks = _joystickMachine->get_joysticks();
|
||||
for(CSJoystick *joystick in _joystickManager.joysticks) {
|
||||
size_t target = c % machine_joysticks.size();
|
||||
++c;
|
||||
@ -373,7 +373,7 @@ struct ActivityObserver: public Activity::Observer {
|
||||
@synchronized(self) {
|
||||
_joystickManager = joystickManager;
|
||||
if(_joystickMachine) {
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &machine_joysticks = _joystickMachine->get_joysticks();
|
||||
auto &machine_joysticks = _joystickMachine->get_joysticks();
|
||||
for(const auto &joystick: machine_joysticks) {
|
||||
joystick->reset_all_inputs();
|
||||
}
|
||||
@ -467,7 +467,7 @@ struct ActivityObserver: public Activity::Observer {
|
||||
auto joystick_machine = _machine->joystick_machine();
|
||||
if(self.inputMode == CSMachineKeyboardInputModeJoystick && joystick_machine) {
|
||||
@synchronized(self) {
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &joysticks = joystick_machine->get_joysticks();
|
||||
auto &joysticks = joystick_machine->get_joysticks();
|
||||
if(!joysticks.empty()) {
|
||||
// Convert to a C++ bool so that the following calls are resolved correctly even if overloaded.
|
||||
bool is_pressed = !!isPressed;
|
||||
|
@ -741,7 +741,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
JoystickMachine::Machine *const joystick_machine = machine->joystick_machine();
|
||||
if(joystick_machine) {
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &joysticks = joystick_machine->get_joysticks();
|
||||
auto &joysticks = joystick_machine->get_joysticks();
|
||||
if(!joysticks.empty()) {
|
||||
switch(event.key.keysym.scancode) {
|
||||
case SDL_SCANCODE_LEFT: joysticks[0]->set_input(Inputs::Joystick::Input::Left, is_pressed); break;
|
||||
@ -791,7 +791,7 @@ int main(int argc, char *argv[]) {
|
||||
// Push new joystick state, if any.
|
||||
JoystickMachine::Machine *const joystick_machine = machine->joystick_machine();
|
||||
if(joystick_machine) {
|
||||
std::vector<std::unique_ptr<Inputs::Joystick>> &machine_joysticks = joystick_machine->get_joysticks();
|
||||
auto &machine_joysticks = joystick_machine->get_joysticks();
|
||||
for(size_t c = 0; c < joysticks.size(); ++c) {
|
||||
size_t target = c % machine_joysticks.size();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user