Skip to content

Commit

Permalink
core, quirks: Add GuliKit KK3 MAX quirks
Browse files Browse the repository at this point in the history
This model has the masking bits for trigger and main motors swapped,
so essentially it doesn't rumble at all. This commit fixes it by adding
a new quirk flag. This quirk is very similar to the quirks needed by
the previous model series.

However, further testing showed that it doesn't properly obey the
motor masking bits it supports and won't stop the motors. So we need
to disable motor masking altogether which makes the swapped mask flag
quite useless. We keep that supported, tho, for future models.

Fixes: #490
Signed-off-by: Kai Krakow <kai@kaishome.de>
  • Loading branch information
kakra committed Dec 6, 2024
1 parent 45dac5d commit 4cdccfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion hid-xpadneo/src/hid-xpadneo.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ MODULE_PARM_DESC(quirks,
", use Linux button mappings = " __stringify(XPADNEO_QUIRK_LINUX_BUTTONS)
", use Nintendo mappings = " __stringify(XPADNEO_QUIRK_NINTENDO)
", use Share button mappings = " __stringify(XPADNEO_QUIRK_SHARE_BUTTON)
", reversed motor masking = " __stringify(XPADNEO_QUIRK_REVERSE_MASK));
", reversed motor masking = " __stringify(XPADNEO_QUIRK_REVERSE_MASK)
", swapped motor masking = " __stringify(XPADNEO_QUIRK_SWAPPED_MASK));

static DEFINE_IDA(xpadneo_device_id_allocator);

Expand Down Expand Up @@ -105,6 +106,8 @@ static const struct quirk xpadneo_quirks[] = {
DEVICE_OUI_QUIRK("98:B6:EA",
XPADNEO_QUIRK_NO_PULSE | XPADNEO_QUIRK_NO_TRIGGER_RUMBLE |
XPADNEO_QUIRK_REVERSE_MASK),
DEVICE_OUI_QUIRK("98:B6:EC",
XPADNEO_QUIRK_SIMPLE_CLONE | XPADNEO_QUIRK_SWAPPED_MASK),
DEVICE_OUI_QUIRK("A0:5A:5D", XPADNEO_QUIRK_NO_HAPTICS),
DEVICE_OUI_QUIRK("E4:17:D8", XPADNEO_QUIRK_SIMPLE_CLONE),
};
Expand Down Expand Up @@ -316,6 +319,10 @@ static void xpadneo_ff_worker(struct work_struct *work)
if (unlikely(xdata->quirks & XPADNEO_QUIRK_REVERSE_MASK))
r->ff.enable = SWAP_BITS(SWAP_BITS(r->ff.enable, 1, 2), 0, 3);

/* swap the bits of trigger and main motors */
if (unlikely(xdata->quirks & XPADNEO_QUIRK_SWAPPED_MASK))
r->ff.enable = SWAP_BITS(SWAP_BITS(r->ff.enable, 0, 2), 1, 3);

ret = xpadneo_output_report(hdev, (__u8 *) r, sizeof(*r));
if (ret < 0)
hid_warn(hdev, "failed to send FF report: %d\n", ret);
Expand Down Expand Up @@ -449,6 +456,13 @@ static void xpadneo_test_rumble(char *which, struct xpadneo_devdata *xdata, stru
if (xdata->quirks & XPADNEO_QUIRK_REVERSE_MASK)
pck.ff.enable = SWAP_BITS(SWAP_BITS(pck.ff.enable, 1, 2), 0, 3);

/*
* XPADNEO_QUIRK_SWAPPED_MASK:
* The controller firmware swaps the bit masks for the trigger motors with those for the main motors.
*/
if (xdata->quirks & XPADNEO_QUIRK_SWAPPED_MASK)
pck.ff.enable = SWAP_BITS(SWAP_BITS(pck.ff.enable, 0, 2), 1, 3);

xpadneo_output_report(xdata->hdev, (u8 *)&pck, sizeof(pck));
mdelay(300);

Expand Down
1 change: 1 addition & 0 deletions hid-xpadneo/src/xpadneo.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ do { \
#define XPADNEO_QUIRK_NINTENDO 32
#define XPADNEO_QUIRK_SHARE_BUTTON 64
#define XPADNEO_QUIRK_REVERSE_MASK 128
#define XPADNEO_QUIRK_SWAPPED_MASK 256

#define XPADNEO_QUIRK_NO_HAPTICS (XPADNEO_QUIRK_NO_PULSE|XPADNEO_QUIRK_NO_MOTOR_MASK)
#define XPADNEO_QUIRK_SIMPLE_CLONE (XPADNEO_QUIRK_NO_HAPTICS|XPADNEO_QUIRK_NO_TRIGGER_RUMBLE)
Expand Down

0 comments on commit 4cdccfd

Please sign in to comment.