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-2021 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 #include "Booster.hxx"
19 
20 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BoosterGrip(Jack jack,const Event & event,const System & system)21 BoosterGrip::BoosterGrip(Jack jack, const Event& event, const System& system)
22   : Joystick(jack, event, system, Controller::Type::BoosterGrip)
23 {
24   if(myJack == Jack::Left)
25   {
26     myTriggerEvent = Event::LeftJoystickFire5;
27     myBoosterEvent = Event::LeftJoystickFire9;
28   }
29   else
30   {
31     myTriggerEvent = Event::RightJoystickFire5;
32     myBoosterEvent = Event::RightJoystickFire9;
33   }
34 
35   setPin(AnalogPin::Five, AnalogReadout::disconnect());
36   setPin(AnalogPin::Nine, AnalogReadout::disconnect());
37 }
38 
39 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
updateButtons()40 void BoosterGrip::updateButtons()
41 {
42   bool firePressed = myEvent.get(myFireEvent) != 0;
43   // The CBS Booster-grip has two more buttons on it.  These buttons are
44   // connected to the inputs usually used by paddles.
45   bool triggerPressed = myEvent.get(myTriggerEvent) != 0;
46   bool boosterPressed = myEvent.get(myBoosterEvent) != 0;
47 
48   updateMouseButtons(firePressed, boosterPressed);
49 
50   setPin(DigitalPin::Six, !getAutoFireState(firePressed));
51   setPin(AnalogPin::Five, triggerPressed ? AnalogReadout::connectToVcc() : AnalogReadout::disconnect());
52   setPin(AnalogPin::Nine, boosterPressed ? AnalogReadout::connectToVcc() : AnalogReadout::disconnect());
53 }
54 
55