linuxserver / docker-emulatorjs

Web based retro emulation frontend with rom scanning and automated art ingestion.
GNU General Public License v3.0
509 stars 51 forks source link

[BUG] Bluetooth Controller Misbehaving #72

Closed hermetic-charm closed 2 months ago

hermetic-charm commented 6 months ago

Is there an existing issue for this?

Current Behavior

Bluetooth controller is connected but either does nothing or goes "crazy" looping through menus.

Expected Behavior

Bluetooth controller works in both the menus and games.

Steps To Reproduce

  1. Open game, controller does nothing
  2. Check Retroarch Menu (F1)->Controls->Port 1 Controls: It can see the controller it's listed under buttons, controller still does nothing image
  3. Select any button menu item, e.g. D-pad Up, to open the next screen which shows button selection options.
  4. Press any button on controller (e.g. A, B, Dpad Up): Controller input gets recognized but now input starts going crazy like I am holding down the Dpad button. It scrolls through menu options infinitely. Oddly, while it is going crazy other buttons seem to work (e.g. I can press B or A and it will go into/out of a menu item as it scrolls through everything).
  5. Pressing F1 gets me out of the crazy menus and back into the game, but now the controller does nothing again
  6. Additionally, now after the above steps, trying to go back into F1 menu nothing works. I can't do anything, keyboard does not work, mouse does not work, gamepad does not work.
  7. Refresh page. Still does not work.
  8. The only way to get control of the menu again is to unpair the Bluetooth controller. I see a message toast in the browser saying controller has been disconnected and then menu functionality comes back with mouse/keyboard.

Environment

- OS: Windows 11
- How docker service was installed: Synology Container Manager
- Browser: Edge
-Controller: 8bitdo NES controller connected via Bluetooth.  Browser sees controller as confirmed on https://gamepadtest.com/

CPU architecture

x86-64

Docker creation

services:
  emulatorjs:
    image: lscr.io/linuxserver/emulatorjs:latest
    container_name: emulatorjs
    environment:
      - PUID=REDACTED
      - PGID=REDACTED
      - TZ=America/New_York
      #- SUBFOLDER=/ #optional
    security_opt:
      - no-new-privileges:true
    network_mode: bridge
    volumes:
      - /path/tomy/config:/config
      - /path/tomy/data:/data
    ports:
      - REDACTED:3000
      - REDACTED:80
      #- REDACTED:4001 #optional
    restart: on-failure:20

Container logs

[migrations] started
[migrations] no migrations found
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    REDACTED
User GID:    REDACTED
───────────────────────────────────────

[ipfs-upgrade] Checking if fs-repo needs to be upgraded (this may take some time)
[custom-init] No custom files found, skipping...
Initializing daemon...
Kubo version: 0.24.0
Repo version: 15
System version: amd64/linux
Golang version: go1.21.3
[ls.io-init] done.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/127.0.0.1/udp/4001/quic-v1
Swarm listening on /ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm listening on /ip4/IP_REDACTED/tcp/4001
Swarm listening on /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm listening on /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm listening on /p2p-circuit
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/127.0.0.1/udp/4001/quic-v1
Swarm announcing /ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm announcing /ip4/IP_REDACTED/tcp/4001
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
RPC API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready

Received interrupt signal, shutting down...
(Hit ctrl-c again to force-shutdown the daemon.)
[migrations] started
[migrations] no migrations found
usermod: no changes
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    REDACTED
User GID:    REDACTED
───────────────────────────────────────

[ipfs-upgrade] Checking if fs-repo needs to be upgraded (this may take some time)
[custom-init] No custom files found, skipping...
Initializing daemon...
Kubo version: 0.24.0
Repo version: 15
System version: amd64/linux
Golang version: go1.21.3
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/127.0.0.1/udp/4001/quic-v1
Swarm listening on /ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm listening on /ip4/IP_REDACTED/tcp/4001
Swarm listening on /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm listening on /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm listening on /p2p-circuit
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/127.0.0.1/udp/4001/quic-v1
Swarm announcing /ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
Swarm announcing /ip4/IP_REDACTED/tcp/4001
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1
Swarm announcing /ip4/IP_REDACTED/udp/4001/quic-v1/webtransport/certhash/HASH_REDACTED/certhash/HASH_REDACTED
RPC API server listening on /ip4/127.0.0.1/tcp/5001
WebUI: http://127.0.0.1:5001/webui
Gateway server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
[ls.io-init] done.
github-actions[bot] commented 6 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

hermetic-charm commented 6 months ago

As an additional note I installed the Retroarch desktop app to test and the controller is working okay in that.

thelamer commented 6 months ago

The only controllers I have to test are Xbox series, Xbox wired(360 and wired), Razr kishi Though I can say that low button controllers likely crash the menu as this logic needs a 16th button to detect triple home button presses to drop back to the menu. https://github.com/linuxserver/emulatorjs/blob/master/frontend/js/index.js#L579 Also are you sure this is Bluetooth and not 2.4 ghz ?

Check the browser console for errors.

thelamer commented 6 months ago

Just to be clear when I say to check the browser console for errors those are the errors I need to know what is going wrong.

hermetic-charm commented 6 months ago

I am not getting any errors controller related in the console, only thing it seems to be reporting on the controller is when I disconnect it. image

I am pretty sure it's Bluetooth, is there an easy-ish way to check? It shows up in device manager on Windows under Bluetooth devices.

thelamer commented 6 months ago

The error should be when you are in the game browser if the controller does not work there.

