craftworkgames / MonoGame.WpfCore

MonoGame embedded inside a WPF app.
MIT License
71 stars 13 forks source link

Mouse input not working #4

Open HelmuthWcs opened 4 years ago

HelmuthWcs commented 4 years ago

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 commented 4 years ago

Same is true for keyboard input.

limbusdev commented 4 years ago

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

MegaChuck64 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Working solution in this project for Mouse and Keyboard states:

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

damian-666 commented 2 years ago

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...