Package: ocamlsdl
Version: 0.9.0-1
Severity: normal
Tags: patch

I noticed that in MOUSEBUTTONDOWN and MOUSEBUTTONUP events the wrong button
is reported. The problem is that SDL starts counting at 1 but the ocaml
type starts at 0. This further causes segfaults when trying to process a
wheel down event since that int is outside the range allowed for mbe_button.

Patch to correct the one-off error attached.

MfG
        Goswin

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=de_DE (charmap=ISO-8859-1)
Shell: /bin/sh linked to /bin/dash
Description: Fix value_of_mouse_button()
 SDL numbers buttons starting at 1 while the ocaml variant starts at 0.
 This causes the left button to be reported as middle, middle as right
 and so on. Wheeldown finaly returns an invalid value causing segfaults
 on use.
Author: Goswin von Brederlow <goswin-...@web.de>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Last-Update: 2013-07-13

---

--- ocamlsdl-0.9.0.orig/src/sdlevent_stub.c
+++ ocamlsdl-0.9.0/src/sdlevent_stub.c
@@ -114,10 +114,10 @@ static value value_of_mouse_button(Uint8
 {
   value r;
   if (SDL_BUTTON_LEFT <= b && b <= SDL_BUTTON_WHEELDOWN)
-    r = Val_int(b);
+    r = Val_int(b - 1);
   else {
     r = caml_alloc_small(1, 0);
-    Field(r, 0) = Val_int(b);
+    Field(r, 0) = Val_int(b - 1);
   }
   return r;
 }

Reply via email to