tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.08k stars 2.57k forks source link

[bug] Global shortcuts not working in some games #7318

Open StenniHub opened 1 year ago

StenniHub commented 1 year ago

Describe the bug

I am working on migrating an electron application for managing savefiles in games over to Tauri, but I am facing some issues with global shortcut handling. While the shortcuts appear to work in most games I tested (for example Elden Ring, Apex and Trackmania), I could not get them working when playing Dark Souls 2 or Dark Souls 3. I believe this is related to either exclusive fullscreen handling or DirectInput, but I am not entirely sure. I faced the same issue with global shortcuts in Electron, where I ended up using node-global-keyboard-listener instead. I tried a few crates for global key listeners, but they did seem to play nicely with Tauri when the window was in focus.

Reproduction

  1. Register global shortcut from @tauri-apps/api/globalShortcut
  2. Launch a conflicting game (e.g. Dark Souls 2 or Dark Souls 3)
  3. Attempt to use the global shortcut while the game is in fullscreen

Expected behavior

Global shortcuts should work in fullscreen games

Platform and versions

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 114.0.1823.58
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 16.13.0
    - npm: 9.7.2

[-] Packages
    - tauri [RUST]: 1.4.1
    - tauri-build [RUST]: 1.4.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.4.0
    - @tauri-apps/cli [NPM]: 1.4.0

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: ../dist
    - framework: Vue.js (Vue CLI)
    - bundler: Webpack

Stack trace

No response

Additional context

No response

FabianLars commented 1 year ago

but they did seem to play nicely with Tauri when the window was in focus.

(i assume there's a "not" missing in that sentence) - did you try playing around with this api? https://docs.rs/tauri/latest/tauri/struct.Builder.html#method.device_event_filter - iirc it was primarily introduced after rdev users complained about that very same issue.

StenniHub commented 1 year ago

but they did seem to play nicely with Tauri when the window was in focus.

(i assume there's a "not" missing in that sentence) - did you try playing around with this api? https://docs.rs/tauri/latest/tauri/struct.Builder.html#method.device_event_filter - iirc it was primarily introduced after rdev users complained about that very same issue.

Yes, that is what I meant to say. For example I tested with a crate called inputbot. Whenever the Tauri app is in focus it would not trigger the callback, while it works fine while not in focus as well as in the aforementioned games that do not work for the regular global shortcuts.

I attempted all the options for device event filter, but it made no difference unfortunately. Thanks for the tip though.