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 KEYBOARD_HXX |
19 | #define KEYBOARD_HXX |
20 | |
21 | #include "bspf.hxx" |
22 | #include "Control.hxx" |
23 | #include "Event.hxx" |
24 | |
25 | /** |
26 | The standard Atari 2600 keyboard controller |
27 | |
28 | @author Bradford W. Mott |
29 | */ |
30 | class Keyboard : public Controller |
31 | { |
32 | public: |
33 | /** |
34 | Create a new keyboard controller plugged into the specified jack |
35 | |
36 | @param jack The jack the controller is plugged into |
37 | @param event The event object to use for events |
38 | @param system The system using this controller |
39 | */ |
40 | Keyboard(Jack jack, const Event& event, const System& system); |
41 | virtual ~Keyboard() = default; |
42 | |
43 | public: |
44 | /** |
45 | Write the given value to the specified digital pin for this |
46 | controller. Writing is only allowed to the pins associated |
47 | with the PIA. Therefore you cannot write to pin six. |
48 | |
49 | @param pin The pin of the controller jack to write to |
50 | @param value The value to write to the pin |
51 | */ |
52 | void write(DigitalPin pin, bool value) override; |
53 | |
54 | /** |
55 | Update the entire digital and analog pin state according to the |
56 | events currently set. |
57 | */ |
58 | void update() override { } |
59 | |
60 | /** |
61 | Returns the name of this controller. |
62 | */ |
63 | string name() const override { return "Keyboard" ; } |
64 | |
65 | private: |
66 | // Pre-compute the events we care about based on given port |
67 | // This will eliminate test for left or right port in update() |
68 | Event::Type myOneEvent, myTwoEvent, myThreeEvent, |
69 | myFourEvent, myFiveEvent, mySixEvent, |
70 | mySevenEvent, myEightEvent, myNineEvent, |
71 | myStarEvent, myZeroEvent, myPoundEvent; |
72 | |
73 | static constexpr Int32 MIN_RESISTANCE = 5600; |
74 | |
75 | private: |
76 | // Following constructors and assignment operators not supported |
77 | Keyboard() = delete; |
78 | Keyboard(const Keyboard&) = delete; |
79 | Keyboard(Keyboard&&) = delete; |
80 | Keyboard& operator=(const Keyboard&) = delete; |
81 | Keyboard& operator=(Keyboard&&) = delete; |
82 | }; |
83 | |
84 | #endif |
85 | |