openMSX
Public Member Functions | Static Public Member Functions | List of all members
openmsx::Joystick Class Referencefinal

Uses an SDL joystick to emulate an MSX joystick. More...

#include <Joystick.hh>

Inheritance diagram for openmsx::Joystick:
Inheritance graph
[legend]
Collaboration diagram for openmsx::Joystick:
Collaboration graph
[legend]

Public Member Functions

 Joystick (MSXEventDistributor &eventDistributor, StateChangeDistributor &stateChangeDistributor, CommandController &commandController, GlobalSettings &globalSettings, SDL_Joystick *joystick)
 
 ~Joystick () override
 
std::string_view getName () const override
 Name used to identify this pluggable. More...
 
std::string_view getDescription () const override
 Description for this pluggable. More...
 
void plugHelper (Connector &connector, EmuTime::param time) override
 
void unplugHelper (EmuTime::param time) override
 
uint8_t read (EmuTime::param time) override
 Read from the joystick device. More...
 
void write (uint8_t value, EmuTime::param time) override
 Write a value to the joystick device. More...
 
template<typename Archive >
void serialize (Archive &ar, unsigned version)
 
- Public Member Functions inherited from openmsx::JoystickDevice
virtual uint8_t read (EmuTime::param time)=0
 Read from the joystick device. More...
 
virtual void write (uint8_t value, EmuTime::param time)=0
 Write a value to the joystick device. More...
 
std::string_view getClass () const final
 A pluggable belongs to a certain class. More...
 
- Public Member Functions inherited from openmsx::Pluggable
virtual ~Pluggable ()=default
 
virtual std::string_view getName () const
 Name used to identify this pluggable. More...
 
virtual std::string_view getClass () const =0
 A pluggable belongs to a certain class. More...
 
virtual std::string_view getDescription () const =0
 Description for this pluggable. More...
 
void plug (Connector &connector, EmuTime::param time)
 This method is called when this pluggable is inserted in a connector. More...
 
void unplug (EmuTime::param time)
 This method is called when this pluggable is removed from a connector. More...
 
ConnectorgetConnector () const
 Get the connector this Pluggable is plugged into. More...
 
bool isPluggedIn () const
 Returns true if this pluggable is currently plugged into a connector. More...
 

Static Public Member Functions

static void registerAll (MSXEventDistributor &eventDistributor, StateChangeDistributor &stateChangeDistributor, CommandController &commandController, GlobalSettings &globalSettings, PluggingController &controller)
 Register all available SDL joysticks. More...
 

Additional Inherited Members

- Static Public Attributes inherited from openmsx::JoystickDevice
static constexpr uint8_t JOY_UP = 0x01
 
static constexpr uint8_t JOY_DOWN = 0x02
 
static constexpr uint8_t JOY_LEFT = 0x04
 
static constexpr uint8_t JOY_RIGHT = 0x08
 
static constexpr uint8_t JOY_BUTTONA = 0x10
 
static constexpr uint8_t JOY_BUTTONB = 0x20
 
static constexpr uint8_t RD_PIN1 = 0x01
 
static constexpr uint8_t RD_PIN2 = 0x02
 
static constexpr uint8_t RD_PIN3 = 0x04
 
static constexpr uint8_t RD_PIN4 = 0x08
 
static constexpr uint8_t RD_PIN6 = 0x10
 
static constexpr uint8_t RD_PIN7 = 0x20
 
static constexpr uint8_t WR_PIN6 = 0x01
 
static constexpr uint8_t WR_PIN7 = 0x02
 
static constexpr uint8_t WR_PIN8 = 0x04
 
- Protected Member Functions inherited from openmsx::Pluggable
 Pluggable ()
 
virtual void plugHelper (Connector &newConnector, EmuTime::param time)=0
 
virtual void unplugHelper (EmuTime::param time)=0
 
void setConnector (Connector *conn)
 

Detailed Description

Uses an SDL joystick to emulate an MSX joystick.

Definition at line 24 of file Joystick.hh.

Constructor & Destructor Documentation

◆ Joystick()

openmsx::Joystick::Joystick ( MSXEventDistributor eventDistributor,
StateChangeDistributor stateChangeDistributor,
CommandController commandController,
GlobalSettings globalSettings,
SDL_Joystick *  joystick 
)

◆ ~Joystick()

openmsx::Joystick::~Joystick ( )
override

Definition at line 173 of file Joystick.cc.

References openmsx::Pluggable::isPluggedIn(), and unplugHelper().

Member Function Documentation

◆ getDescription()

std::string_view openmsx::Joystick::getDescription ( ) const
overridevirtual

Description for this pluggable.

Implements openmsx::Pluggable.

Definition at line 189 of file Joystick.cc.

◆ getName()

std::string_view openmsx::Joystick::getName ( ) const
overridevirtual

Name used to identify this pluggable.

Reimplemented from openmsx::Pluggable.

Definition at line 184 of file Joystick.cc.

◆ plugHelper()

void openmsx::Joystick::plugHelper ( Connector connector,
EmuTime::param  time 
)
overridevirtual

Implements openmsx::Pluggable.

Definition at line 194 of file Joystick.cc.

◆ read()

uint8_t openmsx::Joystick::read ( EmuTime::param  time)
overridevirtual

Read from the joystick device.

The bits in the read byte have following meaning: 7 6 5 4 3 2 1 0 | xx | xx | BUTTON_B | BUTTON_A | RIGHT | LEFT | DOWN | UP | | xx | xx | pin7 | pin6 | pin4 | pin3 | pin2 | pin1|

Implements openmsx::JoystickDevice.

Definition at line 217 of file Joystick.cc.

◆ registerAll()

void openmsx::Joystick::registerAll ( MSXEventDistributor eventDistributor,
StateChangeDistributor stateChangeDistributor,
CommandController commandController,
GlobalSettings globalSettings,
PluggingController controller 
)
static

Register all available SDL joysticks.

Definition at line 24 of file Joystick.cc.

References openmsx::InputEventGenerator::joystickNumButtons(), openmsx::PluggingController::registerPluggable(), and xrange().

Referenced by openmsx::PluggableFactory::createAll().

◆ serialize()

template<typename Archive >
void openmsx::Joystick::serialize ( Archive &  ar,
unsigned  version 
)

Definition at line 363 of file Joystick.cc.

References openmsx::Pluggable::isPluggedIn().

◆ unplugHelper()

void openmsx::Joystick::unplugHelper ( EmuTime::param  time)
overridevirtual

◆ write()

void openmsx::Joystick::write ( uint8_t  value,
EmuTime::param  time 
)
overridevirtual

Write a value to the joystick device.

The bits in the written byte have following meaning: 7 6 5 4 3 2 1 0 | xx | xx | xx | xx | xx | pin8 | pin7 | pin6 | As an optimization, this method might not be called when the new value is the same as the previous one.

Implements openmsx::JoystickDevice.

Definition at line 222 of file Joystick.cc.


The documentation for this class was generated from the following files: