ShadowBlip / HandyGCCS

Handheld Game Console Controller Support (Handy Geeks) for Linux
GNU General Public License v3.0
81 stars 30 forks source link

[bug] Back buttons on GPD Win 4 not functional in gamepadui #121

Closed aarron-lee closed 1 year ago

aarron-lee commented 1 year ago

Device: GPD Win 4 6800u Version: ChimeraOS 43-1 Bios: v3.06

after updating to the latest handycon via pikaur, the back buttons are still not functional on gamepadui.

handycon does seem to be properly registering the power button. Before, a power button tap would immediately go into suspend, but now it shows the Steam Deck suspend animation before actually suspending.

note that on desktop mode, the back-left button registers as a screenshot button, but it turns out that this is probably the default behavior; even when I had handycon fully disabled, it worked as a screenshot button on the desktop only.

created this issue after original discussion in https://github.com/ChimeraOS/chimeraos/issues/728

pastaq commented 1 year ago

Can you run the system profiler from OpenGamepadUI and post the resulting file? Please ensure handycon.service and opengamepadui are both not running before conducting the test. When it asks for the key presses, press the left back button then the right back button before hitting ctrl+c on the keyboard to end the script. This must be run with sudo permissions.

Thanks.

aarron-lee commented 1 year ago

Generated file is here: G1618-04_system_profile.txt

Also, not sure if this helps, but when I tried to manually map the back buttons via input-remapper, it turns out that the back buttons are registered as a mouse. Pause was the back right button, Print was the back left button.

back_buttons

Unfortunately, input-remapper's systemd service seems to fail to initialize in gamepadui on boot, but it does properly work when I tested it in desktop mode BPM.

pastaq commented 1 year ago

Since there are twomouse for windows devices it's possible we're just grabbing the wrong one. Do you know if the events trigger on the device attached to usb-0000:73:00.3-4.2/input0 or the one attached to usb-0000:73:00.3-4.2/input1

aarron-lee commented 1 year ago

hrm, so I tried building handycon after updating gpd_gen3.py with the input1 ID, and noticed the following after a reboot:

I'll try to change around the code in handycon, and try to figure out what's happening.

aarron-lee commented 1 year ago

Going to investigate some more tomorrow, but added some basic logging in gpd_gen3.py.

When pressing the back-left button, the following values were logged:

seed_event event at 1693883873.070568, code 04, type 04, val 458822 
 active_keys [99] 
 button_on 458822 
---
seed_event event at 1693883873.070568, code 99, type 01, val 01 
 active_keys [99] 
 button_on 1 
---
seed_event event at 1693883873.070568, code 00, type 00, val 00 
 active_keys [99] 
 button_on 0 
---
seed_event event at 1693883873.336501, code 99, type 01, val 02 
 active_keys [99] 
 button_on 2 
---
seed_event event at 1693883873.336501, code 00, type 00, val 01 
 active_keys [99] 
 button_on 1 
---
seed_event event at 1693883873.366600, code 04, type 04, val 458822 
 active_keys [] 
 button_on 458822 
---
seed_event event at 1693883873.366600, code 99, type 01, val 00 
 active_keys [] 
 button_on 0 
---
seed_event event at 1693883873.366600, code 00, type 00, val 00 
 active_keys [] 
 button_on 0 
---

When I pressed the back-right button, got the following logs:

seed_event event at 1693883892.136303, code 04, type 04, val 458824 
 active_keys [119] 
 button_on 458824 
---
seed_event event at 1693883892.136303, code 119, type 01, val 01 
 active_keys [119] 
 button_on 1 
 ---
seed_event event at 1693883892.136303, code 00, type 00, val 00 
 active_keys [119] 
 button_on 0 
 button2 [[1, 316], [1, 304]]
---
seed_event event at 1693883892.402902, code 119, type 01, val 02 
 active_keys [119] 
 button_on 2 
---
seed_event event at 1693883892.402902, code 00, type 00, val 01 
 active_keys [119] 
 button_on 1 
---
seed_event event at 1693883892.432318, code 04, type 04, val 458824 
 active_keys [] 
 button_on 458824 
---
seed_event event at 1693883892.432318, code 119, type 01, val 00 
 active_keys [] 
 button_on 0 
---
seed_event event at 1693883892.432318, code 00, type 00, val 00 
 active_keys [] 
 button_on 0 
---
pastaq commented 1 year ago

I just looked at the code. It's super wrong for the key up events...

pastaq commented 1 year ago

Line 41 should have just [119] for seed_event.code and 47 should have 99

pastaq commented 1 year ago

Actually all the GPD devices have this bug

pastaq commented 1 year ago

Just pushed a fix

aarron-lee commented 1 year ago

Thanks, I can confirm that this almost fixed the issue. The last remaining thing to fix is to change from input0 to input1.

https://github.com/ShadowBlip/HandyGCCS/blob/80e86e94021e5e7c476343bcd4f4a5ff461e5862/src/handycon/handhelds/gpd_gen3.py#L21

After updating to input1 on the latest handygccs, I can confirm that the back-left button is working as QAM, back-right for screenshot.

aarron-lee commented 1 year ago

Just to clarify, I had to do one more manual code change, which was updating the KEYBOARD_ADDRESS code in gpd_gen3.py from input0 to input1. Worked perfectly afterwards.

I'm not seeing the code change on the main branch, so I'm assuming it's a change that'll be pushed later.

Anyways, thanks for the help with troubleshooting this issue! :)

pastaq commented 1 year ago

I misread what you wrote. I'll update that soon, thanks!

pastaq commented 1 year ago

Updated. Please verify and we can close this issue.

aarron-lee commented 1 year ago

just updated to the latest handygccs via pikaur, I can confirm that it all works now.