Listing 17. Checking Global State by Axis

uint8_t abs_b[ABS_MAX/8 + 1];
struct input_absinfo abs_feat;

ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_b)), abs_b);

printf("Supported Absolute axes:\n");

for (yalv = 0; yalv < ABS_MAX; yalv++) {
    if (test_bit(yalv, abs_b)) {
        printf("  Absolute axis 0x%02x ", yalv);
        switch ( yalv)
            {
            case ABS_X :
                printf("(X Axis) ");
                break;
            case ABS_Y :
                printf("(Y Axis) ");
                break;
            default:
                printf("(Unknown abs feature)");
            }
        if(ioctl(fd, EVIOCGABS(yalv), &abs_feat)) {
            perror("evdev EVIOCGABS ioctl");
        }
        printf("%d (min:%d max:%d flat:%d fuzz:%d)",
               abs_feat.value,
               abs_feat.minimum,
               abs_feat.maximum,
               abs_feat.flat,
               abs_feat.fuzz);
   printf("\n");
    }
}