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-2014 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 // $Id: TrackBall.hxx 2838 2014-01-17 23:34:03Z stephena $ 18 //============================================================================ 19 20 #ifndef TRACKBALL_HXX 21 #define TRACKBALL_HXX 22 23 #include "bspf.hxx" 24 #include "Control.hxx" 25 #include "Event.hxx" 26 27 /** 28 The various trackball-like controllers supported by the Atari 2600. 29 They're all placed in one class, since other than a few minor 30 differences, they work almost exactly the same. This code was 31 heavily borrowed from z26. 32 33 The supported controllers include: 34 TrackBall22: Atari 2600 CX-22 Trakball 35 TrackBall80: Atari ST CX-80 Trakball 36 AmigaMouse: Amiga Mouse 37 38 @author Stephen Anthony & z26 team 39 @version $Id: TrackBall.hxx 2838 2014-01-17 23:34:03Z stephena $ 40 */ 41 class TrackBall : public Controller 42 { 43 public: 44 /** 45 Create a new TrackBall controller plugged into the specified jack 46 47 @param jack The jack the controller is plugged into 48 @param event The event object to use for events 49 @param system The system using this controller 50 @param type The type of trackball controller 51 */ 52 TrackBall(Jack jack, const Event& event, const System& system, Type type); 53 54 /** 55 Destructor 56 */ 57 virtual ~TrackBall(); 58 59 public: 60 using Controller::read; 61 62 /** 63 Read the entire state of all digital pins for this controller. 64 Note that this method must use the lower 4 bits, and zero the upper bits. 65 66 @return The state of all digital pins 67 */ 68 uInt8 read(); 69 70 /** 71 Update the entire digital and analog pin state according to the 72 events currently set. 73 */ 74 void update(); 75 76 /** 77 Determines how this controller will treat values received from the 78 X/Y axis and left/right buttons of the mouse. Since not all controllers 79 use the mouse the same way (or at all), it's up to the specific class to 80 decide how to use this data. 81 82 In the current implementation, the left button is tied to the X axis, 83 and the right one tied to the Y axis. 84 85 @param xtype The controller to use for x-axis data 86 @param xid The controller ID to use for x-axis data (-1 for no id) 87 @param ytype The controller to use for y-axis data 88 @param yid The controller ID to use for y-axis data (-1 for no id) 89 90 @return Whether the controller supports using the mouse 91 */ 92 bool setMouseControl( 93 Controller::Type xtype, int xid, Controller::Type ytype, int yid); 94 95 private: 96 // Counter to iterate through the gray codes 97 int myHCounter, myVCounter; 98 99 // How many new horizontal and vertical values this frame 100 int myTrakBallCountH, myTrakBallCountV; 101 102 // How many lines to wait before sending new horz and vert val 103 int myTrakBallLinesH, myTrakBallLinesV; 104 105 // Was TrakBall moved left or moved right instead 106 int myTrakBallLeft; 107 108 // Was TrakBall moved down or moved up instead 109 int myTrakBallDown; 110 111 int myScanCountH, myScanCountV, myCountH, myCountV; 112 113 // Whether to use the mouse to emulate this controller 114 int myMouseEnabled; 115 116 // CX-22 117 static const uInt32 ourTrakBallTableTB_H[2][2]; 118 static const uInt32 ourTrakBallTableTB_V[2][2]; 119 120 // ST mouse / CX-80 121 static const uInt32 ourTrakBallTableST_H[4]; 122 static const uInt32 ourTrakBallTableST_V[4]; 123 124 // Amiga mouse 125 static const uInt32 ourTrakBallTableAM_H[4]; 126 static const uInt32 ourTrakBallTableAM_V[4]; 127 }; 128 129 #endif 130