Automatic cursor movement in runcommand
-
Hello!
I use a Raspi 4 with original power supply.
RetroPie is installed from a pre made SD Image from RetroPie website and updated to 4.7.19.When I try to start a game, the runcommand menu is always started. If I try to move the cursor down, it always goes up again automatically. It behaves like someone is pressing 'cursor up' all the time. But it does not stop, even if I disconnect all controllers and the keyboard.
There is a similar behavior when I enter the RetroPie-Setup from the emulationstation. But here it seems to be 'cursor left'. It is not happening, if I start RetroPie-Setup from SSH.
There is NO such strange input behavior in emulationstation or Kodi, so I think it could be a problem with the joy2key script. But I have no idea how I could investigate further.
Has anybody an idea, how I can find out, what is causing this behavior?
Ciao
MiK
-
What gamepads do you have connected and how (USB/Bluetooth) ?
Try to start
joy2key
manually and with debug enabled and see what it reports. Exit EmulationStation and run/opt/retropie/admin/joy2key/joy2key_sdl.py kcub1 kcuf1 kcuu1 kcud1 0x0a 0x20 0x1b 0x00 kpp knp -d
It should report what gamepads are connected and configured, then report any input from the gamepad(s). You can run the command via SSH also.
-
@mitu Thanks, this seems to be the right direction. But I have some problems with this debug command. It seems to output parts of my command history??? And how can I stop the debug output?
-
@mitu OK, the history output comes from the strange "cursor up, left" commands.
How can I stop the debug script?
-
@mik Run
killall python3
and it should stop the script. -
@mitu ok, here are the results:
When the first controller is connected, I only get:
2021-10-31 19:34:52,491 DEBUG Using SDL Version 2.0.10, PySDL2 version 0.9.3. 2021-10-31 19:34:52,492 DEBUG Joystick #0 Microsoft X-Box 360 pad added 2021-10-31 19:34:52,492 DEBUG Added configuration for known device Microsoft X-Box 360 pad, hats: {0: [(1, 'up'), (8, 'left'), (2, 'right'), (4, 'down')]}, buttons: {4: 'pageup', 5: 'pagedown', 2: 'y', 3: 'x', 0: 'b', 1: 'a'}, axis: {3: [(-1, 'up'), (1, 'down')], 2: [(-1, 'left'), (1, 'right')], 1: [(1, 'down'), (-1, 'up')], 0: [(1, 'right'), (-1, 'left')]}
When I connect the adapter for my old C64 joysticks I get:
2021-10-31 19:35:11,245 DEBUG Joystick #1 hexagons.de Joystick added 2021-10-31 19:35:11,246 DEBUG Added configuration for known device hexagons.de Joystick, hats: {}, buttons: {0: 'a'}, axis: {1: [(-1, 'up'), (1, 'down')], 0: [(-1, 'left'), (1, 'right')]} 2021-10-31 19:35:11,247 DEBUG Events emitted: ['up', 'left'] 2021-10-31 19:35:11,499 DEBUG Events emitted: ['up', 'left'] 2021-10-31 19:35:11,650 DEBUG Events emitted: ['up', 'left'] 2021-10-31 19:35:11,801 DEBUG Events emitted: ['up', 'left'] 2021-10-31 19:35:11,953 DEBUG Events emitted: ['up', 'left'] ...
So it seems there is a problem with this adapter. But there are two stranges things:
- The output doesn't stop, when I disconnect the adaper.
- This only happens in joy2key. There is no such unintended input in emulationstation, Kodi or within the games.
-
It looks like the joystick is interpreted by
joy2key
as being pressed NW, that's why the constant movement being translated to key presses.If you use
jstest
to see what values are produced by the gamepad's joystick, what values do you get for the axis when the stick is centered ?The output doesn't stop, when I disconnect the adaper.
This may be a bug, the event queue doesn't get cleared when the joystick is disconnected.
There is no such unintended input in emulationstation, Kodi or within the games.
Is this joystick actually configured in EmulationStation ? Looking at the detected configuration, it wouldn't be mapped in EmulationStation's input dialog.
-
If you're able to compile sdl2-jstest and run it with just the C64 joystick connected, that would help understand what events are received and processed by
joy2key
. You can run it withsdl2-jstest -e 0
and just paste the output (without using the joystick or pressing the button on it).
To install it, just run
git clone --recursive https://github.com/Grumbel/sdl-jstest cd sdl-jstest cmake . make
-
@mitu said in Automatic cursor movement in runcommand:
Is this joystick actually configured in EmulationStation ? Looking at the detected configuration, it wouldn't be mapped in EmulationStation's input dialog.
I thought, it was configured in emulationstation. But it wasn't any more. So I configured it again. The result is some short up/left movement in emulationstation after connecting the adapter. But then it stops an everything behaves normal. When it is connected on startup, I don't register anything strange in emulationstation.
-
I remember a similar issue - joystick starts with NW pressed (see here or here). That's why they drift when you're connecting them in ES. You don't get any spurious movements if they're already connected because any input is discarded during start-up, while the splash screen is shown.
I'd be interested in the
sdl2-jstest
output, we may be able to implement a solution or workaround, though to be honest we might as well disable any gamepad that doesn't have 2 buttons, since you'd not be able to use it in the Runcommand menu. -
@mitu said in Automatic cursor movement in runcommand:
sdl2-jstest -e 0
and just paste the output (without using the joystick or pressing the button on it).
pi@retropie:~/sdl-jstest $ ./sdl2-jstest -e 0 Joystick Name: 'hexagons.de Joystick' Joystick GUID: 03000000c0160000dc27000001010000 Joystick Number: 0 Number of Axes: 2 Number of Buttons: 2 Number of Hats: 0 Number of Balls: 0 GameControllerConfig: missing (see 'gamecontrollerdb.txt' or SDL_GAMECONTROLLERCONFIG) Entering joystick test loop, press Ctrl-c to exit SDL_JOYDEVICEADDED which:0 SDL_JOYAXISMOTION: joystick: 0 axis: 0 value: 0 SDL_JOYAXISMOTION: joystick: 0 axis: 0 value: -32768 SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: 0 SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: -32768
-
Thank you for the test, this confirms what we've been seeing so far. It looks like the joystick has 2 movements added during initialisation (up/left) that don't get reset.
SDL_JOYAXISMOTION: joystick: 0 axis: 0 value: 0 SDL_JOYAXISMOTION: joystick: 0 axis: 0 value: -32768 SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: 0 SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: -32768
If you press down, does the 1 axis go to
0
or32768
? -
@mitu Additional info:
There is no real joystick connected to the adapter at the moment.
If I connect the adapter to my windows system, I don't see any movement.
Perhaps this NW-"drift" is only present in init phase of the adapter.Disabling this controller for joy2key would be fine.
-
@mitu said in Automatic cursor movement in runcommand:
If you press down, does the 1 axis go to 0 or 32768 ?
If I press down direct after init I get:
SDL_JOYAXISMOTION: joystick: 0 axis: 0 value: 0 SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: 32767
After releasing I get:
SDL_JOYAXISMOTION: joystick: 0 axis: 1 value: 0
-
@mik said in Automatic cursor movement in runcommand:
Disabling this controller for joy2key would be fine.
If it actually has 2 buttons, then it would be able to fully operate the runcommand menus (1 button is enough for most actions anyway). I'll think of something and may have an updated version you could test in a day.
-
@mitu said in Automatic cursor movement in runcommand:
If it actually has 2 buttons, then it would be able to fully operate the runcommand menus (1 button is enough for most actions anyway). I'll think of something and may have an updated version you could test in a day.
The adapter supports two joysticks. Each joystick has one button.
But the driver in RetroPie doesn't support the button of the second joystick at all. sdl2-jstest shows that the axis of the second joystick results in the same values as the first joystick. In both cases it says "joystick: 0".
-
@mitu said in Automatic cursor movement in runcommand:
I'll think of something and may have an updated version you could test in a day.
One more information, I forgot: This problem wasn't there in older versions. It appeared in one of the last updates. Unfortunately I can't say which update, because I used only Kodi in the last months an didn't try to start a game.
-
@mik said in Automatic cursor movement in runcommand:
This problem wasn't there in older versions.
Probably because
joy2key
was updated at the end of June and the new version uses now SDL2 under the hood.
I have a tentative fix for this class of problems. Can you repeat the test from yesterday, but with [this version] ofjoy2key
:wget https://raw.githubusercontent.com/cmitu/RetroPie-Setup/99fb97f5aef306f522850c6ebeea0117c2c6dd48/scriptmodules/admin/joy2key/joy2key_sdl.py python3 joy2key_sdl.py kcub1 kcuf1 kcuu1 kcud1 0x0a 0x20 0x1b 0x00 kpp knp -d
You should see the connected devices and any inputs from your gamepad(s). You can try with both controllers connected and see if the inputs are correctly registered.
-
@mitu I will try later in the evening.
I'm not very familiar with python, but shouldn't there be the file name in the second line? -
@mik said in Automatic cursor movement in runcommand:
but shouldn't there be the file name in the second line?
Yes, I forgot to add it. Should be fine now, thanks for noticing.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.