- Added initial joystick support (*UNTESTED*)
- When generating a .app, the OSX version number is now included.
This commit is contained in:
parent
deee1d0a97
commit
198f98b387
12
Makefile
12
Makefile
|
@ -1,5 +1,3 @@
|
|||
LIBS = libs/libSDL-1.2.0.dylib libs/libSDL_image-1.2.0.dylib libs/libSDL_mixer-1.2.0.dylib libs/libSDL_ttf-2.0.0.dylib libs/libjpeg.62.dylib libs/libpng.3.dylib libs/libvorbisfile.3.dylib libs/libogg.0.dylib libs/libsmpeg-0.4.0.dylib libs/libmikmod.2.dylib libs/libvorbis.0.dylib libs/libSDL_gfx.dylib
|
||||
|
||||
all: rc edit
|
||||
|
||||
rc: rc.c shared.c rc.h shared.h globals.h defs.h
|
||||
|
@ -9,12 +7,4 @@ edit: edit.c shared.c edit.h shared.h globals.h defs.h
|
|||
gcc -D__EDITOR -Wall -o edit -g edit.c shared.c `sdl-config --cflags --libs` -I/usr/local/include -L/usr/local/lib -lSDLmain -lSDL -lSDL_image -lSDL_gfx -lSDL_ttf
|
||||
|
||||
app: rc
|
||||
if [ `uname -s` != "Darwin" ]; then echo "Mac .app bundle generation is only available under OSX."; exit 1; fi;
|
||||
if [ -d RatCatcher.app ]; then rm -fr RatCatcher.app ; fi
|
||||
# create staging area without svn files
|
||||
rsync -rC data/ staging/data
|
||||
platypus -a rc -t shell -o TextWindow -R -u "Rob Pearce" -f staging/data -f rc scripts/run.sh RatCatcher.app
|
||||
seticon -d icon.icns RatCatcher.app
|
||||
dylibbundler -od -b -x ./RatCatcher.app/Contents/Resources/rc -d ./RatCatcher.app/Contents/libs/ -p @executable_path/../libs/
|
||||
zip -r RatCatcher.zip RatCatcher.app
|
||||
|
||||
./makeapp.sh
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
if [ `uname -s` != "Darwin" ]; then echo "Mac .app bundle generation is only available under OSX."; exit 1; fi; osverfull=`sw_vers | head -2 | tail -1 | cut -f 2`
|
||||
osver=`echo ${osverfull} | sed -e 's/.[0-9]*$//'`
|
||||
appname=RatCatcher-${osver}.app
|
||||
zipname=RatCatcher-${osver}.zip
|
||||
|
||||
if [ -d ${appname} ]; then rm -fr ${appname} ; fi
|
||||
if [ -e ${zipname} ]; then rm -f ${zipname} ; fi
|
||||
# create staging area without svn files
|
||||
echo "Creating staging area without svn files..."
|
||||
rsync -rC data/ staging/data
|
||||
echo "Creating .app..."
|
||||
platypus -a rc -t shell -o TextWindow -R -u "Rob Pearce" -f staging/data -f rc scripts/run.sh ${appname}
|
||||
seticon -d icon.icns ${appname}
|
||||
echo "Relocating dylib symbols..."
|
||||
dylibbundler -od -b -x ./${appname}/Contents/Resources/rc -d ./${appname}/Contents/libs/ -p @executable_path/../libs/
|
||||
echo "Archiving..."
|
||||
zip -r ${zipname} ${appname}
|
||||
echo "Done."
|
39
rc.c
39
rc.c
|
@ -24,7 +24,9 @@ SDL_Surface *screen;
|
|||
|
||||
TTF_Font *font[MAXLETTERHEIGHT];
|
||||
|
||||
SDL_Joystick *joy;
|
||||
Uint8 *keys;
|
||||
int joyx,joyy,joybut[2];
|
||||
|
||||
Mix_Music *curmusic = NULL; // pointer to currently playing music
|
||||
|
||||
|
@ -5537,6 +5539,16 @@ void initsdl(void) {
|
|||
exit(1);
|
||||
}
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
// find joysticks
|
||||
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
|
||||
joy = SDL_JoystickOpen(0);
|
||||
if (joy) {
|
||||
printf("Joystick detected and enabled.\n");
|
||||
SDL_JoystickEventState(SDL_ENABLE);
|
||||
} else {
|
||||
printf("No joysticks found.\n");
|
||||
}
|
||||
}
|
||||
|
||||
// player collects the given fruit
|
||||
|
@ -6265,10 +6277,22 @@ int getcardvalue(int cardid) {
|
|||
|
||||
|
||||
void handleinput(void) {
|
||||
int i;
|
||||
|
||||
/* check for keys */
|
||||
SDL_PumpEvents();
|
||||
keys = SDL_GetKeyState(NULL);
|
||||
|
||||
// check for joystick
|
||||
if (joy) {
|
||||
joyx = SDL_JoystickGetAxis(joy,0);
|
||||
joyy = SDL_JoystickGetAxis(joy,1);
|
||||
for (i = 0; i < 2; i++) {
|
||||
joybut[i] = SDL_JoystickGetButton(joy,i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************************************************************
|
||||
These keys can always be pressed
|
||||
|
@ -6591,7 +6615,20 @@ int keydown(int checkfor) {
|
|||
if (keys[checkfor]) {
|
||||
return B_TRUE;
|
||||
}
|
||||
// TODO: check for joystick
|
||||
// check for joystick
|
||||
if ((checkfor == SDLK_RIGHT) && (joyx >= 6000)) {
|
||||
return B_TRUE;
|
||||
} else if ((checkfor == SDLK_LEFT) && (joyx <= -6000)) {
|
||||
return B_TRUE;
|
||||
} else if ((checkfor == SDLK_UP) && (joyy <= -6000)) {
|
||||
return B_TRUE;
|
||||
} else if ((checkfor == SDLK_DOWN) && (joyy >= 6000)) {
|
||||
return B_TRUE;
|
||||
} else if ((checkfor == SDLK_z) && (joybut[0])) {
|
||||
return B_TRUE;
|
||||
} else if ((checkfor == SDLK_x) && (joybut[1])) {
|
||||
return B_TRUE;
|
||||
}
|
||||
|
||||
return B_FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue