Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
diagnose_joysticks_issues [2022/02/20 02:39] – minor cleanup (WIP), added section about connection issues ataridiagnose_joysticks_issues [2023/11/12 17:37] (current) – [No controller detected even when connected via USB] syslinux.cfg path for v39 maximumentropy
Line 1: Line 1:
 ====== Input problems ====== ====== Input problems ======
  
-==== ROMs take a long time to load ====+<WRAP center round todo> 
 +Under construction. 
 +</WRAP>
  
-This is caused by the X-Input settings due XBOX ONE and some 8bitdo Pads. It took 30-45s to load a ROM, this is independent from core. To fix this 8bitdo should be setted to Android Mode. You can read more [[https://retropie.org.uk/forum/topic/25820/|about here]].+===== ROMs take a long time to load =====
  
-==== Bluetooth Connection ====+Some controllers (including Xbox One and 8-bitdo ones) can cause certain cores to take a long time to load a ROM, upwards of thirty seconds. In these situations, it can be worked around by setting the controller to D-input mode (may be referred to as "Android mode" by some manuals). Read more about it in [[https://retropie.org.uk/forum/topic/25820/|this Retropie forum post]].
  
-This is a phenomena causes with some issues and like input lag (especially if you connect more than one BT controller)+===== Bluetooth connection =====
  
-  - Try reducing distance from your controller to Raspberry (helps sometimes) +  * Reduce the distance from the controller to the Batocera machine. 
-  - Try to disable internal WiFi - this helps to extent signal strength, you can use ''rfkill wifi'' to disable/enable Wifi (several users report PS3 controller connections problems are vanished since) +  * Disable the internal Wi-Fi - this helps to extent signal strength, you can use ''rfkill wifi'' to disable/enable Wi-Fi. 
-  - Try forcing a lower baud rate in ''/etc/init.d/S31emulationstation'' or ''/etc/init.d/S32bluetooth''. Smaller values of 115200 or 230400 have been known to alleviate input lag on a Pi 3B. +  * Force a lower baud rate in ''/etc/init.d/S31emulationstation'' or ''/etc/init.d/S32bluetooth''. Smaller values of 115200 or 230400 have been known to alleviate input lag on a Pi 3B. 
-  Buy a new BT adapter and put it to your Raspberry. Add ''dtoverlay=pi3-disable-bt'' in ''/boot/config.txt'' to disable internal BT module (ultima ratio, speeds up communication, extents range and speed depending on your BT adapter model)+  Buy a new BT adapter and put it to your Raspberry. Add ''dtoverlay=pi3-disable-bt'' in ''/boot/config.txt'' to disable internal BT module.
  
-==== No controller detected even when connected via USB ====+===== No controller detected even when connected via USB =====
  
 Few things to try: Few things to try:
   * Use a different USB port   * Use a different USB port
   * Ensure controller itself is even functional   * Ensure controller itself is even functional
 +  * If using a third-party controller, switch the input mode on it (refer to your controller's manual)
 +    * D-input typically works best, followed by X-input, then "Mac" and Android modes
   * Disable IOMMU setting in BIOS   * Disable IOMMU setting in BIOS
   * Ensure there's no other obvious settings in the BIOS that could be disabling USB functionality   * Ensure there's no other obvious settings in the BIOS that could be disabling USB functionality
 +  * Add ''hid.ignore_special_drivers=1'' to the ''APPEND'' line in ''/boot/EFI/batocera/syslinux.cfg'' (for Batocera **v39** or higher) or ''/boot/EFI/BOOT/syslinux.cfg'' (for Batocera **v38** or lower) in the [[:edit_boot_partition|boot partition]]. The line should look similar to: ''%%APPEND label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 mitigations=off hid.ignore_special_drivers=1%%'' [[https://forum.batocera.org/d/7360-set-hidignore-special-drivers1-on-x86-architecture/8|Detailed forum post.]]
   * Clean the contacts with rubbing alcohol (when everything is turned off and disconnected from power), let it dry, and try again   * Clean the contacts with rubbing alcohol (when everything is turned off and disconnected from power), let it dry, and try again
-  * If using a third-party controller, switch the input mode on it (refer to your controller's manual) 
-    * D-input typically works best, followed by X-input, then "Mac" and Android modes 
   * Scream   * Scream
  
-==== Controller connected and detected, but no inputs ====+If all else fails, please provide a [[:report_issue|detailed issue report]] so that the devs can look into it. [[https://github.com/batocera-linux/batocera.linux/issues/5696|Here's a real example.]] 
 + 
 +===== Controller connected and detected, but no inputs =====
  
 Try configuring the controller by manually editing the ''/userdata/system/configs/emulationstation/es_input.cfg'' file. Try configuring the controller by manually editing the ''/userdata/system/configs/emulationstation/es_input.cfg'' file.
  
-===== Diagnose Joysticks Issues =====+===== Controller connected, detected and making inputs, but they are unexpected/ghost inputs =====
  
-Physical joystick <--> linux driver <--> linux events stack <-A->  SDL2 library <-B-> EmulationStation+Ensure that all of the controller's inputs are in a neutral position when plugging in/connected the controller.
  
-From your joystick to the batocera interface (EmulationStation), there are several technical steps. +If that still gives unexpected ghost inputs during mapping, try to repair the mapping process by renaming ''/userdata/system/.sdl2'' to ''/userdata/system/.sdl2_bad'' and immediately restarting ES (''[Alt]'' + ''[F4]'' or restart via SSH). If this fixes the issue, it could be because of Batocera's neutral position detection method failingplease report such issues to the Github and the steps to reproduce.
-In case of issuesthere are 2 mains tools, evtest and sdl2-jstest+
  
 +<WRAP center round tip>
 +Run ''%%cat /userdata/system/.sdl2/<GUID><name of controller>.cache%%'' to grab the neutral values that have been detected.
 +</WRAP>
  
-evtest acts on point A to analyse linux events while sdl2-jstest acts on point B to analyse events going to EmulationStation.+===== When using "Emulate cursor with joystick", the cursor is moving by itself ===== 
 + 
 +You can increase the deadzone for pad2key's mouse function by doing the following: 
 + 
 +  - [[:modify_the_system_while_it_s_running|Learn how to use Batocera overlays.]] 
 +  - Download the following file and save it to ''/etc/evmapy.json'': <file - evmapy.json> 
 +{ "mouse_config": { "every": 0.005, "deadzone": 0.15 } } 
 + 
 +</file> 
 +  - Launch a game using the feature and test the cursor. If it's still drifting, increase the "deadzone" value and try again. Higher values decrease the accuracy of pad2key's mouse emulation, so change this conservatively. 
 +  - When a suitable value has been found, run ''batocera-save-overlay''
 + 
 +===== Diagnose joysticks issues ===== 
 + 
 +Physical joystick <--> Linux driver <--> Linux events stack <-**A**->  SDL2 library <-**B**-> EmulationStation 
 + 
 +From your joystick to Batocera's menu interface (EmulationStation), there are several technical steps. There are two tools to analyze two separate parts of the sequence: ''evtest'' and ''sdl2-jstest''
 + 
 +''evtest'' acts on point **A** in the above diagram, used to debug very low-level issues (like a button's state change not being registered by the controller or an incorrect amount of inputs being registered). ''sdl2-jstest'' acts on point **B** in the above diagram, used to debug high-level issues (like EmulationStation not reacting correctly when button X is pressed, certain emulator not "seeing" a controller's inputs which otherwise work fine in other programs, etc.).
  
 ==== evtests ==== ==== evtests ====
  
-events in the linux kernel are the way to handle mouses, keyboards, joysticks, etc...+''events'' in the linux kernel are the way to handle mouses, keyboards, joysticks, etc...
 sdl2 is a library to help to code program compatible with linux, windows, mac os x, ... it converts linux events to a common way to define events. On linux, events are define in /usr/include/linux/input-event-codes.h. For example, the button "yellow" if your joystick has one is : sdl2 is a library to help to code program compatible with linux, windows, mac os x, ... it converts linux events to a common way to define events. On linux, events are define in /usr/include/linux/input-event-codes.h. For example, the button "yellow" if your joystick has one is :
   #define KEY_YELLOW 0x190 (1*16*16 + 9*16 + 0 = 400)   #define KEY_YELLOW 0x190 (1*16*16 + 9*16 + 0 = 400)
Line 73: Line 98:
 ==== sdl2-jstest ==== ==== sdl2-jstest ====
  
-  - run sdl2-jstest --list to check what emulationstation sees when you press buttons+Run ''%%sdl2-jstest --list%%'' to check what EmulationStation sees when you press buttons
 In my case, it displays : In my case, it displays :
   # export DISPLAY=:0.0   # export DISPLAY=:0.0
Line 99: Line 124:
   SDL_JOYBUTTONUP: joystick: 0 button: 2 state: 0 code:306   SDL_JOYBUTTONUP: joystick: 0 button: 2 state: 0 code:306
   ...   ...
 +
 +You can see a graphical representation of your controller by running:
 +
 +<code>
 +sdl2-jstest --test #
 +</code>
 +
 +where ''#'' is the number of the joystick you want to test.
 +
 +{{:sdl2-jstest_-t_0.png?500|A very old joystick indeed!}}
 +
 +===== Configuring es_input manually =====
 +
 +Although Batocera should be able to handle the mapping of nearly any controller, there comes a time where it is only feasibly possible to map a controller manually, such as when the controller is sending multiple signals at once for a single button press or when Batocera thinks the gyroscope is an input for all buttons.
 +
 +Open up two SSH sessions to Batocera. Yes, you can do that, just open the program twice. On one session:
 +  - Run ''sdl2-jstest -l'' and remember the number of the joystick you intend to remap.
 +  - Run ''%%sdl2-jstest --test #%%'', where # is the joystick number.
 +
 +On the other session:
 +  - Run ''evtest''.
 +  - Type in the number of the input device you intend to remap (this may be different from the one in the other session).
 +
 +You now have all the input information you need to make a manual remap.
 +
 +==== es_input syntax ====
 +
 +The syntax for each input line mapped:
 +
 +<code>
 + <input name="<name>" type="<type>" id="<#>" value="<#>" code="<#>" />
 +</code>
 +
 +The two leading spaces are tabs, not spaces. This is important.
 +
 +Explanation of the attributes:
 +  * **name** is the virtual button on the Batocera Retropad. This is most similar to a SNES controller, however ''pageup'' and ''pagedown'' represent ''[L1]'' and ''[R1]'' respectively.
 +  * **type** is the type of input being scanned for. This can be either ''button'' or ''axis''. It does not have to match up with the kind of control specified in **name**.
 +  * **id** is the number affected in the ''sdl2-jstest'' session when the button/axis is manipulated. This behaves differently for hats, as they determine their direction pressed from value alone (when there is only one hat, it is always 0).
 +  * **value** is the value that the control is "pressed" on in the ''evtest'' session. Typically 0 or 1 for buttons, -1 to 1 for axis.
 +  * **code** is the code that the control is "pressed" on in the ''evtest'' session. This should be unique to every input.
 +
 +So for instance a button input line might look like this:
 +
 +<code>
 + <input name="a" type="button" id="0" value="1" code="304" />
 +</code>
 +
 +An axis might look like this:
 +
 +<code>
 + <input name="joystick1left" type="axis" id="0" value="-1" code="0" />
 +</code>
 +
  • diagnose_joysticks_issues.1645321169.txt.gz
  • Last modified: 2 years ago
  • by atari