mirror of https://github.com/stella-emu/stella.git
fixed QuadTari mapping storage
This commit is contained in:
parent
0de952b0cb
commit
ee13c16930
|
@ -485,45 +485,69 @@ void PhysicalJoystickHandler::setDefaultMapping(Event::Type event, EventMode mod
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void PhysicalJoystickHandler::defineControllerMappings(const Controller::Type type, Controller::Jack port)
|
void PhysicalJoystickHandler::defineControllerMappings(const Controller::Type type, Controller::Jack port,
|
||||||
|
const Properties& properties)
|
||||||
|
{
|
||||||
|
// Determine controller events to use
|
||||||
|
if(type == Controller::Type::QuadTari)
|
||||||
|
{
|
||||||
|
if(port == Controller::Jack::Left)
|
||||||
|
{
|
||||||
|
myLeftMode = getMode(properties, PropType::Controller_Left1);
|
||||||
|
myLeft2ndMode = getMode(properties, PropType::Controller_Left2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myRightMode = getMode(properties, PropType::Controller_Right1);
|
||||||
|
myRight2ndMode = getMode(properties, PropType::Controller_Right2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const EventMode mode = getMode(type);
|
||||||
|
|
||||||
|
if(port == Controller::Jack::Left)
|
||||||
|
myLeftMode = mode;
|
||||||
|
else
|
||||||
|
myRightMode = mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
EventMode PhysicalJoystickHandler::getMode(const Properties& properties,
|
||||||
|
const PropType propType)
|
||||||
|
{
|
||||||
|
const string& propName = properties.get(propType);
|
||||||
|
|
||||||
|
if(!propName.empty())
|
||||||
|
return getMode(Controller::getType(propName));
|
||||||
|
|
||||||
|
return EventMode::kJoystickMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
EventMode PhysicalJoystickHandler::getMode(const Controller::Type type)
|
||||||
{
|
{
|
||||||
// determine controller events to use
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case Controller::Type::Keyboard:
|
case Controller::Type::Keyboard:
|
||||||
case Controller::Type::KidVid:
|
case Controller::Type::KidVid:
|
||||||
if(port == Controller::Jack::Left)
|
return EventMode::kKeyboardMode;
|
||||||
myLeftMode = EventMode::kKeyboardMode;
|
|
||||||
else
|
|
||||||
myRightMode = EventMode::kKeyboardMode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Controller::Type::Paddles:
|
case Controller::Type::Paddles:
|
||||||
case Controller::Type::PaddlesIAxDr:
|
case Controller::Type::PaddlesIAxDr:
|
||||||
case Controller::Type::PaddlesIAxis:
|
case Controller::Type::PaddlesIAxis:
|
||||||
if(port == Controller::Jack::Left)
|
return EventMode::kPaddlesMode;
|
||||||
myLeftMode = EventMode::kPaddlesMode;
|
|
||||||
else
|
|
||||||
myRightMode = EventMode::kPaddlesMode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Controller::Type::CompuMate:
|
case Controller::Type::CompuMate:
|
||||||
myLeftMode = myRightMode = EventMode::kCompuMateMode;
|
return EventMode::kCompuMateMode;
|
||||||
break;
|
|
||||||
|
|
||||||
case Controller::Type::Driving:
|
case Controller::Type::Driving:
|
||||||
if(port == Controller::Jack::Left)
|
return EventMode::kDrivingMode;
|
||||||
myLeftMode = EventMode::kDrivingMode;
|
|
||||||
else
|
|
||||||
myRightMode = EventMode::kDrivingMode;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// let's use joystick then
|
// let's use joystick then
|
||||||
if(port == Controller::Jack::Left)
|
return EventMode::kJoystickMode;
|
||||||
myLeftMode = EventMode::kJoystickMode;
|
|
||||||
else
|
|
||||||
myRightMode = EventMode::kJoystickMode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,6 +564,36 @@ void PhysicalJoystickHandler::enableEmulationMappings()
|
||||||
|
|
||||||
enableCommonMappings();
|
enableCommonMappings();
|
||||||
|
|
||||||
|
// Process in increasing priority order, so that in case of mapping clashes
|
||||||
|
// the higher priority controller has preference
|
||||||
|
switch(myRight2ndMode)
|
||||||
|
{
|
||||||
|
case EventMode::kPaddlesMode:
|
||||||
|
enableMappings(QTPaddles4Events, EventMode::kPaddlesMode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventMode::kEmulationMode: // no QuadTari
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
enableMappings(QTJoystick4Events, EventMode::kJoystickMode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(myLeft2ndMode)
|
||||||
|
{
|
||||||
|
case EventMode::kPaddlesMode:
|
||||||
|
enableMappings(QTPaddles3Events, EventMode::kPaddlesMode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EventMode::kEmulationMode: // no QuadTari
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
enableMappings(QTJoystick3Events, EventMode::kJoystickMode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// enable right mode first, so that in case of mapping clashes the left controller has preference
|
// enable right mode first, so that in case of mapping clashes the left controller has preference
|
||||||
switch (myRightMode)
|
switch (myRightMode)
|
||||||
{
|
{
|
||||||
|
@ -644,14 +698,18 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
|
||||||
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
|
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
|
||||||
{
|
{
|
||||||
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|
||||||
|| RightJoystickEvents.find(event) != RightJoystickEvents.end();
|
|| QTJoystick3Events.find(event) != QTJoystick3Events.end()
|
||||||
|
|| RightJoystickEvents.find(event) != RightJoystickEvents.end()
|
||||||
|
|| QTJoystick4Events.find(event) != QTJoystick4Events.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
|
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
|
||||||
{
|
{
|
||||||
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|
||||||
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end();
|
|| QTPaddles3Events.find(event) != QTPaddles3Events.end()
|
||||||
|
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end()
|
||||||
|
|| QTPaddles4Events.find(event) != QTPaddles4Events.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -671,7 +729,8 @@ bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event)
|
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event)
|
||||||
{
|
{
|
||||||
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event));
|
return !(isJoystickEvent(event) || isPaddleEvent(event)
|
||||||
|
|| isKeyboardEvent(event) || isDrivingEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -79,10 +79,16 @@ class PhysicalJoystickHandler
|
||||||
void setDefaultMapping(Event::Type event, EventMode mode);
|
void setDefaultMapping(Event::Type event, EventMode mode);
|
||||||
|
|
||||||
/** define mappings for current controllers */
|
/** define mappings for current controllers */
|
||||||
void defineControllerMappings(const Controller::Type type, Controller::Jack port);
|
void defineControllerMappings(const Controller::Type type, Controller::Jack port,
|
||||||
|
const Properties& properties);
|
||||||
/** enable mappings for emulation mode */
|
/** enable mappings for emulation mode */
|
||||||
void enableEmulationMappings();
|
void enableEmulationMappings();
|
||||||
|
|
||||||
|
/** return event mode for given property */
|
||||||
|
EventMode getMode(const Properties& properties, const PropType propType);
|
||||||
|
/** return event mode for given controller type */
|
||||||
|
EventMode getMode(const Controller::Type type);
|
||||||
|
|
||||||
void eraseMapping(Event::Type event, EventMode mode);
|
void eraseMapping(Event::Type event, EventMode mode);
|
||||||
void saveMapping();
|
void saveMapping();
|
||||||
string getMappingDesc(Event::Type, EventMode mode) const;
|
string getMappingDesc(Event::Type, EventMode mode) const;
|
||||||
|
@ -196,6 +202,9 @@ class PhysicalJoystickHandler
|
||||||
private:
|
private:
|
||||||
EventMode myLeftMode{EventMode::kEmulationMode};
|
EventMode myLeftMode{EventMode::kEmulationMode};
|
||||||
EventMode myRightMode{EventMode::kEmulationMode};
|
EventMode myRightMode{EventMode::kEmulationMode};
|
||||||
|
// Additional modes for QuadTari controller
|
||||||
|
EventMode myLeft2ndMode{EventMode::kEmulationMode};
|
||||||
|
EventMode myRight2ndMode{EventMode::kEmulationMode};
|
||||||
|
|
||||||
// Controller menu and common emulation mappings
|
// Controller menu and common emulation mappings
|
||||||
static EventMappingArray DefaultMenuMapping;
|
static EventMappingArray DefaultMenuMapping;
|
||||||
|
|
|
@ -221,31 +221,27 @@ void PhysicalKeyboardHandler::defineControllerMappings(
|
||||||
const Controller::Type type, Controller::Jack port, const Properties& properties)
|
const Controller::Type type, Controller::Jack port, const Properties& properties)
|
||||||
{
|
{
|
||||||
// Determine controller events to use
|
// Determine controller events to use
|
||||||
switch(type) // NOLINT (could be written as IF/ELSE)
|
if(type == Controller::Type::QuadTari)
|
||||||
{
|
{
|
||||||
case Controller::Type::QuadTari:
|
if(port == Controller::Jack::Left)
|
||||||
if(port == Controller::Jack::Left)
|
|
||||||
{
|
|
||||||
myLeftMode = getMode(properties, PropType::Controller_Left1);
|
|
||||||
myLeft2ndMode = getMode(properties, PropType::Controller_Left2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myRightMode = getMode(properties, PropType::Controller_Right1);
|
|
||||||
myRight2ndMode = getMode(properties, PropType::Controller_Right2);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
{
|
||||||
const EventMode mode = getMode(type);
|
myLeftMode = getMode(properties, PropType::Controller_Left1);
|
||||||
|
myLeft2ndMode = getMode(properties, PropType::Controller_Left2);
|
||||||
if(port == Controller::Jack::Left)
|
|
||||||
myLeftMode = mode;
|
|
||||||
else
|
|
||||||
myRightMode = mode;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myRightMode = getMode(properties, PropType::Controller_Right1);
|
||||||
|
myRight2ndMode = getMode(properties, PropType::Controller_Right2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const EventMode mode = getMode(type);
|
||||||
|
|
||||||
|
if(port == Controller::Jack::Left)
|
||||||
|
myLeftMode = mode;
|
||||||
|
else
|
||||||
|
myRightMode = mode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +254,7 @@ EventMode PhysicalKeyboardHandler::getMode(const Properties& properties,
|
||||||
if(!propName.empty())
|
if(!propName.empty())
|
||||||
return getMode(Controller::getType(propName));
|
return getMode(Controller::getType(propName));
|
||||||
|
|
||||||
return getMode(Controller::Type::Joystick);
|
return EventMode::kJoystickMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -446,13 +442,6 @@ bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event)
|
||||||
|| QTPaddles4Events.find(event) != QTPaddles4Events.end();
|
|| QTPaddles4Events.find(event) != QTPaddles4Events.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
||||||
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event)
|
|
||||||
{
|
|
||||||
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|
|
||||||
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
|
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
|
||||||
{
|
{
|
||||||
|
@ -460,10 +449,18 @@ bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
|
||||||
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
|
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event)
|
||||||
|
{
|
||||||
|
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|
||||||
|
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event)
|
bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event)
|
||||||
{
|
{
|
||||||
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event));
|
return !(isJoystickEvent(event) || isPaddleEvent(event)
|
||||||
|
|| isKeyboardEvent(event) || isDrivingEvent(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -856,7 +856,7 @@ void Console::setControllers(string_view romMd5)
|
||||||
myOSystem.eventHandler().defineKeyControllerMappings(
|
myOSystem.eventHandler().defineKeyControllerMappings(
|
||||||
Controller::Type::CompuMate, Controller::Jack::Left, myProperties);
|
Controller::Type::CompuMate, Controller::Jack::Left, myProperties);
|
||||||
myOSystem.eventHandler().defineJoyControllerMappings(
|
myOSystem.eventHandler().defineJoyControllerMappings(
|
||||||
Controller::Type::CompuMate, Controller::Jack::Left);
|
Controller::Type::CompuMate, Controller::Jack::Left, myProperties);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -947,7 +947,7 @@ unique_ptr<Controller> Console::getControllerPort(
|
||||||
unique_ptr<Controller> controller;
|
unique_ptr<Controller> controller;
|
||||||
|
|
||||||
myOSystem.eventHandler().defineKeyControllerMappings(type, port, myProperties);
|
myOSystem.eventHandler().defineKeyControllerMappings(type, port, myProperties);
|
||||||
myOSystem.eventHandler().defineJoyControllerMappings(type, port);
|
myOSystem.eventHandler().defineJoyControllerMappings(type, port, myProperties);
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
|
|
|
@ -279,8 +279,9 @@ class EventHandler
|
||||||
/**
|
/**
|
||||||
Enable controller specific keyboard event mappings.
|
Enable controller specific keyboard event mappings.
|
||||||
*/
|
*/
|
||||||
void defineJoyControllerMappings(const Controller::Type type, Controller::Jack port) {
|
void defineJoyControllerMappings(const Controller::Type type, Controller::Jack port,
|
||||||
myPJoyHandler->defineControllerMappings(type, port);
|
const Properties& properties) {
|
||||||
|
myPJoyHandler->defineControllerMappings(type, port, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue