Changeset 731


Ignore:
Timestamp:
Jul 21, 2014, 12:50:29 AM (3 years ago)
Author:
jjsimpso
Message:

sdlport: Add support for SDL2, inculding the game controller API. Configure
script will check for SDL2 and use it if present, otherwise it will fall
back to SDL v1. Some old SDL v1 features not implemented yet on SDL2, such
as saving screenshots.

core: Small change for SDL2 game controller API to disable the game
controller in the save/load game menu.

Summary of game controller API changes:

  • Enable with -gamepad
  • Tested with PS3 dualshock 3.
  • D-pad moves, right analog controls aiming
  • X: change weapon, []: jump, R1: fire, L1: special ability, /\:use/activate
  • All menu navigation requires the mouse, which is disabled during normal game play.
Location:
abuse/trunk
Files:
15 added
5 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/AUTHORS

    r618 r731  
    66  Current code maintainer
    77  Debian package maintainer
     8
     9Jonathan Simpson <jjsimpso@gmail.com>
     10  SDL2 port
     11  Game controller support
    812
    913Anthony Kruize <trandor@labyrinth.net.au>
  • abuse/trunk/configure.ac

    r651 r731  
    5151
    5252dnl Check for SDL
    53 SDL_VERSION=1.1.6
    54 AM_PATH_SDL($SDL_VERSION, :,
    55     AC_MSG_ERROR([*** SDL version $SDL_VERSION or above not found!]))
     53SDL2_VERSION=2.0.0
     54SDL2_FOUND="no"
     55SDLPORT_DIR=sdl2port
     56AM_PATH_SDL2($SDL2_VERSION, SDL2_FOUND="yes",
     57    AC_MSG_ERROR([*** SDL2 version $SDL2_VERSION or above not found!]))
     58
     59if test $SDL2_FOUND = "no"; then
     60  SDL_VERSION=1.1.6
     61  SDLPORT_DIR=sdlport
     62  AM_PATH_SDL($SDL_VERSION, :,
     63      AC_MSG_ERROR([*** SDL version $SDL_VERSION or above not found!]))
     64fi
     65
    5666CFLAGS="$CFLAGS $SDL_CFLAGS"
    5767LIBS="$LIBS $SDL_LIBS $X_LIBS"
     68AC_SUBST(SDLPORT_DIR)
    5869
    5970dnl Check for SDL mixer
    60 ac_cv_my_have_sdl_mixer="no"
    61 save_CPPFLAGS="${CPPFLAGS}"
    62 CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
    63 AC_CHECK_HEADERS(SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
    64 CPPFLAGS="${save_CPPFLAGS}"
    65 if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
    66   AC_MSG_ERROR([*** SDL_mixer not found!])
    67 fi
    68 LIBS="$LIBS -lSDL_mixer"
     71if test $SDL2_FOUND = "yes"; then
     72  ac_cv_my_have_sdl_mixer="no"
     73  save_CPPFLAGS="${CPPFLAGS}"
     74  CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
     75  AC_CHECK_HEADERS(SDL2/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
     76  CPPFLAGS="${save_CPPFLAGS}"
     77  if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
     78    AC_MSG_ERROR([*** SDL_mixer not found!])
     79  fi
     80  LIBS="$LIBS -lSDL2_mixer"
     81else
     82  ac_cv_my_have_sdl_mixer="no"
     83  save_CPPFLAGS="${CPPFLAGS}"
     84  CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
     85  AC_CHECK_HEADERS(SDL/SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
     86  CPPFLAGS="${save_CPPFLAGS}"
     87  if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
     88    AC_MSG_ERROR([*** SDL_mixer not found!])
     89  fi
     90  LIBS="$LIBS -lSDL_mixer"
     91fi
    6992
    7093if test "${enable_debug}" = "yes"; then
     
    150173    src/net/Makefile
    151174    src/imlib/Makefile
    152     src/sdlport/Makefile
    153175    data/Makefile
    154176    doc/Makefile
     
    156178    doc/abuse-tool.6])
    157179
     180if test $SDL2_FOUND = "yes"; then
     181  AC_OUTPUT([src/sdl2port/Makefile])
     182else
     183  AC_OUTPUT([src/sdlport/Makefile])
     184fi
     185
     186if test $SDL2_FOUND = "yes"; then
     187echo "
     188------ Configuration for $PACKAGE $VERSION ------
     189    Compiler:          ${CC} (`${CC} --version | head -n 1`)
     190    Install prefix:    ${prefix}
     191    Asset directory:   ${with_assetdir}
     192    SDL version:       `sdl2-config --version`
     193
     194Now type 'make' to build $PACKAGE.
     195"
     196else
    158197echo "
    159198------ Configuration for $PACKAGE $VERSION ------
     
    166205Now type 'make' to build $PACKAGE.
    167206"
     207fi
  • abuse/trunk/src/Makefile.am

    r651 r731  
    11## Process this file with automake to produce Makefile.in
    22
    3 SUBDIRS = lisp net imlib sdlport
     3SUBDIRS = lisp net imlib @SDLPORT_DIR@
    44
    55bin_PROGRAMS = abuse abuse-tool
     
    6565    $(NULL)
    6666
    67 EXTRALIBS = lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a
     67EXTRALIBS = lisp/liblisp.a @SDLPORT_DIR@/libsdlport.a imlib/libimlib.a net/libnet.a
    6868abuse_LDADD = $(EXTRALIBS)
    6969abuse_DEPENDENCIES = $(EXTRALIBS)
     
    7575abuse_tool_DEPENDENCIES = $(abuse_tool_LDADD)
    7676
    77 INCLUDES = -I$(srcdir) -I$(srcdir)/lisp -I$(srcdir)/imlib \
     77INCLUDES = -I$(srcdir) -I $(srcdir)/lisp -I$(srcdir)/imlib \
    7878           -I$(srcdir)/net $(SDL_CFLAGS)
    7979
    8080CPPFLAGS = @CPPFLAGS@ -DNO_CHECK
    81 
  • abuse/trunk/src/imlib/event.h

    r682 r731  
    9090    }
    9191
     92  // To enable/disable game controller
     93  // enables switching between mouse and gamepad when entering certain screens
     94  // Added for SDL2 game controller support
     95  void enable_controller(bool enabled)
     96  {
     97      controller_enabled = enabled;
     98  }
     99
    92100private:
    93101    linked_list m_events;
     
    95103
    96104    image *m_screen;
     105    bool controller_enabled;
    97106
    98107protected:
  • abuse/trunk/src/loadgame.cpp

    r682 r731  
    243243    do
    244244    {
     245        // disable game controller during save/load screen so that mouse can be used
     246        wm->enable_controller(false);
     247       
    245248        wm->flush_screen();
    246249        wm->get_event(ev);
     
    259262    } while (!got_level && !quit);
    260263
     264    wm->enable_controller(true);
     265
    261266    wm->close_window(l_win);
    262267    wm->close_window(preview);
Note: See TracChangeset for help on using the changeset viewer.