all repos — mgba @ e74b0125a775173515a93b710b66bd7c32ebab0c

mGBA Game Boy Advance Emulator

Expose rumble
Jeffrey Pfau jeffrey@endrift.com
Mon, 21 Oct 2013 21:50:29 -0700
commit

e74b0125a775173515a93b710b66bd7c32ebab0c

parent

2fde9738bef25e0cd097dba87a82096040ab2c6c

4 files changed, 32 insertions(+), 1 deletions(-)

jump to
M src/gba/gba-gpio.csrc/gba/gba-gpio.c

@@ -16,6 +16,8 @@ static unsigned _rtcBCD(unsigned value);

static void _gyroReadPins(struct GBACartridgeGPIO* gpio); +static void _rumbleReadPins(struct GBACartridgeGPIO* gpio); + static const int RTC_BYTES[8] = { 0, // Force reset 0, // Empty

@@ -79,6 +81,10 @@ }

if (gpio->gpioDevices & GPIO_GYRO) { _gyroReadPins(gpio); + } + + if (gpio->gpioDevices & GPIO_RUMBLE) { + _rumbleReadPins(gpio); } }

@@ -252,7 +258,6 @@ gpio->gyroSample = 0;

gpio->gyroEdge = 0; } - void _gyroReadPins(struct GBACartridgeGPIO* gpio) { struct GBARotationSource* gyro = gpio->p->rotationSource; if (!gyro) {

@@ -278,3 +283,18 @@ }

gpio->gyroEdge = gpio->p1; } + +// == Rumble + +void GBAGPIOInitRumble(struct GBACartridgeGPIO* gpio) { + gpio->gpioDevices |= GPIO_RUMBLE; +} + +void _rumbleReadPins(struct GBACartridgeGPIO* gpio) { + struct GBARumble* rumble = gpio->p->rumble; + if (!rumble) { + return; + } + + rumble->setRumble(rumble, gpio->p3); +}
M src/gba/gba-gpio.hsrc/gba/gba-gpio.h

@@ -63,6 +63,10 @@ union RTCControl control;

uint8_t time[7]; }; +struct GBARumble { + void (*setRumble)(struct GBARumble*, int enable); +}; + struct GBACartridgeGPIO { struct GBA* p; int gpioDevices;

@@ -101,5 +105,7 @@

void GBAGPIOInitRTC(struct GBACartridgeGPIO* gpio); void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio); + +void GBAGPIOInitRumble(struct GBACartridgeGPIO* gpio); #endif
M src/gba/gba.csrc/gba/gba.c

@@ -534,6 +534,10 @@

if (_overrides[i].gpio & GPIO_GYRO) { GBAGPIOInitGyro(&gba->memory.gpio); } + + if (_overrides[i].gpio & GPIO_RUMBLE) { + GBAGPIOInitRumble(&gba->memory.gpio); + } return; } }
M src/gba/gba.hsrc/gba/gba.h

@@ -88,6 +88,7 @@

int springIRQ; int* keySource; struct GBARotationSource* rotationSource; + struct GBARumble* rumble; const char* activeFile; const char* savefile;