Expose rumble

This commit is contained in:
Jeffrey Pfau 2013-10-21 21:50:29 -07:00
parent 2fde9738be
commit e74b0125a7
4 changed files with 32 additions and 1 deletions

View File

@ -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
@ -80,6 +82,10 @@ void _readPins(struct GBACartridgeGPIO* gpio) {
if (gpio->gpioDevices & GPIO_GYRO) {
_gyroReadPins(gpio);
}
if (gpio->gpioDevices & GPIO_RUMBLE) {
_rumbleReadPins(gpio);
}
}
void _outputPins(struct GBACartridgeGPIO* gpio, unsigned pins) {
@ -252,7 +258,6 @@ void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio) {
gpio->gyroEdge = 0;
}
void _gyroReadPins(struct GBACartridgeGPIO* gpio) {
struct GBARotationSource* gyro = gpio->p->rotationSource;
if (!gyro) {
@ -278,3 +283,18 @@ void _gyroReadPins(struct GBACartridgeGPIO* gpio) {
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);
}

View File

@ -63,6 +63,10 @@ struct GBARTC {
uint8_t time[7];
};
struct GBARumble {
void (*setRumble)(struct GBARumble*, int enable);
};
struct GBACartridgeGPIO {
struct GBA* p;
int gpioDevices;
@ -102,4 +106,6 @@ void GBAGPIOInitRTC(struct GBACartridgeGPIO* gpio);
void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio);
void GBAGPIOInitRumble(struct GBACartridgeGPIO* gpio);
#endif

View File

@ -534,6 +534,10 @@ void _checkOverrides(struct GBA* gba, uint32_t id) {
if (_overrides[i].gpio & GPIO_GYRO) {
GBAGPIOInitGyro(&gba->memory.gpio);
}
if (_overrides[i].gpio & GPIO_RUMBLE) {
GBAGPIOInitRumble(&gba->memory.gpio);
}
return;
}
}

View File

@ -88,6 +88,7 @@ struct GBA {
int springIRQ;
int* keySource;
struct GBARotationSource* rotationSource;
struct GBARumble* rumble;
const char* activeFile;
const char* savefile;