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

Allow setting the mouse cursor position #584

Open
sitaktif opened this issue Mar 1, 2020 · 9 comments
Open

Allow setting the mouse cursor position #584

sitaktif opened this issue Mar 1, 2020 · 9 comments
Labels
enhance-feature Create a new user-facing feature

Comments

@sitaktif
Copy link

sitaktif commented Mar 1, 2020

It would be great to be able to move the mouse cursor position to a specific location.

I imagine doing it with something like window.mouse().set_position(pos: Vector).

@lenscas
Copy link
Contributor

lenscas commented Mar 1, 2020

Setting the cursor position isn't possible on the web.

https://stackoverflow.com/questions/4752501/move-the-mouse-pointer-to-a-specific-position

@ryanisaacg
Copy link
Owner

Seconding @lenscas, unfortunately moving the mouse cursor isn't supported on web. I'm hesitant to add a method only supported on desktop.

@ryanisaacg ryanisaacg added the enhance-feature Create a new user-facing feature label Mar 2, 2020
@lenscas
Copy link
Contributor

lenscas commented Mar 2, 2020

if it gets added, please only expose it for native builds, and/or add it behind a module that makes it painfully clear that it is native only.

In my opinion, the fewer run time differences between native and WASM the better.

@sitaktif
Copy link
Author

sitaktif commented Mar 2, 2020

Following @lenscas' link, this answer seems to provide a way to do it: https://stackoverflow.com/a/19870963/551779 - it seems that one could lock the mouse and let the app control an internal cursor using mouse position deltas, in which case it's up to the framework to decide where the (internal) pointer is.

It would probably mean changing the current web implementation of the mouse handling though.

(Also, I should have probably shared my use-case: I'd like to keep the mouse within the bounds of the window when not playing in fullscreen mode.)

@lenscas
Copy link
Contributor

lenscas commented Mar 2, 2020

(Also, I should have probably shared my use-case: I'd like to keep the mouse within the bounds of the window when not playing in fullscreen mode.)

As an user: please don't. If I am not playing in full screen mode, it probably is because I want to quickly use other things as well/have the game behave like normal programs for other reasons.

Personally, I dislike the workaround as I think it would degrade the user experience that quicksilver games will have if it got implemented

  • Binary bloat: About 35 images are needed to fully implemented it (one for every mouse state)
  • cursor look is always overwritten.
  • platform specific functionality a cursor may have gets disabled

If you however think that this feature is really needed for your game, you should actually already be able to implement the workaround without having to change anything in quicksilver. Though, libraries that get the mouse cursor location themselves may not work correctly.

@ryanisaacg
Copy link
Owner

@lenscas, I'm a little lost.

  • Binary bloat: About 35 images are needed to fully implemented it (one for every mouse state)
  • cursor look is always overwritten.
  • platform specific functionality a cursor may have gets disabled

What is this referring to?

@sitaktif Just a heads up, all of the input / windowing / cursor handling is upstream in winit. Setting a cursor position isn't possible on web, but you could implement cursor grab (see the docs for an overview on the platform-specific quirks.) If cursor grab worked in a consistent way between desktop and web, I would be open to supporting in Quicksilver.

@lenscas
Copy link
Contributor

lenscas commented Mar 2, 2020

@lenscas, I'm a little lost.

  • Binary bloat: About 35 images are needed to fully implemented it (one for every mouse state)
  • cursor look is always overwritten.
  • platform specific functionality a cursor may have gets disabled

that is what the result would be if quicksilver would implement the workaround given in the stackoverflow answers (unless I am missing something). The workaround is to hide the cursor and replace it with an image that is at the location you want the cursor to be.

@ryanisaacg
Copy link
Owner

I would probably not emulate the cursor states, but only allow cursor grab when the cursor is set to not draw. Then the application can draw its custom cursor or not draw one.

@sitaktif
Copy link
Author

sitaktif commented Mar 6, 2020

(Also, I should have probably shared my use-case: I'd like to keep the mouse within the bounds of the window when not playing in fullscreen mode.)

As an user: please don't. If I am not playing in full screen mode, it probably is because I want to quickly use other things as well/have the game behave like normal programs for other reasons.

@lenscas I hear you but for some games, allowing the cursor to leave the window may provide a bad experience (just one example: if the main "character" follows the cursor constantly as a fundamental mechanic). These users may want to play in windowed mode and still have a good game experience, at the expense of needing to press <esc> to do other tasks. Also, if the mechanics of a game involve dodging foes all the time it doesn't make sense to do something else at the same time without pausing first.

@ryanisaacg thanks for the pointers! I'll have a look at winit and see how audacious that would be given my very basic skillset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhance-feature Create a new user-facing feature
Projects
None yet
Development

No branches or pull requests

3 participants