hermetic-charm commented 6 months ago

Tried in the game browser, I am not really seeing anything useful there either. I tried connecting/disconnecting the controller, pressing all of the buttons. No response, no logs/errors/warning output other than things that seem ordinary (see below screenshot).

As a note again, the controller is completely non-responsive until I open (F1)->Controls->Port 1 Controls and then select one of the control buttons. Once I am in that menu and press a button all of a sudden, the controller works on other screens but it is going crazy. So it seems like the controller is not even recognized until I go to that screen for whatever reason.

image

thelamer commented 6 months ago

Does this page work for you ? https://hardwaretester.com/gamepad

hermetic-charm commented 6 months ago

Yes, below is the mapping: B0 = "A" button B1 = "B" button

B10 = "Select" button B11 = "Start" button

Axis 0 @ -1 = D-pad left Axis 0 @ +1 = D-pad right Axis 1 @ -1 = D-pad up Axis 1 @ +1 = D-pad down

thelamer commented 6 months ago

I think I can work with that, i have a lot on my plate right now will take a bit to get you something to test.

thelamer commented 5 months ago

@hermetic-charm Can you please test this code?

Exec into the container to replace the file with head:

docker exec emulatorjs sh -c 'curl -L https://raw.githubusercontent.com/linuxserver/emulatorjs/master/frontend/js/index.js -o /emulatorjs/frontend/js/index.js'

Then in your browser use a private window to make sure you don't get any cache and see if the controller works at all in the menu or in game.

hermetic-charm commented 5 months ago

Thanks for the work! I am trying it now, definitely getting different behavior but it seems to still not be working.

When the game selection screen loads, the first page, I can choose between SNES or NES. Whichever is selected is repeatedly playing its zoom animation. But if I press the D-pad it does switch between the two, although if I want to select the non-default I have to hold the D-pad down or it reverts to the default selection. There does seem to be some errors here now, they are ever increasing in count, seemingly in sync with the animation starting over:

image

A/B seem to work too here, as pressing A loads the game selection screen.

On the game selection screen D-pad is still working. Same issue with the animations. Now, when pressing D-pad it does switch between games but now there is an error displayed whenever I do press the D-pad: image

A/B seems to work as I am able to select a game.

Once a game is loaded, the D-pad become unresponsive, but it seems like A/B are still working. Start/Select do not appear to work. Trying to open retroarch F1 menu, the controller there is completely unresponsive, but also now mouse and keyboard are also completely unresponsive. No errors at first, but I did notice that when I scroll the mouse wheel in the F1 menu an error shows: image

thelamer commented 5 months ago

It looks like your controller dpad is registered as n analogue device, I will get a fix in for the up down not working in the menu. The other errors are because you have to click on the page chrome does not see the controller input as interaction it seems anymore.

As for gameplay in retroarch itself you need to set I believe:

Settings, Input, User 1 Binds, set User 1 Analog to Digital Type to Left Analog. 

Keep in mind retroarch thinks your dpad is an analogue input.

thelamer commented 5 months ago

Run this again this should fix the menu:

docker exec emulatorjs sh -c 'curl -L https://raw.githubusercontent.com/linuxserver/emulatorjs/master/frontend/js/index.js -o /emulatorjs/frontend/js/index.js'

And again I think you need to interact with the page (mouse click into it or keyboard) before you start doing controller stuff or at the very least before trying to launch a game. That last error is from Retroarch itself and I have never seen it though I doubt it is related to a controller.

hermetic-charm commented 5 months ago

This one is working a bit better.

Still issues on System/Game selection, if the controller is turned on it constantly switches between the options as if I was rapidly pressing up or down on the d-pad repeatedly.

Once I do load a game A/B works, if I head into options and set Left Analog the D-Pad does start working. "Select" and "Start" buttons do not work at all as far as I can tell.

Additionally, the controller working as described above seems somewhat hit or miss. Sometimes it works right away (after setting Left Analog). Other times it is non-responsive, and I need to turn the controller off and back on again. Sometimes the Retroarch menu scrolls through options infinitely (similiar to System/Game selection screens). Other times, the Retroarch menu completely locked up again (i.e. controller didn't work in the menus but also mouse and keyboard stopped working until I disconnected the controller).

thelamer commented 5 months ago

Can you show me a screenshot of what it looks like when you press down or up on your controller from here https://hardwaretester.com/gamepad ?

hermetic-charm commented 5 months ago

Pressing nothing: image

Pressing up: image

Pressing down: image

thelamer commented 5 months ago

So you see the problem here right? It's two fold, you have a dead zone registered on the controller that -0.00952 registered with no input (it should be 0). That is fine and we work around that by only registering analog presses of .5 and greater. But you also have these axis 3 and 4 that are permanently pressed. That is not something I believe Retroarch can deal with and I do not want to shim anything in to blacklist in the frontend as it does not fix retroarch and axis 3 is the right analog on all normal controllers and it can be the left analog on many others.

Basically everything should be registered as 0 as seen with my series controller here:

controller

Your only real course of action is to contact 8bitdo, they need to work to get their controller sane in web browsers and participate in its mapping and identification.

Edit: also the start select has to be a trial and error thing, which is made difficult if the menu is going bonkers when you try to select buttons to try from the controller mapping.

hermetic-charm commented 5 months ago

I see what you mean here, I will reach out to 8bitdo and start a conversation with them.

LinuxServer-CI commented 4 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 month ago

This issue is locked due to inactivity