ShadowBlip / InputPlumber

Open source input router and remapper daemon for Linux
GNU General Public License v3.0
112 stars 13 forks source link

Flydigi Apex 4 support #208

Open zany130 opened 2 months ago

zany130 commented 2 months ago

As previously discussed on discord, this is to track adding support to the Flydigi Apex 4 controller

Relevant discussions and dumps can be found here:

https://github.com/hhd-dev/hhd/issues/73

https://github.com/libsdl-org/SDL/issues/10161

https://github.com/zany130/hwinfo/tree/master/devices/Apex4

Fabianoshz commented 1 week ago

@zany130 I don't know if this helps you but I've managed to make the back buttons of the flydigi work with a set of patches:

+// A "flavor" is an aftermarket variant of an existing model supporting +// additional features. +static const struct xpad_flavor {

+/ used for extra buttons in addition to paddles on Flydigi Vader Pro 3/ +static const signed short xpad_btn_extra[] = {

The type of configuration schema

kind: CompositeDevice

Name of the composite device mapping

name: flydigi-vader-4-pro

Only use this profile if any of the given matches matches. If this list is

empty,then the source devices will always be checked.

/sys/class/dmi/id/product_name

matches: []

Only allow a single source device per composite device of this type.

single_source: true

One or more source devices to combine into a single virtual device. The events

from these devices will be watched and translated according to the key map.

source_devices:

The target input device(s) that the virtual device profile can use

target_devices:

capability_map_id: flydigi-vader-4-pro

options: auto_manage: true

yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/capability_map_v1.json

Schema version number

version: 1

The type of configuration schema

kind: CapabilityMap

Name for the device event map

name: flydigi-vader-4-pro

Unique identifier of the capability mapping

id: flydigi-vader-4-pro

List of mapped events that are activated by a specific set of activation keys.

mapping:

List of events to filter from the source devices

filtered_events: []

zany130 commented 1 week ago

Oh, interesting! I'll try this out! So, basically, this is patching xpad to support the back buttons of the Apex 4 when in x-input mode and then using input plumber to emulate an elite controller so it shows in Steam?

The only thing missing with this would be gyro and the extra "circle button" (button next to home)

D-input is still probably the better mode to use on Linux. Everything except rumble is already exposed. So I guess the only thing that needs to be done is get input plumber to map everything to a dual sense edge or something

Though rumble would not work

pastaq commented 1 week ago

What does the home button map to? Is there another input device exposed for the circle button in xinput mode? Is there an hidraw device that exposes the gyro events?

zany130 commented 1 week ago

No the circle button doesn't send anything in x-input mode

The home button maps to the xbox guide button on x-input mode.

on d-input I think it's BTN_GUIDE so guide button also

The rest is all d-input mode

In d-input the circle button sends the right trigger so it might not be possible to map it separately from the the right trigger thinking back on it

The only mode the circle button is sent as its own button is in dual sense mode (windows software only) and switch mode in bothe cases it's mapped to the share/capture button

Gyro is sent in two hidraws.

The flydigi fly mouse (gyro mouse actived by the circle button (in d-input it sends both the right trigger to the OS and internally it also activates the fly mouse) it sent in a separate hidraw from everything else . There are also mouse buttons on this hidraw mapped to two of the back buttons (I think it was the inner two)

There is also what seems to be raw gyro data on the main hidraw were all the other buttons and sticks are , but a gyro mapping (button combo to enable gyro aim in the windows software) has to be set in the software for it to show up. What buttons are mapped do not matter all that matters is that some type of mapping is set.

This should all be documented in handheld dameon doc fork I mentioned in the op

zany130 commented 6 days ago

If it helps, this is how the Apex 4 is mapped in d-input (note that it identifies as a Vader 3, probably because they use the same firmware or something.)

Input device ID: bus 0x3 vendor 0x4b4 product 0x2412 version 0x111
Input device name: "Flydigi Flydigi VADER3"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 304 (BTN_SOUTH) A
    Event code 305 (BTN_EAST) B
    Event code 306 (BTN_C) not used prob leftover from vader
    Event code 307 (BTN_NORTH) X
    Event code 308 (BTN_WEST) Y
    Event code 309 (BTN_Z) not used prob leftover from vader
    Event code 310 (BTN_TL) LB
    Event code 311 (BTN_TR) RB
    Event code 312 (BTN_TL2) LT
    Event code 313 (BTN_TR2) RT
    Event code 314 (BTN_SELECT) Select
    Event code 315 (BTN_START) Start
    Event code 317 (BTN_THUMBL) L3
    Event code 318 (BTN_THUMBR) R3
    Event code 319 (?)  M1
    Event code 398 (KEY_RED) Guide/home 
    Event code 704 (BTN_TRIGGER_HAPPY1) M2
    Event code 705 (BTN_TRIGGER_HAPPY2) M3
    Event code 706 (BTN_TRIGGER_HAPPY3) M4
    Event code 707 (BTN_TRIGGER_HAPPY4) not used. vader?
  Event type 3 (EV_ABS)
    Event code 0 (ABS_X)  Left stick X axis
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 1 (ABS_Y) Left stick Y axis
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 2 (ABS_Z)  Right stick Y axis
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 5 (ABS_RZ) Right stick X axis
      Value    127
      Min        0
      Max      255
      Flat      15
    Event code 9 (ABS_GAS) Right trigger and Circle button (sends a value of 2 or 0 corresponding to the fly mouse toggle (2 for on and 0 for off))
      Value      0
      Min        0
      Max      255
      Flat      15
    Event code 10 (ABS_BRAKE) Left trigger
      Value      0
      Min        0
      Max      255
      Flat      15
    Event code 16 (ABS_HAT0X) Dpad left + right
      Value      0
      Min       -1
      Max        1
    Event code 17 (ABS_HAT0Y) Dpad Up + down
      Value      0
      Min       -1
      Max        1
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)