mirror of https://github.com/stella-emu/stella.git
remove some debugging output
refactored controller mapping loading
This commit is contained in:
parent
f7c70e46f5
commit
a36e01ac71
|
@ -665,7 +665,6 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
|
|||
if (value != j->axisLastValue[axis])
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
cerr << "axis event" << endl;
|
||||
myHandler.overlay().handleJoyAxisEvent(stick, axis, value, button);
|
||||
#endif
|
||||
j->axisLastValue[axis] = value;
|
||||
|
|
|
@ -67,11 +67,11 @@ void PhysicalJoystick::initialize(int index, const string& desc,
|
|||
axisLastValue[a] = 0;
|
||||
|
||||
// Erase the mappings
|
||||
eraseMap(kMenuMode);
|
||||
eraseMap(kJoystickMode);
|
||||
eraseMap(kPaddlesMode);
|
||||
eraseMap(kKeypadMode);
|
||||
eraseMap(kMenuMode);
|
||||
|
||||
eraseMap(kCommonMode);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -96,24 +96,33 @@ string PhysicalJoystick::getMap() const
|
|||
bool PhysicalJoystick::setMap(const string& mapString)
|
||||
{
|
||||
istringstream buf(mapString);
|
||||
StringList mappings;
|
||||
string map;
|
||||
int i = 0;
|
||||
|
||||
// Skip joystick name
|
||||
getline(buf, map, MODE_DELIM);
|
||||
|
||||
while (getline(buf, map, MODE_DELIM))
|
||||
{
|
||||
// remove leading "<mode>|" string
|
||||
map.erase(0, 2);
|
||||
mappings.push_back(map);
|
||||
}
|
||||
// Error checking
|
||||
if(mappings.size() != 1 + 5)
|
||||
return false;
|
||||
int mode;
|
||||
|
||||
joyMap.loadMapping(mappings[1], kMenuMode);
|
||||
joyMap.loadMapping(mappings[2], kJoystickMode);
|
||||
joyMap.loadMapping(mappings[3], kPaddlesMode);
|
||||
joyMap.loadMapping(mappings[4], kKeypadMode);
|
||||
joyMap.loadMapping(mappings[5], kCommonMode);
|
||||
// Get event mode
|
||||
std::replace(map.begin(), map.end(), '|', ' ');
|
||||
istringstream modeBuf(map);
|
||||
modeBuf >> mode;
|
||||
|
||||
// Remove leading "<mode>|" string
|
||||
map.erase(0, 2);
|
||||
|
||||
joyMap.loadMapping(map, EventMode(mode));
|
||||
i++;
|
||||
}
|
||||
// Brief error checking
|
||||
if(i != 5)
|
||||
{
|
||||
cerr << "ERROR: Invalid controller mappings found" << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -146,7 +155,7 @@ void PhysicalJoystick::getValues(const string& list, IntArray& map) const
|
|||
string PhysicalJoystick::about() const
|
||||
{
|
||||
ostringstream buf;
|
||||
buf << " with: " << numAxes << " axes, " << numButtons << " buttons, "
|
||||
buf << "'" << name << "' with: " << numAxes << " axes, " << numButtons << " buttons, "
|
||||
<< numHats << " hats";
|
||||
|
||||
return buf.str();
|
||||
|
|
|
@ -56,6 +56,7 @@ class PhysicalJoystick
|
|||
int axes, int buttons, int hats, int balls);
|
||||
|
||||
private:
|
||||
// TODO: these are not required anymore, delete or keep for future usage?
|
||||
enum JoyType {
|
||||
JT_NONE = 0,
|
||||
JT_REGULAR = 1,
|
||||
|
|
|
@ -54,7 +54,6 @@ enum class JoyDir {
|
|||
ANALOG = 2
|
||||
};
|
||||
|
||||
|
||||
enum class JoyHat {
|
||||
UP = 0, // make sure these are set correctly,
|
||||
DOWN = 1, // since they'll be used as array indices
|
||||
|
@ -79,17 +78,15 @@ static const int NUM_JOY_HAT_DIRS = 4;
|
|||
|
||||
// TODO - make this 'enum class' somehow
|
||||
enum EventMode {
|
||||
kEmulationMode = 0, // make sure these are set correctly,
|
||||
kMenuMode = 1, // since they'll be used as array indices
|
||||
kNumModes = 2,
|
||||
kJoystickMode = kNumModes, // 5 extra modes for mapping controller keys separately
|
||||
kEmulationMode, // active mapping used for emulation
|
||||
kMenuMode, // mapping used for dialogs
|
||||
kJoystickMode, // 4 extra modes for mapping controller keys separately for emulation mode
|
||||
kPaddlesMode,
|
||||
kKeypadMode,
|
||||
kCompuMateMode,
|
||||
kCommonMode
|
||||
kCompuMateMode, // cannot be remapped
|
||||
kCommonMode // mapping common between controllers
|
||||
};
|
||||
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
#ifdef RETRON77
|
||||
|
|
|
@ -327,13 +327,11 @@ void DialogContainer::handleJoyAxisEvent(int stick, int axis, int value, int but
|
|||
// Only stop firing events if it's the current stick
|
||||
if(myCurrentAxisDown.stick == stick && value == 0)
|
||||
{
|
||||
cerr << "handleJoyAxisEvent 0" << endl;
|
||||
myCurrentAxisDown.stick = myCurrentAxisDown.axis = -1;
|
||||
myAxisRepeatTime = 0;
|
||||
}
|
||||
else if(value != 0 && myAxisRepeatTime < myTime) // never repeat the 'off' event; prevent pending repeats after enabling repeat again
|
||||
{
|
||||
cerr << "handleJoyAxisEvent repeat" << endl;
|
||||
// Now account for repeated axis events (press and hold)
|
||||
myCurrentAxisDown.stick = stick;
|
||||
myCurrentAxisDown.axis = axis;
|
||||
|
|
|
@ -153,7 +153,6 @@ void EventMappingWidget::setDefaults()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::startRemapping()
|
||||
{
|
||||
cerr << "startRemapping" << endl;
|
||||
if(myActionSelected < 0 || myRemapStatus)
|
||||
return;
|
||||
|
||||
|
@ -217,7 +216,6 @@ void EventMappingWidget::stopRemapping()
|
|||
{
|
||||
// Turn off remap mode
|
||||
myRemapStatus = false;
|
||||
cerr << "stopRemapping " << myRemapStatus << endl;
|
||||
|
||||
// Reset all previous events for determining correct axis/hat values
|
||||
myLastStick = -1;
|
||||
|
@ -311,11 +309,9 @@ bool EventMappingWidget::handleKeyUp(StellaKey key, StellaMod mod)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::handleJoyDown(int stick, int button, bool longPress)
|
||||
{
|
||||
cerr << "handleJoyDown" << endl;
|
||||
// Remap joystick buttons in remap mode
|
||||
if(myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
cerr << "remap button start " << myRemapStatus << endl;
|
||||
myLastStick = stick;
|
||||
myLastButton = button;
|
||||
}
|
||||
|
@ -324,7 +320,6 @@ void EventMappingWidget::handleJoyDown(int stick, int button, bool longPress)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::handleJoyUp(int stick, int button)
|
||||
{
|
||||
cerr << "handleJoyUp" << endl;
|
||||
// Remap joystick buttons in remap mode
|
||||
if (myRemapStatus && myActionSelected >= 0)
|
||||
{
|
||||
|
@ -333,7 +328,6 @@ void EventMappingWidget::handleJoyUp(int stick, int button)
|
|||
EventHandler& eh = instance().eventHandler();
|
||||
Event::Type event = eh.eventAtIndex(myActionSelected, myEventMode);
|
||||
|
||||
cerr << "remap button stop" << endl;
|
||||
// map either button/hat, solo button or button/axis combinations
|
||||
if(myLastHat != -1)
|
||||
{
|
||||
|
@ -350,7 +344,6 @@ void EventMappingWidget::handleJoyUp(int stick, int button)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventMappingWidget::handleJoyAxis(int stick, int axis, int value, int button)
|
||||
{
|
||||
cerr << "handleJoyAxis:" << axis << ", " << value << ", (" << stick << ", " << myLastStick << "), (" << axis << ", " << myLastAxis << ")" << endl;
|
||||
// Remap joystick axes in remap mode
|
||||
// There are two phases to detection:
|
||||
// First, detect an axis 'on' event
|
||||
|
@ -360,7 +353,6 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value, int butto
|
|||
// Detect the first axis event that represents 'on'
|
||||
if((myLastStick == -1 || myLastStick == stick) && myLastAxis == -1 && value != 0)
|
||||
{
|
||||
cerr << "remap axis start" << endl;
|
||||
myLastStick = stick;
|
||||
myLastAxis = axis;
|
||||
myLastValue = value;
|
||||
|
@ -372,7 +364,6 @@ void EventMappingWidget::handleJoyAxis(int stick, int axis, int value, int butto
|
|||
EventHandler& eh = instance().eventHandler();
|
||||
Event::Type event = eh.eventAtIndex(myActionSelected, myEventMode);
|
||||
|
||||
cerr << "remap axis stop" << endl;
|
||||
if (eh.addJoyMapping(event, myEventMode, stick, myLastButton, JoyAxis(axis), myLastValue))
|
||||
stopRemapping();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue