mirror of https://github.com/mgba-emu/mgba.git
Core: Split out semantics of rumble integrator init/reset (fixes #3309)
This commit is contained in:
parent
5fb7c5e3ee
commit
7950279a09
|
@ -133,6 +133,7 @@ struct mRumbleIntegrator {
|
||||||
};
|
};
|
||||||
|
|
||||||
void mRumbleIntegratorInit(struct mRumbleIntegrator*);
|
void mRumbleIntegratorInit(struct mRumbleIntegrator*);
|
||||||
|
void mRumbleIntegratorReset(struct mRumbleIntegrator*);
|
||||||
|
|
||||||
struct mCoreChannelInfo {
|
struct mCoreChannelInfo {
|
||||||
size_t id;
|
size_t id;
|
||||||
|
|
|
@ -110,14 +110,14 @@ void mRTCGenericSourceInit(struct mRTCGenericSource* rtc, struct mCore* core) {
|
||||||
rtc->d.deserialize = _rtcGenericDeserialize;
|
rtc->d.deserialize = _rtcGenericDeserialize;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mRumbleIntegratorReset(struct mRumble* rumble, bool enable) {
|
static void _mRumbleIntegratorReset(struct mRumble* rumble, bool enable) {
|
||||||
struct mRumbleIntegrator* integrator = (struct mRumbleIntegrator*) rumble;
|
struct mRumbleIntegrator* integrator = (struct mRumbleIntegrator*) rumble;
|
||||||
integrator->state = enable;
|
integrator->state = enable;
|
||||||
integrator->timeOn = 0;
|
integrator->timeOn = 0;
|
||||||
integrator->totalTime = 0;
|
integrator->totalTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mRumbleIntegratorSetRumble(struct mRumble* rumble, bool enable, uint32_t sinceLast) {
|
static void _mRumbleIntegratorSetRumble(struct mRumble* rumble, bool enable, uint32_t sinceLast) {
|
||||||
struct mRumbleIntegrator* integrator = (struct mRumbleIntegrator*) rumble;
|
struct mRumbleIntegrator* integrator = (struct mRumbleIntegrator*) rumble;
|
||||||
|
|
||||||
if (integrator->state) {
|
if (integrator->state) {
|
||||||
|
@ -127,7 +127,7 @@ static void mRumbleIntegratorSetRumble(struct mRumble* rumble, bool enable, uint
|
||||||
integrator->state = enable;
|
integrator->state = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mRumbleIntegratorIntegrate(struct mRumble* rumble, uint32_t period) {
|
static void _mRumbleIntegratorIntegrate(struct mRumble* rumble, uint32_t period) {
|
||||||
if (!period) {
|
if (!period) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,11 @@ static void mRumbleIntegratorIntegrate(struct mRumble* rumble, uint32_t period)
|
||||||
|
|
||||||
void mRumbleIntegratorInit(struct mRumbleIntegrator* integrator) {
|
void mRumbleIntegratorInit(struct mRumbleIntegrator* integrator) {
|
||||||
memset(integrator, 0, sizeof(*integrator));
|
memset(integrator, 0, sizeof(*integrator));
|
||||||
integrator->d.reset = mRumbleIntegratorReset;
|
integrator->d.reset = _mRumbleIntegratorReset;
|
||||||
integrator->d.setRumble = mRumbleIntegratorSetRumble;
|
integrator->d.setRumble = _mRumbleIntegratorSetRumble;
|
||||||
integrator->d.integrate = mRumbleIntegratorIntegrate;
|
integrator->d.integrate = _mRumbleIntegratorIntegrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mRumbleIntegratorReset(struct mRumbleIntegrator* integrator) {
|
||||||
|
_mRumbleIntegratorReset(&integrator->d, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -834,7 +834,7 @@ static void _setupMaps(struct mCore* core) {
|
||||||
|
|
||||||
void retro_reset(void) {
|
void retro_reset(void) {
|
||||||
core->reset(core);
|
core->reset(core);
|
||||||
mRumbleIntegratorInit(&rumble);
|
mRumbleIntegratorReset(&rumble);
|
||||||
_setupMaps(core);
|
_setupMaps(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ static void _setup(struct mGUIRunner* runner) {
|
||||||
}
|
}
|
||||||
_updateRenderer(runner, fakeBool);
|
_updateRenderer(runner, fakeBool);
|
||||||
|
|
||||||
mRumbleIntegratorInit(&rumble.d);
|
mRumbleIntegratorReset(&rumble.d);
|
||||||
runner->core->setPeripheral(runner->core, mPERIPH_RUMBLE, &rumble.d.d);
|
runner->core->setPeripheral(runner->core, mPERIPH_RUMBLE, &rumble.d.d);
|
||||||
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
runner->core->setPeripheral(runner->core, mPERIPH_ROTATION, &rotation);
|
||||||
runner->core->setAVStream(runner->core, &stream);
|
runner->core->setAVStream(runner->core, &stream);
|
||||||
|
@ -363,13 +363,10 @@ static void _gameLoaded(struct mGUIRunner* runner) {
|
||||||
runner->core->reloadConfigOption(runner->core, "videoScale", &runner->config);
|
runner->core->reloadConfigOption(runner->core, "videoScale", &runner->config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mRumbleIntegratorInit(&rumble.d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _gameUnloaded(struct mGUIRunner* runner) {
|
static void _gameUnloaded(struct mGUIRunner* runner) {
|
||||||
UNUSED(runner);
|
UNUSED(runner);
|
||||||
mRumbleIntegratorInit(&rumble.d);
|
|
||||||
HidVibrationValue values[4];
|
HidVibrationValue values[4];
|
||||||
memcpy(&values[0], &vibrationStop, sizeof(rumble.value));
|
memcpy(&values[0], &vibrationStop, sizeof(rumble.value));
|
||||||
memcpy(&values[1], &vibrationStop, sizeof(rumble.value));
|
memcpy(&values[1], &vibrationStop, sizeof(rumble.value));
|
||||||
|
@ -812,6 +809,7 @@ static void hidSetup(void) {
|
||||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||||
padInitializeDefault(&pad);
|
padInitializeDefault(&pad);
|
||||||
|
|
||||||
|
mRumbleIntegratorInit(&rumble.d);
|
||||||
rumble.d.setRumble = _setRumble;
|
rumble.d.setRumble = _setRumble;
|
||||||
rumble.value.freq_low = 120.0;
|
rumble.value.freq_low = 120.0;
|
||||||
rumble.value.freq_high = 180.0;
|
rumble.value.freq_high = 180.0;
|
||||||
|
|
Loading…
Reference in New Issue