diff options
author | nsayer <nsayer@FreeBSD.org> | 2001-04-21 14:28:31 +0800 |
---|---|---|
committer | nsayer <nsayer@FreeBSD.org> | 2001-04-21 14:28:31 +0800 |
commit | 637920c9ed4b747cb211aecaaff203152436c280 (patch) | |
tree | 6326779083d9046002e7b1d68d9ab2cab85f1d05 | |
parent | a6a931c449fe20a2671172afb4c345a48ac5200c (diff) | |
download | freebsd-ports-graphics-637920c9ed4b747cb211aecaaff203152436c280.tar.gz freebsd-ports-graphics-637920c9ed4b747cb211aecaaff203152436c280.tar.zst freebsd-ports-graphics-637920c9ed4b747cb211aecaaff203152436c280.zip |
Update to 1.7e2. Add USB Joystick support.
-rw-r--r-- | games/bzflag/Makefile | 9 | ||||
-rw-r--r-- | games/bzflag/distinfo | 2 | ||||
-rw-r--r-- | games/bzflag/files/config-sys | 5 | ||||
-rw-r--r-- | games/bzflag/files/patch-aa | 213 | ||||
-rw-r--r-- | games/bzflag/files/patch-usbstick | 363 |
5 files changed, 371 insertions, 221 deletions
diff --git a/games/bzflag/Makefile b/games/bzflag/Makefile index 730fdf1af3f..1bbfa3bddc3 100644 --- a/games/bzflag/Makefile +++ b/games/bzflag/Makefile @@ -6,17 +6,16 @@ # PORTNAME= bzflag -PORTVERSION= 1.7e.1 -PORTREVISION= 1 +PORTVERSION= 1.7e.2 CATEGORIES= games MASTER_SITES= ${MASTER_SITE_SOURCEFORGE} MASTER_SITE_SUBDIR= bzflag -DISTNAME= ${PORTNAME}_1.7e1 -EXTRACT_SUFX= .tar.gz +DISTNAME= ${PORTNAME}-1.7e2 +EXTRACT_SUFX= .tgz MAINTAINER= nsayer@FreeBSD.org -WRKSRC= ${WRKDIR}/bzflag +WRKSRC= ${WRKDIR}/${DISTNAME} USE_XLIB= yes USE_MESA= yes diff --git a/games/bzflag/distinfo b/games/bzflag/distinfo index f0650e728a6..2cb10de8a7c 100644 --- a/games/bzflag/distinfo +++ b/games/bzflag/distinfo @@ -1 +1 @@ -MD5 (bzflag_1.7e1.tar.gz) = 5e136af2423f6d2ca9108099e10d565f +MD5 (bzflag-1.7e2.tgz) = ba1d37a175369dcede18a2da9d362cba diff --git a/games/bzflag/files/config-sys b/games/bzflag/files/config-sys index acfee53f540..f006323ea27 100644 --- a/games/bzflag/files/config-sys +++ b/games/bzflag/files/config-sys @@ -52,8 +52,8 @@ PCXXDEFS = $(XF86VIDMODE_DEF) # PCOPTS = -Wall -W -ansi $(ACOPTS) PCXXOPTS = -Wall -W -fno-exceptions -fno-rtti $(ACXXOPTS) -COPT = -DNDEBUG ${PORTCFLAGS} -CXXOPT = -DNDEBUG ${PORTCXXFLAGS} -ffast-math -fomit-frame-pointer \ +COPT = -DNDEBUG ${PORTCFLAGS} -DUSBJOYSTICK +CXXOPT = -DNDEBUG ${PORTCXXFLAGS} -DUSBJOYSTICK -ffast-math -fomit-frame-pointer \ -fnonnull-objects -fexpensive-optimizations CDEBUG = -DDEBUG -g CXXDEBUG = -DDEBUG -g @@ -98,6 +98,7 @@ NETWORK_LIBS = \ $(NULL) WINDOW_LIBS = \ + -lusb \ -lXext \ -lX11 \ $(NULL) diff --git a/games/bzflag/files/patch-aa b/games/bzflag/files/patch-aa deleted file mode 100644 index 6772b47fcdc..00000000000 --- a/games/bzflag/files/patch-aa +++ /dev/null @@ -1,213 +0,0 @@ -Index: include/common.h -=================================================================== -RCS file: /cvsroot/bzflag/bzflag/include/common.h,v -retrieving revision 1.6 -diff -u -r1.6 common.h ---- include/common.h 2001/03/09 02:38:24 1.6 -+++ include/common.h 2001/03/28 01:12:02 -@@ -17,6 +17,11 @@ - #ifndef BZF_COMMON_H - #define BZF_COMMON_H - -+// Might we be BSDish? sys/param.h has BSD defined if so -+#if (defined(__unix__) || defined(unix)) && !defined(USG) -+#include <sys/param.h> -+#endif -+ - #if defined(_WIN32) - // turn off bogus `this used in base member initialization list' - #pragma warning(disable: 4355) -@@ -77,7 +82,7 @@ - - #if !defined(_WIN32) & !defined(macintosh) - --#ifndef __FreeBSD__ -+#ifndef BSD - #include <values.h> - #endif - #include <sys/types.h> -Index: src/net/multicast.cxx -=================================================================== -RCS file: /cvsroot/bzflag/bzflag/src/net/multicast.cxx,v -retrieving revision 1.6 -diff -u -r1.6 multicast.cxx ---- src/net/multicast.cxx 2001/03/09 02:38:24 1.6 -+++ src/net/multicast.cxx 2001/03/28 01:12:02 -@@ -21,10 +21,8 @@ - { - #if defined(_WIN32) - const BOOL optOn = TRUE; -- BOOL opt = optOn; - #else - const int optOn = 1; -- int opt = optOn; - #endif - int fd; - -@@ -67,18 +65,16 @@ - - #if defined(SO_REUSEPORT) - /* set reuse port */ -- opt = optOn; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, -- (SSOType)&opt, sizeof(opt)) < 0) { -+ (SSOType)&optOn, sizeof(optOn)) < 0) { - nerror("openBroadcast: setsockopt SO_REUSEPORT"); - close(fd); - return -1; - } - #elif defined(SO_REUSEADDR) - /* set reuse address */ -- opt = optOn; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, -- (SSOType)&opt, sizeof(opt)) < 0) { -+ (SSOType)&optOn, sizeof(optOn)) < 0) { - nerror("openBroadcast: setsockopt SO_REUSEADDR"); - close(fd); - return -1; -@@ -93,9 +89,8 @@ - } - - /* make broadcast */ -- opt = optOn; - if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, -- (SSOType)&opt, sizeof(opt)) < 0) { -+ (SSOType)&optOn, sizeof(optOn)) < 0) { - nerror("openBroadcast: setsockopt SO_BROADCAST"); - close(fd); - return -1; -@@ -174,6 +169,11 @@ - struct ip_mreq mreq; - struct in_addr ifaddr; - int fd; -+#if defined(_WIN32) -+ const BOOL optOn = TRUE; -+#else -+ const int optOn = 1; -+#endif - - /* check parameters */ - if (!addr) { -@@ -322,9 +322,8 @@ - else { - #if defined(SO_REUSEPORT) - /* set reuse port */ -- int opt = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, -- (SSOType)&opt, sizeof(opt)) < 0) { -+ (SSOType)&optOn, sizeof(optOn)) < 0) { - nerror("WARNING: openMulticast: setsockopt SO_REUSEPORT"); - close(fd); - return -1; -@@ -332,13 +331,8 @@ - #endif - #if defined(SO_REUSEADDR) - /* set reuse address */ --#if defined(_WIN32) -- BOOL opt = TRUE; --#else -- int opt = 1; --#endif - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, -- (SSOType)&opt, sizeof(opt)) < 0) { -+ (SSOType)&optOn, sizeof(optOn)) < 0) { - nerror("WARNING: openMulticast: setsockopt SO_REUSEADDR"); - close(fd); - return -1; -Index: src/platform/LinuxDisplay.h -=================================================================== -RCS file: /cvsroot/bzflag/bzflag/src/platform/LinuxDisplay.h,v -retrieving revision 1.4 -diff -u -r1.4 LinuxDisplay.h ---- src/platform/LinuxDisplay.h 2001/02/02 09:14:10 1.4 -+++ src/platform/LinuxDisplay.h 2001/03/28 01:12:02 -@@ -18,7 +18,7 @@ - #define BZF_LINUXDISPLAY_H - - #include "XDisplay.h" --#if defined(__linux__) && defined(XF86VIDMODE_EXT) -+#if defined(XF86VIDMODE_EXT) - #define USE_XF86VIDMODE_EXT - #define private c_private - #include <X11/extensions/xf86vmode.h> -Index: src/platform/LinuxMedia.cxx -=================================================================== -RCS file: /cvsroot/bzflag/bzflag/src/platform/LinuxMedia.cxx,v -retrieving revision 1.8 -diff -u -r1.8 LinuxMedia.cxx ---- src/platform/LinuxMedia.cxx 2001/03/02 08:02:49 1.8 -+++ src/platform/LinuxMedia.cxx 2001/03/28 01:12:02 -@@ -13,7 +13,7 @@ - #include "LinuxMedia.h" - #include <math.h> - #include <fcntl.h> --#ifdef __FreeBSD__ -+#ifdef BSD - #include <machine/endian.h> - #else - #include <endian.h> -Index: src/platform/XWindow.cxx -=================================================================== -RCS file: /cvsroot/bzflag/bzflag/src/platform/XWindow.cxx,v -retrieving revision 1.8 -diff -u -r1.8 XWindow.cxx ---- src/platform/XWindow.cxx 2001/03/06 22:07:42 1.8 -+++ src/platform/XWindow.cxx 2001/03/28 01:12:02 -@@ -13,7 +13,7 @@ - #include "XWindow.h" - #include "XVisual.h" - #include "OpenGLGState.h" --#if defined(__linux__) && defined(XF86VIDMODE_EXT) -+#if defined(XF86VIDMODE_EXT) - # define USE_XF86VIDMODE_EXT - # define private c_private - # include <X11/extensions/xf86vmode.h> -@@ -362,6 +362,23 @@ - xsh.base_height = getDisplay()->getHeight(); - xsh.flags |= USPosition | PPosition | PBaseSize; - -+#if defined(USE_XF86VIDMODE_EXT) -+ { -+ int eventbase, errorbase; -+ // Check if we have the XF86 vidmode extension, for virtual roots -+ if (XF86VidModeQueryExtension(display->getDisplay(), &eventbase, &errorbase)) { -+ int dotclock; -+ XF86VidModeModeLine modeline; -+ -+ XF86VidModeGetModeLine(display->getDisplay(), display->getScreen(), &dotclock, &modeline); -+ xsh.base_width=modeline.hdisplay; -+ xsh.base_height=modeline.vdisplay; -+ if (modeline.c_private) -+ XFree(modeline.c_private); -+ } -+ } -+#endif -+// this might want to be used on non-linux too? - #ifdef __linux__ - { - char *env; -@@ -371,23 +388,6 @@ - xsh.base_width=getDisplay()->getPassthroughWidth(); - xsh.base_height=getDisplay()->getPassthroughHeight(); - } --#if defined(USE_XF86VIDMODE_EXT) -- else { -- int eventbase, errorbase; -- // Check if we have the XF86 vidmode extension, for virtual roots -- if (XF86VidModeQueryExtension(display->getDisplay(), &eventbase, -- &errorbase)) { -- int dotclock; -- XF86VidModeModeLine modeline; -- -- XF86VidModeGetModeLine(display->getDisplay(), display->getScreen(), -- &dotclock, &modeline); -- xsh.base_width=modeline.hdisplay; -- xsh.base_height=modeline.vdisplay; -- if (modeline.c_private) XFree(modeline.c_private); -- } -- } --#endif - } - #endif - - diff --git a/games/bzflag/files/patch-usbstick b/games/bzflag/files/patch-usbstick new file mode 100644 index 00000000000..33f69a62493 --- /dev/null +++ b/games/bzflag/files/patch-usbstick @@ -0,0 +1,363 @@ +? src/platform/usbjoy.cxx +Index: include/BzfWindow.h +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/include/BzfWindow.h,v +retrieving revision 1.5 +diff -u -r1.5 BzfWindow.h +--- include/BzfWindow.h 2001/03/04 16:35:56 1.5 ++++ include/BzfWindow.h 2001/04/08 17:08:32 +@@ -67,6 +67,7 @@ + virtual void initJoystick(const char* joystickName); + virtual boolean joystick() const { return False; } + virtual void getJoy(int& x, int& y) const { x = 0; y = 0; } ++ virtual unsigned long getJoyButtons() const { return 0; } + + void callExposeCallbacks() const; + void addExposeCallback(void (*cb)(void*), void* data); +Index: src/bzflag/MainWindow.cxx +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/src/bzflag/MainWindow.cxx,v +retrieving revision 1.6 +diff -u -r1.6 MainWindow.cxx +--- src/bzflag/MainWindow.cxx 2001/04/03 02:38:13 1.6 ++++ src/bzflag/MainWindow.cxx 2001/04/08 17:08:33 +@@ -241,3 +241,8 @@ + my = ((viewHeight >> 1)*my)/(900); + } + ++unsigned long MainWindow::getJoyButtonSet() const ++{ ++ return window->getJoyButtons(); ++} ++ +Index: src/bzflag/MainWindow.h +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/src/bzflag/MainWindow.h,v +retrieving revision 1.6 +diff -u -r1.6 MainWindow.h +--- src/bzflag/MainWindow.h 2001/03/04 16:35:56 1.6 ++++ src/bzflag/MainWindow.h 2001/04/08 17:08:33 +@@ -76,6 +76,8 @@ + // for these values that we need every frame. + void getMousePosition(int& mx, int& my) const; + void getJoyPosition(int& mx, int& my) const; ++ unsigned long getJoyButtonSet() const; ++ + + private: + // no copying +Index: src/bzflag/playing.cxx +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/src/bzflag/playing.cxx,v +retrieving revision 1.31 +diff -u -r1.31 playing.cxx +--- src/bzflag/playing.cxx 2001/04/03 02:38:13 1.31 ++++ src/bzflag/playing.cxx 2001/04/08 17:08:36 +@@ -401,6 +401,8 @@ + static float roamZoom = 60.0f, roamDZoom; + #endif + ++static void doKeyPlaying(const BzfKeyEvent& key, boolean pressed); ++ + static void doMotion() + { + #if defined(FREEZING) +@@ -409,9 +411,36 @@ + + // get mouse position + int mx, my; +- if (mainWindow->joystick()) ++ if (mainWindow->joystick()) { + mainWindow->getJoyPosition(mx, my); +- else ++ ++ static const BzfKeyEvent::Button button_map[] = { BzfKeyEvent::LeftMouse, ++ BzfKeyEvent::MiddleMouse, ++ BzfKeyEvent::RightMouse, ++ BzfKeyEvent::F1, ++ BzfKeyEvent::F2, ++ BzfKeyEvent::F3, ++ BzfKeyEvent::F4, ++ BzfKeyEvent::F5, ++ BzfKeyEvent::F6, ++ BzfKeyEvent::F7, ++ BzfKeyEvent::F8, ++ BzfKeyEvent::F9 ++ }; ++ ++ static unsigned long old_buttons = 0; ++ unsigned long new_buttons = mainWindow->getJoyButtonSet(); ++ if (old_buttons != new_buttons) ++ for (int j = 0; j<12; j++) ++ if ((old_buttons & (1<<j)) != (new_buttons & (1<<j))) { ++ BzfKeyEvent ev; ++ ev.button = button_map[j]; ++ ev.ascii = 0; ++ ev.shift = 0; ++ doKeyPlaying(ev, new_buttons&(1<<j)); ++ } ++ old_buttons = new_buttons; ++ } else + mainWindow->getMousePosition(mx, my); + + // calculate desired rotation +Index: src/platform/Make-linux +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/src/platform/Make-linux,v +retrieving revision 1.4 +diff -u -r1.4 Make-linux +--- src/platform/Make-linux 2001/02/02 09:14:10 1.4 ++++ src/platform/Make-linux 2001/04/08 17:08:36 +@@ -16,5 +16,6 @@ + XWindow.cxx \ + LinuxDisplay.cxx \ + LinuxMedia.cxx \ ++ usbjoy.cxx \ + $(NULL) + +Index: src/platform/XWindow.h +=================================================================== +RCS file: /cvsroot/bzflag/bzflag/src/platform/XWindow.h,v +retrieving revision 1.6 +diff -u -r1.6 XWindow.h +--- src/platform/XWindow.h 2001/03/04 16:35:56 1.6 ++++ src/platform/XWindow.h 2001/04/08 17:08:36 +@@ -26,6 +26,27 @@ + #include <X11/extensions/XInput.h> + #endif + ++#ifdef USBJOYSTICK ++#ifdef __cplusplus ++/* Argh! usb.h has a structure with a member "class". We don't use it, so ++ * let's just move it out of the way ++ */ ++#define class CLASS ++extern "C" { ++#endif ++#ifdef __FreeBSD__ ++#include <libusb.h> ++#else ++#include <usb.h> ++#endif ++#include <dev/usb/usb.h> ++#include <dev/usb/usbhid.h> ++#ifdef __cplusplus ++#undef class ++} ++#endif ++#endif ++ + class XVisual; + + class XWindow : public BzfWindow { +@@ -61,6 +82,13 @@ + void swapBuffers(); + void makeContext(); + void freeContext(); ++ ++#ifdef USBJOYSTICK ++ void initJoystick(const char* joystickName); ++ boolean joystick() const; ++ void getJoy(int& x, int& y) const; ++ unsigned long getJoyButtons() const; ++#endif + + #ifdef XIJOYSTICK + void initJoystick(char* joystickName); +--- /dev/null Sun Apr 8 09:22:24 2001 ++++ src/platform/usbjoy.cxx Sun Apr 8 09:59:19 2001 +@@ -0,0 +1,194 @@ ++/* ++ * USB Joystick support for {Net,Free}BSD. ++ * ++ * Copyright 2001, Nick Sayer ++ * This package is free software; you can redistribute it and/or ++ * modify it under the terms of the license found in the file ++ * named LICENSE that should have accompanied this file. ++ * ++ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ++ * ++ * This file was "inspired" by the joy_usb.c file that is part of the ++ * xmame project. To the extent that code was copied from that file, ++ * it is the author's opinion that distribution under the GPL of the ++ * derivative work is allowed. ++ * ++ */ ++ ++#ifdef USBJOYSTICK ++#include "XWindow.h" ++#include <X11/Intrinsic.h> ++#include <fcntl.h> ++#include <unistd.h> ++ ++#include <stdio.h> ++ ++#define MAX_AXIS 3 ++ ++class usb_joystick { ++public: ++ usb_joystick(const char *name); ++ ~usb_joystick(); ++ void poll(); ++ int num_axis; ++ int axis[MAX_AXIS]; ++ int axis_scale[MAX_AXIS]; ++ int axis_const[MAX_AXIS]; ++ unsigned long buttons; ++ boolean status; ++private: ++ int fd; ++ struct hid_item *hids; ++ char *data_buf; ++ int data_buf_size; ++ int data_buf_offset; ++}; ++ ++usb_joystick *stick=NULL; ++ ++usb_joystick::usb_joystick(const char *name) ++{ ++ report_desc_t rd; ++ hid_data *d; ++ hid_item h; ++ int report_id; ++ ++ status = FALSE; ++ hids = NULL; ++ num_axis = 0; ++ ++ if ((fd = open(name, O_RDONLY | O_NONBLOCK))<0) ++ return; ++ ++ if ((rd = hid_get_report_desc(fd)) == 0) { ++ close(fd); ++ return; ++ } ++ ++ data_buf_size = hid_report_size(rd, hid_input, &report_id); ++ if ((data_buf = (char *)malloc(data_buf_size)) == NULL) { ++ hid_dispose_report_desc(rd); ++ } ++ data_buf_offset = (report_id != 0); ++ ++ int is_joystick = 0; ++ int interesting_hid = FALSE; ++ for (d = hid_start_parse(rd, 1 << hid_input); hid_get_item(d, &h); ) { ++ int page = HID_PAGE(h.usage); ++ int usage = HID_USAGE(h.usage); ++ is_joystick = is_joystick || ++ (h.kind == hid_collection && ++ page == HUP_GENERIC_DESKTOP && ++ (usage == HUG_JOYSTICK || usage == HUG_GAME_PAD)); ++ ++ if (h.kind != hid_input) ++ continue; ++ ++ if (!is_joystick) ++ continue; ++ ++ interesting_hid = TRUE; ++ if (page == HUP_GENERIC_DESKTOP) { ++ int which_axis; ++ switch (usage) { ++ case HUG_X: ++ case HUG_RX: which_axis = 0; break; ++ case HUG_Y: ++ case HUG_RY: which_axis = 1; break; ++ case HUG_Z: ++ case HUG_RZ: which_axis = 2; break; ++ default: interesting_hid = FALSE; ++ } ++ if (interesting_hid) { ++ axis_const[which_axis] = 1000 + (2000*h.logical_maximum)/(h.logical_minimum-h.logical_maximum); ++ axis_scale[which_axis] = (2000*10000)/(h.logical_maximum-h.logical_minimum); ++ axis[which_axis] = (h.logical_minimum + ++ h.logical_maximum) / 2; ++ if (num_axis < (which_axis + 1)) ++ num_axis = which_axis + 1; ++ } ++ } ++ if (interesting_hid) { ++ struct hid_item *newhid = new struct hid_item; ++ if (newhid == NULL) { ++ close(fd); ++ return; ++ } ++ *newhid = h; ++ newhid->next = hids; ++ hids = newhid; ++ } ++ } ++ hid_end_parse(d); ++ ++ status = TRUE; ++} ++usb_joystick::~usb_joystick() { ++ close(fd); ++} ++ ++void usb_joystick::poll() { ++ int len; ++ ++/* ++ * The device will buffer a lot of deltas. This can lead to a lot of ++ * latency. To avoid this, we will empty the buffer every time. ++ * It's possible the device may report only changed entries, so we ++ * must process all of the frames to avoid dropping buttons (for example). ++ */ ++ while ((len = read(fd, data_buf, data_buf_size)) == data_buf_size) { ++ ++ struct hid_item *h; ++ ++ for (h = hids ; h; h = h->next) { ++ int d = hid_get_data(data_buf + data_buf_offset, h); ++ int page = HID_PAGE(h->usage); ++ int usage = HID_USAGE(h->usage); ++ ++ int which_axis; ++ if (page == HUP_GENERIC_DESKTOP) { ++ switch (usage) { ++ case HUG_X: ++ case HUG_RX: which_axis = 0; break; ++ case HUG_Y: ++ case HUG_RY: which_axis = 1; break; ++ case HUG_Z: ++ case HUG_RZ: which_axis = 2; break; ++ } ++ axis[which_axis] = d; ++ } else if (page == HUP_BUTTON) { ++ buttons &= ~ (1 << (usage - 1)); ++ buttons |= (d == h->logical_maximum)?1 << (usage - 1):0; ++ } ++ } ++ } ++ ++} ++ ++void XWindow::initJoystick(const char *joystickName) ++{ ++ stick= new usb_joystick(joystickName); ++} ++ ++boolean XWindow::joystick() const ++{ ++ return (stick!=NULL)?stick->status:FALSE; ++} ++ ++void XWindow::getJoy(int &x, int &y) const ++{ ++ stick->poll(); ++ x = (stick->axis[0]*stick->axis_scale[0])/10000 + stick->axis_const[0]; ++ y = (stick->axis[1]*stick->axis_scale[1])/10000 + stick->axis_const[1]; ++} ++ ++unsigned long XWindow::getJoyButtons() const ++{ ++ stick->poll(); ++ return stick->buttons; ++} ++ ++#endif ++ |