mirror of https://github.com/stella-emu/stella.git
minor enhancement of input global keys
This commit is contained in:
parent
dbdc984e77
commit
e76fed006b
|
@ -2926,7 +2926,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><pre>-dsense <number></pre></td>
|
<td><pre>-dsense <number></pre></td>
|
||||||
<td>Sensitivity for emulation of paddles when using a digital device
|
<td>Sensitivity for emulation of paddles when using a digital device
|
||||||
(ie, joystick digital axis or button, keyboard key, etc.).
|
(i.e. joystick digital axis or button, keyboard key, etc.).
|
||||||
Valid range of values is from 1 to 20, with larger numbers causing
|
Valid range of values is from 1 to 20, with larger numbers causing
|
||||||
faster movement.</td>
|
faster movement.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -267,6 +267,24 @@ void PhysicalJoystickHandler::mapStelladaptors(const string& saport)
|
||||||
myOSystem.settings().setValue("saport", saport);
|
myOSystem.settings().setValue("saport", saport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool PhysicalJoystickHandler::hasStelladaptors() const
|
||||||
|
{
|
||||||
|
for(auto& [_id, _joyptr] : mySticks)
|
||||||
|
{
|
||||||
|
// remove previously added emulated ports
|
||||||
|
size_t pos = _joyptr->name.find(" (emulates ");
|
||||||
|
|
||||||
|
if(pos != std::string::npos)
|
||||||
|
_joyptr->name.erase(pos);
|
||||||
|
|
||||||
|
if(BSPF::startsWithIgnoreCase(_joyptr->name, "Stelladaptor")
|
||||||
|
|| BSPF::startsWithIgnoreCase(_joyptr->name, "2600-daptor"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// Depending on parameters, this method does the following:
|
// Depending on parameters, this method does the following:
|
||||||
// 1. update all events with default (event == Event::NoType, updateDefault == true)
|
// 1. update all events with default (event == Event::NoType, updateDefault == true)
|
||||||
|
@ -989,7 +1007,7 @@ void PhysicalJoystickHandler::changeDrivingSensitivity(int direction)
|
||||||
ostringstream ss;
|
ostringstream ss;
|
||||||
ss << sense * 10 << "%";
|
ss << sense * 10 << "%";
|
||||||
|
|
||||||
myOSystem.frameBuffer().showGaugeMessage("Mouse driving controller sensitivity",
|
myOSystem.frameBuffer().showGaugeMessage("Driving controller sensitivity",
|
||||||
ss.str(), sense,
|
ss.str(), sense,
|
||||||
Driving::MIN_SENSE, Driving::MAX_SENSE);
|
Driving::MIN_SENSE, Driving::MAX_SENSE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ class PhysicalJoystickHandler
|
||||||
bool remove(int id);
|
bool remove(int id);
|
||||||
bool remove(const string& name);
|
bool remove(const string& name);
|
||||||
void mapStelladaptors(const string& saport);
|
void mapStelladaptors(const string& saport);
|
||||||
|
bool hasStelladaptors() const;
|
||||||
void setDefaultMapping(Event::Type type, EventMode mode);
|
void setDefaultMapping(Event::Type type, EventMode mode);
|
||||||
|
|
||||||
/** define mappings for current controllers */
|
/** define mappings for current controllers */
|
||||||
|
|
|
@ -246,7 +246,7 @@ void EventHandler::changeMouseControl(int direction)
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool EventHandler::hasMouseControl()
|
bool EventHandler::hasMouseControl() const
|
||||||
{
|
{
|
||||||
return myMouseControl && myMouseControl->hasMouseControl();
|
return myMouseControl && myMouseControl->hasMouseControl();
|
||||||
}
|
}
|
||||||
|
@ -416,97 +416,120 @@ bool EventHandler::isTrackball(const Controller& controller) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
AdjustFunction EventHandler::cycleAdjustSetting(int direction)
|
bool EventHandler::skipAVSetting() const
|
||||||
|
{
|
||||||
|
const bool isFullScreen = myOSystem.frameBuffer().fullScreen();
|
||||||
|
const bool isCustomPalette =
|
||||||
|
myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM;
|
||||||
|
const bool isCustomFilter =
|
||||||
|
myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM);
|
||||||
|
|
||||||
|
return (myAdjustSetting == AdjustSetting::OVERSCAN && !isFullScreen)
|
||||||
|
#ifdef ADAPTABLE_REFRESH_SUPPORT
|
||||||
|
|| (myAdjustSetting == AdjustSetting::ADAPT_REFRESH && !isFullScreen)
|
||||||
|
#endif
|
||||||
|
|| (myAdjustSetting >= AdjustSetting::PALETTE_PHASE
|
||||||
|
&& myAdjustSetting <= AdjustSetting::PALETTE_BLUE_SHIFT
|
||||||
|
&& !isCustomPalette)
|
||||||
|
|| (myAdjustSetting >= AdjustSetting::NTSC_SHARPNESS
|
||||||
|
&& myAdjustSetting <= AdjustSetting::NTSC_BLEEDING
|
||||||
|
&& !isCustomFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool EventHandler::skipInputSetting() const
|
||||||
|
{
|
||||||
|
const bool grabMouseAllowed = myOSystem.frameBuffer().grabMouseAllowed();
|
||||||
|
const bool analog = myOSystem.console().leftController().isAnalog()
|
||||||
|
|| myOSystem.console().rightController().isAnalog();
|
||||||
|
const bool joystick = isJoystick(myOSystem.console().leftController())
|
||||||
|
|| isJoystick(myOSystem.console().rightController());
|
||||||
|
const bool paddle = isPaddle(myOSystem.console().leftController())
|
||||||
|
|| isPaddle(myOSystem.console().rightController());
|
||||||
|
const bool trackball = isTrackball(myOSystem.console().leftController())
|
||||||
|
|| isTrackball(myOSystem.console().rightController());
|
||||||
|
const bool driving =
|
||||||
|
myOSystem.console().leftController().type() == Controller::Type::Driving
|
||||||
|
|| myOSystem.console().rightController().type() == Controller::Type::Driving;
|
||||||
|
const bool useMouse =
|
||||||
|
BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"))
|
||||||
|
|| (BSPF::equalsIgnoreCase("analog", myOSystem.settings().getString("usemouse"))
|
||||||
|
&& analog);
|
||||||
|
const bool stelladapter = myPJoyHandler->hasStelladaptors();
|
||||||
|
|
||||||
|
return (!grabMouseAllowed && myAdjustSetting == AdjustSetting::GRAB_MOUSE)
|
||||||
|
|| (!joystick
|
||||||
|
&& (myAdjustSetting == AdjustSetting::DEADZONE
|
||||||
|
|| myAdjustSetting == AdjustSetting::FOUR_DIRECTIONS))
|
||||||
|
|| (!paddle
|
||||||
|
&& (myAdjustSetting == AdjustSetting::ANALOG_SENSITIVITY
|
||||||
|
|| myAdjustSetting == AdjustSetting::DEJITTER_AVERAGING
|
||||||
|
|| myAdjustSetting == AdjustSetting::DEJITTER_REACTION
|
||||||
|
|| myAdjustSetting == AdjustSetting::DIGITAL_SENSITIVITY
|
||||||
|
|| myAdjustSetting == AdjustSetting::SWAP_PADDLES
|
||||||
|
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_X
|
||||||
|
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_Y))
|
||||||
|
|| ((!paddle || !useMouse)
|
||||||
|
&& myAdjustSetting == AdjustSetting::PADDLE_SENSITIVITY)
|
||||||
|
|| ((!trackball || !useMouse)
|
||||||
|
&& myAdjustSetting == AdjustSetting::TRACKBALL_SENSITIVITY)
|
||||||
|
|| (!driving
|
||||||
|
&& myAdjustSetting == AdjustSetting::DRIVING_SENSITIVITY) // also affects digital device input sensitivity
|
||||||
|
|| ((!hasMouseControl() || !useMouse)
|
||||||
|
&& myAdjustSetting == AdjustSetting::MOUSE_CONTROL)
|
||||||
|
|| ((!paddle || !useMouse)
|
||||||
|
&& myAdjustSetting == AdjustSetting::MOUSE_RANGE)
|
||||||
|
|| (!stelladapter
|
||||||
|
&& myAdjustSetting == AdjustSetting::SA_PORT_ORDER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool EventHandler::skipDebugSetting() const
|
||||||
{
|
{
|
||||||
const bool isPAL = myOSystem.console().timing() == ConsoleTiming::pal;
|
const bool isPAL = myOSystem.console().timing() == ConsoleTiming::pal;
|
||||||
bool repeat = false;
|
|
||||||
|
|
||||||
|
return (myAdjustSetting == AdjustSetting::COLOR_LOSS && !isPAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
AdjustFunction EventHandler::cycleAdjustSetting(int direction)
|
||||||
|
{
|
||||||
|
bool skip = false;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
switch (getAdjustGroup())
|
switch (getAdjustGroup())
|
||||||
{
|
{
|
||||||
case AdjustGroup::AV:
|
case AdjustGroup::AV:
|
||||||
{
|
|
||||||
const bool isFullScreen = myOSystem.frameBuffer().fullScreen();
|
|
||||||
const bool isCustomPalette =
|
|
||||||
myOSystem.settings().getString("palette") == PaletteHandler::SETTING_CUSTOM;
|
|
||||||
const bool isCustomFilter =
|
|
||||||
myOSystem.settings().getInt("tv.filter") == int(NTSCFilter::Preset::CUSTOM);
|
|
||||||
|
|
||||||
myAdjustSetting =
|
myAdjustSetting =
|
||||||
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
||||||
int(AdjustSetting::START_AV_ADJ), int(AdjustSetting::END_AV_ADJ)));
|
int(AdjustSetting::START_AV_ADJ), int(AdjustSetting::END_AV_ADJ)));
|
||||||
// skip currently non-relevant adjustments
|
// skip currently non-relevant adjustments
|
||||||
repeat = (myAdjustSetting == AdjustSetting::OVERSCAN && !isFullScreen)
|
skip = skipAVSetting();
|
||||||
#ifdef ADAPTABLE_REFRESH_SUPPORT
|
|
||||||
|| (myAdjustSetting == AdjustSetting::ADAPT_REFRESH && !isFullScreen)
|
|
||||||
#endif
|
|
||||||
|| (myAdjustSetting >= AdjustSetting::PALETTE_PHASE
|
|
||||||
&& myAdjustSetting <= AdjustSetting::PALETTE_BLUE_SHIFT
|
|
||||||
&& !isCustomPalette)
|
|
||||||
|| (myAdjustSetting >= AdjustSetting::NTSC_SHARPNESS
|
|
||||||
&& myAdjustSetting <= AdjustSetting::NTSC_BLEEDING
|
|
||||||
&& !isCustomFilter);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case AdjustGroup::INPUT:
|
case AdjustGroup::INPUT:
|
||||||
{
|
|
||||||
const bool grabMouseAllowed = myOSystem.frameBuffer().grabMouseAllowed();
|
|
||||||
const bool joystick = isJoystick(myOSystem.console().leftController())
|
|
||||||
|| isJoystick(myOSystem.console().rightController());
|
|
||||||
const bool paddle = isPaddle(myOSystem.console().leftController())
|
|
||||||
|| isPaddle(myOSystem.console().rightController());
|
|
||||||
const bool trackball = isTrackball(myOSystem.console().leftController())
|
|
||||||
|| isTrackball(myOSystem.console().rightController());
|
|
||||||
const bool driving = myOSystem.console().leftController().type() == Controller::Type::Driving
|
|
||||||
|| myOSystem.console().rightController().type() == Controller::Type::Driving;
|
|
||||||
const bool useMouse = myOSystem.settings().getString("usemouse") != "never";
|
|
||||||
|
|
||||||
myAdjustSetting =
|
myAdjustSetting =
|
||||||
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
||||||
int(AdjustSetting::START_INPUT_ADJ), int(AdjustSetting::END_INPUT_ADJ)));
|
int(AdjustSetting::START_INPUT_ADJ), int(AdjustSetting::END_INPUT_ADJ)));
|
||||||
// skip currently non-relevant adjustments
|
// skip currently non-relevant adjustments
|
||||||
repeat = (!grabMouseAllowed && myAdjustSetting == AdjustSetting::GRAB_MOUSE)
|
skip = skipInputSetting();
|
||||||
|| (!joystick
|
|
||||||
&& (myAdjustSetting == AdjustSetting::DEADZONE
|
|
||||||
|| myAdjustSetting == AdjustSetting::FOUR_DIRECTIONS))
|
|
||||||
|| (!paddle
|
|
||||||
&& (myAdjustSetting == AdjustSetting::ANALOG_SENSITIVITY
|
|
||||||
|| myAdjustSetting == AdjustSetting::DEJITTER_AVERAGING
|
|
||||||
|| myAdjustSetting == AdjustSetting::DEJITTER_REACTION
|
|
||||||
|| myAdjustSetting == AdjustSetting::DIGITAL_SENSITIVITY
|
|
||||||
|| myAdjustSetting == AdjustSetting::SWAP_PADDLES
|
|
||||||
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_X
|
|
||||||
|| myAdjustSetting == AdjustSetting::PADDLE_CENTER_Y))
|
|
||||||
|| ((!paddle || !useMouse)
|
|
||||||
&& myAdjustSetting == AdjustSetting::PADDLE_SENSITIVITY)
|
|
||||||
|| ((!trackball || !useMouse)
|
|
||||||
&& myAdjustSetting == AdjustSetting::TRACKBALL_SENSITIVITY)
|
|
||||||
|| (!driving
|
|
||||||
&& myAdjustSetting == AdjustSetting::DRIVING_SENSITIVITY) // also affects keyboard input sensitivity
|
|
||||||
|| ((!hasMouseControl() || !useMouse)
|
|
||||||
&& myAdjustSetting == AdjustSetting::MOUSE_CONTROL)
|
|
||||||
|| ((!paddle || !useMouse)
|
|
||||||
&& myAdjustSetting == AdjustSetting::MOUSE_RANGE);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case AdjustGroup::DEBUG:
|
case AdjustGroup::DEBUG:
|
||||||
myAdjustSetting =
|
myAdjustSetting =
|
||||||
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
AdjustSetting(BSPF::clampw(int(myAdjustSetting) + direction,
|
||||||
int(AdjustSetting::START_DEBUG_ADJ), int(AdjustSetting::END_DEBUG_ADJ)));
|
int(AdjustSetting::START_DEBUG_ADJ), int(AdjustSetting::END_DEBUG_ADJ)));
|
||||||
// skip currently non-relevant adjustments
|
// skip currently non-relevant adjustments
|
||||||
repeat = (myAdjustSetting == AdjustSetting::COLOR_LOSS && !isPAL);
|
skip = skipDebugSetting();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// avoid endless loop
|
// avoid endless loop
|
||||||
if(repeat && !direction)
|
if(skip && !direction)
|
||||||
direction = 1;
|
direction = 1;
|
||||||
} while(repeat);
|
} while(skip);
|
||||||
|
|
||||||
return getAdjustSetting(myAdjustSetting);
|
return getAdjustSetting(myAdjustSetting);
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,7 +361,7 @@ class EventHandler
|
||||||
Handle changing mouse modes.
|
Handle changing mouse modes.
|
||||||
*/
|
*/
|
||||||
void changeMouseControl(int direction = +1);
|
void changeMouseControl(int direction = +1);
|
||||||
bool hasMouseControl();
|
bool hasMouseControl() const;
|
||||||
|
|
||||||
void saveKeyMapping();
|
void saveKeyMapping();
|
||||||
void saveJoyMapping();
|
void saveJoyMapping();
|
||||||
|
@ -576,6 +576,11 @@ class EventHandler
|
||||||
bool isPaddle(const Controller& controller) const;
|
bool isPaddle(const Controller& controller) const;
|
||||||
bool isTrackball(const Controller& controller) const;
|
bool isTrackball(const Controller& controller) const;
|
||||||
|
|
||||||
|
// Check if a currently non-relevant adjustment can be skipped
|
||||||
|
bool skipAVSetting() const;
|
||||||
|
bool skipInputSetting() const;
|
||||||
|
bool skipDebugSetting() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Structure used for action menu items
|
// Structure used for action menu items
|
||||||
struct ActionList {
|
struct ActionList {
|
||||||
|
|
Loading…
Reference in New Issue