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

Mouse input not working #4

Open
HelmuthWcs opened this issue Apr 5, 2020 · 6 comments
Open

Mouse input not working #4

HelmuthWcs opened this issue Apr 5, 2020 · 6 comments

Comments

@HelmuthWcs
Copy link

I am trying to get mouse input to work like this in the update method as usual:

if (Mouse.GetState().LeftButton == ButtonState.Pressed)

This is just using the sample project and does not pick up any type of clicks.

@limbusdev
Copy link

Same is true for keyboard input.

@limbusdev
Copy link

limbusdev commented May 4, 2020

Mouse.PrimaryWindow is not set. That seems to be the case because the Game class is not used, where it is usually set.

@MegaChuck64
Copy link

Mouse.PrimaryWindow is not set. That seems to be the case because the Game class is not used, where it is usually set.

Have you found a solution? PrimaryWindow is an internal variable, so I cannot manually set it. Any work around?

@MegaChuck64
Copy link

Mouse.PrimaryWindow is not set. That seems to be the case because the Game class is not used, where it is usually set.

Have you found a solution? PrimaryWindow is an internal variable, so I cannot manually set it. Any work around?

Okay, I found a workaround. I just use the System.Windows.Input Keyboard and Mouse objects to handle input. Seems to work about the same. Although I'm trying to figure out a good solution for storing previous states.
Using the monogame input objects, you can get the state of every key being pressed and store it. You have to solve this issue your self. For mouse input, this isn't that bad because there's only three buttons, but for keyboard, I suppose you could loop through every value in the Keys enum. Or you could get fancy and only do it for certain keys; Something like mapping controls to certain keys and only checking those ones.

@mxmissile
Copy link

Working solution in this project for Mouse and Keyboard states:

https://github.com/MarcStan/monogame-framework-wpfinterop

@damian-666
Copy link

thta project handles iMG nput but for my level editor i stick wiht the windows input... i just want to draw the stuff...this one is simpler... its almost better to build an in game editor in some cases....i use an input manager and map key to gamepad like buttons .. issue is threading and polling as well in WPF...

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

5 participants