FosterOld icon indicating copy to clipboard operation
FosterOld copied to clipboard

Add mouse motion support

Open sherjilozair opened this issue 4 years ago • 2 comments

  • Added a new Point2 Position property to Mouse.
  • 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.

sherjilozair avatar May 23 '20 14:05 sherjilozair

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.

NoelFB avatar May 23 '20 23:05 NoelFB

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.

sherjilozair avatar May 24 '20 19:05 sherjilozair