Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call for Participation - Test More Joysticks On Linux #5

Closed
AldaronLau opened this issue May 3, 2020 · 41 comments
Closed

Call for Participation - Test More Joysticks On Linux #5

AldaronLau opened this issue May 3, 2020 · 41 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@AldaronLau
Copy link
Member

AldaronLau commented May 3, 2020

I don't have all the possible game controllers that exist out there, and I can't afford to buy them all. So if you have one and feel like contributing, then try it out with the simple readme example in the repository (cargo run --example readme), and make sure all the buttons return an Event, and that the each axis goes from -1 to 1 if it rests at 0 - joysticks (if it only goes one direction it goes positive - L & R triggers). I also want to make sure each controller has the correct mapping of buttons (ActionA shouldn't be mapped to the B button, and ActionV should always be the top button of an ABXY style layout - always either X, Y, or Triangle).

For more advanced contributions, looking at how Firefox maps joysticks for the w3c gamepad API might be helpful, as the stick API is based on that. There might also be something similar in the SDL source code.

You can either report back by leaving a comment with all of the unknown button and axis ids, or you can make your own mapping file in the database at ./pad_db/pad/mapping/JOYSTICK_ID.toml and file a Pull Request:

name = "Name from the packaging or descriptive name (Don't abbreviate PlayStation PS)"
type = "PLAYSTATION" # or whatever other type of controller

[[button]]
code = 0
event = "ActionV" # Triangle Button

[[wheel]] # unusual event type, usually won't have to include
code = 0
event = "WheelX"

[[axis]]
code = 0
event = "JoyX"
max = 0.92 # OPTIONAL: divide axis by some number (usually not needed)

[[three_way]]
code = 1
neg = "DpadLeft"
pos = "DpadRight"

[[trigger]] # An unsigned axis from 0 to 255
code = 2
event = "TriggerL"
max = 0.25 # OPTIONAL: divide axis by some number (usually not needed)

If your gamepad/joystick already works plug-and-play there's no need to comment.

@AldaronLau AldaronLau added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels May 3, 2020
@sanpii
Copy link

sanpii commented May 6, 2020

Steam Controller.

Here a list what I found wrong (I don’t sure for the a/b/x/y buttons):

  • a = cancel;
  • b = accept;
  • x = common;
  • y = action;
  • lt = Unknown Axis: 21;
  • rt = Unknown Axis: 20;
  • back left button = Button 48 is Unknown;
  • back right button = Button 49 is Unknown.

All other things work fine.

@AldaronLau
Copy link
Member Author

Thanks! Looks like the A/B are swapped from what they should be, x and y are correct. Can you post the joystick ID printed in the example at start up? Just to clarify, by back left and back right, do you mean the L/LB & R/RB buttons as they would be labelled on other controllers?

@jaapschouwenburg

This comment has been minimized.

@AldaronLau
Copy link
Member Author

@jaapschouwenburg Thanks, I'll look into fixing this!

@sanpii
Copy link

sanpii commented May 6, 2020

Can you post the joystick ID printed in the example at start up?

id: 28DE1142, name: Wireless Steam Controller

Just to clarify, by back left and back right, do you mean the L/LB & R/RB buttons as they would be labelled on other controllers?

No it’s two paddle buttons on the back off the controller. The xbox-one elite controller has 4 labelled p1 to p4.

@AldaronLau
Copy link
Member Author

@sanpii Thanks. Interesting, I've never seen a controller with those buttons!

@knightpp
Copy link

knightpp commented May 6, 2020

Mad Catz R.A.T. Pro X mouse
IDK maybe this will be helpful.
id: 7381718, name: Mad Catz Mad Catz R.A.T. Pro X
It is a mouse with features of a stick, mapped on scroll left/right tilt. Accept is triggered by RMB, Cancel by pushing on the scroll wheel.
Triggered events

/// Rz was in range 0-1
p2: Rz 0.64                 
p2: Cancel Pushed
p2: Cancel Released
p2: Accept Pushed
p2: Accept Released

Xbox One S
id: 45E02EA, name: Microsoft X-Box One S pad
Everything works. Connected via cable.

I couldn't test Steam Controller. By default it maps its buttons to mouse and keyboard, so you need opened steam client to remap bindings to controller layout. When steam client was opened jstest didn't show controller but I could read it from /dev/input/js. Steam Controller was connected by a cable.

@AldaronLau
Copy link
Member Author

@knightpp is there a left mouse button on stick with id 7381718? What does Rz represent, the scroll wheel? Getting steam controller to work might be tricky, since it sounds like steam client doesn't emulate the joystick in evdev, only in the old linux joystick location.

@AldaronLau
Copy link
Member Author

@sanpii @jaapschouwenburg I just pushed up changes to master that hopefully fixed the mapping issues, but I can't test them myself. If you wouldn't mind doing a git pull and reporting if something still doesn't work, that'd be awesome!

@sanpii
Copy link

sanpii commented May 6, 2020

@AldaronLau it’s fine for me!

@knightpp
Copy link

knightpp commented May 6, 2020

@knightpp is there a left mouse button on stick with id 7381718?

If I understood right - no, left mouse button didn't show anything in the log.

What does Rz represent, the scroll wheel?

Yes, Rz 0 shows up when the scroll wheel is tilted to the left and Rz 1 when to the right.

@AldaronLau
Copy link
Member Author

AldaronLau commented May 6, 2020

@knightpp Can you check to see if the changes I just pushed make the left button show something in the log?

@knightpp
Copy link

knightpp commented May 6, 2020

No, there is nothing on LMB, but I forgot to test all the mouse buttons.

A lot of text

LMB - nothing
RMB -

[src/ffi/linux.rs:537] id = 1
p1: Accept Pushed
[src/ffi/linux.rs:537] id = 1
p1: Accept Released

Middle-click ( push scroll wheel down ) -

[src/ffi/linux.rs:537] id = 2
p1: Cancel Pushed
[src/ffi/linux.rs:537] id = 2
p1: Cancel Released

DPI switch button -

[src/ffi/linux.rs:537] id = 6
p1: L Pushed
[src/ffi/linux.rs:537] id = 6
p1: L Released

Forward button (on the left side ) -

[src/ffi/linux.rs:537] id = 4
p1: Lt 1
[src/ffi/linux.rs:537] id = 4
p1: Lt 0

Backward button (on the left side) -

[src/ffi/linux.rs:537] id = 3
p1: Common Pushed
[src/ffi/linux.rs:537] id = 3
p1: Common Released

Additional button (just below the forward and backward buttons) -

[src/ffi/linux.rs:537] id = 5
p1: Rt 1
[src/ffi/linux.rs:537] id = 5
p1: Rt 0.5019608

Tilt the scroll wheel to the left

p1: Rt 0
p1: Rt 0.26666668
p1: Rt 0.5019608

Tilt the scroll wheel to the right

p1: Rt 1
p1: Rt 0.99215686
p1: Rt 0.9411765
p1: Rt 0.8
p1: Rt 0.72156864
p1: Rt 0.6509804
p1: Rt 0.5529412
p1: Rt 0.5019608

@lucasyvas
Copy link

lucasyvas commented May 6, 2020

I haven't got tons of time at the moment, but I may be able to help you with the official DualShock 4 over USB/bluetooth in the near future if nobody beats me to the punch.

@jaapschouwenburg
Copy link

jaapschouwenburg commented May 6, 2020

@sanpii @jaapschouwenburg I just pushed up changes to master that hopefully fixed the mapping issues, but I can't test them myself. If you wouldn't mind doing a git pull and reporting if something still doesn't work, that'd be awesome!

The PDP Xbox One controller (E6F02A8) now has correct mappings.

The Speedlink PS3 controller (E8F3075) has the following issues:

  • Circle (id: 17) is Action but should be either Accept or Cancel
  • Triangle (id: 16) is Accept but should be Action

The PDP controller rumbles as long as Accept is pressed, the Speedlink doesn't rumble at all.

@AldaronLau
Copy link
Member Author

@knightpp I just pushed changes for the mouse, let me know if it makes sense to you. Also added debugging stuff, so maybe left button will print something now.

@AldaronLau
Copy link
Member Author

AldaronLau commented May 7, 2020

@jaapschouwenburg I think the Speedlink PS3 controller is fixed now, maybe it'll even rumble (probably not). If it doesn't work can you run install and run fftest, and tell me what it allows?

@cinphart
Copy link

cinphart commented May 7, 2020

I have a Wii U Pro Controller, but the test program doesn't appear to recognize it at all. It does show up in firefox when I try https://html5gamepad.com/. It's connected through bluetooth (the only way to connect this controller), not sure if that makes a difference. htm5gamepad.com gives the id as:

057e-0330-Nintendo Wii Remote Pro Controller

I do see output for my XBox One S controller, but I see you have a response for that one above.

For PS4 dual shock, I see:

Connected p1, id: 54C05C4, name: Sony Computer Entertainment Wireless Controller

square (left) is Action
X (bottom) is Accept
triangle (top) is Common
circle (right) is Cancel
ps button disconnects
share is Back
options is Forward
left stick is motion h/v
right stick is camera h/v
R1 is R
L1 is L
R2 is Rt 0-1
L2 is Lt 0-1
directional pad is left/right/up/down as expected.

The PS4 touchpad isn't picked up, this seems to be being treated as a mouse by the driver (left & right click, touchpad itself moves mouse).

@AldaronLau
Copy link
Member Author

@cinphart PS4 should be fixed on master now, thanks! I wonder if stick can only read usb controllers at the moment, I'm going to attempt to get Nintendo switch joycons working once I get bluetooth working on my computer. Don't think there's anything I can do about the touchpad, though.

@jaapschouwenburg
Copy link

jaapschouwenburg commented May 7, 2020

@jaapschouwenburg I think the Speedlink PS3 controller is fixed now, maybe it'll even rumble (probably not). If it doesn't work can you run install and run fftest, and tell me what it allows?

The Speedlink works perfectly now, aside from the lack of rumble. fftest shows no rumble support (though it is physically capable of rumbling):

Device /dev/input/by-id/usb-0e8f_PS_R__Gamepad-event-joystick opened
Features:
  * Absolute axes: X, Y, Z, RZ, Hat 0 X, Hat 0 Y, 
    [27 00 03 00 00 00 00 00 ]
  * Relative axes: 
    [00 00 ]
  * Force feedback effects types: 
    Force feedback periodic effects: 
    [00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ]
  * Number of simultaneous effects: 0

Uploading effect #0 (Periodic sinusoidal) ... Error:: Function not implemented
Uploading effect #1 (Constant) ... Error: Function not implemented
Uploading effect #2 (Spring) ... Error: Function not implemented
Uploading effect #3 (Damper) ... Error: Function not implemented
Uploading effect #4 (Strong rumble, with heavy motor) ... Error: Function not implemented
Uploading effect #5 (Weak rumble, with light motor) ... Error: Function not implemented
Enter effect number, -1 to exit

@knightpp
Copy link

knightpp commented May 7, 2020

@knightpp I just pushed changes for the mouse, let me know if it makes sense to you. Also added debugging stuff, so maybe left button will print something now.

LMB still prints nothing. Forward and back buttons are ok. Now the mouse scroll prints something

scroll debug info

Scroll up

[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    2,
    8,
    1,
)
[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    2,
    11,
    120,
)
[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    0,
    0,
    0,
)

Scroll down

[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    2,
    8,
    4294967295,
)
[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    2,
    11,
    4294967176,
)
[src/ffi/linux.rs:636] (ev.ev_type, ev.ev_code, ev.ev_value) = (
    0,
    0,
    0,
)

@Chronophylos
Copy link
Contributor

Stick: Connected p1, id: 44FB10A, name: Thrustmaster T.16000M Amazon
Note: This is the V1 version FCS could be different
Note: stick is the crate not the controller.

Stick:
Motion forward and backward (MotionV): works
Motion leftward and rightward (MotionH): works
Rotating the stick (Rudder): shows as Rt
Multidirectional hat: works
Trigger (Action, id=0): works
Left button (Cancel, id=2): works
Middle button (Accept, id=1): works
Right button (Common, id=3): works

The resolution of the stick is a lot higher than what stick reports when
moving the stick horizontal and vertical. stick only reports changes as big as 1% but the stick is capable of more. The resolution of the rudder seems to
be right.

Throttle slider (Axis 6): does not work

Buttons:
There are two groups of 6 buttons each. These buttons are not labeled and are
meant to be mapped however the user likes.

LL id LC id LR id RL id RC id RR id
Lt 4 Rt 5 L 6 Up 12 unkwn 11 unkwn 10
Forward 9 Back 8 R 7 Right 13 Down 14 Left 15

@AldaronLau
Copy link
Member Author

@jaapschouwenburg Thanks! Unfortunately, it looks like it's probably a Linux driver issue, so I don't think it's possible to get stick to support rumble on the speedlink controller.

@AldaronLau
Copy link
Member Author

@knightpp @Chronophylos Mappings/resolution should be better now on master. If you want to make sure it's fixed, that would be awesome! LMB doesn't give an event at all through evdev, then which means I probably can't get it to work.

@Chronophylos
Copy link
Contributor

Rudder is now mapped as CameraH and Throttle as CameraV and the resolution of both of them is only between -1 and -0.97. The rest seem to work

@AldaronLau
Copy link
Member Author

@Chronophylos I think that mapping makes sense, let me know if you think it doesn't. New changes on master just now should fix the resolution issues, hopefully.

@Chronophylos
Copy link
Contributor

The resolution looks good. I think the mapping is fine.

@cinphart
Copy link

cinphart commented May 7, 2020

PS4 - buttons are now:

square (left) common
triangle (top) action
circle (right) accept
X (bottom) cancel

I have a few others that I dug out of a closet, that I'll see if I can't try later, mostly third party controllers.

@cinphart
Copy link

cinphart commented May 7, 2020

Connected p1, id: E6F0213, name: Afterglow Gamepad for Xbox 360
left stick maps to motionH/V
right stick maps to camera H/V
directional pad maps OK
LT maps to LT 0-1
RT maps to RT 0-1
back maps to back
start maps to forward
X (left) maps to Common
Y (top) maps to Action
B (left) maps to Cancel
A (bottom) maps to Accept
Xbox button quits

@AldaronLau
Copy link
Member Author

@cinphart Thanks! Looks like they both work, yay!

@cinphart
Copy link

cinphart commented May 8, 2020

Connected p1, id: E6F6302, name: Afterglow controller for PS3
left/right stick work OK for motion
left pad click reports back (id =26)
right pad click reports forward (id=27)
dpad works
select reports Lt (id =24), would expect Back
start reports Rt (id = 25), would expect forward
PS button quits
Square (left) reports Accept
Triangle (top) reports Common
Circle (right) reports Cancel (id=18)
x (bottom) reports Cancel (id=17)
L1 reports Action (id=20)
L2 reports L (id=22)
R1 reports R (id=21)
R2 reports R (id =23)

@cinphart
Copy link

cinphart commented May 8, 2020

Connected p1, id: 46DC216, name: Logitech Logitech Dual Action
Dpad works as expected.
left stick reports motionV/H, click reports 'Button 10 is Unknown)
right stick reports Lt for horizontal motion, RT for vertical motion, click is 'Button 11 is unknown'
button 1 (left) is Action
button 4 (top) is Common
button 3 (right) is Cancel
button 2 (bottom) is Accept
L1 reports Lt (id=4)
L2 reports L (id=6)
R1 reports Rt (id=5)
R2 reports R (id=7)
back/forward report back/forward.

There's no PS/XBOX button on this controller. There is a mode switch that converts the DPAD to report Motion axes, but it's either full on or full off, and that also converts the left stick to report DPAD positions.

@cinphart
Copy link

cinphart commented May 8, 2020

Mayflash Arcade Fightstick F300.

This one has three modes, XInput, gamepad, and PS3/DInput. There's a single 8-way joystick, 8 arcade buttons, select/back button and home/ps button, and a large 'start/options/menu' button. It also has a selectable DPAD or X/Y switch.

In xbox mode:
Connected p1, id: 791832, name: Generic X-Box pad

Stick generate MotionH/V either 1,0 or -1 in X/Y mode, or Dpad responses in DPAD mode.

Eight buttons (two rows of 4, generate):

Common Action R
Accept* Cancel* Rt

Accept also generate 'Unknown 21 0 1'. Cancel also generate 'Unknown 21 0 1'
back generates back, home start generates forward

Gamepad mode:
Connected p1, id: 79181C, name: MAYFLASH Arcade Fightstick F300

Stick generates motion/dpad responses as above

Buttons:

Common Action R L
Accept Cancel Rt* Lt*

Rt/Lt also generate 'Unknown Axis 9' reports

In PS3/DInput mode
Connected p1, id: 791830, name: MAYFLASH Arcade Fightstick F300

Stick generates motion/dpad responses as above

select/back generate Rt (id=25)
start generates Lt (id=24)

Accept Common R id=21 Action
Cancel id=17 Cancel id=18 R id=23 L

@AldaronLau
Copy link
Member Author

@cinphart I think those controllers should work correctly on master now, if you want to verify that they do.

@AldaronLau
Copy link
Member Author

@cinphart Didn't see that last one until just now, so just the 2 Playstation controllers before that

@AldaronLau
Copy link
Member Author

@cinphart The first two modes look fine to me, after looking up what the controller looks like. The third mode should make more sense now.

@pickfire
Copy link

pickfire commented May 18, 2020

Twin USB Gamepad bought from local store for MYR 20 (USD 4.60), it have two gamepad connected using one USB 2.0. Only one random gamepad will work and the other won't be detected.

buttons[0] id = 2 Cancel Pushed/Released, Misc 4 589827. it also vibrates when I hold it
buttons[1] id = 1 Accept Pushed/Released, Misc 4 589826. it also have some sound and some vibrations when I hold it
buttons[2] id = 3 Common Pushed/Released, Misc 4 589828.
buttons[3] id = 0 Action Pushed/Released, Misc 4 589825.
buttons[4] id = 4 Lt 1/0
buttons[5] id = 5 Rt 1/0
buttons[6] id = 6 L Pushed/Released
buttons[7] id = 7 R Pushed/Released
buttons[8] id = 8 Back Pushed/Released
buttons[9] id = 9 Forward Pushed/Released
buttons[10] id = 10 MotionButton Pushed/Released Misc 4 589835.
buttons[11] id = 11 CameraButton Pushed/Released Misc 4 589836.
buttons[12] MotionV -1/0
buttons[13] MotionV 1/0
buttons[14] MotionH -1/0
buttons[15] MotionH 1/0
axis[0] MotionH -1/0, 1/0
axis[1] MotionV -1/0, 1/0
axis[2] id = 3 Common Pushed/Released, Misc 4 589828., id = 1 Accept Pushed/Released, Misc 4 589826. it also have some sound and some vibrations when I hold it
axis[3] id = 0 Action Pushed/Released, Misc 4 589825., Cancel Pushed/Released, Misc 4 589827. it also vibrates when I hold it

Axis does not seemed to work, based on buttons[N] and axis[N] in https://w3c.github.io/gamepad/#remapping

On another site https://html5gamepad.com/ axis does not work on both chrome and firefox, firefox is able to detect both gamepad controllers but chrome cannot, chrome is able to vibrate when pressing a button but it cannot make sound like Bottom button in right cluster pressed in the jstest example.

I tried https://gitlab.com/gilrs-project/gilrs and it can detect both controllers, I think probably because they uses https://github.com/gabomdq/gamecontrollerdb.git

@AldaronLau
Copy link
Member Author

@pickfire Thanks! I'll look into fixing it.

@pickfire
Copy link

@AldaronLau Is there any reason why this crate is created despite gilrs is already there? Maybe the project have different aims? This seemed to be more specific which only works for controllers.

@AldaronLau
Copy link
Member Author

@pickfire The main reason is that I hadn't heard of gilrs when I started stick back in 2017 when gilrs was only a year old and had less than 500 all-time downloads (checking from crates.io). Now, I think the main reason is it's an option for people who want to use async/.await. Additionally, stick provides lower level support in case you want to customize how the hot-plugging should work. I also disagree with the design decision to use Button::South and Button::East rather than Event::Accept or Event::Cancel depending on the controller (since the locations of those buttons are swapped depending on the controller). Also, in the design of this crate, I tried to keep dependencies to a minimum (there's only one), to improve compile times and bloat. On the legal side of things, I think the Apache-2.0/MIT license is not great for making proprietary video games. In order to make something that would be used more by those developers, I licensed Apache-2.0 OR Zlib, Zlib being the more permissive license than MIT, and also what I think SDL uses. And, yes, this crate is only targeting the subset of computer input that isn't picked up by window managers, and is intended to be used with a windowing crate to get access to all HIDs. Hopefully that answers your question.

@AldaronLau
Copy link
Member Author

With the new changes to stick, you can now easily make your own stick mappings in the ./pad_db/pad/mapping folder (instead of hard-coding it in the old spaghetti code). I'll still make the file if you only want to do the testing, though.

Example TOML mapping file:

name = "Name from the packaging or descriptive name (Don't abbreviate PlayStation PS)"
type = "PLAYSTATION" # or whatever other type of controller

[[button]]
code = 0
event = "ActionV" # Triangle Button

[[wheel]] # unusual event type, usually won't have to include
code = 0
event = "WheelX"

[[axis]]
code = 0
event = "JoyX"
max = 0.92 # OPTIONAL: divide axis by some number (usually not needed)

[[three_way]]
code = 1
neg = "DpadLeft"
pos = "DpadRight"

[[trigger]] # An unsigned axis from 0 to 255
code = 2
event = "TriggerL"
max = 0.25 # OPTIONAL: divide axis by some number (usually not needed)

When I converted everything, I don't believe I broke anything, but it might be a good idea to check to make sure if you're up for it.

The file names are the hexadecimal ids returned from stick (Now twice as long to account for different joysticks having the same id). 4 digit sections may be replaced with "xxxx" to match on any controller with the other fields matching. Example: "0300FFFFFFFFxxxx.toml" will include all gamepads starting with 0300FFFFFFFF.

@ardaku ardaku deleted a comment from offalynne Jan 3, 2021
@ardaku ardaku deleted a comment from offalynne Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

8 participants