Author: bdefreese
Date: 2009-04-06 18:16:21 +0000 (Mon, 06 Apr 2009)
New Revision: 9436

Added:
   packages/trunk/gravitywars/debian/patches/020_sdl_joystick.diff
Modified:
   packages/trunk/gravitywars/debian/changelog
   packages/trunk/gravitywars/debian/control
   packages/trunk/gravitywars/debian/copyright
   packages/trunk/gravitywars/debian/patches/series
   packages/trunk/gravitywars/debian/rules
Log:
  * Add myself to uploaders.
  * 020_sdl_joystick.diff - Add joystick support. (Closes: #508933).
    + Thanks to Titon Barua for the patch.
  * Version link to GPL license in copyright.
  * Add appropriate copyright holder to debian/copyright.
  * Remove quilt .pc dir on clean.
  * Bump Standards Version to 3.8.1. (No changes needed).
Refresh changelog.


Modified: packages/trunk/gravitywars/debian/changelog
===================================================================
--- packages/trunk/gravitywars/debian/changelog 2009-04-06 17:23:29 UTC (rev 
9435)
+++ packages/trunk/gravitywars/debian/changelog 2009-04-06 18:16:21 UTC (rev 
9436)
@@ -1,14 +1,21 @@
-gravitywars (1.102-32) UNRELEASED; urgency=low
+gravitywars (1.102-32) unstable; urgency=low
 
   [ Barry deFreese ]
+  * Add myself to uploaders.
   * Add desktop file (Closes: #452576)
   * debian/rules - Remove -s option from install (Closes: #437080)
   * Don't ignore make clean errors
+  * 020_sdl_joystick.diff - Add joystick support. (Closes: #508933).
+    + Thanks to Titon Barua for the patch.
+  * Version link to GPL license in copyright.
+  * Add appropriate copyright holder to debian/copyright.
+  * Remove quilt .pc dir on clean.
+  * Bump Standards Version to 3.8.1. (No changes needed).
 
   [ Ansgar Burchardt ]
   * debian/control: Change XS-Vcs-* to Vcs-*
 
- -- Ansgar Burchardt <[email protected]>  Fri, 29 Feb 2008 03:08:34 +0100
+ -- Barry deFreese <[email protected]>  Mon, 06 Apr 2009 14:01:48 -0400
 
 gravitywars (1.102-31) unstable; urgency=low
 

Modified: packages/trunk/gravitywars/debian/control
===================================================================
--- packages/trunk/gravitywars/debian/control   2009-04-06 17:23:29 UTC (rev 
9435)
+++ packages/trunk/gravitywars/debian/control   2009-04-06 18:16:21 UTC (rev 
9436)
@@ -2,8 +2,8 @@
 Section: games
 Priority: optional
 Maintainer: Debian Games Team <[email protected]>
-Uploaders: Sam Hocevar (Debian packages) <[email protected]>
-Standards-Version: 3.7.2
+Uploaders: Sam Hocevar (Debian packages) <[email protected]>, Barry deFreese 
<[email protected]>
+Standards-Version: 3.8.1
 Build-Depends: debhelper (>= 5.0), quilt, libsdl1.2-dev (>= 1.2.5-8)
 Vcs-Svn: svn://svn.debian.org/pkg-games/packages/trunk/gravitywars
 Vcs-Browser: http://svn.debian.org/wsvn/pkg-games/packages/trunk/gravitywars/

Modified: packages/trunk/gravitywars/debian/copyright
===================================================================
--- packages/trunk/gravitywars/debian/copyright 2009-04-06 17:23:29 UTC (rev 
9435)
+++ packages/trunk/gravitywars/debian/copyright 2009-04-06 18:16:21 UTC (rev 
9436)
@@ -7,6 +7,8 @@
 
 Upstream Author: Sami Niemi <[email protected]> 
 
+Copyright: Copyright (C) 1995, 1996 Sami Niemi <[email protected]>
+
 Edward Betts <[email protected]> Fri, 11 Aug 2000 01:00:00 +0100
 
 I had an email discussion with the author about licensing. I asked for the
@@ -15,4 +17,4 @@
 to say that the licence had changed, but I said that an email was sufficient.
 
 On Debian GNU/Linux systems, the complete text of the GNU General
-Public License can be found in `/usr/share/common-licenses/GPL'.
+Public License can be found in `/usr/share/common-licenses/GPL-2'.

Added: packages/trunk/gravitywars/debian/patches/020_sdl_joystick.diff
===================================================================
--- packages/trunk/gravitywars/debian/patches/020_sdl_joystick.diff             
                (rev 0)
+++ packages/trunk/gravitywars/debian/patches/020_sdl_joystick.diff     
2009-04-06 18:16:21 UTC (rev 9436)
@@ -0,0 +1,757 @@
+/*
+ * Objective: This patch implements simple joystick support
+ * Program: gravitywars
+ * Author : Titon Barua (titanix)
+ * patch_version: 0.2
+ * email: [email protected]
+ * source_package_to_apply_patch: 1.102-31ubuntu1
+ * Date : 17-12-2008
+ * License: This code is released under GNU GPL v2 or higher
+ */
+
+
+Index: gw3/GravityWars101.c
+===================================================================
+--- gw3.orig/GravityWars101.c  2008-12-16 20:11:30.000000000 +0600
++++ gw3/GravityWars101.c       2008-12-16 20:11:30.000000000 +0600
+@@ -44,10 +44,76 @@
+ #include <unistd.h>
+ #include "includes.h"
+ #include "memory.h"
+- 
++
++#if defined (USE_SDL) && defined (USE_JOYSTICK)
++#include <stdlib.h>
++#include <errno.h>
++extern SDL_Joystick * joy;
++extern int JOY_INDEX;
++extern int JOY_XAXIS;
++extern int JOY_YAXIS;
++extern int JOY_BUTTON_UP;
++extern int JOY_BUTTON_SHOOT;
++extern int JOY_BUTTON_TOGGLE_FULLSCREEN;
++extern int JOY_BUTTON_ESCAPE;
++extern Sint16 JOY_XAXIS_CENTER;
++extern Sint16 JOY_XAXIS_MINIMUM;
++extern Sint16 JOY_XAXIS_MAXIMUM;
++extern Sint16 JOY_XAXIS_NULLZONE;
++extern Sint16 JOY_YAXIS_CENTER;
++extern Sint16 JOY_YAXIS_MINIMUM;
++extern Sint16 JOY_YAXIS_MAXIMUM;
++extern Sint16 JOY_YAXIS_NULLZONE;
++
++int get_int_env_var (char * env_name,int * i)
++{
++      char * env_val = NULL;
++      int tmp = 0;
++
++      if ((env_val = getenv (env_name)) != NULL) {
++#ifdef DEBUG
++              printf ("env_var : %s=%s\n", env_name, env_val);
++#endif
++              errno = 0;
++              tmp = (int) strtol (env_val, NULL, 10);
++              if (!errno) {
++                      *i = tmp;
++                      return 0;
++              } else {
++                      return (1);
++              }
++      }
++      return (2);
++}
++
++int get_Sint16_env_var (char * env_name,Sint16 * i)
++{
++      char * env_val = NULL;
++      Sint16 tmp = 0;
++
++      if ((env_val = getenv (env_name)) != NULL) {
++#ifdef DEBUG
++              printf ("env_var : %s=%s\n", env_name, env_val);
++#endif
++              errno = 0;
++              tmp = (Sint16) strtol (env_val, NULL, 10);
++              if (!errno) {
++                      *i = tmp;
++                      return (0);
++              } else {
++                      return (1);
++              }
++      }
++      return (2);
++}
++#endif
++
+ /*--------------------------------------------------------------------- main 
*/
+ int main(int n_args, char *arg[]) {
+-  
++#if defined (USE_SDL) && defined (USE_JOYSTICK)
++      int c, index, calibrate_joystick = 0;
++      opterr = 0;
++#endif
+ 
+   int n,ch,x,y;
+   
+@@ -67,6 +133,20 @@
+   if (readlink(arg[0],buf,128)==-1) 
+     strcpy(buf,arg[0]);
+ 
++#if defined (USE_SDL) && defined (USE_JOYSTICK)
++      while ((c = getopt (n_args, arg, "j")) != -1) {
++              switch (c) {
++                      case 'j':
++                              calibrate_joystick = 1;
++                              break;
++                      case '?':
++                              fprintf (stderr, "Unknown option. Use '-j' to 
configure joystick.\n\n");
++                              break;
++                      default:
++                              break;
++              }
++      }
++#endif
+ /*  
+   n=strlen(buf);
+   while(n>=0)                       
+@@ -85,11 +165,20 @@
+       strcpy(gamename,"/usr/share/games/gravitywars/");
+       gamenamelen=strlen(gamename);
+ 
++#if defined (USE_SDL) && (USE_JOYSTICK)
++      if (optind < n_args) {
++#else
+   if (n_args>1) {
++#endif
+     n=0;
+     do {
+       n++;
++#if defined (USE_SDL) && (USE_JOYSTICK)
++    } while ( (strncmp(arg[optind],codes[n],6)) && (n<99));
++#else
+     } while ( (strncmp(arg[1],codes[n],6)) && (n<99));
++#endif
++
+     if (n!=99) {
+       levelnum=n+1;
+ #ifndef USE_SDL
+@@ -98,7 +187,11 @@
+ #endif
+     } else {
+ #ifdef USE_SDL
++#ifndef USE_JOYSTICK
+       printf("\nUsage: %s [code-to-a-given-level]\n"
++#else
++      printf("\nUsage: %s [-j] [code-to-a-given-level]\n"
++#endif
+            "(Sure you've got the right code?)\n\n",arg[0]);
+       exit(0);
+ #else
+@@ -130,6 +223,38 @@
+   initScreen();
+ 
+   keyboard_init();
++
++#ifdef USE_SDL
++#ifdef USE_JOYSTICK
++      if (calibrate_joystick == 1)
++              set_joystick ();
++      else
++              if (load_joystick_settings () == 0)
++                      printf ("Joystick configuration loaded from file.\n");
++              else
++                      printf ("Can not load joystick configuration file. 
Using defaults.\n");
++/*Parsing environment variables*/
++      get_int_env_var ("GW_JOY_INDEX", &JOY_INDEX);
++      get_int_env_var ("GW_JOY_XAXIS", &JOY_XAXIS);
++      get_int_env_var ("GW_JOY_YAXIS", &JOY_YAXIS);
++      get_int_env_var ("GW_JOY_BUTTON_UP", &JOY_BUTTON_UP);
++      get_int_env_var ("GW_JOY_BUTTON_SHOOT", &JOY_BUTTON_SHOOT);
++      get_int_env_var ("GW_JOY_BUTTON_TOGGLE_FULLSCREEN", 
&JOY_BUTTON_TOGGLE_FULLSCREEN);
++      get_int_env_var ("GW_JOY_BUTTON_ESCAPE", &JOY_BUTTON_ESCAPE);
++
++      get_Sint16_env_var ("GW_JOY_XAXIS_CENTER", &JOY_XAXIS_CENTER);
++      get_Sint16_env_var ("GW_JOY_XAXIS_MINIMUM", &JOY_XAXIS_MINIMUM);
++      get_Sint16_env_var ("GW_JOY_XAXIS_MAXIMUM", &JOY_XAXIS_MAXIMUM);
++      get_Sint16_env_var ("GW_JOY_XAXIS_NULLZONE", &JOY_XAXIS_NULLZONE);
++      get_Sint16_env_var ("GW_JOY_YAXIS_CENTER", &JOY_YAXIS_CENTER);
++      get_Sint16_env_var ("GW_JOY_YAXIS_MINIMUM", &JOY_YAXIS_MINIMUM);
++      get_Sint16_env_var ("GW_JOY_YAXIS_MAXIMUM", &JOY_YAXIS_MAXIMUM);
++      get_Sint16_env_var ("GW_JOY_YAXIS_NULLZONE", &JOY_YAXIS_NULLZONE);
++
++      joystick_init ();
++#endif
++#endif
++
+   mouse_init("/dev/mouse", MOUSE_MICROSOFT, MOUSE_DEFAULTSAMPLERATE);
+   scans=keyboard_getstate();
+ 
+@@ -284,6 +409,13 @@
+   mouse_close();
+   keyboard_close();
+ 
++#ifdef USE_SDL
++#ifdef USE_JOYSTICK
++      if (joy != NULL)
++              joystick_close ();
++#endif
++#endif
++
+   vga_setmode(TEXT);
+   printf("\n");
+   exit(0);
+Index: gw3/Makefile
+===================================================================
+--- gw3.orig/Makefile  2008-12-16 20:11:30.000000000 +0600
++++ gw3/Makefile       2008-12-16 20:11:30.000000000 +0600
+@@ -3,11 +3,13 @@
+ #
+ 
+ USE_SDL=1
++USE_JOYSTICK=1
++DEBUG=1
+ 
+ BINDIR=/usr/local/bin
+ 
+ ifeq (1,$(USE_SDL))
+-CFLAGS= -g -O2 -Wall -DUSE_SDL `sdl-config --cflags`
++CFLAGS= -g -Wall -DUSE_SDL -DUSE_JOYSTICK `sdl-config --cflags`
+ LIBS= -lm `sdl-config --libs`
+ else
+ CFLAGS= -O2 -Wall
+Index: gw3/vgastubs.c
+===================================================================
+--- gw3.orig/vgastubs.c        2008-12-16 20:11:30.000000000 +0600
++++ gw3/vgastubs.c     2008-12-16 20:20:00.000000000 +0600
+@@ -10,7 +10,9 @@
+ #ifdef USE_SDL
+ #include "vgastubs.h"
+ 
++/*
+ #include <SDL.h>
++*/
+ 
+ /* VGA */
+ 
+@@ -21,8 +23,319 @@
+ SDL_Surface *bg;
+ SDL_Rect score_rect, level_rect, game_rect;
+ 
++#ifdef USE_JOYSTICK
++SDL_Joystick * joy = NULL;
++
++int JOY_INDEX = 0;
++int JOY_XAXIS = 0;
++int JOY_YAXIS = 1;
++int JOY_BUTTON_UP = 0;
++int JOY_BUTTON_SHOOT = 1;
++int JOY_BUTTON_TOGGLE_FULLSCREEN = 2;
++int JOY_BUTTON_ESCAPE = 2;
++
++Sint16 JOY_XAXIS_CENTER = 0;
++Sint16 JOY_XAXIS_MINIMUM = -32767;
++Sint16 JOY_XAXIS_MAXIMUM = 32767;
++Sint16 JOY_XAXIS_NULLZONE = 1024;
++
++Sint16 JOY_YAXIS_CENTER = 0;
++Sint16 JOY_YAXIS_MINIMUM = -32767;
++Sint16 JOY_YAXIS_MAXIMUM = 32767;
++Sint16 JOY_YAXIS_NULLZONE = 1024;
++
++int save_joystick_settings (void) {
++      /*Just a dirty hack to save the joystick settings*/
++      FILE * joyset = NULL;
++      char * home = NULL;
++      char   fpath[1000];
++
++      if ((home = getenv ("HOME")) == NULL)
++              return (2);
++      strcpy (fpath, home);
++      joyset = fopen (strcat (fpath, "/.gravitywars-joystick-settings"), "w");
++
++      if (joyset != NULL) {
++              if (fprintf (
++                      joyset,
++                      "%d %d %d %d %d %d %d %hd %hd %hd %hd %hd %hd %hd 
%hd\n",
++                      JOY_INDEX,
++                      JOY_XAXIS,
++                      JOY_YAXIS,
++                      JOY_BUTTON_UP,
++                      JOY_BUTTON_SHOOT,
++                      JOY_BUTTON_TOGGLE_FULLSCREEN,
++                      JOY_BUTTON_ESCAPE,
++                      JOY_XAXIS_CENTER,
++                      JOY_XAXIS_MINIMUM,
++                      JOY_XAXIS_MAXIMUM,
++                      JOY_XAXIS_NULLZONE,
++                      JOY_YAXIS_CENTER,
++                      JOY_YAXIS_MINIMUM,
++                      JOY_YAXIS_MAXIMUM,
++                      JOY_YAXIS_NULLZONE
++                      ) >= 0) {
++                      fclose (joyset);
++                      return (0);
++              } else {
++                      fclose (joyset);
++                      return (1);
++              }
++      } else {
++              return (2);
++      }
++}
++
++int load_joystick_settings (void) {
++      FILE * joyset = NULL;
++      char * lineptr = NULL;
++      size_t n = 0;
++      char * home = NULL;
++      char   fpath[1000];
++
++      if ((home = getenv ("HOME")) == NULL)
++              return (2);
++      strcpy (fpath, home);
++      joyset = fopen (strcat (fpath, "/.gravitywars-joystick-settings"), "r");
++
++      if (joyset != NULL) {
++              if (getline (&lineptr, &n, joyset) == -1)
++                      return 1;
++              if (
++                      sscanf (
++                      lineptr,
++                      "%d %d %d %d %d %d %d %hd %hd %hd %hd %hd %hd %hd %hd",
++                      &JOY_INDEX,
++                      &JOY_XAXIS,
++                      &JOY_YAXIS,
++                      &JOY_BUTTON_UP,
++                      &JOY_BUTTON_SHOOT,
++                      &JOY_BUTTON_TOGGLE_FULLSCREEN,
++                      &JOY_BUTTON_ESCAPE,
++                      &JOY_XAXIS_CENTER,
++                      &JOY_XAXIS_MINIMUM,
++                      &JOY_XAXIS_MAXIMUM,
++                      &JOY_XAXIS_NULLZONE,
++                      &JOY_YAXIS_CENTER,
++                      &JOY_YAXIS_MINIMUM,
++                      &JOY_YAXIS_MAXIMUM,
++                      &JOY_YAXIS_NULLZONE
++              ) == 15) {
++                      fclose (joyset);
++                      return 0;
++              } else {
++                      fclose (joyset);
++                      return 2;
++              }
++      } else {
++      return 3;
++      }
++}
++
++void set_joystick (void)
++{
++      SDL_Joystick ** joyar = NULL;
++      SDL_Event e;
++      int i, axis_set, axis_ref, axis_ref_set, axis_max, axis_min, 
num_of_joystick;
++
++      SDL_JoystickEventState (SDL_ENABLE);
++      num_of_joystick = SDL_NumJoysticks();
++
++      if (num_of_joystick > 0) {
++              printf ("Found %d joystick.\n", num_of_joystick);
++
++              joyar = (SDL_Joystick **) malloc (sizeof (SDL_Joystick *) * 
num_of_joystick);
++              if (joyar != NULL) {
++                      for (i = 0; i < num_of_joystick; i++) {
++                              if (!SDL_JoystickOpened(i))
++                                      joyar[i] = SDL_JoystickOpen(i);
++                      }
++
++              } else {
++                      SDL_Quit ();
++                      exit (1);
++              }
++
++/*Select the joystick*/
++              printf ("Press any button or move the axis on the joystick you 
want to configure...\n");
++
++/* Emptying the event queue. My joystick throws
++ * some false event right after it is opened.*/
++              while (SDL_PollEvent(&e));
++
++              while (1) {
++                      if (SDL_WaitEvent (&e)){
++                              if (e.type == SDL_JOYAXISMOTION) {
++                                      JOY_INDEX = e.jaxis.which;
++                                      break;
++                              } else if (e.type == SDL_JOYBUTTONDOWN) {
++                                      JOY_INDEX = e.jbutton.which;
++                                      break;
++                              }
++                      }
++              }
++              printf ("Joystick with index %d selected.\n", JOY_INDEX);
++
++/* Closing other opened (if any) joystick. */
++              for (i = 0; i < num_of_joystick; i++) {
++                      if (i != JOY_INDEX) {
++                              if (SDL_JoystickOpened(i))
++                                      SDL_JoystickClose (joyar[i]);
++                      }
++              }
++
++              printf ("Move x-axis to full left and right. Then press a 
button...\n");
++
++              axis_set = 0;
++              axis_ref_set = 0;
++
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      if (SDL_WaitEvent (&e) == 1) {
++                              if (e.type == SDL_JOYAXISMOTION) {
++                                      if (axis_set == 0) {
++                                              JOY_XAXIS = e.jaxis.axis;
++                                              axis_set = 1;
++                                      }
++                                      if (axis_set == 1) {
++                                              if (e.jaxis.axis == JOY_XAXIS) {
++                                                      if (axis_ref_set == 0) {
++                                                              axis_ref = 
e.jaxis.value;
++                                                              axis_max = 
axis_ref;
++                                                              axis_min = 
axis_ref;
++                                                              axis_ref_set = 
1;
++                                                      } else {
++                                                              if 
(e.jaxis.value > axis_max)
++                                                                      
axis_max = e.jaxis.value;
++                                                              else if 
(e.jaxis.value < axis_min)
++                                                                      
axis_min = e.jaxis.value;
++                                                      }
++                                              }
++                                      }
++                              } else if (e.type == SDL_JOYBUTTONDOWN) {
++                                      if (axis_set == 1) {
++                                              if (axis_ref_set == 1) {
++                                                      if (axis_min != 
axis_max) {
++                                                              
JOY_XAXIS_MAXIMUM = axis_max;
++                                                              
JOY_XAXIS_MINIMUM = axis_min;
++                                                              
JOY_XAXIS_CENTER = axis_min + (axis_max - axis_min)/2;
++                                                              
JOY_XAXIS_NULLZONE = (axis_max - axis_min)/(20); /*10% of difference max and 
center*/
++                                                              break;
++                                                      }
++                                              }
++                                      }
++                              }
++                      }
++              }
++
++              printf ("Selected axis %d as x-axis.\n", JOY_XAXIS);
++              printf ("Move y-axis to full up and down. Then press a 
button...\n");
++
++              axis_set = 0;
++              axis_ref_set = 0;
++
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      if (SDL_WaitEvent (&e) == 1) {
++                              if (e.type == SDL_JOYAXISMOTION) {
++                                      if (e.jaxis.axis != JOY_XAXIS) {
++                                              if (axis_set == 0) {
++                                                      JOY_YAXIS = 
e.jaxis.axis;
++                                                      axis_set = 1;
++                                              }
++                                              if (axis_set == 1) {
++                                                      if (e.jaxis.axis ==  
JOY_YAXIS) {
++                                                              if 
(axis_ref_set == 0) {
++                                                                      
axis_ref = e.jaxis.value;
++                                                                      
axis_max = axis_ref;
++                                                                      
axis_min = axis_ref;
++                                                                      
axis_ref_set = 1;
++                                                              } else {
++                                                                      if 
(e.jaxis.value > axis_max)
++                                                                              
axis_max = e.jaxis.value;
++                                                                      else if 
(e.jaxis.value < axis_min)
++                                                                              
axis_min = e.jaxis.value;
++                                                              }
++                                                      }
++                                              }
++                                      }
++                              } else if (e.type == SDL_JOYBUTTONDOWN) {
++                                      if (axis_set == 1) {
++                                              if (axis_ref_set == 1) {
++                                                      if (axis_min != 
axis_max) {
++                                                              
JOY_YAXIS_MAXIMUM = axis_max;
++                                                              
JOY_YAXIS_MINIMUM = axis_min;
++                                                              
JOY_YAXIS_CENTER = axis_min + (axis_max - axis_min)/2;
++                                                              
JOY_YAXIS_NULLZONE = (axis_max - axis_min)/(20); /*10% of difference max and 
center*/
++                                                              break;
++                                                      }
++                                              }
++                                      }
++                              }
++                      }
++              }
++
++              printf ("Selected axis %d as y-yxis.\n", JOY_YAXIS);
++
++              printf ("Press the button for action:\"up\"...\n");
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      SDL_WaitEvent (&e);
++                      if (e.type == SDL_JOYBUTTONDOWN) {
++                              JOY_BUTTON_UP = e.jbutton.button;
++                              break;
++                      }
++              }
++              printf ("\"up\":%d\n", JOY_BUTTON_UP);
++
++              printf ("Press the button for action:\"shoot\"...\n");
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      SDL_WaitEvent (&e);
++                      if (e.type == SDL_JOYBUTTONDOWN) {
++                              JOY_BUTTON_SHOOT = e.jbutton.button;
++                              break;
++                      }
++              }
++              printf ("\"shoot\":%d\n", JOY_BUTTON_SHOOT);
++              printf ("Press the button for action:\"toggle 
fullscreen\"...\n");
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      SDL_WaitEvent (&e);
++                      if (e.type == SDL_JOYBUTTONDOWN) {
++                              JOY_BUTTON_TOGGLE_FULLSCREEN = e.jbutton.button;
++                              break;
++                      }
++              }
++              printf ("\"toggle fullscreen\":%d\n", 
JOY_BUTTON_TOGGLE_FULLSCREEN);
++              printf ("Press the button for action:\"escape\"...\n");
++              while (SDL_PollEvent(&e));
++              while (1) {
++                      SDL_WaitEvent (&e);
++                      if (e.type == SDL_JOYBUTTONDOWN) {
++                              JOY_BUTTON_ESCAPE = e.jbutton.button;
++                              break;
++                      }
++              }
++              printf ("\"escape\":%d\n", JOY_BUTTON_ESCAPE);
++              SDL_JoystickClose (joyar[JOY_INDEX]);
++              free (joyar);
++              if (save_joystick_settings ())
++                      printf ("Error saving joystick settings.\n");
++              else
++                      printf ("Joystick configuration saved.\n");
++      }       else {
++              printf ("No joystick found.\n");
++      }
++}
++#endif
++
+ int vga_init(void) {
++#ifdef USE_JOYSTICK
++  if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) < 0)
++#else
+   if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
++#endif
+     return -1;
+ 
+   atexit(SDL_Quit);
+@@ -196,6 +509,9 @@
+   mod = SDL_GetModState();
+   scans[SCANCODE_LEFTCONTROL] = mod & KMOD_LCTRL;
+   scans[SCANCODE_RIGHTCONTROL] = mod & KMOD_RCTRL;
++#ifdef USE_JOYSTICK
++      scans[SCANCODE_LEFTCONTROL] = SDL_JoystickGetButton (joy, 
JOY_BUTTON_SHOOT);
++#endif
+ 
+   while(SDL_PollEvent(&e)) {
+     if(e.type == SDL_KEYDOWN) {
+@@ -241,9 +557,115 @@
+           break;
+       }
+     }
++#ifdef USE_JOYSTICK
++/*Joystick*/
++                      else if (joy != NULL) {
++                              if (e.type == SDL_JOYAXISMOTION) {
++#ifdef DEBUG
++                              puts ("Joystick axis motion detected.");
++#endif
++                                      if (e.jaxis.which == JOY_INDEX) {
++                                              if (e.jaxis.axis == JOY_XAXIS) {
++#ifdef DEBUG
++                                                      printf ("Axis : X, 
Value : %i\n", e.jaxis.value);
++#endif
++                                                      if ((JOY_XAXIS_MINIMUM 
<= e.jaxis.value) &&
++                                                              (e.jaxis.value 
< JOY_XAXIS_CENTER - JOY_XAXIS_NULLZONE)) {
++                                                              
scans[SCANCODE_CURSORBLOCKLEFT] = 1;
++                                                              
scans[SCANCODE_CURSORBLOCKRIGHT] = 0;
++                                                              updated = 1;
++                                                      } else if 
((JOY_XAXIS_CENTER + JOY_XAXIS_NULLZONE < e.jaxis.value) &&
++                                                              (e.jaxis.value 
<= JOY_XAXIS_MAXIMUM)) {
++                                                              
scans[SCANCODE_CURSORBLOCKRIGHT] = 1;
++                                                              
scans[SCANCODE_CURSORBLOCKLEFT] = 0;
++                                                              updated = 1;
++                                                      } else {
++                                                              
scans[SCANCODE_CURSORBLOCKRIGHT] = 0;
++                                                              
scans[SCANCODE_CURSORBLOCKLEFT] = 0;
++                                                      }
++                                              } else if (e.jaxis.axis == 
JOY_YAXIS) {
++#ifdef DEBUG
++                                              printf ("Axis : Y, Value : 
%d\n", e.jaxis.value);
++#endif
++                                              if ((JOY_YAXIS_MINIMUM <= 
e.jaxis.value) &&
++                                                      (e.jaxis.value < 
JOY_YAXIS_CENTER - JOY_YAXIS_NULLZONE)) {
++                                                      
scans[SCANCODE_CURSORBLOCKUP] = 1;
++                                                      updated = 1;
++                                              } else if ((JOY_YAXIS_CENTER + 
JOY_YAXIS_NULLZONE < e.jaxis.value) &&
++                                                      (e.jaxis.value <= 
JOY_YAXIS_MAXIMUM)) {
++                                                      
scans[SCANCODE_CURSORBLOCKUP] = 1;
++                                                      updated = 1;
++                                              } else {
++                                                      
scans[SCANCODE_CURSORBLOCKUP] = 0;
++                                              }
++                                      }
++                              }
++                      } else if (e.type == SDL_JOYBUTTONDOWN) {
++                              if (e.jbutton.which == JOY_INDEX) {
++                                      if (e.jbutton.button == JOY_BUTTON_UP) {
++                                              scans[SCANCODE_CURSORBLOCKUP] = 
1;
++                                              updated = 1;
++/*
++                                      } else if (e.jbutton.button == 
JOY_BUTTON_SHOOT) {
++                                              scans[SCANCODE_LEFTCONTROL] = 1;
++                                              scans[SCANCODE_RIGHTCONTROL] = 
1;
++                                              updated = 1;
++*/
++                                      } else if (e.jbutton.button == 
JOY_BUTTON_ESCAPE) {
++                                              scans[SCANCODE_ESCAPE] = 1;
++                                              updated = 1;
++                                      } else if (e.jbutton.button == 
JOY_BUTTON_TOGGLE_FULLSCREEN) {
++                      SDL_WM_ToggleFullScreen(screen);
++                                      }
++                              }
++                      } else if (e.type == SDL_JOYBUTTONUP) {
++                              if (e.jbutton.which == JOY_INDEX) {
++                                      if (e.jbutton.button == JOY_BUTTON_UP) {
++                                              scans[SCANCODE_CURSORBLOCKUP] = 
0;
++/*
++                                      } else if (e.jbutton.button == 
JOY_BUTTON_SHOOT) {
++                                              scans[SCANCODE_LEFTCONTROL] = 0;
++                                              scans[SCANCODE_RIGHTCONTROL] = 
0;
++*/
++                                      } else if (e.jbutton.button == 
JOY_BUTTON_ESCAPE) {
++                                              scans[SCANCODE_ESCAPE] = 0;
++                                      }
++                              }
++                      }
++              }
++#endif
+   }
+-
+   return updated;
+ }
+ 
++#ifdef USE_JOYSTICK
++int joystick_init (void) {
++      SDL_JoystickEventState (SDL_ENABLE);
++      if (SDL_NumJoysticks () >= JOY_INDEX) {
++              joy = SDL_JoystickOpen (JOY_INDEX);
++
++              if (joy == NULL) {
++#ifdef DEBUG
++                      printf ("Failed to open joystick.\n");
++#endif
++                      return (1);
++              }
++              else
++                      return (0);
++      }
++      else {
++#ifdef DEBUG
++              printf ("Joystick not found.\n");
++#endif
++              return (2);
++      }
++}
++
++void joystick_close (void) {
++      if (SDL_JoystickOpened (JOY_INDEX)) {
++              SDL_JoystickClose (joy);
++      }
++}
++#endif
++
+ #endif /* USE_SDL */
+Index: gw3/vgastubs.h
+===================================================================
+--- gw3.orig/vgastubs.h        2008-12-16 20:11:30.000000000 +0600
++++ gw3/vgastubs.h     2008-12-16 20:11:30.000000000 +0600
+@@ -18,6 +18,8 @@
+ #define SCANCODE_CURSORBLOCKRIGHT 4
+ #define SCANCODE_CURSORBLOCKUP 5
+ 
++#include <SDL.h>
++
+ typedef void vga_modeinfo;
+ 
+ int vga_init(void);
+@@ -39,3 +41,11 @@
+ void keyboard_close(void);
+ char *keyboard_getstate(void);
+ int keyboard_update(void);
++
++#ifdef USE_JOYSTICK
++int joystick_init (void);
++void joystick_close (void);
++void set_joystick (void);
++int load_joystick_settings (void);
++int save_joystick_settings (void);
++#endif
+Index: gw3/README.joystick
+===================================================================
+--- /dev/null  1970-01-01 00:00:00.000000000 +0000
++++ gw3/README.joystick        2008-12-16 20:11:30.000000000 +0600
+@@ -0,0 +1,44 @@
++ ****************
++ * INTRODUCTION *
++ ****************
++   The joystick support is implemented using SDL. The command line option 
'-j' will
++prompt you (of course in command line :) with joystick configuration. Do 
exactly as
++you are asked. The configuration will be saved in a file 
".gravitywars-joystick-settings"
++in your home directory. From next time, configurations will be loaded from 
the file.
++By default, there is no file, and default joystick values (embeded in program 
code)
++are used. You must use '-j' atleast once for the configuration file to be 
created.
++
++   There are also some environment variables which can be used to manually 
setup your
++joystick. They are parsed after the configuration file, so they overshadow 
the confi-
++guration file, but are not saved when program exits.
++
++ *************************
++ * ENVIRONMENT VARIABLES *
++ *************************
++ GW_JOY_INDEX
++ GW_JOY_XAXIS
++ GW_JOY_YAXIS
++ GW_JOY_BUTTON_UP
++ GW_JOY_BUTTON_SHOOT
++ GW_JOY_BUTTON_TOGGLE_FULLSCREEN
++ GW_JOY_BUTTON_ESCAPE
++ GW_JOY_XAXIS_CENTER
++ GW_JOY_XAXIS_MINIMUM
++ GW_JOY_XAXIS_MAXIMUM
++ GW_JOY_XAXIS_NULLZONE
++ GW_JOY_YAXIS_CENTER
++ GW_JOY_YAXIS_MINIMUM
++ GW_JOY_YAXIS_MAXIMUM
++ GW_JOY_YAXIS_NULLZONE
++
++ ********
++ * BUGS *
++ ********
++   If you unplug the joystick, or somehow disable joystick event during 
joystick conf-
++iguration, the program will stuck there. 'killall -HUP gravitywars' will do 
the job though.
++
++ **********
++ * AUTHOR *
++ **********
++ Titon Barua / titanix
++ [email protected]
+

Modified: packages/trunk/gravitywars/debian/patches/series
===================================================================
--- packages/trunk/gravitywars/debian/patches/series    2009-04-06 17:23:29 UTC 
(rev 9435)
+++ packages/trunk/gravitywars/debian/patches/series    2009-04-06 18:16:21 UTC 
(rev 9436)
@@ -6,3 +6,4 @@
 010_highscores.diff
 010_reduce_verbosity.diff
 010_sdl_port.diff
+020_sdl_joystick.diff

Modified: packages/trunk/gravitywars/debian/rules
===================================================================
--- packages/trunk/gravitywars/debian/rules     2009-04-06 17:23:29 UTC (rev 
9435)
+++ packages/trunk/gravitywars/debian/rules     2009-04-06 18:16:21 UTC (rev 
9436)
@@ -13,6 +13,9 @@
        rm -f build-stamp
        [ ! -f Makefile ] || $(MAKE) clean
        QUILT_PATCHES=debian/patches quilt pop -a -R || test $$? = 2
+
+       rm -rf .pc
+
        dh_clean
 
 install: build


_______________________________________________
Pkg-games-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/pkg-games-commits

Reply via email to