mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-03-06 21:00:31 +01:00
Fix Motion Pak emulation axes
This commit is contained in:
parent
10c308a6a4
commit
b6ff439708
2 changed files with 26 additions and 3 deletions
|
@ -113,7 +113,8 @@ u8 CartMotionPakHomebrew::SRAMRead(u32 addr)
|
|||
return 0;
|
||||
case 8:
|
||||
// Read Z rotation
|
||||
ShiftVal = RotationToMotionPak(Platform::Addon_MotionQuery(Platform::MotionRotationZ, UserData)) << 4;
|
||||
// CHECKME: This is a guess, compare with real hardware
|
||||
ShiftVal = RotationToMotionPak(-Platform::Addon_MotionQuery(Platform::MotionRotationZ, UserData)) << 4;
|
||||
return 0;
|
||||
case 10:
|
||||
// Identify cart
|
||||
|
|
|
@ -144,13 +144,35 @@ float EmuInstance::inputMotionQuery(melonDS::Platform::MotionQueryType type)
|
|||
{
|
||||
if (controller && hasAccelerometer)
|
||||
if (SDL_GameControllerGetSensorData(controller, SDL_SENSOR_ACCEL, values, 3) == 0)
|
||||
return values[type % 3];
|
||||
{
|
||||
// Map values from DS console orientation to SDL controller orientation.
|
||||
switch (type)
|
||||
{
|
||||
case melonDS::Platform::MotionAccelerationX:
|
||||
return values[0];
|
||||
case melonDS::Platform::MotionAccelerationY:
|
||||
return -values[2];
|
||||
case melonDS::Platform::MotionAccelerationZ:
|
||||
return values[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (type <= melonDS::Platform::MotionRotationZ)
|
||||
{
|
||||
if (controller && hasGyroscope)
|
||||
if (SDL_GameControllerGetSensorData(controller, SDL_SENSOR_GYRO, values, 3) == 0)
|
||||
return values[type % 3];
|
||||
{
|
||||
// Map values from DS console orientation to SDL controller orientation.
|
||||
switch (type)
|
||||
{
|
||||
case melonDS::Platform::MotionRotationX:
|
||||
return values[0];
|
||||
case melonDS::Platform::MotionRotationY:
|
||||
return -values[2];
|
||||
case melonDS::Platform::MotionRotationZ:
|
||||
return values[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue