mirror of https://github.com/stella-emu/stella.git
initial work on lightgun
This commit is contained in:
parent
0a9b289b44
commit
dbb4328ad5
|
@ -47,6 +47,7 @@
|
||||||
#include "AmigaMouse.hxx"
|
#include "AmigaMouse.hxx"
|
||||||
#include "AtariMouse.hxx"
|
#include "AtariMouse.hxx"
|
||||||
#include "TrakBall.hxx"
|
#include "TrakBall.hxx"
|
||||||
|
#include "Lightgun.hxx"
|
||||||
#include "FrameBuffer.hxx"
|
#include "FrameBuffer.hxx"
|
||||||
#include "TIASurface.hxx"
|
#include "TIASurface.hxx"
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
|
@ -876,6 +877,10 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
||||||
controller = make_unique<MindLink>(port, myEvent, *mySystem);
|
controller = make_unique<MindLink>(port, myEvent, *mySystem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Controller::Type::Lightgun:
|
||||||
|
controller = make_unique<Lightgun>(port, myEvent, *mySystem);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// What else can we do?
|
// What else can we do?
|
||||||
// always create because it may have been changed by user dialog
|
// always create because it may have been changed by user dialog
|
||||||
|
|
|
@ -112,7 +112,8 @@ string Controller::getName(const Type type)
|
||||||
"Unknown",
|
"Unknown",
|
||||||
"AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate",
|
"AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate",
|
||||||
"Driving", "Sega Genesis", "Joystick", "Keyboard", "KidVid", "MindLink",
|
"Driving", "Sega Genesis", "Joystick", "Keyboard", "KidVid", "MindLink",
|
||||||
"Paddles", "Paddles_IAxis", "Paddles_IAxDr", "SaveKey", "TrakBall"
|
"Paddles", "Paddles_IAxis", "Paddles_IAxDr", "SaveKey", "TrakBall",
|
||||||
|
"Lightgun"
|
||||||
};
|
};
|
||||||
|
|
||||||
return NAMES[int(type)];
|
return NAMES[int(type)];
|
||||||
|
@ -126,7 +127,8 @@ string Controller::getPropName(const Type type)
|
||||||
"AUTO",
|
"AUTO",
|
||||||
"AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE",
|
"AMIGAMOUSE", "ATARIMOUSE", "ATARIVOX", "BOOSTERGRIP", "COMPUMATE",
|
||||||
"DRIVING", "GENESIS", "JOYSTICK", "KEYBOARD", "KIDVID", "MINDLINK",
|
"DRIVING", "GENESIS", "JOYSTICK", "KEYBOARD", "KIDVID", "MINDLINK",
|
||||||
"PADDLES", "PADDLES_IAXIS", "PADDLES_IAXDR", "SAVEKEY", "TRAKBALL"
|
"PADDLES", "PADDLES_IAXIS", "PADDLES_IAXDR", "SAVEKEY", "TRAKBALL",
|
||||||
|
"LIGHTGUN"
|
||||||
};
|
};
|
||||||
|
|
||||||
return PROP_NAMES[int(type)];
|
return PROP_NAMES[int(type)];
|
||||||
|
|
|
@ -94,6 +94,7 @@ class Controller : public Serializable
|
||||||
AmigaMouse, AtariMouse, AtariVox, BoosterGrip, CompuMate,
|
AmigaMouse, AtariMouse, AtariVox, BoosterGrip, CompuMate,
|
||||||
Driving, Genesis, Joystick, Keyboard, KidVid, MindLink,
|
Driving, Genesis, Joystick, Keyboard, KidVid, MindLink,
|
||||||
Paddles, PaddlesIAxis, PaddlesIAxDr, SaveKey, TrakBall,
|
Paddles, PaddlesIAxis, PaddlesIAxDr, SaveKey, TrakBall,
|
||||||
|
Lightgun,
|
||||||
LastType
|
LastType
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,9 @@ Controller::Type ControllerDetector::autodetectPort(const uInt8* image, size_t s
|
||||||
else if(usesKeyboard(image, size, port))
|
else if(usesKeyboard(image, size, port))
|
||||||
type = Controller::Type::Keyboard;
|
type = Controller::Type::Keyboard;
|
||||||
else if(usesGenesisButton(image, size, port))
|
else if(usesGenesisButton(image, size, port))
|
||||||
|
|
||||||
type = Controller::Type::Genesis;
|
type = Controller::Type::Genesis;
|
||||||
|
else if(isProbablyLightGun(image, size, port))
|
||||||
|
type = Controller::Type::Lightgun;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -643,3 +644,41 @@ bool ControllerDetector::isProbablySaveKey(const uInt8* image, size_t size,
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
bool ControllerDetector::isProbablyLightGun(const uInt8* image, size_t size,
|
||||||
|
Controller::Jack port)
|
||||||
|
{
|
||||||
|
if (port == Controller::Jack::Left)
|
||||||
|
{
|
||||||
|
// check for INPT4 after NOPs access
|
||||||
|
const int NUM_SIGS = 2;
|
||||||
|
const int SIG_SIZE = 6;
|
||||||
|
uInt8 signature[NUM_SIGS][SIG_SIZE] = {
|
||||||
|
{ 0xea, 0xea, 0xea, 0x24, 0x0c, 0x10 },
|
||||||
|
{ 0xea, 0xea, 0xea, 0x24, 0x3c, 0x10 }
|
||||||
|
}; // all pattern checked, only 'Sentinel' and 'Shooting Arcade' match
|
||||||
|
|
||||||
|
for (uInt32 i = 0; i < NUM_SIGS; ++i)
|
||||||
|
if (searchForBytes(image, size, signature[i], SIG_SIZE))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(port == Controller::Jack::Right)
|
||||||
|
{
|
||||||
|
// check for INPT5 after NOPs access
|
||||||
|
const int NUM_SIGS = 2;
|
||||||
|
const int SIG_SIZE = 6;
|
||||||
|
uInt8 signature[NUM_SIGS][SIG_SIZE] = {
|
||||||
|
{ 0xea, 0xea, 0xea, 0x24, 0x0d, 0x10 },
|
||||||
|
{ 0xea, 0xea, 0xea, 0x24, 0x3d, 0x10 }
|
||||||
|
}; // all pattern checked, only 'Bobby is Hungry' matches
|
||||||
|
|
||||||
|
for (uInt32 i = 0; i < NUM_SIGS; ++i)
|
||||||
|
if (searchForBytes(image, size, signature[i], SIG_SIZE))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -111,6 +111,10 @@ class ControllerDetector
|
||||||
// Returns true if a SaveKey code pattern is found.
|
// Returns true if a SaveKey code pattern is found.
|
||||||
static bool isProbablySaveKey(const uInt8* image, size_t size, Controller::Jack port);
|
static bool isProbablySaveKey(const uInt8* image, size_t size, Controller::Jack port);
|
||||||
|
|
||||||
|
// Returns true if a Lightgun code pattern is found
|
||||||
|
static bool isProbablyLightGun(const uInt8* image, size_t size, Controller::Jack port);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Following constructors and assignment operators not supported
|
// Following constructors and assignment operators not supported
|
||||||
ControllerDetector() = delete;
|
ControllerDetector() = delete;
|
||||||
|
|
|
@ -121,6 +121,7 @@ class Event
|
||||||
CompuMateSlash,
|
CompuMateSlash,
|
||||||
|
|
||||||
ToggleInter,
|
ToggleInter,
|
||||||
|
LightgunZeroFire, LightgunZeroPos, LightgunOneFire, LightgunOnePos,
|
||||||
|
|
||||||
LastType
|
LastType
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "OSystem.hxx"
|
#include "OSystem.hxx"
|
||||||
#include "Joystick.hxx"
|
#include "Joystick.hxx"
|
||||||
#include "Paddles.hxx"
|
#include "Paddles.hxx"
|
||||||
|
#include "Lightgun.hxx"
|
||||||
#include "PointingDevice.hxx"
|
#include "PointingDevice.hxx"
|
||||||
#include "PropsSet.hxx"
|
#include "PropsSet.hxx"
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
|
@ -100,6 +101,7 @@ void EventHandler::initialize()
|
||||||
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff"));
|
Paddles::setDejitterDiff(myOSystem.settings().getInt("dejitter.diff"));
|
||||||
Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense"));
|
Paddles::setDigitalSensitivity(myOSystem.settings().getInt("dsense"));
|
||||||
Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense"));
|
Paddles::setMouseSensitivity(myOSystem.settings().getInt("msense"));
|
||||||
|
Lightgun::setMouseSensitivity(myOSystem.settings().getInt("msense"));
|
||||||
PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense"));
|
PointingDevice::setSensitivity(myOSystem.settings().getInt("tsense"));
|
||||||
|
|
||||||
#ifdef GUI_SUPPORT
|
#ifdef GUI_SUPPORT
|
||||||
|
|
|
@ -841,6 +841,9 @@ void FrameBuffer::setCursorState()
|
||||||
bool analog = myOSystem.hasConsole() ?
|
bool analog = myOSystem.hasConsole() ?
|
||||||
(myOSystem.console().leftController().isAnalog() ||
|
(myOSystem.console().leftController().isAnalog() ||
|
||||||
myOSystem.console().rightController().isAnalog()) : false;
|
myOSystem.console().rightController().isAnalog()) : false;
|
||||||
|
bool lightgun = emulation && myOSystem.hasConsole() ?
|
||||||
|
myOSystem.console().leftController().type() == Controller::Type::Lightgun ||
|
||||||
|
myOSystem.console().rightController().type() == Controller::Type::Lightgun : false;
|
||||||
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
|
bool alwaysUseMouse = BSPF::equalsIgnoreCase("always", myOSystem.settings().getString("usemouse"));
|
||||||
|
|
||||||
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
|
grabMouse(emulation && (analog || alwaysUseMouse) && myGrabMouse);
|
||||||
|
|
|
@ -220,6 +220,7 @@ GameInfoDialog::GameInfoDialog(
|
||||||
VarList::push_back(ctrls, "SaveKey", "SAVEKEY");
|
VarList::push_back(ctrls, "SaveKey", "SAVEKEY");
|
||||||
VarList::push_back(ctrls, "Sega Genesis", "GENESIS");
|
VarList::push_back(ctrls, "Sega Genesis", "GENESIS");
|
||||||
VarList::push_back(ctrls, "KidVid", "KIDVID");
|
VarList::push_back(ctrls, "KidVid", "KIDVID");
|
||||||
|
VarList::push_back(ctrls, "Lightgun", "LIGHTGUN");
|
||||||
VarList::push_back(ctrls, "MindLink", "MINDLINK");
|
VarList::push_back(ctrls, "MindLink", "MINDLINK");
|
||||||
|
|
||||||
ypos = VBORDER;
|
ypos = VBORDER;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "EventHandler.hxx"
|
#include "EventHandler.hxx"
|
||||||
#include "Joystick.hxx"
|
#include "Joystick.hxx"
|
||||||
#include "Paddles.hxx"
|
#include "Paddles.hxx"
|
||||||
|
#include "Lightgun.hxx"
|
||||||
#include "PointingDevice.hxx"
|
#include "PointingDevice.hxx"
|
||||||
#include "SaveKey.hxx"
|
#include "SaveKey.hxx"
|
||||||
#include "AtariVox.hxx"
|
#include "AtariVox.hxx"
|
||||||
|
@ -349,6 +350,8 @@ void InputDialog::saveConfig()
|
||||||
sensitivity = myMPaddleSpeed->getValue();
|
sensitivity = myMPaddleSpeed->getValue();
|
||||||
instance().settings().setValue("msense", sensitivity);
|
instance().settings().setValue("msense", sensitivity);
|
||||||
Paddles::setMouseSensitivity(sensitivity);
|
Paddles::setMouseSensitivity(sensitivity);
|
||||||
|
Lightgun::setMouseSensitivity(sensitivity);
|
||||||
|
|
||||||
|
|
||||||
// Trackball speed
|
// Trackball speed
|
||||||
sensitivity = myTrackBallSpeed->getValue();
|
sensitivity = myTrackBallSpeed->getValue();
|
||||||
|
|
|
@ -487,6 +487,7 @@
|
||||||
<ClCompile Include="..\emucore\EmulationTiming.cxx" />
|
<ClCompile Include="..\emucore\EmulationTiming.cxx" />
|
||||||
<ClCompile Include="..\emucore\EmulationWorker.cxx" />
|
<ClCompile Include="..\emucore\EmulationWorker.cxx" />
|
||||||
<ClCompile Include="..\emucore\FBSurface.cxx" />
|
<ClCompile Include="..\emucore\FBSurface.cxx" />
|
||||||
|
<ClCompile Include="..\emucore\Lightgun.cxx" />
|
||||||
<ClCompile Include="..\emucore\MindLink.cxx" />
|
<ClCompile Include="..\emucore\MindLink.cxx" />
|
||||||
<ClCompile Include="..\emucore\PointingDevice.cxx" />
|
<ClCompile Include="..\emucore\PointingDevice.cxx" />
|
||||||
<ClCompile Include="..\emucore\ProfilingRunner.cxx" />
|
<ClCompile Include="..\emucore\ProfilingRunner.cxx" />
|
||||||
|
@ -1210,6 +1211,7 @@
|
||||||
<ClInclude Include="..\emucore\exception\FatalEmulationError.hxx" />
|
<ClInclude Include="..\emucore\exception\FatalEmulationError.hxx" />
|
||||||
<ClInclude Include="..\emucore\FBSurface.hxx" />
|
<ClInclude Include="..\emucore\FBSurface.hxx" />
|
||||||
<ClInclude Include="..\emucore\FrameBufferConstants.hxx" />
|
<ClInclude Include="..\emucore\FrameBufferConstants.hxx" />
|
||||||
|
<ClInclude Include="..\emucore\Lightgun.hxx" />
|
||||||
<ClInclude Include="..\emucore\MindLink.hxx" />
|
<ClInclude Include="..\emucore\MindLink.hxx" />
|
||||||
<ClInclude Include="..\emucore\PointingDevice.hxx" />
|
<ClInclude Include="..\emucore\PointingDevice.hxx" />
|
||||||
<ClInclude Include="..\emucore\ProfilingRunner.hxx" />
|
<ClInclude Include="..\emucore\ProfilingRunner.hxx" />
|
||||||
|
|
|
@ -996,6 +996,9 @@
|
||||||
<ClCompile Include="..\common\PhosphorHandler.cxx">
|
<ClCompile Include="..\common\PhosphorHandler.cxx">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\emucore\Lightgun.cxx">
|
||||||
|
<Filter>Source Files\emucore</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\common\bspf.hxx">
|
<ClInclude Include="..\common\bspf.hxx">
|
||||||
|
@ -2036,6 +2039,9 @@
|
||||||
<ClInclude Include="..\common\PhosphorHandler.hxx">
|
<ClInclude Include="..\common\PhosphorHandler.hxx">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\emucore\Lightgun.hxx">
|
||||||
|
<Filter>Header Files\emucore</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="stella.ico">
|
<None Include="stella.ico">
|
||||||
|
|
Loading…
Reference in New Issue