From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Jun 2 11:30:22 2003 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 54CEC37B437 for ; Mon, 2 Jun 2003 11:30:22 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 05DFF43FE9 for ; Mon, 2 Jun 2003 11:30:20 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h52IUJUp086562 for ; Mon, 2 Jun 2003 11:30:19 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h52IUJSH086561; Mon, 2 Jun 2003 11:30:19 -0700 (PDT) Resent-Date: Mon, 2 Jun 2003 11:30:19 -0700 (PDT) Resent-Message-Id: <200306021830.h52IUJSH086561@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, Tony Voet <20030602@hoegisan.com> Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A38637B405 for ; Mon, 2 Jun 2003 11:29:14 -0700 (PDT) Received: from imaging.ugent.be (imaging.ugent.be [157.193.133.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id E1DC543F3F for ; Mon, 2 Jun 2003 11:29:12 -0700 (PDT) (envelope-from tv@imaging.ugent.be) Received: (from tv@localhost) by imaging.ugent.be (8.11.6/8.11.6) id h52IT8h61121; Mon, 2 Jun 2003 20:29:08 +0200 (CEST) (envelope-from tv) Message-Id: <200306021829.h52IT8h61121@imaging.ugent.be> Date: Mon, 2 Jun 2003 20:29:08 +0200 (CEST) From: Tony Voet <20030602@hoegisan.com> To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/52875: devel/sdl12 - patch to support gameport joysticks X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jun 2003 18:30:22 -0000 >Number: 52875 >Category: ports >Synopsis: devel/sdl12 - patch to support gameport joysticks >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 02 11:30:19 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Tony Voet >Release: >Organization: >Environment: >Description: Port devel/sdl12 doesn't support /dev/joy? style gameport joysticks. >How-To-Repeat: >Fix: Buzzword compliant patch featuring noise reduction and auto calibration: --- src/joystick/bsd/SDL_sysjoystick.c.orig Sun Jun 1 18:42:04 2003 +++ src/joystick/bsd/SDL_sysjoystick.c Sun Jun 1 21:57:24 2003 @@ -55,6 +55,7 @@ #ifdef __FreeBSD__ #include +#include #endif #include "SDL_error.h" @@ -196,7 +197,18 @@ joy->hwdata = hw; hw->fd = fd; hw->path = strdup(path); - hw->type = BSDJOY_UHID; + if (! strncmp(path, "/dev/joy", 8)) + { + hw->type = BSDJOY_JOY; + joy->naxes = 2; + joy->nbuttons = 2; + joy->nhats = 0; + joy->nballs = 0; + joydevnames[joy->index] = strdup("Gameport joystick"); + goto usbend; + } + else + hw->type = BSDJOY_UHID; hw->repdesc = hid_get_report_desc(fd); if (hw->repdesc == NULL) { SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, @@ -280,6 +292,7 @@ } hid_end_parse(hdata); +usbend: /* The poll blocks the event thread. */ fcntl(fd, F_SETFL, O_NONBLOCK); @@ -299,6 +312,55 @@ struct report *rep; int nbutton, naxe = -1; Sint32 v; + struct joystick gameport; + static int x, y, xmin=0xffff, ymin=0xffff, xmax=0, ymax=0; + + if (!strncmp(joy->hwdata->path, "/dev/joy", 8)) { + if (read(joy->hwdata->fd, &gameport, sizeof(gameport)) != sizeof(gameport)) { + return; + } + if (abs(x - gameport.x) > 8) { + x = gameport.x; + if (x < xmin) { + xmin = x; + } + if (x > xmax) { + xmax = x; + } + if (xmin == xmax) { + xmin--; + xmax++; + } + v = (Sint32)x; + v -= (xmax + xmin + 1)/2; + v *= 32768/((xmax - xmin + 1)/2); + SDL_PrivateJoystickAxis(joy, 0, v); + } + if (abs(y - gameport.y) > 8) { + y = gameport.y; + if (y < ymin) { + ymin = y; + } + if (y > ymax) { + ymax = y; + } + if (ymin == ymax) { + ymin--; + ymax++; + } + v = (Sint32)y; + v -= (ymax + ymin + 1)/2; + v *= 32768/((ymax - ymin + 1)/2); + SDL_PrivateJoystickAxis(joy, 1, v); + } + if (gameport.b1 != joy->buttons[0]) { + SDL_PrivateJoystickButton(joy, 0, gameport.b1); + } + if (gameport.b2 != joy->buttons[1]) { + SDL_PrivateJoystickButton(joy, 1, gameport.b2); + } + return; + } rep = &joy->hwdata->inreport; @@ -375,8 +437,10 @@ void SDL_SYS_JoystickClose(SDL_Joystick *joy) { - report_free(&joy->hwdata->inreport); - hid_dispose_report_desc(joy->hwdata->repdesc); + if (strncmp(joy->hwdata->path, "/dev/joy", 8)) { + report_free(&joy->hwdata->inreport); + hid_dispose_report_desc(joy->hwdata->repdesc); + } close(joy->hwdata->fd); free(joy->hwdata->path); free(joy->hwdata); >Release-Note: >Audit-Trail: >Unformatted: