Re: [AD] Should al_set_mouse_xy generate events?

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


As I'm currently using this function for infinite movement. I have an
inside perspective.
I think that when you use the function you should get a mouse axes
event just like you had moved the mouse there.
In my program I just ignore that event by checking if the event I got
is pointing to the coordinates I set.

People may want to use that mouse axes event, I think it's unnecesary
to do anything special. Possibly you may add a flag in the event.

On Sat, Feb 28, 2009 at 6:42 PM, Evert Glebbeek <eglebbk@xxxxxxxxxx> wrote:
> On 28 feb 2009, at 09:17, Elias Pschernig wrote:
>> 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.
>
> I prefer C:
> C) If the mouse position was changed by al_set_mouse_xy, send
> ALLEGRO_EVENT_MOUSE_WARPED instead of ALLEGRO_EVENT_MOUSE_AXES. The
> structure is set exactly the same as for ALLEGRO_EVENT_MOUSE_AXES.
>
> This avoids the hacky nature of adding an extra field to the struct of
> the first solution and it includes the second solution implicitly by
> allowing the user to ignore ALLEGRO_EVENT_MOUSE_WARPED events. If you
> want to catch both, you simply do
>
> case ALLEGRO_EVENT_MOUSE_AXES:
> case ALLEGRO_EVENT_MOUSE_WARPED:
>    do_stuff();
>
> I think it's the most elegant solution to the problem (but then, I
> thought of it).
> It's not stupid user proof in the sense of
> "al_set_mouse_xy(event.mouse.x + 1, 0)", but can we trust to people to
> not be that stupid (or at least tell them not to be)? ;)
>
> Evert
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
>




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