+ array[i] = min;
+ contains[min] = 1;
+ }
+
+ return 1;
+}
+
+
+void setAxismap(int fd, char* mapstr)
+{
+ __u8 map[ABS_CNT] = {-1};
+ int imap[ABS_CNT] = {-1};
+
+
+ const __u8 cnt = getNumberOfAxes(fd);
+ printf("Setting %d axes.\n", cnt);
+ assert( cnt <= ABS_CNT);
+
+
+ const unsigned readcnt = parseIntArray(imap, cnt, mapstr);
+ if( readcnt != cnt )
+ {
+ fprintf(stderr, "Invalid number of values given: %d\n", readcnt);
+ exit(EXIT_VALUE);
+ }
+
+ // Nothing to do
+ if( cnt<=0 )
+ return;
+
+ // Fill the remaining array such that we obtain a permutation
+ if( !fillPermutation(imap, cnt, ABS_CNT) )
+ {
+ fprintf(stderr, "Mapping needs to be a permutation.\n");
+ exit(EXIT_VALUE);
+ }
+
+ // Copy array and check bounds
+ for(unsigned i=0; i<ABS_CNT; ++i)
+ {
+ if( imap[i]<0 || imap[i]>=ABS_CNT )