mirror of https://github.com/mgba-emu/mgba.git
Expose rumble
This commit is contained in:
parent
2fde9738be
commit
e74b0125a7
|
@ -16,6 +16,8 @@ static unsigned _rtcBCD(unsigned value);
|
||||||
|
|
||||||
static void _gyroReadPins(struct GBACartridgeGPIO* gpio);
|
static void _gyroReadPins(struct GBACartridgeGPIO* gpio);
|
||||||
|
|
||||||
|
static void _rumbleReadPins(struct GBACartridgeGPIO* gpio);
|
||||||
|
|
||||||
static const int RTC_BYTES[8] = {
|
static const int RTC_BYTES[8] = {
|
||||||
0, // Force reset
|
0, // Force reset
|
||||||
0, // Empty
|
0, // Empty
|
||||||
|
@ -80,6 +82,10 @@ void _readPins(struct GBACartridgeGPIO* gpio) {
|
||||||
if (gpio->gpioDevices & GPIO_GYRO) {
|
if (gpio->gpioDevices & GPIO_GYRO) {
|
||||||
_gyroReadPins(gpio);
|
_gyroReadPins(gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gpio->gpioDevices & GPIO_RUMBLE) {
|
||||||
|
_rumbleReadPins(gpio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _outputPins(struct GBACartridgeGPIO* gpio, unsigned pins) {
|
void _outputPins(struct GBACartridgeGPIO* gpio, unsigned pins) {
|
||||||
|
@ -252,7 +258,6 @@ void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio) {
|
||||||
gpio->gyroEdge = 0;
|
gpio->gyroEdge = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _gyroReadPins(struct GBACartridgeGPIO* gpio) {
|
void _gyroReadPins(struct GBACartridgeGPIO* gpio) {
|
||||||
struct GBARotationSource* gyro = gpio->p->rotationSource;
|
struct GBARotationSource* gyro = gpio->p->rotationSource;
|
||||||
if (!gyro) {
|
if (!gyro) {
|
||||||
|
@ -278,3 +283,18 @@ void _gyroReadPins(struct GBACartridgeGPIO* gpio) {
|
||||||
|
|
||||||
gpio->gyroEdge = gpio->p1;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,10 @@ struct GBARTC {
|
||||||
uint8_t time[7];
|
uint8_t time[7];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GBARumble {
|
||||||
|
void (*setRumble)(struct GBARumble*, int enable);
|
||||||
|
};
|
||||||
|
|
||||||
struct GBACartridgeGPIO {
|
struct GBACartridgeGPIO {
|
||||||
struct GBA* p;
|
struct GBA* p;
|
||||||
int gpioDevices;
|
int gpioDevices;
|
||||||
|
@ -102,4 +106,6 @@ void GBAGPIOInitRTC(struct GBACartridgeGPIO* gpio);
|
||||||
|
|
||||||
void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio);
|
void GBAGPIOInitGyro(struct GBACartridgeGPIO* gpio);
|
||||||
|
|
||||||
|
void GBAGPIOInitRumble(struct GBACartridgeGPIO* gpio);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -534,6 +534,10 @@ void _checkOverrides(struct GBA* gba, uint32_t id) {
|
||||||
if (_overrides[i].gpio & GPIO_GYRO) {
|
if (_overrides[i].gpio & GPIO_GYRO) {
|
||||||
GBAGPIOInitGyro(&gba->memory.gpio);
|
GBAGPIOInitGyro(&gba->memory.gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_overrides[i].gpio & GPIO_RUMBLE) {
|
||||||
|
GBAGPIOInitRumble(&gba->memory.gpio);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ struct GBA {
|
||||||
int springIRQ;
|
int springIRQ;
|
||||||
int* keySource;
|
int* keySource;
|
||||||
struct GBARotationSource* rotationSource;
|
struct GBARotationSource* rotationSource;
|
||||||
|
struct GBARumble* rumble;
|
||||||
|
|
||||||
const char* activeFile;
|
const char* activeFile;
|
||||||
const char* savefile;
|
const char* savefile;
|
||||||
|
|
Loading…
Reference in New Issue