Revisiting Mouse Input

BlitzMax Forums/BlitzMax Programming/Revisiting Mouse Input

Tom Darby(Posted 2005) [#1]
Hello all,

I know this has been discussed in the past, but it'd be really, really wonderful if we use the mouse as a proportional controller. It is trivial enough to hack together a rough mouse speed function using MoveMouse, but it can't give anything better than integer-level functionality. Thus, you're either going to lose fine mouse movement entirely (if you call MoveMouse each time you get the mouse speed) or end up with 'jerky' movement (if you only call MoveMouse once the mouse has actually moved.)

I'd heard it mentioned that using the freejoy module to get mouse input might be a possibility--does anybody have advice on how to use freejoy to get mouse input? Are there any plans to implement, say, something along the lines of MouseX#() and MouseY#()?

I've got a workaround that'll hold water for the time being, but I really don't want to be using it when release time comes...

TIA,
Tom


Robert(Posted 2005) [#2]
Hi Tom,

How would getting the mouse position with floating point accuracy help?

After all, it is almost physically impossible to move the mouse cursor by less than one pixel.

Could you explain how "using the mouse as a proportional controller" would work in the context of a game?


Tom Darby(Posted 2005) [#3]
Robert:

The mouse registers very fine, "pixel-independent" movement and returns this information to the system. The system then determines how many pixels to move the cursor based on this amount. I want to be able to capture this sub-pixel motion; a floating-point MouseX and MouseY function would do the trick.

Getting a mouse reading with floating point accuracy would allow me to tell if the mouse has been moved, say, 0.37 "pixels". For moving a cursor, this is a non-issue, but if you're usint the mouse to, say, aim a camera, or modify a floating-point velocity or if the user has their sensitivity turned way down you may actually want this level of granularity (as I do.) It really matters if you want to use the mouse in a manner other than as a pointing device--as a flight yoke, for example. If all you want is to know how much the mouse has moved, the fact that MouseX() and MouseY() are demarcated and bound by an arbitrary pixel width and screen size causes problems.

A floating-point mouse call would let you set up a trivial mouse speed function that calls MoveMouse every time it runs to keep the mouse coordinates at the center of the screen at all times. You can't really do this with the integer values, as you end up with jerky performance--not to mention the fact that you lose all mouse movement that isn't enough to move the pointer one pixel.

Basically, I just want to use the mouse as a simple input device, -not- as a pointing device. Getting freejoy to recognize the mouse would be sufficient to make this happen, as would being able to get raw mouse information or a floating-point pixel position.

Context of the game: The mouse will be used as a simple X-axis controller for a 2D ball-and-paddle game. While the mouse is the primary means of input, it isn't the only thing that will influence the paddle position--for example, there will be situations where I'll need to 'speed up' or 'slow down' the paddle's responsiveness, and there will be secondary keyboard controls for the mouse, all of which can and do result in funky control issues when dealing solely with MouseX, MouseY, and MoveMouse. In addition, I want to be able to 'lock' the mouse when playing in windowed mode--that is, while the game is playing, I don't want users to be able to mouse out of the game window. Without this, it's too easy to accidentally click outside the app during particularly frantic gaming sessions--a common and frustrating problem, for example, with Flash games.

I hope I'm making sense here...