+
+ unsigned char buf[ABS_CNT/sizeof(unsigned char)/8];
+ // get axes maximums
+ if( ioctl( fd, EVIOCGBIT(EV_ABS,ABS_MAX), buf ) == -1 ) {
+ SG_LOG( SG_INPUT, SG_WARN, "Can't get abs-axes for " << devname );
+ } else {
+ for( unsigned i = 0; i < ABS_MAX; i++ ) {
+ if( bitSet( buf, i ) ) {
+ struct input_absinfo ai;
+ if( ioctl(fd, EVIOCGABS(i), &ai) == -1 ) {
+ SG_LOG( SG_INPUT, SG_WARN, "Can't get abs-axes maximums for " << devname );
+ continue;
+ }
+ absinfo[i] = ai;
+ }
+ }
+ }
+}
+
+double FGLinuxInputDevice::Normalize( struct input_event & event )
+{
+ if( absinfo.count(event.code) > 0 ) {
+ const struct input_absinfo & ai = absinfo[(unsigned int)event.code];
+ if( ai.maximum == ai.minimum )
+ return 0.0;
+ return ((double)event.value-(double)ai.minimum)/((double)ai.maximum-(double)ai.minimum);
+ } else {
+ return (double)event.value;
+ }