Wii: Add adjustable gyroscope settings (closes #2245)

This commit is contained in:
Vicki Pfau 2021-10-12 14:33:55 -07:00
parent a7ad0e61e2
commit 2ef08d8d09
2 changed files with 25 additions and 3 deletions

View File

@ -14,6 +14,8 @@ Other fixes:
- Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281) - Libretro: Fix crash when using Game Boy codes (fixes mgba.io/i/2281)
- Qt: Remove potentially deadlocking optimization - Qt: Remove potentially deadlocking optimization
- Qt: Fix corrupted savestate and fatal error text - Qt: Fix corrupted savestate and fatal error text
Misc:
- Wii: Add adjustable gyroscope settings (closes mgba.io/i/2245)
0.9.2: (2021-07-10) 0.9.2: (2021-07-10)
Emulation fixes: Emulation fixes:

View File

@ -43,7 +43,7 @@
#define ANALOG_DEADZONE 0x30 #define ANALOG_DEADZONE 0x30
static void _mapKey(struct mInputMap* map, uint32_t binding, int nativeKey, enum GBAKey key) { static void _mapKey(struct mInputMap* map, uint32_t binding, int nativeKey, int key) {
mInputBindKey(map, binding, __builtin_ctz(nativeKey), key); mInputBindKey(map, binding, __builtin_ctz(nativeKey), key);
} }
@ -124,6 +124,7 @@ static bool sgbCrop = false;
static int32_t tiltX; static int32_t tiltX;
static int32_t tiltY; static int32_t tiltY;
static int32_t gyroZ; static int32_t gyroZ;
static float gyroSensitivity = 1.f;
static uint32_t retraceCount; static uint32_t retraceCount;
static uint32_t referenceRetraceCount; static uint32_t referenceRetraceCount;
static bool frameLimiter = true; static bool frameLimiter = true;
@ -564,8 +565,26 @@ int main(int argc, char* argv[]) {
}, },
.nStates = 8 .nStates = 8
}, },
{
.title = "Gyroscope sensitivity",
.data = GUI_V_S("gyroSensitivity"),
.submenu = 0,
.state = 0,
.validStates = (const char*[]) {
"1x", "1x flipped", "2x", "2x flipped", "1/2x", "1/2x flipped"
},
.stateMappings = (const struct GUIVariant[]) {
GUI_V_F(1.f),
GUI_V_F(-1.f),
GUI_V_F(2.f),
GUI_V_F(-2.f),
GUI_V_F(0.5f),
GUI_V_F(-0.5f),
},
.nStates = 6
},
}, },
.nConfigExtra = 5, .nConfigExtra = 6,
.setup = _setup, .setup = _setup,
.teardown = 0, .teardown = 0,
.gameLoaded = _gameLoaded, .gameLoaded = _gameLoaded,
@ -976,6 +995,7 @@ void _unpaused(struct mGUIRunner* runner) {
if (mCoreConfigGetFloatValue(&runner->config, "stretchHeight", &stretch)) { if (mCoreConfigGetFloatValue(&runner->config, "stretchHeight", &stretch)) {
hStretch = fminf(1.0f, fmaxf(0.5f, stretch)); hStretch = fminf(1.0f, fmaxf(0.5f, stretch));
} }
mCoreConfigGetFloatValue(&runner->config, "gyroSensitivity", &gyroSensitivity);
} }
void _prepareForFrame(struct mGUIRunner* runner) { void _prepareForFrame(struct mGUIRunner* runner) {
@ -1220,7 +1240,7 @@ int32_t _readTiltY(struct mRotationSource* source) {
int32_t _readGyroZ(struct mRotationSource* source) { int32_t _readGyroZ(struct mRotationSource* source) {
UNUSED(source); UNUSED(source);
return gyroZ; return gyroZ * gyroSensitivity;
} }
static s8 WPAD_StickX(u8 chan, u8 right) { static s8 WPAD_StickX(u8 chan, u8 right) {