From a57cda1b93a4dd8c8ffcc0df0b6930015c560555 Mon Sep 17 00:00:00 2001 From: Diederick Niehorster Date: Wed, 14 Jun 2017 20:51:20 +0000 Subject: [PATCH] multi-touch demo: if an index 64 would come in, this would be written in the wrong place in the cursor buffer. Supporting 64 IDs means writing to slots 0--63 (cherry picked from commit bef94a71b19e92de5ff82b620fbac853bf83a15b) git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1806 7f0cb862-5218-0410-a997-914c9d46530a --- progs/demos/multi-touch/multi-touch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/progs/demos/multi-touch/multi-touch.c b/progs/demos/multi-touch/multi-touch.c index e4fc596..37f5d79 100644 --- a/progs/demos/multi-touch/multi-touch.c +++ b/progs/demos/multi-touch/multi-touch.c @@ -109,8 +109,8 @@ void onMotion(int x, int y) { /* Using FG2.8 (reversed) prototype for now */ /* void onMultiButton(int cursor_id, int button, int state, int x, int y) { */ void onMultiButton(int cursor_id, int x, int y, int button, int state) { - if (cursor_id > NUM_CURSORS) { - fprintf(stderr, "cursor_id (%d) > NUM_CURSORS (%d)\n", cursor_id, NUM_CURSORS); + if (cursor_id >= NUM_CURSORS) { + fprintf(stderr, "cursor_id (%d) >= NUM_CURSORS (%d), out of slots\n", cursor_id, NUM_CURSORS); return; } if (button == 0) { @@ -122,8 +122,8 @@ void onMultiButton(int cursor_id, int x, int y, int button, int state) { } void onMultiMotion(int cursor_id, int x, int y) { - if (cursor_id > NUM_CURSORS) { - fprintf(stderr, "cursor_id (%d) > NUM_CURSORS (%d)\n", cursor_id, NUM_CURSORS); + if (cursor_id >= NUM_CURSORS) { + fprintf(stderr, "cursor_id (%d) >= NUM_CURSORS (%d), out of slots\n", cursor_id, NUM_CURSORS); return; } cursors[0][cursor_id].x = (float)x; -- 1.7.10.4