tkashkin / GameHub

All your games in one place
https://tkashkin.github.io/projects/gamehub
GNU General Public License v3.0
2.23k stars 129 forks source link

Controller support: generate GTK events instead of X11 keypresses #545

Open poperigby opened 3 years ago

poperigby commented 3 years ago
Steps to reproduce
  1. Open GameHub
  2. Plug in a controller
  3. Press any of the buttons on the controller, or move the sticks around
Version and environment
- GameHub
    Version: 0.16.0-3e2cb8a-makepkg
    Branch:  makepkg
    Commit:  3e2cb8a1e3b91e10fb244e7c6983ba49d934eb8f
- Environment
    Distro:  Arch Linux
    DE:      Unity
    GTK:     3.24.28
    Themes:  Ant-Dracula | Papirus-Dark

It's saying Unity is my DE, even though I'm actually using Sway. This is because I've manually set XDG_CURRENT_DESKTOP to Unity, to make the system tray work correctly in Sway.

GDB log
GDB log ``` [INFO] Restarting with GDB [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1". [DEBUG] [Database.migrate] Latest db version: 11, current: 11 [INFO] - GameHub [INFO] Version: 0.16.0-3e2cb8a-makepkg [INFO] Branch: makepkg [INFO] Commit: 3e2cb8a1e3b91e10fb244e7c6983ba49d934eb8f [INFO] - Environment [INFO] Distro: Arch Linux [INFO] DE: Unity [INFO] GTK: 3.24.28 [INFO] Themes: Ant-Dracula | Papirus-Dark [DEBUG] [Gamepad] 'Microsoft X-Box 360 pad' connected [ignored] [DEBUG] [Gamepad] 'Microsoft X-Box One S pad' connected [FATAL] [Json] json_object_get_string_member: assertion 'node != NULL' failed [FATAL] [Json] json_object_get_string_member: assertion 'node != NULL' failed [INFO] [ButlerClient: log] Fetching fresh data... [INFO] [ButlerClient: log] Fetching page 1 [INFO] [ButlerClient: log] Fetching page 2 [INFO] [ButlerClient: log] Fetching page 3 [INFO] [ButlerClient: log] Waited 270.652577ms for fetch (non-shared) [FATAL] [Json] json_object_get_string_member: assertion 'node != NULL' failed [FATAL] [Json] json_object_get_string_member: assertion 'node != NULL' failed [FATAL] [Json] json_object_get_string_member: assertion 'node != NULL' failed [FATAL] [Gdk] gdk_x11_display_get_xdisplay: assertion 'GDK_IS_DISPLAY (display)' failed Thread 1 "com.github.tkas" received signal SIGSEGV, Segmentation fault. 0x00007ffff30efb5a in XKeysymToKeycode () from /usr/lib/libX11.so.6 Thread 17 (Thread 0x7fffcd074640 (LWP 145310) "pool-com.github"): #0 0x00007ffff2f83a9d in syscall () at /usr/lib/libc.so.6 #1 0x00007ffff7c1f06b in g_cond_wait_until () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff7ba08b3 in () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff7ba0a44 in g_async_queue_timeout_pop () at /usr/lib/libglib-2.0.so.0 #4 0x00007ffff7c01d2a in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #6 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #7 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 13 (Thread 0x7fffcf078640 (LWP 145306) "pool-com.github"): #0 0x00007ffff7ac1e6a in () at /usr/lib/libgio-2.0.so.0 #1 0x00007ffff7a4bbe0 in g_content_type_guess () at /usr/lib/libgio-2.0.so.0 #2 0x00007ffff7aba0d2 in () at /usr/lib/libgio-2.0.so.0 #3 0x00007ffff7abb3f5 in () at /usr/lib/libgio-2.0.so.0 #4 0x00007ffff7ab3446 in () at /usr/lib/libgio-2.0.so.0 #5 0x00007ffff79f2c6d in g_file_enumerator_next_file () at /usr/lib/libgio-2.0.so.0 #6 0x0000555555721b82 in game_hub_utils_fs_utils_find_case_insensitive (root=0x5555643d1e80, path=0x7fffbc378310 "appmanifest_233610.acf", parts=0x0, parts_length1=0) at ../src/utils/FSUtils.vala:340 #7 0x000055555559d398 in game_hub_data_sources_steam_steam_find_app_install_dir (app=0x7fffbc35cd00 "233610", install_dir=0x0) at ../src/data/sources/steam/Steam.vala:105 #8 0x000055555559d89a in game_hub_data_sources_steam_steam_is_app_installed (app=0x7fffbc35cd00 "233610") at ../src/data/sources/steam/Steam.vala:119 #9 0x00005555555a9960 in game_hub_data_sources_steam_steam_game_real_update_status (base=0x7fffbc352c60) at ../src/data/sources/steam/SteamGame.vala:248 #10 0x0000555555573b82 in game_hub_data_runnable_update_status (self=0x7fffbc352c60) at ../src/data/Runnable.vala:162 #11 0x00005555555a6071 in game_hub_data_sources_steam_steam_game_construct (object_type=Python Exception No type named TypeNode.: , src=0x555555cca840, json_node=0x555555bbf8a0) at ../src/data/sources/steam/SteamGame.vala:56 #12 0x00005555555a60e5 in game_hub_data_sources_steam_steam_game_new (src=0x555555cca840, json_node=0x555555bbf8a0) at ../src/data/sources/steam/SteamGame.vala:37 #13 0x000055555559f6da in __lambda9_ (_data12_=0x55556077fd40) at ../src/data/sources/steam/Steam.vala:267 #14 0x000055555559fb27 in ___lambda9__game_hub_utils_future (self=0x55556077fd40) at ../src/data/sources/steam/Steam.vala:229 #15 0x0000555555712a7a in game_hub_utils_worker_run (self=Python Exception Variable 'static_fundamental_type_nodes' not found.: ) at ../src/utils/Utils.vala:47 #16 0x0000555555718e32 in ____lambda7_ (w=Python Exception Variable 'static_fundamental_type_nodes' not found.: ) at ../src/utils/Utils.vala:328 #17 0x0000555555718e6b in _____lambda7__gfunc (data=0x55556077fd80, self=0x0) at ../src/utils/Utils.vala:328 #18 0x00007ffff7c01c87 in () at /usr/lib/libglib-2.0.so.0 #19 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #20 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #21 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 11 (Thread 0x7fffe5f95640 (LWP 145304) "pool-com.github"): #0 0x00007ffff2f51125 in clock_nanosleep@GLIBC_2.2.5 () at /usr/lib/libc.so.6 #1 0x00007ffff2f56357 in nanosleep () at /usr/lib/libc.so.6 #2 0x00007ffff7bfa5f1 in g_usleep () at /usr/lib/libglib-2.0.so.0 #3 0x00005555556a922d in __lambda395_ (self=0x55555fd56a00) at ../src/ui/views/GamesView/GamesView.vala:919 #4 0x00005555556a9272 in ___lambda395__game_hub_utils_future (self=0x55555fd56a00) at ../src/ui/views/GamesView/GamesView.vala:911 #5 0x0000555555712a7a in game_hub_utils_worker_run (self=Python Exception Variable 'static_fundamental_type_nodes' not found.: ) at ../src/utils/Utils.vala:47 #6 0x0000555555718e32 in ____lambda7_ (w=Python Exception Variable 'static_fundamental_type_nodes' not found.: ) at ../src/utils/Utils.vala:328 #7 0x0000555555718e6b in _____lambda7__gfunc (data=0x555555884340, self=0x0) at ../src/utils/Utils.vala:328 #8 0x00007ffff7c01c87 in () at /usr/lib/libglib-2.0.so.0 #9 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #10 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #11 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 5 (Thread 0x7fffe6ffd640 (LWP 145263) "dconf worker"): #0 0x00007ffff2f7e37f in poll () at /usr/lib/libc.so.6 #1 0x00007ffff7c24ae8 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff7bce781 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff7fadebe in () at /usr/lib/gio/modules/libdconfsettings.so #4 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 3 (Thread 0x7fffe7fff640 (LWP 145261) "gdbus"): #0 0x00007ffff2f7e37f in poll () at /usr/lib/libc.so.6 #1 0x00007ffff7c24ae8 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff7bd0593 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff7a95558 in () at /usr/lib/libgio-2.0.so.0 #4 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 2 (Thread 0x7fffeceea640 (LWP 145260) "gmain"): #0 0x00007ffff2f7e37f in poll () at /usr/lib/libc.so.6 #1 0x00007ffff7c24ae8 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff7bce781 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff7bce7d2 in () at /usr/lib/libglib-2.0.so.0 #4 0x00007ffff7bff0c1 in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff28f7299 in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff2f89053 in clone () at /usr/lib/libc.so.6 Thread 1 (Thread 0x7fffed658100 (LWP 145224) "com.github.tkas"): #0 0x00007ffff30efb5a in XKeysymToKeycode () at /usr/lib/libX11.so.6 #1 0x000055555575d37c in game_hub_utils_gamepad_emit_key_event (key_code=65293, press=1) at ../src/utils/Gamepad.vala:263 #2 0x000055555575b16b in game_hub_utils_gamepad_button_emit_key_event (self=0x55555fc60e50, press=1) at ../src/utils/Gamepad.vala:142 #3 0x00005555556a8c76 in game_hub_ui_views_games_view_games_view_on_gamepad_button (self=0x55555fd56a00, btn=304, press=1) at ../src/ui/views/GamesView/GamesView.vala:880 #4 0x00005555556a8a67 in game_hub_ui_views_games_view_games_view_on_gamepad_button_press_event (self=0x55555fd56a00, device=0x5555604a3d10, e=0x555564ae7b20) at ../src/ui/views/GamesView/GamesView.vala:865 #5 0x00005555556a834c in _game_hub_ui_views_games_view_games_view_on_gamepad_button_press_event_manette_device_button_press_event (_sender=0x5555604a3d10, event=0x555564ae7b20, self=0x55555fd56a00) at ../src/ui/views/GamesView/GamesView.vala:846 #6 0x00007ffff7cc4ddf in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0 #7 0x00007ffff7cedfbd in () at /usr/lib/libgobject-2.0.so.0 #8 0x00007ffff7ce1cad in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0 #9 0x00007ffff7ce2210 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0 #10 0x00007ffff31a6388 in () at /usr/lib/libmanette-0.2.so.0 #11 0x00007ffff7bd0f30 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #12 0x00007ffff7c24b59 in () at /usr/lib/libglib-2.0.so.0 #13 0x00007ffff7bce781 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #14 0x00007ffff7a6022e in g_application_run () at /usr/lib/libgio-2.0.so.0 #15 0x000055555556db2e in game_hub_application_main (args=0x7fffffffe868, args_length1=2) at ../src/app.vala:242 #16 0x000055555556db87 in main (argc=2, argv=0x7fffffffe868) at ../src/app.vala:226 ```
tkashkin commented 3 years ago

GameHub currently uses XTest to generate fake keypresses so it only works on X11 now.

refactoring branch has more checks to prevent crashes on Wayland and there's a message in Controller Settings if it's not supported.

There probably should be a way to generate GTK events instead of fake keypresses to make it work on Wayland, but I haven't tried to do it yet.

poperigby commented 3 years ago

Got it. Should I open a new issue for Wayland controller support?