mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Auto switch option
This commit is contained in:
parent
d79b451188
commit
a56e56cf53
@ -857,7 +857,7 @@ static ConfigSetting controlSettings[] = {
|
||||
#ifdef MOBILE_DEVICE
|
||||
ConfigSetting("TiltBaseX", &g_Config.fTiltBaseX, 0.0f, true, true),
|
||||
ConfigSetting("TiltBaseY", &g_Config.fTiltBaseY, 0.0f, true, true),
|
||||
ConfigSetting("TiltVertical", &g_Config.TiltVertical, false, true, true),
|
||||
ConfigSetting("TiltOrientation", &g_Config.iTiltOrientation, 0, true, true),
|
||||
ConfigSetting("InvertTiltX", &g_Config.bInvertTiltX, false, true, true),
|
||||
ConfigSetting("InvertTiltY", &g_Config.bInvertTiltY, true, true, true),
|
||||
ConfigSetting("TiltSensitivityX", &g_Config.iTiltSensitivityX, 100, true, true),
|
||||
|
@ -266,8 +266,7 @@ public:
|
||||
//the base x and y tilt. this inclination is treated as (0,0) and the tilt input
|
||||
//considers this orientation to be equal to no movement of the analog stick.
|
||||
float fTiltBaseX, fTiltBaseY;
|
||||
//tilt vertically will use Z accelerometer axis as X (X would require phone on flat plane)
|
||||
bool TiltVertical;
|
||||
int iTiltOrientation;
|
||||
//whether the x axes and y axes should invert directions (left becomes right, top becomes bottom.)
|
||||
bool bInvertTiltX, bInvertTiltY;
|
||||
//the sensitivity of the tilt in the x direction
|
||||
|
@ -1260,6 +1260,13 @@ bool NativeAxis(const AxisInput &axis) {
|
||||
// This is static, since we need to remember where we last were (in terms of orientation)
|
||||
static Tilt currentTilt;
|
||||
|
||||
// tilt on x or y?
|
||||
static bool TiltVertical;
|
||||
if (g_Config.iTiltOrientation == 0)
|
||||
TiltVertical = false;
|
||||
else if (g_Config.iTiltOrientation == 1)
|
||||
TiltVertical = true;
|
||||
|
||||
// x and y are flipped if we are in landscape orientation. The events are
|
||||
// sent with respect to the portrait coordinate system, while we
|
||||
// take all events in landscape.
|
||||
@ -1268,8 +1275,12 @@ bool NativeAxis(const AxisInput &axis) {
|
||||
switch (axis.axisId) {
|
||||
//TODO: make this generic.
|
||||
case JOYSTICK_AXIS_ACCELEROMETER_X:
|
||||
if (g_Config.TiltVertical) // use Z axis instead
|
||||
return false;
|
||||
if (TiltVertical) {
|
||||
if (fabs(axis.value) < 0.8f && g_Config.iTiltOrientation == 2) // Auto tilt switch
|
||||
TiltVertical = false;
|
||||
else
|
||||
return false; // Tilt on Z instead
|
||||
}
|
||||
if (portrait) {
|
||||
currentTilt.x_ = axis.value;
|
||||
} else {
|
||||
@ -1286,12 +1297,16 @@ bool NativeAxis(const AxisInput &axis) {
|
||||
break;
|
||||
|
||||
case JOYSTICK_AXIS_ACCELEROMETER_Z:
|
||||
if (!g_Config.TiltVertical) // use X axis instead
|
||||
return false;
|
||||
if (!TiltVertical) {
|
||||
if (fabs(axis.value) < 0.8f && g_Config.iTiltOrientation == 2) // Auto tilt switch
|
||||
TiltVertical = true;
|
||||
else
|
||||
return false; // Tilt on X instead
|
||||
}
|
||||
if (portrait) {
|
||||
currentTilt.x_ = axis.value;
|
||||
currentTilt.x_ = -axis.value;
|
||||
} else {
|
||||
currentTilt.y_ = axis.value;
|
||||
currentTilt.y_ = -axis.value;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -35,7 +35,8 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
||||
settings->Add(new ItemHeader(co->T("Invert Axes")));
|
||||
settings->Add(new CheckBox(&g_Config.bInvertTiltX, co->T("Invert Tilt along X axis")));
|
||||
settings->Add(new CheckBox(&g_Config.bInvertTiltY, co->T("Invert Tilt along Y axis")));
|
||||
settings->Add(new CheckBox(&g_Config.TiltVertical, co->T("Tilt along Z axis instead of X")));
|
||||
static const char* tiltMode[] = { "Screen parallel to ground", "Screen orthogonal to ground", "Auto-switch" };
|
||||
settings->Add(new PopupMultiChoice(&g_Config.iTiltOrientation, co->T("Base tilt position"), tiltMode, 0, ARRAY_SIZE(tiltMode), co->GetName(), screenManager()));
|
||||
|
||||
settings->Add(new ItemHeader(co->T("Sensitivity")));
|
||||
//TODO: allow values greater than 100? I'm not sure if that's needed.
|
||||
|
Loading…
Reference in New Issue
Block a user