1//============================================================================
2//
3// SSSS tt lll lll
4// SS SS tt ll ll
5// SS tttttt eeee ll ll aaaa
6// SSSS tt ee ee ll ll aa
7// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
8// SS SS tt ee ll ll aa aa
9// SSSS ttt eeeee llll llll aaaaa
10//
11// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
12// and the Stella Team
13//
14// See the file "License.txt" for information on usage and redistribution of
15// this file, and for a DISCLAIMER OF ALL WARRANTIES.
16//============================================================================
17
18#ifndef PHYSICAL_JOYSTICK_HXX
19#define PHYSICAL_JOYSTICK_HXX
20
21#include "Event.hxx"
22#include "EventHandlerConstants.hxx"
23#include "JoyMap.hxx"
24
25/**
26 An abstraction of a physical (real) joystick in Stella.
27
28 A PhysicalJoystick holds its own event mapping information, space for
29 which is dynamically allocated based on the actual number of buttons,
30 axes, etc that the device contains.
31
32 Specific backend class(es) will inherit from this class, and implement
33 functionality specific to the device.
34
35 @author Stephen Anthony, Thomas Jentzsch
36*/
37
38class PhysicalJoystick
39{
40 friend class PhysicalJoystickHandler;
41
42 static constexpr char MODE_DELIM = '>'; // must not be '^', '|' or '#'
43
44 public:
45 PhysicalJoystick();
46 virtual ~PhysicalJoystick();
47
48 string getMap() const;
49 bool setMap(const string& map);
50 void eraseMap(EventMode mode);
51 void eraseEvent(Event::Type event, EventMode mode);
52 string about() const;
53
54 protected:
55 void initialize(int index, const string& desc,
56 int axes, int buttons, int hats, int balls);
57
58 private:
59 // TODO: these are not required anymore, delete or keep for future usage?
60 enum JoyType {
61 JT_NONE = 0,
62 JT_REGULAR = 1,
63 JT_STELLADAPTOR_LEFT = 2,
64 JT_STELLADAPTOR_RIGHT = 3,
65 JT_2600DAPTOR_LEFT = 4,
66 JT_2600DAPTOR_RIGHT = 5
67 };
68
69 JoyType type;
70 int ID;
71 string name;
72 int numAxes, numButtons, numHats;
73 int* axisLastValue;
74 int* buttonLast;
75
76 // Hashmaps of controller events
77 JoyMap joyMap;
78
79 private:
80 void getValues(const string& list, IntArray& map) const;
81
82 friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) {
83 os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes
84 << ", numbtns: " << s.numButtons << ", numhats: " << s.numHats;
85 return os;
86 }
87};
88
89#endif
90