mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
Fix Motion Pak emulation axes
This commit is contained in:
parent
f9a426bba6
commit
742cff5dbc
@ -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
|
||||
|
@ -140,13 +140,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…
Reference in New Issue
Block a user