[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: patch for ocamlsdl bug: mouse button event mismatch



Le lundi 18 juin 2012 22:12:37, Florent Monnier a écrit :
> Hi,
> 
> In current ocamlsdl, if the user does a mouse left clic, ocamlsdl sends a
> right clic event. (right clic will send middle clic, etc...)
> 
> This is because ocamlsdl's stub doesn't uses the macros SDL_BUTTON_LEFT,
> but uses an integer value instead (probably a value from an older SDL
> version).
> 
> This patch can be applied for the current CVS or for the version 0.9.0.

This kind of code is weak. If the value of the macro changes again, your code 
will be broken again.

http://ocamlsdl.cvs.sourceforge.net/viewvc/ocamlsdl/OCamlSDL/src/sdlevent_stub.c?r1=1.25&r2=1.26

The header API of the lib provides macros like SDL_BUTTON_LEFT, you should use 
it, not its int value that may change in the future.
During the last month I've used 2 ocaml bindings where this case actually 
happened, bindings using the int value that had changed in the last version of 
the libs. So this is not only hypothetical, it really happens!

-- 


Reply to: