linuxserver / emulatorjs

Self hosted web based retro emulation front end with rom and art management.
409 stars 31 forks source link

Broken gamepad support on google chrome #63

Closed deepio closed 1 year ago

deepio commented 2 years ago

I'm looking to migrate towards emulatorjs and have come across these problems so far.

Questions

Keypress problem

This gamepad has a no-key signal of (11, 128, 128, 127, 127, 15, 0, 0) and when that signal is sent the emulator will do the opposite of whichever directional key was pressed last. Meaning if you click right and release, the selector in game will go right and back left to the same point of origin.

I verified the key-pressing functionality like this:

import hid

for device in hid.enumerate():
    print(f"0x{device['vendor_id']:04x}:0x{device['product_id']:04x} {device['product_string']}")

gamepad = hid.device()
gamepad.open(0x0810, 0xe501)
gamepad.set_nonblocking(True)

key_map = {
    (1, 128, 128, 127, 127, 15, 32, 0): "START",

    (1, 128, 128, 127,   0, 15, 0, 0): "UP",
    (1, 128, 128, 127, 255, 15, 0, 0): "DOWN",
    (1, 128, 128, 0,   127, 15, 0, 0): "LEFT",
    (1, 128, 128, 255, 127, 15, 0, 0): "RIGHT",

    (1, 128, 128, 0, 0, 15, 0, 0): "UP-LEFT",
    (1, 128, 128, 255, 0, 15, 0, 0): "UP-RIGHT",
    (1, 128, 128, 0, 255, 15, 0, 0): "DOWN-LEFT",
    (1, 128, 128, 255, 255, 15, 0, 0): "DOWN-RIGHT",

    (1, 128, 128, 127, 127, 15, 1, 0): "B",
    (1, 128, 128, 127, 127, 15, 2, 0): "A",

    (1, 128, 128, 127, 127, 31, 0, 0): "C-UP",
    (1, 128, 128, 127, 127, 79, 0, 0): "C-DOWN",
    (1, 128, 128, 127, 127, 143, 0, 0): "C-LEFT",
    (1, 128, 128, 127, 127, 47, 0, 0): "C-RIGHT",

    (1, 128, 128, 127, 127, 159, 0, 0): "C-UP-LEFT",
    (1, 128, 128, 127, 127, 63, 0, 0): "C-UP-RIGHT",
    (1, 128, 128, 127, 127, 207, 0, 0): "C-DOWN-LEFT",
    (1, 128, 128, 127, 127, 111, 0, 0): "C-DOWN-RIGHT",

    (1, 128, 128, 127, 127, 15, 8, 0): "R",
    (1, 128, 128, 127, 127, 15, 4, 0): "L",
    (1, 128, 128, 127, 127, 15, 16, 0): "Z",
}

last_pressed = (11, 128, 128, 127, 127, 15, 0, 0)
while True:
    report = tuple(gamepad.read(64))
    if report != last_pressed and report != () and report != (1, 128, 128, 127, 127, 15, 0, 0):
        last_pressed = report
        print(f"{key_map.get(report, report)} -> {report}")

In N64 specifically there's also 4 directions missing from the mapping button because only up, down, left, right are available. What setting do I need to disable to fix this in retroarch? Should I be playing with the controls in the UI at all or all in retroarch??

deepio commented 2 years ago

It should be noted that the same gamepad IDs are used for different devices from the mario retro line and they have different mappings.

The n64 device has this mapping above, but the SNES has the left shoulder as B -> (1, 128, 128, 127, 127, 15, 1, 0) right shoulder as L -> (1, 128, 128, 127, 127, 15, 4, 0), all the C's from n64 are mapped the X,Y,A,B, and Z from n64 is mapped to Select on SNES.

github-actions[bot] commented 1 year 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.

deepio commented 1 year ago

/unstale

github-actions[bot] commented 1 year 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 year ago

This issue is locked due to inactivity