Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Mouse Position has stopped working #137

Open
Flatfingers opened this issue Jul 11, 2023 · 2 comments
Open

Set Mouse Position has stopped working #137

Flatfingers opened this issue Jul 11, 2023 · 2 comments

Comments

@Flatfingers
Copy link
Collaborator

The Lua call window:setMousePosition(x, y) previously placed the system mouse cursor at the center of the game window.

When starting the game now, the mouse cursor is no longer placed in the center of the game window.

Now it is placed near (but not exactly at) the Y center of the game window, and at either the far left or far right of the entire system window, rather than in the center of the game window based on dividing the game window's user.ini-provided X and Y values by 2.

window:setMousePosition() (which in /phx/src/system/window.rs calls SDL_WarpMouseInWindow(handle, x, y)) is called by /script/States/Application.lua:

    self.window:setWindowGrab(true)
    self.window:setMousePosition(self.resX / 2, self.resY / 2)
    self.window:setWindowGrab(false)

as well as by Application:update() when the game window is resized. This Lua code also no longer moves the mouse cursor to the X/Y center of the game window as it once did when the game window is resized.

Is it possible something in the engine changed related to mouse positioning? (Or maybe window:setWindowGrab()?) Setting the system mouse cursor to a new shape still seems to work, just not setting the system mouse position.

Note 1: The round cursor you see when flying the ship in flight mode gets its position from the yaw() and pitch() functions, not from any call to get the current mouse position. So it still works.

Note 2: Interestingly, clicking on buttons still works. Whatever is reading the mouse position when a click event occurs is getting the correct X, Y position within the game window, since we can see that when you click some button under the system mouse cursor, the correct button gets activated. It's just setting the mouse position programmatically that seems to have stopped working.

Note 3: There is one other different kind of call to set the mouse position, which is Input:SetMousePosition(x, y) as used in HUD.lua. This uses SDL_GetMouseState(&x, &y) (defined in /phx/src/input/mouse.rs) to set the mouse X and Y position within the current window. This may not be working, either. Input.GetMousePosition() returns an x and y value, but they are always both 0. Oddly, there is no window:getMousePosition() function defined in window.rs to go along with the window:setMousePosition() function.

@IllustrisJack
Copy link
Member

IllustrisJack commented Nov 24, 2023

you can now use InputInstance:setCursorPosition(x, y) or WindowInstance:setCursorPosition(Vec2f(x, y))

@IllustrisJack
Copy link
Member

note: ffi_ext/window & input are outdated now and should be removed or updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants