mirror of https://github.com/stella-emu/stella.git
Grabmouse is not used when using a virtual controller that doesn't output
analog data (ie, not a mouse). This fixes the issue of mouse grabbing when a ROM isn't even using the mouse.
This commit is contained in:
parent
d99f83580f
commit
8b4096e1ef
|
@ -1868,6 +1868,26 @@ void EventHandler::takeSnapshot(uInt32 number)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool EventHandler::controllerIsAnalog(Controller::Jack jack) const
|
||||||
|
{
|
||||||
|
const Controller& controller = jack == Controller::Left ?
|
||||||
|
myOSystem.console().leftController() : myOSystem.console().rightController();
|
||||||
|
|
||||||
|
switch(controller.type())
|
||||||
|
{
|
||||||
|
case Controller::Paddles:
|
||||||
|
case Controller::Driving:
|
||||||
|
case Controller::TrackBall22:
|
||||||
|
case Controller::TrackBall80:
|
||||||
|
case Controller::AmigaMouse:
|
||||||
|
case Controller::MindLink:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void EventHandler::setMouseControllerMode(const string& enable)
|
void EventHandler::setMouseControllerMode(const string& enable)
|
||||||
{
|
{
|
||||||
|
@ -1880,32 +1900,9 @@ void EventHandler::setMouseControllerMode(const string& enable)
|
||||||
usemouse = false;
|
usemouse = false;
|
||||||
else // 'analog'
|
else // 'analog'
|
||||||
{
|
{
|
||||||
switch(myOSystem.console().leftController().type())
|
if(controllerIsAnalog(Controller::Left) ||
|
||||||
{
|
controllerIsAnalog(Controller::Right))
|
||||||
case Controller::Paddles:
|
usemouse = true;
|
||||||
case Controller::Driving:
|
|
||||||
case Controller::TrackBall22:
|
|
||||||
case Controller::TrackBall80:
|
|
||||||
case Controller::AmigaMouse:
|
|
||||||
case Controller::MindLink:
|
|
||||||
usemouse = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch(myOSystem.console().rightController().type())
|
|
||||||
{
|
|
||||||
case Controller::Paddles:
|
|
||||||
case Controller::Driving:
|
|
||||||
case Controller::TrackBall22:
|
|
||||||
case Controller::TrackBall80:
|
|
||||||
case Controller::AmigaMouse:
|
|
||||||
case Controller::MindLink:
|
|
||||||
usemouse = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const string& control = usemouse ?
|
const string& control = usemouse ?
|
||||||
|
|
|
@ -314,6 +314,14 @@ class EventHandler
|
||||||
*/
|
*/
|
||||||
void allowAllDirections(bool allow) { myAllowAllDirectionsFlag = allow; }
|
void allowAllDirections(bool allow) { myAllowAllDirectionsFlag = allow; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Determines whether the given controller must use the mouse (aka,
|
||||||
|
whether the controller generates analog output).
|
||||||
|
|
||||||
|
@param jack The controller to query
|
||||||
|
*/
|
||||||
|
bool controllerIsAnalog(Controller::Jack jack) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a list of all joysticks currently in the internal database
|
Return a list of all joysticks currently in the internal database
|
||||||
(first part of variant) and its internal ID (second part of variant).
|
(first part of variant) and its internal ID (second part of variant).
|
||||||
|
|
|
@ -581,10 +581,15 @@ bool FrameBuffer::changeWindowedVidMode(int direction)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void FrameBuffer::setCursorState()
|
void FrameBuffer::setCursorState()
|
||||||
{
|
{
|
||||||
// Always grab mouse in emulation (if enabled)
|
// Always grab mouse in emulation (if enabled) and emulating a controller
|
||||||
|
// that always uses the mouse
|
||||||
bool emulation =
|
bool emulation =
|
||||||
myOSystem.eventHandler().state() == EventHandler::S_EMULATE;
|
myOSystem.eventHandler().state() == EventHandler::S_EMULATE;
|
||||||
grabMouse(emulation && myOSystem.settings().getBool("grabmouse"));
|
bool analog = myOSystem.hasConsole() ?
|
||||||
|
(myOSystem.eventHandler().controllerIsAnalog(Controller::Left) ||
|
||||||
|
myOSystem.eventHandler().controllerIsAnalog(Controller::Right)) : false;
|
||||||
|
|
||||||
|
grabMouse(emulation && analog && myOSystem.settings().getBool("grabmouse"));
|
||||||
|
|
||||||
// Show/hide cursor in UI/emulation mode based on 'cursor' setting
|
// Show/hide cursor in UI/emulation mode based on 'cursor' setting
|
||||||
switch(myOSystem.settings().getInt("cursor"))
|
switch(myOSystem.settings().getInt("cursor"))
|
||||||
|
|
Loading…
Reference in New Issue