diff --git a/linux.md b/linux.md index 2dc365e7..c0b44724 100644 --- a/linux.md +++ b/linux.md @@ -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 diff --git a/source/frontends/common2/programoptions.cpp b/source/frontends/common2/programoptions.cpp index fb650cb9..3d71e9ba 100644 --- a/source/frontends/common2/programoptions.cpp +++ b/source/frontends/common2/programoptions.cpp @@ -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(), "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(); + } + 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); } diff --git a/source/frontends/common2/programoptions.h b/source/frontends/common2/programoptions.h index c34d068e..e72d37df 100644 --- a/source/frontends/common2/programoptions.h +++ b/source/frontends/common2/programoptions.h @@ -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) diff --git a/source/frontends/ncurses/main.cpp b/source/frontends/ncurses/main.cpp index a5e3ea68..6173a310 100644 --- a/source/frontends/ncurses/main.cpp +++ b/source/frontends/ncurses/main.cpp @@ -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); diff --git a/source/frontends/ncurses/world.cpp b/source/frontends/ncurses/world.cpp index b7ca8029..5df2d255 100644 --- a/source/frontends/ncurses/world.cpp +++ b/source/frontends/ncurses/world.cpp @@ -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); diff --git a/source/frontends/ncurses/world.h b/source/frontends/ncurses/world.h index 2f93b4e3..bb9ec98e 100644 --- a/source/frontends/ncurses/world.h +++ b/source/frontends/ncurses/world.h @@ -1,9 +1,12 @@ #pragma once +#include + 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;