[Plib-devel] [patch] getting high-resolution uhid joysticks to work on (Free)BSD
Brought to you by:
sjbaker
From: Magnus R. <bm...@ri...> - 2008-06-02 14:45:29
|
Good morning/day/evening/easter dear plib developers, I had to make the below change to plib to get a joystick to work fully on FreeBSD. Well - removal of the comment is maybe cosmetic, but assuming that it pertains to getting the range of the stick from the HID, the rest of the change makes it no longer punted. If it applies to hat switches, it should be reinstated to hopefully give someone else a good itch. Joysticks: Saitek Pro Flight Yoke System Saitek Pro Rudder Pedals ---8<------8<--- diff -u -r plib-1.8.5/src/js/jsBSD.cxx plib-1.8.5-mine/src/js/jsBSD.cxx --- plib-1.8.5/src/js/jsBSD.cxx 2008-03-11 03:06:21.000000000 +0100 +++ plib-1.8.5-mine/src/js/jsBSD.cxx 2008-06-02 16:36:39.000000000 +0200 @@ -98,6 +98,8 @@ // on every read of a USB device int cache_buttons ; float cache_axes [ _JS_MAX_AXES ] ; + float axes_minimum [ _JS_MAX_AXES ] ; + float axes_maximum [ _JS_MAX_AXES ] ; }; // Idents lower than USB_IDENT_OFFSET are for analog joysticks. @@ -240,6 +242,8 @@ if (*num_axes < _JS_MAX_AXES) { os->axes_usage[*num_axes] = usage; + os->axes_minimum[*num_axes] = h.logical_minimum; + os->axes_maximum[*num_axes] = h.logical_maximum; (*num_axes)++; } break; @@ -365,9 +369,6 @@ for ( int i = 0 ; i < _JS_MAX_AXES ; i++ ) { - // We really should get this from the HID, but that data seems - // to be quite unreliable for analog-to-USB converters. Punt for - // now. if ( os->axes_usage [ i ] == HUG_HAT_SWITCH ) { max [ i ] = 1.0f ; @@ -376,9 +377,9 @@ } else { - max [ i ] = 255.0f ; - center [ i ] = 127.0f ; - min [ i ] = 0.0f ; + max [ i ] = os->axes_maximum [ i ]; + min [ i ] = os->axes_minimum [ i ]; + center [ i ] = (max [ i ] + min [ i ]) / 2; } dead_band [ i ] = 0.0f ; saturate [ i ] = 1.0f ; ---8<------8<--- Magnus |