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 TRAKBALL_HXX
19#define TRAKBALL_HXX
20
21#include "PointingDevice.hxx"
22
23class TrakBall : public PointingDevice
24{
25 public:
26 /**
27 Create a new trakball controller plugged into the specified jack
28
29 @param jack The jack the controller is plugged into
30 @param event The event object to use for events
31 @param system The system using this controller
32 */
33 TrakBall(Jack jack, const Event& event, const System& system)
34 : PointingDevice(jack, event, system, Controller::Type::TrakBall,
35 trackballSensitivity) { }
36 virtual ~TrakBall() = default;
37
38 /**
39 Returns the name of this controller.
40 */
41 string name() const override { return "TrakBall"; }
42
43 protected:
44 uInt8 ioPortA(uInt8 countH, uInt8 countV, uInt8 left, uInt8 down) override
45 {
46 static constexpr uInt32 ourTableH[2][2] = {{ 0b00, 0b01 }, { 0b10, 0b11 }};
47 static constexpr uInt32 ourTableV[2][2] = {{ 0b0100, 0b0000 }, { 0b1100, 0b1000 }};
48
49 return ourTableH[countH & 0b1][left] | ourTableV[countV & 0b1][down];
50 }
51
52 // 50% of Atari and Amiga mouse
53 static constexpr float trackballSensitivity = 0.4f;
54};
55
56#endif // TRAKBALL_HXX
57