Allow users to specify Paddle device for applen.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2020-12-31 14:34:00 +00:00
parent 0e574fad7b
commit ed27650368
6 changed files with 33 additions and 14 deletions

View file

@ -71,11 +71,11 @@ Keyboard shortcuts
In order to properly appreciate the wider hi res graphics, open a big terminal window and choose a small font size.
Try ``CTRL-`` as well if ``ALT-`` does not work: terminals do not report a consistent keycode for these combinations.
The joystick uses evdev (currently the device name is hardcoded).
The joystick uses evdev (``--device-name /dev/input/by-id/id_of_device``).
### qapple
This is based on Qt, currently tested with 5.10
This is based on Qt.
* keyboard shortcuts are listed in the menu entries
* graphics: runs the native NTSC code

View file

@ -56,10 +56,15 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & edit
("headless", "Headless: disable video (freewheel)")
("fixed-speed", "Fixed (non-adaptive) speed")
("ntsc,nt", "NTSC: execute NTSC code")
("benchmark,b", "Benchmark emulator")
("no-squaring", "Gamepad range is (already) a square");
("benchmark,b", "Benchmark emulator");
desc.add(emulatorDesc);
po::options_description paddleDesc("Paddle");
paddleDesc.add_options()
("no-squaring", "Gamepad range is (already) a square")
("device-name", po::value<std::string>(), "Gamepad device name");
desc.add(paddleDesc);
po::variables_map vm;
try
{
@ -113,9 +118,14 @@ bool getEmulatorOptions(int argc, const char * argv [], const std::string & edit
options.headless = vm.count("headless") > 0;
options.log = vm.count("log") > 0;
options.ntsc = vm.count("ntsc") > 0;
options.squaring = vm.count("no-squaring") == 0;
options.fixedSpeed = vm.count("fixed-speed") > 0;
options.paddleSquaring = vm.count("no-squaring") == 0;
if (vm.count("device-name"))
{
options.paddleDeviceName = vm["device-name"].as<std::string>();
}
return true;
}
catch (const po::error& e)
@ -152,5 +162,5 @@ void applyOptions(const EmulatorOptions & options)
setSnapshotFilename(options.snapshotFilename, options.loadSnapshot);
}
Paddle::setSquaring(options.squaring);
Paddle::setSquaring(options.paddleSquaring);
}

View file

@ -20,7 +20,10 @@ struct EmulatorOptions
bool headless = false;
bool ntsc = false; // only for applen
bool squaring = true; // turn the x/y range to a square
bool paddleSquaring = true; // turn the x/y range to a square
// on my PC it is something like
// "/dev/input/by-id/usb-©Microsoft_Corporation_Controller_1BBE3DB-event-joystick"
std::string paddleDeviceName;
bool saveConfigurationOnExit = false;
bool useQtIni = false; // use Qt .ini file (read only)

View file

@ -148,8 +148,9 @@ namespace
g_nMemoryClearType = options.memclear;
initialiseEmulator();
NVideoInitialize(options.headless);
NVideoInitialise(options.headless);
applyOptions(options);
PaddleInitialise(options.paddleDeviceName);
GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, true);

View file

@ -239,15 +239,17 @@ int MessageBox(HWND, const char * text, const char * caption, UINT)
return IDOK;
}
void NVideoInitialize(const bool headless)
void PaddleInitialise(const std::string & device)
{
paddle.reset(new EvDevPaddle(device));
Paddle::instance = paddle;
}
void NVideoInitialise(const bool headless)
{
frame.reset(new Frame());
asciiArt.reset(new ASCIIArt());
paddle.reset(new EvDevPaddle("/dev/input/by-id/usb-©Microsoft_Corporation_Controller_1BBE3DB-event-joystick"));
Paddle::instance = paddle;
if (headless)
{
signal(SIGINT, sig_handler_exit);

View file

@ -1,9 +1,12 @@
#pragma once
#include <string>
int ProcessKeyboard();
void ProcessInput();
void NVideoInitialize(const bool headless);
void NVideoInitialise(const bool headless);
void NVideoRedrawScreen();
void PaddleInitialise(const std::string & device);
extern double g_relativeSpeed;