mirror of https://github.com/stella-emu/stella.git
Added ability to completely disable the mouse from being used as a
controller. Added '-usemouse' commandline argument and associated UI item in InputDialog to accommodate this. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1935 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
8ca34a4d90
commit
eb5f8efc78
|
@ -153,6 +153,7 @@ void EventHandler::initialize()
|
|||
|
||||
Joystick::setDeadZone(myOSystem->settings().getInt("joydeadzone"));
|
||||
Paddles::setDigitalSpeed(myOSystem->settings().getInt("pspeed"));
|
||||
setPaddleMode(myOSystem->settings().getBool("usemouse") ? 0 : -1, false);
|
||||
|
||||
// Set quick select delay when typing characters in listwidgets
|
||||
ListWidget::setQuickSelectDelay(myOSystem->settings().getInt("listdelay"));
|
||||
|
@ -776,11 +777,14 @@ void EventHandler::handleMouseMotionEvent(SDL_Event& event)
|
|||
{
|
||||
// Determine which mode we're in, then send the event to the appropriate place
|
||||
if(myState == S_EMULATE)
|
||||
{
|
||||
if(myMouseEnabled)
|
||||
{
|
||||
int x = event.motion.xrel, y = event.motion.yrel;
|
||||
myEvent->set(Event::MouseAxisXValue, x);
|
||||
myEvent->set(Event::MouseAxisYValue, y);
|
||||
}
|
||||
}
|
||||
else if(myOverlay)
|
||||
{
|
||||
int x = event.motion.x, y = event.motion.y;
|
||||
|
@ -793,7 +797,10 @@ void EventHandler::handleMouseButtonEvent(SDL_Event& event, int state)
|
|||
{
|
||||
// Determine which mode we're in, then send the event to the appropriate place
|
||||
if(myState == S_EMULATE)
|
||||
{
|
||||
if(myMouseEnabled)
|
||||
myEvent->set(Event::MouseButtonValue, state);
|
||||
}
|
||||
else if(myOverlay)
|
||||
{
|
||||
// Take window zooming into account
|
||||
|
@ -955,15 +962,6 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
break;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
case Event::ConsoleReset:
|
||||
if(state)
|
||||
{
|
||||
myOSystem->console().tia().frameReset();
|
||||
myOSystem->frameBuffer().refresh();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case Event::Fry:
|
||||
myFryingFlag = bool(state);
|
||||
return;
|
||||
|
@ -1869,6 +1867,7 @@ void EventHandler::setPaddleMode(int num, bool showmessage)
|
|||
{
|
||||
if(num >= 0 && num <= 3)
|
||||
{
|
||||
myMouseEnabled = true;
|
||||
Paddles::setMouseIsPaddle(num);
|
||||
if(showmessage)
|
||||
{
|
||||
|
@ -1877,6 +1876,8 @@ void EventHandler::setPaddleMode(int num, bool showmessage)
|
|||
myOSystem->frameBuffer().showMessage(buf.str());
|
||||
}
|
||||
}
|
||||
else
|
||||
myMouseEnabled = false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -474,6 +474,9 @@ class EventHandler
|
|||
// Indicates whether the mouse cursor is grabbed
|
||||
bool myGrabMouseFlag;
|
||||
|
||||
// Indicates whether the mouse is enabled for game controller actions
|
||||
bool myMouseEnabled;
|
||||
|
||||
// Indicates whether the joystick emulates 'impossible' directions
|
||||
bool myAllowAllDirectionsFlag;
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ Settings::Settings(OSystem* osystem)
|
|||
setInternal("joyhatmap", "");
|
||||
setInternal("joydeadzone", "0");
|
||||
setInternal("joyallow4", "false");
|
||||
setInternal("usemouse", "true");
|
||||
setInternal("pspeed", "6");
|
||||
setInternal("sa1", "left");
|
||||
setInternal("sa2", "right");
|
||||
|
@ -355,6 +356,7 @@ void Settings::usage()
|
|||
<< " -showinfo <1|0> Shows some game info on commandline\n"
|
||||
<< " -joydeadzone <number> Sets 'deadzone' area for analog joysticks (0-29)\n"
|
||||
<< " -joyallow4 <1|0> Allow all 4 directions on a joystick to be pressed simultaneously\n"
|
||||
<< " -usemouse <1|0> Use mouse for various controllers (paddle, driving, etc)\n"
|
||||
<< " -pspeed <number> Speed of digital emulated paddle movement (1-15)\n"
|
||||
<< " -sa1 <left|right> Stelladaptor 1 emulates specified joystick port\n"
|
||||
<< " -sa2 <left|right> Stelladaptor 2 emulates specified joystick port\n"
|
||||
|
|
|
@ -149,6 +149,12 @@ void InputDialog::addVDeviceTab(const GUI::Font& font)
|
|||
myPaddleModeLabel->setFlags(WIDGET_CLEARBG);
|
||||
wid.push_back(myPaddleMode);
|
||||
|
||||
// Add mouse enable/disable
|
||||
xpos += 8 + myPaddleModeLabel->getWidth();
|
||||
myMouseEnabled = new CheckboxWidget(myTab, font, xpos, ypos,
|
||||
"Use mouse", kPMouseChanged);
|
||||
wid.push_back(myMouseEnabled);
|
||||
|
||||
// Add paddle speed
|
||||
xpos = 5; ypos += lineHeight + 3;
|
||||
myPaddleSpeed = new SliderWidget(myTab, font, xpos, ypos, pwidth, lineHeight,
|
||||
|
@ -199,6 +205,10 @@ void InputDialog::loadConfig()
|
|||
myPaddleMode->setValue(0);
|
||||
myPaddleModeLabel->setLabel("0");
|
||||
|
||||
// Mouse/paddle enabled
|
||||
bool usemouse = instance().settings().getBool("usemouse");
|
||||
myMouseEnabled->setState(usemouse);
|
||||
|
||||
// Paddle speed
|
||||
myPaddleSpeed->setValue(instance().settings().getInt("pspeed"));
|
||||
myPaddleLabel->setLabel(instance().settings().getString("pspeed"));
|
||||
|
@ -210,6 +220,7 @@ void InputDialog::loadConfig()
|
|||
myAllowAll4->setState(instance().settings().getBool("joyallow4"));
|
||||
|
||||
myTab->loadConfig();
|
||||
handleMouseChanged(usemouse);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -228,6 +239,11 @@ void InputDialog::saveConfig()
|
|||
// Paddle mode
|
||||
Paddles::setMouseIsPaddle(myPaddleMode->getValue());
|
||||
|
||||
// Mouse/paddle enabled
|
||||
bool usemouse = myMouseEnabled->getState();
|
||||
instance().settings().setBool("usemouse", usemouse);
|
||||
instance().eventHandler().setPaddleMode(usemouse ? 0 : -1);
|
||||
|
||||
// Paddle speed
|
||||
int speed = myPaddleSpeed->getValue();
|
||||
instance().settings().setInt("pspeed", speed);
|
||||
|
@ -290,6 +306,13 @@ bool InputDialog::handleJoyHat(int stick, int hat, int value)
|
|||
return Dialog::handleJoyHat(stick, hat, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleMouseChanged(bool state)
|
||||
{
|
||||
myPaddleMode->setEnabled(state);
|
||||
myPaddleModeLabel->setEnabled(state);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void InputDialog::handleCommand(CommandSender* sender, int cmd,
|
||||
int data, int id)
|
||||
|
@ -328,6 +351,10 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
myPaddleLabel->setValue(myPaddleSpeed->getValue());
|
||||
break;
|
||||
|
||||
case kPMouseChanged:
|
||||
handleMouseChanged(data == 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
Dialog::handleCommand(sender, cmd, data, 0);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class InputDialog : public Dialog
|
|||
|
||||
private:
|
||||
void addVDeviceTab(const GUI::Font& font);
|
||||
void handleMouseChanged(bool state);
|
||||
|
||||
private:
|
||||
enum {
|
||||
|
@ -58,7 +59,8 @@ class InputDialog : public Dialog
|
|||
kRightChanged = 'RCch',
|
||||
kDeadzoneChanged = 'DZch',
|
||||
kPaddleChanged = 'PDch',
|
||||
kPSpeedChanged = 'PSch'
|
||||
kPSpeedChanged = 'PSch',
|
||||
kPMouseChanged = 'PMch'
|
||||
};
|
||||
|
||||
TabWidget* myTab;
|
||||
|
@ -75,6 +77,7 @@ class InputDialog : public Dialog
|
|||
StaticTextWidget* myPaddleModeLabel;
|
||||
SliderWidget* myPaddleSpeed;
|
||||
StaticTextWidget* myPaddleLabel;
|
||||
CheckboxWidget* myMouseEnabled;
|
||||
EditTextWidget* myAVoxPort;
|
||||
CheckboxWidget* myAllowAll4;
|
||||
};
|
||||
|
|
|
@ -1809,7 +1809,7 @@
|
|||
2D91752309BA903B0026E9FF /* Deployment */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
|
||||
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
.,
|
||||
"$(HOME)/Library/Frameworks",
|
||||
|
|
Loading…
Reference in New Issue