added extra buttons to right Paddle A too

This commit is contained in:
thrust26 2025-06-23 09:06:18 +02:00
parent ac57149ebd
commit 6ce835b3e6
7 changed files with 68 additions and 57 deletions

View File

@ -1048,6 +1048,8 @@ PhysicalKeyboardHandler::DefaultPaddleMapping = {
{Event::RightPaddleADecrease, KBDK_J}, {Event::RightPaddleADecrease, KBDK_J},
{Event::RightPaddleAIncrease, KBDK_G}, {Event::RightPaddleAIncrease, KBDK_G},
{Event::RightPaddleAFire, KBDK_F}, {Event::RightPaddleAFire, KBDK_F},
{Event::RightPaddleAButton1, KBDK_Y, KBDM_SHIFT},
{Event::RightPaddleAButton2, KBDK_H, KBDM_SHIFT},
{Event::RightPaddleBDecrease, KBDK_H}, {Event::RightPaddleBDecrease, KBDK_H},
{Event::RightPaddleBIncrease, KBDK_Y}, {Event::RightPaddleBIncrease, KBDK_Y},

View File

@ -123,6 +123,8 @@ NLOHMANN_JSON_SERIALIZE_ENUM(Event::Type, {
{Event::RightPaddleAIncrease, "RightPaddleAIncrease"}, {Event::RightPaddleAIncrease, "RightPaddleAIncrease"},
{Event::RightPaddleAAnalog, "RightPaddleAAnalog"}, {Event::RightPaddleAAnalog, "RightPaddleAAnalog"},
{Event::RightPaddleAFire, "RightPaddleAFire"}, {Event::RightPaddleAFire, "RightPaddleAFire"},
{Event::RightPaddleAButton1, "RightPaddleAButton1"},
{Event::RightPaddleAButton2, "RightPaddleAButton2"},
{Event::RightPaddleBDecrease, "RightPaddleBDecrease"}, {Event::RightPaddleBDecrease, "RightPaddleBDecrease"},
{Event::RightPaddleBIncrease, "RightPaddleBIncrease"}, {Event::RightPaddleBIncrease, "RightPaddleBIncrease"},
{Event::RightPaddleBAnalog, "RightPaddleBAnalog"}, {Event::RightPaddleBAnalog, "RightPaddleBAnalog"},

View File

@ -50,8 +50,9 @@ class Event
LeftPaddleADecrease, LeftPaddleAIncrease, LeftPaddleAAnalog, LeftPaddleADecrease, LeftPaddleAIncrease, LeftPaddleAAnalog,
LeftPaddleAFire, LeftPaddleAButton1, LeftPaddleAButton2, LeftPaddleAFire, LeftPaddleAButton1, LeftPaddleAButton2,
LeftPaddleBDecrease, LeftPaddleBIncrease, LeftPaddleBAnalog, LeftPaddleBDecrease, LeftPaddleBIncrease, LeftPaddleBAnalog,
LeftPaddleBFire, LeftPaddleBFire, RightPaddleAButton1, RightPaddleAButton2,
RightPaddleADecrease, RightPaddleAIncrease, RightPaddleAAnalog, RightPaddleAFire, RightPaddleADecrease, RightPaddleAIncrease, RightPaddleAAnalog,
RightPaddleAFire,
RightPaddleBDecrease, RightPaddleBIncrease, RightPaddleBAnalog, RightPaddleBFire, RightPaddleBDecrease, RightPaddleBIncrease, RightPaddleBAnalog, RightPaddleBFire,
LeftKeyboard1, LeftKeyboard2, LeftKeyboard3, LeftKeyboard1, LeftKeyboard2, LeftKeyboard3,
@ -307,8 +308,10 @@ static const Event::EventSet QTPaddles3Events = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const Event::EventSet RightPaddlesEvents = { static const Event::EventSet RightPaddlesEvents = {
Event::RightPaddleADecrease, Event::RightPaddleAIncrease, Event::RightPaddleAAnalog, Event::RightPaddleAFire, Event::RightPaddleADecrease, Event::RightPaddleAIncrease, Event::RightPaddleAAnalog,
Event::RightPaddleBDecrease, Event::RightPaddleBIncrease, Event::RightPaddleBAnalog, Event::RightPaddleBFire, Event::RightPaddleAFire, Event::RightPaddleAButton1, Event::RightPaddleAButton2,
Event::RightPaddleBDecrease, Event::RightPaddleBIncrease, Event::RightPaddleBAnalog,
Event::RightPaddleBFire,
}; };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static const Event::EventSet QTPaddles4Events = { static const Event::EventSet QTPaddles4Events = {

View File

@ -2891,6 +2891,8 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
{ Event::RightPaddleAIncrease, "Right Paddle A Turn Left" }, { Event::RightPaddleAIncrease, "Right Paddle A Turn Left" },
{ Event::RightPaddleADecrease, "Right Paddle A Turn Right" }, { Event::RightPaddleADecrease, "Right Paddle A Turn Right" },
{ Event::RightPaddleAFire, "Right Paddle A Fire" }, { Event::RightPaddleAFire, "Right Paddle A Fire" },
{ Event::RightPaddleAButton1, "Right Paddle A Button 1" },
{ Event::RightPaddleAButton2, "Right Paddle A Button 2" },
{ Event::RightPaddleBAnalog, "Right Paddle B Analog" }, { Event::RightPaddleBAnalog, "Right Paddle B Analog" },
{ Event::RightPaddleBIncrease, "Right Paddle B Turn Left" }, { Event::RightPaddleBIncrease, "Right Paddle B Turn Left" },
@ -3204,8 +3206,10 @@ const Event::EventSet EventHandler::PaddlesEvents = {
Event::LeftPaddleAFire, Event::LeftPaddleAButton1, Event::LeftPaddleAButton2, Event::LeftPaddleAFire, Event::LeftPaddleAButton1, Event::LeftPaddleAButton2,
Event::LeftPaddleBDecrease, Event::LeftPaddleBIncrease, Event::LeftPaddleBAnalog, Event::LeftPaddleBDecrease, Event::LeftPaddleBIncrease, Event::LeftPaddleBAnalog,
Event::LeftPaddleBFire, Event::LeftPaddleBFire,
Event::RightPaddleADecrease, Event::RightPaddleAIncrease, Event::RightPaddleAAnalog, Event::RightPaddleAFire, Event::RightPaddleADecrease, Event::RightPaddleAIncrease, Event::RightPaddleAAnalog,
Event::RightPaddleBDecrease, Event::RightPaddleBIncrease, Event::RightPaddleBAnalog, Event::RightPaddleBFire, Event::RightPaddleAFire, Event::RightPaddleAButton1, Event::RightPaddleAButton2,
Event::RightPaddleBDecrease, Event::RightPaddleBIncrease, Event::RightPaddleBAnalog,
Event::RightPaddleBFire,
Event::QTPaddle3AFire, Event::QTPaddle3BFire,Event::QTPaddle4AFire,Event::QTPaddle4BFire, Event::QTPaddle3AFire, Event::QTPaddle3BFire,Event::QTPaddle4AFire,Event::QTPaddle4BFire,
}; };

View File

@ -544,7 +544,7 @@ class EventHandler
#else #else
REFRESH_SIZE = 0, REFRESH_SIZE = 0,
#endif #endif
EMUL_ACTIONLIST_SIZE = 240 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE, EMUL_ACTIONLIST_SIZE = 242 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
MENU_ACTIONLIST_SIZE = 20 MENU_ACTIONLIST_SIZE = 20
; ;

View File

@ -44,35 +44,37 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
// As much as possible, precompute which events we care about for // As much as possible, precompute which events we care about for
// a given port; this will speed up processing in update() // a given port; this will speed up processing in update()
// Clear some potentially unused events:
myAAxisValue = myBAxisValue =
myADecEvent = myAIncEvent =
myAButton1Event = myAButton2Event =
myBDecEvent = myBIncEvent = Event::NoType;
// Consider whether this is the left or right port // Consider whether this is the left or right port
if(myJack == Jack::Left) if(myJack == Jack::Left)
{ {
if(!altmap) if(!altmap)
{ {
// First paddle is left A, second is left B // First paddle is left A, second is left B
myAAxisValue = Event::LeftPaddleAAnalog; myAAxisValue = Event::LeftPaddleAAnalog;
myBAxisValue = Event::LeftPaddleBAnalog; myBAxisValue = Event::LeftPaddleBAnalog;
myLeftAFireEvent = Event::LeftPaddleAFire; myAFireEvent = Event::LeftPaddleAFire;
myLeftAButton1Event = Event::LeftPaddleAButton1; myAButton1Event = Event::LeftPaddleAButton1;
myLeftAButton2Event = Event::LeftPaddleAButton2; myAButton2Event = Event::LeftPaddleAButton2;
myLeftBFireEvent = Event::LeftPaddleBFire; myBFireEvent = Event::LeftPaddleBFire;
// These can be affected by changes in axis orientation // These can be affected by changes in axis orientation
myLeftADecEvent = Event::LeftPaddleADecrease; myAIncEvent = Event::LeftPaddleAIncrease;
myLeftAIncEvent = Event::LeftPaddleAIncrease; myBDecEvent = Event::LeftPaddleBDecrease;
myLeftBDecEvent = Event::LeftPaddleBDecrease; myBIncEvent = Event::LeftPaddleBIncrease;
myLeftBIncEvent = Event::LeftPaddleBIncrease; myADecEvent = Event::LeftPaddleADecrease;
} }
else else
{ {
// First paddle is QT 3A, second is QT 3B (fire buttons only) // First paddle is QT 3A, second is QT 3B (fire buttons only)
myLeftAFireEvent = Event::QTPaddle3AFire; myAFireEvent = Event::QTPaddle3AFire;
myLeftBFireEvent = Event::QTPaddle3BFire; myBFireEvent = Event::QTPaddle3BFire;
myAAxisValue = myBAxisValue =
myLeftADecEvent = myLeftAIncEvent =
myLeftBDecEvent = myLeftBIncEvent = Event::NoType;
} }
} }
else // Jack is right port else // Jack is right port
@ -80,26 +82,25 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
if(!altmap) if(!altmap)
{ {
// First paddle is right A, second is right B // First paddle is right A, second is right B
myAAxisValue = Event::RightPaddleAAnalog; myAAxisValue = Event::RightPaddleAAnalog;
myBAxisValue = Event::RightPaddleBAnalog; myBAxisValue = Event::RightPaddleBAnalog;
myLeftAFireEvent = Event::RightPaddleAFire; myAFireEvent = Event::RightPaddleAFire;
myLeftBFireEvent = Event::RightPaddleBFire; myAButton1Event = Event::RightPaddleAButton1;
myAButton2Event = Event::RightPaddleAButton2;
myBFireEvent = Event::RightPaddleBFire;
// These can be affected by changes in axis orientation // These can be affected by changes in axis orientation
myLeftADecEvent = Event::RightPaddleADecrease; myADecEvent = Event::RightPaddleADecrease;
myLeftAIncEvent = Event::RightPaddleAIncrease; myAIncEvent = Event::RightPaddleAIncrease;
myLeftBDecEvent = Event::RightPaddleBDecrease; myBDecEvent = Event::RightPaddleBDecrease;
myLeftBIncEvent = Event::RightPaddleBIncrease; myBIncEvent = Event::RightPaddleBIncrease;
} }
else else
{ {
// First paddle is QT 4A, second is QT 4B (fire buttons only) // First paddle is QT 4A, second is QT 4B (fire buttons only)
myLeftAFireEvent = Event::QTPaddle4AFire; myAFireEvent = Event::QTPaddle4AFire;
myLeftBFireEvent = Event::QTPaddle4BFire; myBFireEvent = Event::QTPaddle4BFire;
myAAxisValue = myBAxisValue =
myLeftADecEvent = myLeftAIncEvent =
myLeftBDecEvent = myLeftBIncEvent = Event::NoType;
} }
} }
@ -108,11 +109,10 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
{ {
// First paddle is right A|B, second is left A|B // First paddle is right A|B, second is left A|B
std::swap(myAAxisValue, myBAxisValue); std::swap(myAAxisValue, myBAxisValue);
std::swap(myLeftAFireEvent, myLeftBFireEvent); std::swap(myAFireEvent, myBFireEvent);
myLeftAButton1Event = Event::NoType; myAButton1Event = myAButton2Event = Event::NoType;
myLeftAButton2Event = Event::NoType; std::swap(myADecEvent, myBDecEvent);
std::swap(myLeftADecEvent, myLeftBDecEvent); std::swap(myAIncEvent, myBIncEvent);
std::swap(myLeftAIncEvent, myLeftBIncEvent);
} }
// Direction of movement can be swapped // Direction of movement can be swapped
@ -120,8 +120,8 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
// result in either increasing or decreasing paddle movement // result in either increasing or decreasing paddle movement
if(swapdir) if(swapdir)
{ {
std::swap(myLeftADecEvent, myLeftAIncEvent); std::swap(myADecEvent, myAIncEvent);
std::swap(myLeftBDecEvent, myLeftBIncEvent); std::swap(myBDecEvent, myBIncEvent);
} }
// The following are independent of whether or not the port // The following are independent of whether or not the port
@ -141,7 +141,7 @@ Paddles::Paddles(Jack jack, const Event& event, const System& system,
myAxisDigitalOne = 0; myAxisDigitalOne = 0;
} }
// Digital pins 1, 2 and 6 are not connected // Digital pins 1, 2 and 6 are (usually, see below) not connected
//setPin(DigitalPin::One, true); //setPin(DigitalPin::One, true);
//setPin(DigitalPin::Two, true); //setPin(DigitalPin::Two, true);
setPin(DigitalPin::Six, true); setPin(DigitalPin::Six, true);
@ -160,7 +160,7 @@ void Paddles::updateA()
setPin(DigitalPin::Four, true); setPin(DigitalPin::Four, true);
// Digital events (from keyboard or joystick hats & buttons) // Digital events (from keyboard or joystick hats & buttons)
bool firePressedA = myEvent.get(myLeftAFireEvent) != 0; bool firePressedA = myEvent.get(myAFireEvent) != 0;
// Paddle movement is a very difficult thing to accurately emulate, // Paddle movement is a very difficult thing to accurately emulate,
// since it originally came from an analog device that had very // since it originally came from an analog device that had very
@ -189,8 +189,8 @@ void Paddles::updateA()
setPin(DigitalPin::Four, !getAutoFireState(firePressedA)); setPin(DigitalPin::Four, !getAutoFireState(firePressedA));
// Joystick up/down pins when using a splitter: // Joystick up/down pins when using a splitter:
setPin(DigitalPin::One, myEvent.get(myLeftAButton1Event) == 0); setPin(DigitalPin::One, myEvent.get(myAButton1Event) == 0);
setPin(DigitalPin::Two, myEvent.get(myLeftAButton2Event) == 0); setPin(DigitalPin::Two, myEvent.get(myAButton2Event) == 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -328,13 +328,13 @@ void Paddles::updateDigitalAxesA()
myKeyRepeatA = false; myKeyRepeatA = false;
if(myEvent.get(myLeftADecEvent)) if(myEvent.get(myADecEvent))
{ {
myKeyRepeatA = true; myKeyRepeatA = true;
if(myCharge[myAxisDigitalZero] > myPaddleRepeatA) if(myCharge[myAxisDigitalZero] > myPaddleRepeatA)
myCharge[myAxisDigitalZero] -= myPaddleRepeatA; myCharge[myAxisDigitalZero] -= myPaddleRepeatA;
} }
if(myEvent.get(myLeftAIncEvent)) if(myEvent.get(myAIncEvent))
{ {
myKeyRepeatA = true; myKeyRepeatA = true;
if((myCharge[myAxisDigitalZero] + myPaddleRepeatA) < TRIGRANGE) if((myCharge[myAxisDigitalZero] + myPaddleRepeatA) < TRIGRANGE)
@ -348,7 +348,7 @@ void Paddles::updateB()
setPin(DigitalPin::Three, true); setPin(DigitalPin::Three, true);
// Digital events (from keyboard or joystick hats & buttons) // Digital events (from keyboard or joystick hats & buttons)
bool firePressedB = myEvent.get(myLeftBFireEvent) != 0; bool firePressedB = myEvent.get(myBFireEvent) != 0;
if(!updateAnalogAxesB()) if(!updateAnalogAxesB())
{ {
@ -435,13 +435,13 @@ void Paddles::updateDigitalAxesB()
myKeyRepeatB = false; myKeyRepeatB = false;
if(myEvent.get(myLeftBDecEvent)) if(myEvent.get(myBDecEvent))
{ {
myKeyRepeatB = true; myKeyRepeatB = true;
if(myCharge[myAxisDigitalOne] > myPaddleRepeatB) if(myCharge[myAxisDigitalOne] > myPaddleRepeatB)
myCharge[myAxisDigitalOne] -= myPaddleRepeatB; myCharge[myAxisDigitalOne] -= myPaddleRepeatB;
} }
if(myEvent.get(myLeftBIncEvent)) if(myEvent.get(myBIncEvent))
{ {
myKeyRepeatB = true; myKeyRepeatB = true;
if((myCharge[myAxisDigitalOne] + myPaddleRepeatB) < TRIGRANGE) if((myCharge[myAxisDigitalOne] + myPaddleRepeatB) < TRIGRANGE)

View File

@ -177,10 +177,10 @@ class Paddles : public Controller
// Pre-compute the events we care about based on given port // Pre-compute the events we care about based on given port
// This will eliminate test for left or right port in update() // This will eliminate test for left or right port in update()
Event::Type myAAxisValue, myBAxisValue, Event::Type myAAxisValue, myBAxisValue,
myLeftADecEvent, myLeftAIncEvent, myADecEvent, myAIncEvent,
myLeftBDecEvent, myLeftBIncEvent, myBDecEvent, myBIncEvent,
myLeftAFireEvent, myLeftAButton1Event, myLeftAButton2Event, myAFireEvent, myAButton1Event, myAButton2Event,
myLeftBFireEvent, myBFireEvent,
myAxisMouseMotion; myAxisMouseMotion;
// The following are used for the various mouse-axis modes // The following are used for the various mouse-axis modes