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