mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Remove the last use of accelerometer axis events (calibration)
This commit is contained in:
parent
8baae83136
commit
3b004e7a4b
@ -19,6 +19,12 @@ static u32 tiltButtonsDown = 0;
|
||||
float rawTiltAnalogX;
|
||||
float rawTiltAnalogY;
|
||||
|
||||
float g_currentYAngle = 0.0f;
|
||||
|
||||
float GetCurrentYAngle() {
|
||||
return g_currentYAngle;
|
||||
}
|
||||
|
||||
// These functions generate tilt events given the current Tilt amount,
|
||||
// and the deadzone radius.
|
||||
void GenerateAnalogStickEvent(float analogX, float analogY);
|
||||
@ -73,6 +79,7 @@ void ProcessTilt(bool landscape, float calibrationAngle, float x, float y, float
|
||||
Lin::Vec3 down = Lin::Vec3(x, y, z).normalized();
|
||||
|
||||
float angleAroundX = atan2(down.z, down.y);
|
||||
g_currentYAngle = angleAroundX; // TODO: Should smooth this out over time a bit.
|
||||
float yAngle = angleAroundX - calibrationAngle;
|
||||
float xAngle = asinf(down.x);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/Math/lin/vec3.h"
|
||||
|
||||
namespace TiltEventProcessor {
|
||||
|
||||
// generates a tilt in the correct coordinate system based on
|
||||
@ -7,6 +9,8 @@ namespace TiltEventProcessor {
|
||||
void ProcessTilt(bool landscape, const float calibrationAngle, float x, float y, float z, bool invertX, bool invertY, float xSensitivity, float ySensitivity);
|
||||
void ResetTiltEvents();
|
||||
|
||||
float GetCurrentYAngle();
|
||||
|
||||
// Lets you preview the amount of tilt in TiltAnalogSettingsScreen.
|
||||
extern float rawTiltAnalogX;
|
||||
extern float rawTiltAnalogY;
|
||||
|
@ -137,22 +137,8 @@ void TiltAnalogSettingsScreen::CreateViews() {
|
||||
settings->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
}
|
||||
|
||||
void TiltAnalogSettingsScreen::axis(const AxisInput &axis) {
|
||||
UIDialogScreenWithGameBackground::axis(axis);
|
||||
|
||||
if (axis.deviceId == DEVICE_ID_ACCELEROMETER) {
|
||||
switch (axis.axisId) {
|
||||
case JOYSTICK_AXIS_ACCELEROMETER_X: down_.x = axis.value; break;
|
||||
case JOYSTICK_AXIS_ACCELEROMETER_Y: down_.y = axis.value; break;
|
||||
case JOYSTICK_AXIS_ACCELEROMETER_Z: down_.z = axis.value; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UI::EventReturn TiltAnalogSettingsScreen::OnCalibrate(UI::EventParams &e) {
|
||||
Lin::Vec3 down = down_.normalized();
|
||||
g_Config.fTiltBaseAngleY = atan2(down.z, down.x);
|
||||
g_Config.fTiltBaseAngleY = TiltEventProcessor::GetCurrentYAngle();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ public:
|
||||
TiltAnalogSettingsScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
||||
|
||||
void CreateViews() override;
|
||||
void axis(const AxisInput &axis) override;
|
||||
void update() override;
|
||||
const char *tag() const override { return "TiltAnalogSettings"; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user