[AD] Should al_set_mouse_xy generate events?

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Prompted by a post by Trezker in the 3.9.8 thread on allegro.cc, I was
thinking a bit about al_set_mouse_xy. The problematic use case is a game
where you want to have infinite mouse movement.

X11 only reports absolute screen coordinates for the mouse, so if the
mouse reaches the screen edge, no movement info "against the screen
edge" can be reported. One trick to work around this is to warp the
mouse to the screen center from time to time. However, if you do:

al_set_mouse_xy(100, 100)

And the mouse was at (110, 100) before, this right now generates a
movement event with event.mouse.dx = -10. So the dx/dy fields can not be
used any longer as the events from al_set_mouse_xy will cancel out each
user movement. The two solutions I see are:

A) Add a field event.mouse.was_set to ALLEGRO_MOUSE_EVENT. If this field
is true, the movement came from al_set_mouse_xy and is not a real user
movement. Now dx/dy from only user events can be used in the game for
perfectly smooth movement.

B) Do not generate any mouse events for al_set_mouse_xy in the first
place. This also can prevent a "feedback loop" where a user does
something foolish like calling al_set_mouse_xy(event.mouse.x + 1, 0) in
response to each mouse movement event...

I have a very slight preference for B.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/