Skip to content

Commit

Permalink
rumble fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesofarrell committed Nov 4, 2019
1 parent a34f924 commit 9880daf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ DEFAULT_CFLAGS = -DGCW -DLINUX -O2 -mno-shared -Wall -DNDEBUG -I./bulletml \
#senquack TODO: remember to add WIZ define to Makefile
#LDFLAGS = -static `/usr/local/gp2xdev/bin/sdl-config --libs` -lpng -L. -lbulletml -lSDL_mixer -lSDL_image -lpng -mwindows -lstdc++ -lGL -lm -lpthread -lz -lpng -ljpeg -lgpu940 -lsmpeg -lvorbisidec `/usr/local/gp2xdev/bin/sdl-config --libs`
# -lglu32 -lopengl32 -lmingw32 -lmingwex
LDFLAGS = `/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/sdl-config --libs` -lGLESv1_CM -lEGL \
LDFLAGS = `/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/sdl-config --libs` -lGLESv1_CM -lEGL -lshake \
-L./bulletml/ -lbulletml -lSDL_mixer -lSDL_image -lstdc++ -lm -lpthread -lz

#MORE_CFLAGS = -DLINUX -O0 -Wall -g
Expand Down
53 changes: 46 additions & 7 deletions rr.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@
#include <unistd.h>
#include <fcntl.h>

#include <shake.h>


static int noSound = 0;

Shake_Device *device;
Shake_Effect r_effect, r_effect1;
int r_effect_id, r_effect_id1;



//senquack - modified code to store files in subdir, modified filenames:
Expand Down Expand Up @@ -402,6 +408,7 @@ quitLast ()
savePreference ();
closeFoes ();
closeBarragemanager ();
closeRumble ();
closeSDL ();
SDL_Quit ();
exit (1);
Expand Down Expand Up @@ -511,18 +518,49 @@ static void rumble (int frame)
if (rumble_level > 0 ) {
rumble_time = rumble_time - frame;
if (rumble_time > 0) {
if(!rumble_fd) {
rumble_fd = open("/dev/input/event1", O_RDWR);
}
Shake_Stop(device, r_effect_id);
Shake_Stop(device, r_effect_id1);
Shake_Play(device, r_effect_id);
Shake_Play(device, r_effect_id1);
return;
} else {
rumble_level = 0;
}
}
if(rumble_fd) {
close(rumble_fd);
rumble_fd = 0;
}
Shake_Stop(device, r_effect_id);
Shake_Stop(device, r_effect_id1);
}

static void initRumble () {
Shake_Init();
device = Shake_Open(0);

Shake_InitEffect(&r_effect, SHAKE_EFFECT_RUMBLE);
r_effect.u.rumble.strongMagnitude = SHAKE_RUMBLE_STRONG_MAGNITUDE_MAX;
r_effect.u.rumble.weakMagnitude = SHAKE_RUMBLE_STRONG_MAGNITUDE_MAX*0.9;
r_effect.length = 20;
r_effect.delay = 0;

r_effect_id = Shake_UploadEffect(device, &r_effect);

Shake_InitEffect(&r_effect1, SHAKE_EFFECT_RUMBLE);
r_effect1.u.rumble.strongMagnitude = SHAKE_RUMBLE_STRONG_MAGNITUDE_MAX;
r_effect1.u.rumble.weakMagnitude = SHAKE_RUMBLE_STRONG_MAGNITUDE_MAX*0.9;
r_effect1.length = 380;
r_effect1.delay = 0;

r_effect_id1 = Shake_UploadEffect(device, &r_effect1);

}

void closeRumble() {
Shake_Stop(device, r_effect_id);
Shake_Stop(device, r_effect_id1);

Shake_EraseEffect(device, r_effect_id);
Shake_EraseEffect(device, r_effect_id1);
Shake_Close(device);
Shake_Quit();
}


Expand Down Expand Up @@ -725,6 +763,7 @@ int main (int argc, char *argv[])

initDegutil ();
initSDL ();
initRumble ();
initFirst ();
initTitle ();

Expand Down

0 comments on commit 9880daf

Please sign in to comment.