Added ability to specify MouseAxis range from the UI, and send it to

the Paddles class to be actually used.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3250 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2016-01-18 18:33:45 +00:00
parent a85debea63
commit b9d71634a7
5 changed files with 80 additions and 24 deletions

View File

@ -27,6 +27,10 @@
loading a ROM would always point to the last opened ROM, not to the one loading a ROM would always point to the last opened ROM, not to the one
currently selected. currently selected.
* Fixed bug in storing ROM properties; in some cases, a copy of the
ROM properties was being stored in the external file when it was
exactly the same as the internal entry.
* Added more C++11 updates all over the codebase, and ran Stella * Added more C++11 updates all over the codebase, and ran Stella
through Coverity for the first time. I'm proud to say that Stella through Coverity for the first time. I'm proud to say that Stella
now has a 0.00 defect rate! now has a 0.00 defect rate!

View File

@ -3330,7 +3330,10 @@ Ms Pac-Man (Stella extended codes):
<tr><td>5 </td><td>Driving 1</td></tr> <tr><td>5 </td><td>Driving 1</td></tr>
<tr><td>6 </td><td>MindLink 0</td></tr> <tr><td>6 </td><td>MindLink 0</td></tr>
<tr><td>7 </td><td>MindLink 1</td></tr> <tr><td>7 </td><td>MindLink 1</td></tr>
</table></td> </table>
An <I>optional</I> second parameter (default of 100) indicates how much
of the paddle range that the mouse should emulate.
</td>
</tr> </tr>
<!-- <!--

View File

@ -19,6 +19,7 @@
#include "Console.hxx" #include "Console.hxx"
#include "Control.hxx" #include "Control.hxx"
#include "Paddles.hxx"
#include "Props.hxx" #include "Props.hxx"
#include "MouseControl.hxx" #include "MouseControl.hxx"
@ -30,17 +31,21 @@ MouseControl::MouseControl(Console& console, const string& mode)
myRightController(console.rightController()), myRightController(console.rightController()),
myCurrentModeNum(0) myCurrentModeNum(0)
{ {
if(BSPF_equalsIgnoreCase(mode, "none")) istringstream m_axis(mode);
string m_mode;
m_axis >> m_mode;
if(BSPF_equalsIgnoreCase(m_mode, "none"))
{ {
myModeList.push_back(MouseMode("Mouse input is disabled")); myModeList.push_back(MouseMode("Mouse input is disabled"));
return; return;
} }
else if(!BSPF_equalsIgnoreCase(mode, "auto") && mode.length() == 2 && else if(!BSPF_equalsIgnoreCase(m_mode, "auto") && m_mode.length() == 2 &&
mode[0] >= '0' && mode[0] <= '8' && m_mode[0] >= '0' && m_mode[0] <= '8' &&
mode[1] >= '0' && mode[1] <= '8') m_mode[1] >= '0' && m_mode[1] <= '8')
{ {
Axis xaxis = Axis(int(mode[0]) - '0'); Axis xaxis = Axis(int(m_mode[0]) - '0');
Axis yaxis = Axis(int(mode[1]) - '0'); Axis yaxis = Axis(int(m_mode[1]) - '0');
ostringstream msg; ostringstream msg;
msg << "Mouse X-axis is "; msg << "Mouse X-axis is ";
Controller::Type xtype = Controller::Joystick, ytype = Controller::Joystick; Controller::Type xtype = Controller::Joystick, ytype = Controller::Joystick;
@ -155,6 +160,13 @@ MouseControl::MouseControl(Console& console, const string& mode)
addLeftControllerModes(noswap); addLeftControllerModes(noswap);
} }
// Set range information (currently only for paddles, but may be used
// for other controllers in the future)
int m_range = 100;
if(!(m_axis >> m_range))
m_range = 100;
Paddles::setPaddleRange(m_range);
// If the mouse isn't used at all, we still need one item in the list // If the mouse isn't used at all, we still need one item in the list
if(myModeList.size() == 0) if(myModeList.size() == 0)
myModeList.push_back(MouseMode("Mouse not used for current controllers")); myModeList.push_back(MouseMode("Mouse not used for current controllers"));

View File

@ -248,7 +248,7 @@ GameInfoDialog::GameInfoDialog(
lwidth = font.getStringWidth("Mouse axis mode: "); lwidth = font.getStringWidth("Mouse axis mode: ");
pwidth = font.getStringWidth("Specific axis"); pwidth = font.getStringWidth("Specific axis");
items.clear(); items.clear();
VarList::push_back(items, "Automatic", "auto"); VarList::push_back(items, "Automatic", "AUTO");
VarList::push_back(items, "Specific axis", "specific"); VarList::push_back(items, "Specific axis", "specific");
myMouseControl = myMouseControl =
new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,
@ -279,6 +279,18 @@ GameInfoDialog::GameInfoDialog(
"Y-Axis is: ", lwidth); "Y-Axis is: ", lwidth);
wid.push_back(myMouseY); wid.push_back(myMouseY);
xpos = 10; ypos += lineHeight + 8;
lwidth = font.getStringWidth("Mouse axis range: ");
myMouseRange = new SliderWidget(myTab, font, xpos, ypos, 8*fontWidth, lineHeight,
"Mouse axis range: ", lwidth, kMRangeChanged);
myMouseRange->setMinValue(1); myMouseRange->setMaxValue(100);
wid.push_back(myMouseRange);
myMouseRangeLabel = new StaticTextWidget(myTab, font,
xpos + myMouseRange->getWidth() + 4, ypos+1,
3*fontWidth, fontHeight, "", kTextAlignLeft);
myMouseRangeLabel->setFlags(WIDGET_CLEARBG);
// Add items for tab 2 // Add items for tab 2
addToFocusList(wid, myTab, tabID); addToFocusList(wid, myTab, tabID);
@ -337,7 +349,7 @@ GameInfoDialog::GameInfoDialog(
wid.push_back(myPPBlend); wid.push_back(myPPBlend);
myPPBlendLabel = new StaticTextWidget(myTab, font, myPPBlendLabel = new StaticTextWidget(myTab, font,
xpos + lwidth + myPhosphor->getWidth() + 10 + \ xpos + lwidth + myPhosphor->getWidth() + 10 +
myPPBlend->getWidth() + 4, ypos+1, myPPBlend->getWidth() + 4, ypos+1,
3*fontWidth, fontHeight, "", kTextAlignLeft); 3*fontWidth, fontHeight, "", kTextAlignLeft);
myPPBlendLabel->setFlags(WIDGET_CLEARBG); myPPBlendLabel->setFlags(WIDGET_CLEARBG);
@ -419,8 +431,12 @@ void GameInfoDialog::loadView()
myP0Controller->setSelected(myGameProperties.get(Controller_Left), "JOYSTICK"); myP0Controller->setSelected(myGameProperties.get(Controller_Left), "JOYSTICK");
myP1Controller->setSelected(myGameProperties.get(Controller_Right), "JOYSTICK"); myP1Controller->setSelected(myGameProperties.get(Controller_Right), "JOYSTICK");
mySwapPaddles->setSelected(myGameProperties.get(Controller_SwapPaddles), "NO"); mySwapPaddles->setSelected(myGameProperties.get(Controller_SwapPaddles), "NO");
const string& mcontrol = myGameProperties.get(Controller_MouseAxis);
bool autoAxis = BSPF_equalsIgnoreCase(mcontrol, "auto"); // MouseAxis property (potentially contains 'range' information)
istringstream m_axis(myGameProperties.get(Controller_MouseAxis));
string m_control, m_range;
m_axis >> m_control;
bool autoAxis = BSPF_equalsIgnoreCase(m_control, "AUTO");
if(autoAxis) if(autoAxis)
{ {
myMouseControl->setSelectedIndex(0); myMouseControl->setSelectedIndex(0);
@ -430,11 +446,21 @@ void GameInfoDialog::loadView()
else else
{ {
myMouseControl->setSelectedIndex(1); myMouseControl->setSelectedIndex(1);
myMouseX->setSelected(mcontrol[0] - '0'); myMouseX->setSelected(m_control[0] - '0');
myMouseY->setSelected(mcontrol[1] - '0'); myMouseY->setSelected(m_control[1] - '0');
} }
myMouseX->setEnabled(!autoAxis); myMouseX->setEnabled(!autoAxis);
myMouseY->setEnabled(!autoAxis); myMouseY->setEnabled(!autoAxis);
if(m_axis >> m_range)
{
myMouseRange->setValue(atoi(m_range.c_str()));
myMouseRangeLabel->setLabel(m_range);
}
else
{
myMouseRange->setValue(100);
myMouseRangeLabel->setLabel("100");
}
// Display properties // Display properties
myFormat->setSelected(myGameProperties.get(Display_Format), "AUTO"); myFormat->setSelected(myGameProperties.get(Display_Format), "AUTO");
@ -479,10 +505,15 @@ void GameInfoDialog::saveConfig()
myGameProperties.set(Console_SwapPorts, myGameProperties.set(Console_SwapPorts,
myLeftPort->getSelectedTag().toString() == "L" ? "NO" : "YES"); myLeftPort->getSelectedTag().toString() == "L" ? "NO" : "YES");
myGameProperties.set(Controller_SwapPaddles, mySwapPaddles->getSelectedTag().toString()); myGameProperties.set(Controller_SwapPaddles, mySwapPaddles->getSelectedTag().toString());
// MouseAxis property (potentially contains 'range' information)
string mcontrol = myMouseControl->getSelectedTag().toString(); string mcontrol = myMouseControl->getSelectedTag().toString();
if(mcontrol != "auto") if(mcontrol != "AUTO")
mcontrol = myMouseX->getSelectedTag().toString() + mcontrol = myMouseX->getSelectedTag().toString() +
myMouseY->getSelectedTag().toString(); myMouseY->getSelectedTag().toString();
string range = myMouseRangeLabel->getLabel();
if(range != "100")
mcontrol += " " + range;
myGameProperties.set(Controller_MouseAxis, mcontrol); myGameProperties.set(Controller_MouseAxis, mcontrol);
// Display properties // Display properties
@ -498,10 +529,9 @@ void GameInfoDialog::saveConfig()
else else
instance().propSet().insert(myGameProperties); instance().propSet().insert(myGameProperties);
// In any event, inform the Console and save the properties // In any event, inform the Console
if(instance().hasConsole()) if(instance().hasConsole())
instance().console().setProperties(myGameProperties); instance().console().setProperties(myGameProperties);
instance().propSet().save(instance().propertiesFile());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -553,6 +583,10 @@ void GameInfoDialog::handleCommand(CommandSender* sender, int cmd,
myPPBlendLabel->setValue(myPPBlend->getValue()); myPPBlendLabel->setValue(myPPBlend->getValue());
break; break;
case kMRangeChanged:
myMouseRangeLabel->setValue(myMouseRange->getValue());
break;
case kMCtrlChanged: case kMCtrlChanged:
{ {
bool state = myMouseControl->getSelectedTag().toString() != "auto"; bool state = myMouseControl->getSelectedTag().toString() != "auto";

View File

@ -66,14 +66,16 @@ class GameInfoDialog : public Dialog, public CommandSender
PopUpWidget* myTVType; PopUpWidget* myTVType;
// Controller properties // Controller properties
PopUpWidget* myP0Controller; PopUpWidget* myP0Controller;
PopUpWidget* myP1Controller; PopUpWidget* myP1Controller;
PopUpWidget* mySwapPaddles; PopUpWidget* mySwapPaddles;
PopUpWidget* myLeftPort; PopUpWidget* myLeftPort;
PopUpWidget* myRightPort; PopUpWidget* myRightPort;
PopUpWidget* myMouseControl; PopUpWidget* myMouseControl;
PopUpWidget* myMouseX; PopUpWidget* myMouseX;
PopUpWidget* myMouseY; PopUpWidget* myMouseY;
SliderWidget* myMouseRange;
StaticTextWidget* myMouseRangeLabel;
// Display properties // Display properties
PopUpWidget* myFormat; PopUpWidget* myFormat;
@ -86,6 +88,7 @@ class GameInfoDialog : public Dialog, public CommandSender
enum { enum {
kLeftCChanged = 'LCch', kLeftCChanged = 'LCch',
kRightCChanged = 'RCch', kRightCChanged = 'RCch',
kMRangeChanged = 'MRch',
kPhosphorChanged = 'PPch', kPhosphorChanged = 'PPch',
kPPBlendChanged = 'PBch', kPPBlendChanged = 'PBch',
kMCtrlChanged = 'MCch' kMCtrlChanged = 'MCch'