Mouse stuck in the middle of the overlay when toggled from a fps game #55
Description
Hey there! I have an issue that first occurred on my app once I tried to toggle input.intercept
manually and after some digging realized it was reproducible with the demo as well.
Basically if a fps game is focused and I call the overlay to make it appear, the mouse is stuck at the center of the screen as if the game still had focus.
I assume that's because fps games recenter the mouse to the center of the screen for their own purpose but I didn't find a way to switch the focus to the overlay or a browser window properly to prevent that from happening so after many days of trial and error this is my last stop before I attempt another approach for my application. This is the only thing that keeps me from reaching my goal unfortunately.
To reproduce the issue:
- Add global shortcuts to toggle the overlay
- Inject the overlay into a fps game (I mostly tested on "Lovely Planet" and "ULTRAKILL")
- Get into the game and shoot to make sure the window is focused
- Toggle the overlay and you'll notice the cursor is stuck in the middle of the screen
-- Here's a gif of what's happening --
Here's the code I added in app-entry.ts
to toggle the overlay:
// line 1
import {app, BrowserWindow, globalShortcut, ipcMain} from "electron"
...
...
// line 12
app.on("ready", () => {
globalShortcut.register("z", () => {
IOverlay.sendCommand({
command: "input.intercept",
intercept: true
})
})
globalShortcut.register("x", () => {
IOverlay.sendCommand({
command: "input.intercept",
intercept: false
})
})
})
Thank you in advance if you manage to find some time to help ❤️