2021-11-26 22:50:47 +00:00
|
|
|
//
|
|
|
|
// MouseJoystick.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 26/11/2021.
|
|
|
|
// Copyright © 2021 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2021-11-26 22:50:47 +00:00
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
#include "../../Inputs/Joystick.hpp"
|
|
|
|
#include "../../Inputs/Mouse.hpp"
|
|
|
|
|
|
|
|
namespace Amiga {
|
|
|
|
|
|
|
|
struct MouseJoystickInput {
|
|
|
|
virtual uint16_t get_position() = 0;
|
|
|
|
virtual uint8_t get_cia_button() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Mouse: public Inputs::Mouse, public MouseJoystickInput {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
uint16_t get_position() final;
|
|
|
|
uint8_t get_cia_button() const final;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int get_number_of_buttons() const final;
|
|
|
|
void set_button_pressed(int, bool) final;
|
|
|
|
void reset_all_buttons() final;
|
|
|
|
void move(int, int) final;
|
|
|
|
|
|
|
|
uint8_t declared_position_[2]{};
|
|
|
|
uint8_t cia_state_ = 0xff;
|
|
|
|
std::array<std::atomic<int>, 2> position_{};
|
2021-11-26 22:50:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Joystick: public Inputs::ConcreteJoystick, public MouseJoystickInput {
|
2024-12-02 02:44:14 +00:00
|
|
|
public:
|
|
|
|
Joystick();
|
2021-11-26 22:50:47 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
uint16_t get_position() final;
|
|
|
|
uint8_t get_cia_button() const final;
|
2021-11-26 22:50:47 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
private:
|
|
|
|
void did_set_input(const Input &input, bool is_active) final;
|
2021-11-26 22:50:47 +00:00
|
|
|
|
2024-12-02 02:44:14 +00:00
|
|
|
bool inputs_[Joystick::Input::Type::Max]{};
|
|
|
|
uint16_t position_ = 0;
|
2021-11-26 22:50:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|