diff options
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/state.c b/src/state.c index eff9c3e..e5ca1c1 100644 --- a/src/state.c +++ b/src/state.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #include "state.h" | 1 | #include "state.h" |
| 2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
| 3 | #include <limits.h> | ||
| 3 | 4 | ||
| 4 | /******************************************************/ | 5 | /******************************************************/ |
| 5 | 6 | ||
| @@ -75,6 +76,13 @@ void modify_state(struct State *s, | |||
| 75 | /* sort fingers in touching order */ | 76 | /* sort fingers in touching order */ |
| 76 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); | 77 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); |
| 77 | 78 | ||
| 79 | /* make sure wrap-around does not create very strange effects */ | ||
| 80 | if (s->lastid > INT_MAX / 2) { | ||
| 81 | s->lastid = 0; | ||
| 82 | for (j = 0; j < s->nfinger; j++) | ||
| 83 | s->finger[j].id = ++s->lastid; | ||
| 84 | } | ||
| 85 | |||
| 78 | /* copy buttons */ | 86 | /* copy buttons */ |
| 79 | for (i = 0; i < DIM_BUTTON; i++) | 87 | for (i = 0; i < DIM_BUTTON; i++) |
| 80 | s->button[i] = hw->button[i]; | 88 | s->button[i] = hw->button[i]; |
