FosterOld
FosterOld copied to clipboard
Add mouse motion support
- Added a new
Point2 Position
property toMouse
. - Added GLFW callback and SDL2 event handling to get mouse position.
Note that SDL2's mouse position is always as integers (but with float type), while GLFW provides double-precision floating point values. To make the framework platform agnostic, I chose to cast both to integers. This shouldn't be a problem since mouse positions don't really need to be floating points.
There currently is Mouse Support, but it's through the Window class. I agree it is confusing that the actual Mouse class has no implementation for mouse position ... A few options I could see working:
- Mouse.cs has Screen Mouse position, with comments describing how to get Window-specific mouse coordinates from the Window class
- Mouse.cs also somehow has a list of Mouse coordinates for each window? Not sure how this would work though.
How about Mouse.Position is basically a getter, which returns the mouse position for the window for which MouseOver is true. And similarly for MouseRender.
Maybe another variable could also expose the screen mouse position. For gamedev purposes, this is not as useful as the window mouse position though.
But honestly, maybe the best is to just add a comment that the mouse position is in App.Window. No need to add code when it's not needed. I just thought that mouse position isn't implemented, and didn't know to check Window. A few lines of comments in the right places would be enough and keep complexity down.