From: <pa...@us...> - 2003-10-07 13:49:09
|
Update of /cvsroot/fuse-emulator/fuse/ui/svga In directory sc8-pr-cvs1:/tmp/cvs-serv31876/ui/svga Modified Files: Makefile.am Added Files: svgajoystick.c Log Message: Real joystick support (Darren/Fred) --- NEW FILE: svgajoystick.c --- /* svgajoystick.c: Joystick emulation (using svgalib) Copyright (c) 2003 Darren Salt $Id: svgajoystick.c,v 1.1 2003/10/07 13:49:01 pak21 Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Author contact information: E-mail: pak...@sr... Postal address: 15 Crescent Road, Wokingham, Berks, RG40 2DB, England Darren: li...@yo... */ #include <config.h> #ifdef UI_SVGA /* Use this iff we're using svgalib */ #if !defined USE_JOYSTICK || defined HAVE_JSW_H /* Fake joystick, or override UI-specific handling */ #include "../uijoystick.c" #else /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ /* Use the svgalib joystick support */ #include <string.h> #include <errno.h> #include <libspectrum.h> #include <vgajoystick.h> #include "fuse.h" #include "joystick.h" #include "keyboard.h" #include "settings.h" #include "spectrum.h" #include "machine.h" #include "ui/ui.h" static int init_stick( int which ) { if( !joystick_init( which, JOY_CALIB_STDOUT ) ) { ui_error( UI_ERROR_ERROR, "failed to initialise joystick %i: %s", which + 1, errno ? strerror (errno) : "not configured?" ); return 1; } if( joystick_getnumaxes( which ) < 2 || joystick_getnumbuttons( which ) < 1 ) { joystick_close( which ); ui_error( UI_ERROR_ERROR, "sorry, joystick %i is inadequate!", which + 1 ); return 1; } return 0; } int ui_joystick_init( void ) { /* If we can't init the first, don't try the second */ if( init_stick( 0 ) ) return 0; if( init_stick( 1 ) ) return 1; return 2; } int ui_joystick_end( void ) { joystick_close( -1 ); return 0; } BYTE ui_joystick_read( WORD port, BYTE which ) { BYTE ret = 0; int x, y; joystick_update(); x = joystick_x( which ); y = joystick_y( which ); if( x > 0 ) ret |= 1; /* right */ else if( x < 0 ) ret |= 2; /* left */ if( y > 0 ) ret |= 4; /* down */ else if( y < 0 ) ret |= 8; /* up */ if( joystick_button1( which ) ) ret |= 16; /* fire */ return ret; } #endif /* #if !defined USE_JOYSTICK || defined HAVE_JSW_H */ #endif /* #ifdef UI_SVGA */ Index: Makefile.am =================================================================== RCS file: /cvsroot/fuse-emulator/fuse/ui/svga/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.am 2 Apr 2003 12:44:24 -0000 1.5 --- Makefile.am 7 Oct 2003 13:49:01 -0000 1.6 *************** *** 29,33 **** INCLUDES = @GLIB_CFLAGS@ @LIBSPEC_CFLAGS@ ! libuisvga_a_SOURCES = error.c svgadisplay.c svgakeyboard.c svgaui.c keysyms.c BUILT_SOURCES = keysyms.c --- 29,38 ---- INCLUDES = @GLIB_CFLAGS@ @LIBSPEC_CFLAGS@ ! libuisvga_a_SOURCES = error.c \ ! svgadisplay.c \ ! svgajoystick.c \ ! svgakeyboard.c \ ! svgaui.c \ ! keysyms.c BUILT_SOURCES = keysyms.c |