From bef94a71b19e92de5ff82b620fbac853bf83a15b Mon Sep 17 00:00:00 2001 From: "Diederick C. Niehorster" Date: Mon, 5 Jun 2017 20:50:44 +0200 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 --- freeglut/freeglut/progs/demos/multi-touch/multi-touch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/freeglut/freeglut/progs/demos/multi-touch/multi-touch.c b/freeglut/freeglut/progs/demos/multi-touch/multi-touch.c index e4fc596..37f5d79 100644 --- a/freeglut/freeglut/progs/demos/multi-touch/multi-touch.c +++ b/freeglut/freeglut/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;