From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Apr 26 06:20:00 2014 Return-Path: Delivered-To: freebsd-ports-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D1F9C46B for ; Sat, 26 Apr 2014 06:20:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id ADBF61834 for ; Sat, 26 Apr 2014 06:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s3Q6K0xP097390 for ; Sat, 26 Apr 2014 06:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s3Q6K02o097389; Sat, 26 Apr 2014 06:20:00 GMT (envelope-from gnats) Resent-Date: Sat, 26 Apr 2014 06:20:00 GMT Resent-Message-Id: <201404260620.s3Q6K02o097389@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Thomas Russo Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7F61E43D for ; Sat, 26 Apr 2014 06:11:38 +0000 (UTC) Received: from cgiserv.freebsd.org (cgiserv.freebsd.org [IPv6:2001:1900:2254:206a::50:4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6AFBB1815 for ; Sat, 26 Apr 2014 06:11:38 +0000 (UTC) Received: from cgiserv.freebsd.org ([127.0.1.6]) by cgiserv.freebsd.org (8.14.8/8.14.8) with ESMTP id s3Q6BcAD059140 for ; Sat, 26 Apr 2014 06:11:38 GMT (envelope-from nobody@cgiserv.freebsd.org) Received: (from nobody@localhost) by cgiserv.freebsd.org (8.14.8/8.14.8/Submit) id s3Q6Bcoj059131; Sat, 26 Apr 2014 06:11:38 GMT (envelope-from nobody) Message-Id: <201404260611.s3Q6Bcoj059131@cgiserv.freebsd.org> Date: Sat, 26 Apr 2014 06:11:38 GMT From: Thomas Russo To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: ports/189006: x11-toolkits/plib improperly handles USB joystick min/max/center, and ignores "dial" axes X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Apr 2014 06:20:01 -0000 >Number: 189006 >Category: ports >Synopsis: x11-toolkits/plib improperly handles USB joystick min/max/center, and ignores "dial" axes >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 26 06:20:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Thomas Russo >Release: 9.2-STABLE >Organization: >Environment: FreeBSD bogodyn.org 9.2-STABLE FreeBSD 9.2-STABLE #0 r261812: Wed Feb 12 17:21:14 MST 2014 russo@bogodyn.org:/usr/obj/usr/src/sys/BOGODYN i386 >Description: plib upstream has not produced a release tarball since 2006, and in the release version the min/max/center values of USB uhid joysticks is hard coded as 0/255/127. This is clearly wrong for many joysticks on the market today. In 2008 someone submitted a patch to the PLIB developers and it was put into their sourceforge repository, but no release was created after that. Thus, the plib in the FreeBSD ports collection still has the hard-coded min/max/center. Further, the jsBSD.cxx file switch statement that detects various axis types doesn't recognize "Dial" type axes. Joysticks such as the Saitek X45 have such dials, which get ignored by plib. The result is that UHID devices that have min/max values other than 0/255 fail to perform correctly in games such as flightgear --- they will either not have the full range of values showing up, will not center properly, or will otherwise produce weird, uncalibrated input to the game. >How-To-Repeat: Install Flightgear. Plug a USB joystick device such as the Saitek X45 Flight Controller or the Saitek Pro Flight Rudder Pedals into a BSD machine, and run the "js_demo" program. For the X45, only 6 of the 7 axes will show up. Few of the axes will show their full range -1 to 1. This is because most of the axes don't have logical min/max of 0/255: Input rid=0 size=12 count=1 page=Generic_Desktop usage=X, logical range 52..264 Input rid=0 size=12 count=1 page=Generic_Desktop usage=Y, logical range 22..232 Input rid=0 size=8 count=1 page=Generic_Desktop usage=Slider, logical range 96..246 Input rid=0 size=8 count=1 page=Generic_Desktop usage=Rz, logical range 91..253 Input rid=0 size=8 count=1 page=Generic_Desktop usage=Dial, logical range 1..163 Input rid=0 size=8 count=1 page=Generic_Desktop usage=Rx, logical range 4..172 Input rid=0 size=4 count=1 page=Generic_Desktop usage=Hat_Switch, logical range 1..8, physical range 0..315, unit=0x14 exp=0 For the Pro Flight Rudder Pedals, the logical range is 0 to 511, and so 0-255 (left rudder) are mapped to -1 to +1, and 256-511 (right rudder)are treated as "saturated", always showing up as +1 >Fix: The attached patch completely fixes the problem for me. It is a combination of the 2008 patch that fixes the min/max/center issue, and an addition of HUG_DIAL to the recognized axis types. Patch attached with submission follows: --- src/js/jsBSD.cxx_orig 2014-04-25 23:37:11.000000000 -0600 +++ src/js/jsBSD.cxx 2014-04-25 23:38:54.000000000 -0600 @@ -99,6 +99,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. @@ -196,9 +198,12 @@ case HUG_Z: case HUG_RZ: case HUG_SLIDER: + case HUG_DIAL: 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; @@ -324,9 +329,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 ; @@ -335,9 +337,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.0 ; } dead_band [ i ] = 0.0f ; saturate [ i ] = 1.0f ; >Release-Note: >Audit-Trail: >Unformatted: