Auto rotating analog
This commit is contained in:
parent
edbd01807b
commit
45da319ce7
11 changed files with 77 additions and 2 deletions
|
@ -700,6 +700,7 @@ const KeyMap_IntStrPair psp_button_names[] = {
|
|||
{VIRTKEY_TEXTURE_REPLACE, "Texture Replacement"},
|
||||
{VIRTKEY_SCREENSHOT, "Screenshot"},
|
||||
{VIRTKEY_MUTE_TOGGLE, "Mute toggle"},
|
||||
{VIRTKEY_ANALOG_ROTATE, "Auto Rotate Analog"},
|
||||
|
||||
{CTRL_HOME, "Home"},
|
||||
{CTRL_HOLD, "Hold"},
|
||||
|
|
|
@ -59,6 +59,7 @@ enum {
|
|||
VIRTKEY_SCREENSHOT = 0x4000001B,
|
||||
VIRTKEY_MUTE_TOGGLE = 0x4000001C,
|
||||
VIRTKEY_OPENCHAT = 0x4000001D,
|
||||
VIRTKEY_ANALOG_ROTATE = 0x4000001E,
|
||||
VIRTKEY_LAST,
|
||||
VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST
|
||||
};
|
||||
|
|
|
@ -866,6 +866,7 @@ static ConfigSetting controlSettings[] = {
|
|||
ConfigSetting("TouchButtonOpacity", &g_Config.iTouchButtonOpacity, 65, true, true),
|
||||
ConfigSetting("TouchButtonHideSeconds", &g_Config.iTouchButtonHideSeconds, 20, true, true),
|
||||
ConfigSetting("AutoCenterTouchAnalog", &g_Config.bAutoCenterTouchAnalog, false, true, true),
|
||||
ConfigSetting("AnalogAutoRotSpeed", &g_Config.fAnalogAutoRotSpeed, 15.0f, true, true),
|
||||
|
||||
// Snap touch control position
|
||||
ConfigSetting("TouchSnapToGrid", &g_Config.bTouchSnapToGrid, false, true, true),
|
||||
|
@ -894,6 +895,7 @@ static ConfigSetting controlSettings[] = {
|
|||
ConfigSetting("Speed1KeyX", "Speed1KeyY", "Speed1KeyScale", "ShowSpeed1Key", &g_Config.touchSpeed1Key, defaultTouchPosHide, true, true),
|
||||
ConfigSetting("Speed2KeyX", "Speed2KeyY", "Speed2KeyScale", "ShowSpeed2Key", &g_Config.touchSpeed2Key, defaultTouchPosHide, true, true),
|
||||
ConfigSetting("RapidFireKeyX", "RapidFireKeyY", "RapidFireKeyScale", "ShowRapidFireKey", &g_Config.touchRapidFireKey, defaultTouchPosHide, true, true),
|
||||
ConfigSetting("AnalogRotationKeyX", "AnalogRotationKeyY", "AnalogRotationKeyScale", "ShowAnalogRotationKey", &g_Config.touchAnalogRotationKey, defaultTouchPosHide, true, true),
|
||||
|
||||
#ifdef _WIN32
|
||||
ConfigSetting("DInputAnalogDeadzone", &g_Config.fDInputAnalogDeadzone, 0.1f, true, true),
|
||||
|
@ -1629,6 +1631,7 @@ void Config::ResetControlLayout() {
|
|||
reset(g_Config.touchSpeed1Key);
|
||||
reset(g_Config.touchSpeed2Key);
|
||||
reset(g_Config.touchRapidFireKey);
|
||||
reset(g_Config.touchAnalogRotationKey);
|
||||
}
|
||||
|
||||
void Config::GetReportingInfo(UrlEncoder &data) {
|
||||
|
|
|
@ -292,6 +292,8 @@ public:
|
|||
int iTouchButtonStyle;
|
||||
int iTouchButtonOpacity;
|
||||
int iTouchButtonHideSeconds;
|
||||
// Auto rotation speed
|
||||
float fAnalogAutoRotSpeed;
|
||||
|
||||
// Snap touch control position
|
||||
bool bTouchSnapToGrid;
|
||||
|
@ -325,6 +327,7 @@ public:
|
|||
ConfigTouchPos touchSpeed1Key;
|
||||
ConfigTouchPos touchSpeed2Key;
|
||||
ConfigTouchPos touchRapidFireKey;
|
||||
ConfigTouchPos touchAnalogRotationKey;
|
||||
|
||||
// Controls Visibility
|
||||
bool bShowTouchControls;
|
||||
|
|
|
@ -665,6 +665,9 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) {
|
|||
case VIRTKEY_MUTE_TOGGLE:
|
||||
g_Config.bEnableSound = !g_Config.bEnableSound;
|
||||
break;
|
||||
case VIRTKEY_ANALOG_ROTATE:
|
||||
autoRotatingAnalog_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -718,6 +721,12 @@ void EmuScreen::onVKeyUp(int virtualKeyCode) {
|
|||
__CtrlSetRapidFire(false);
|
||||
break;
|
||||
|
||||
case VIRTKEY_ANALOG_ROTATE:
|
||||
autoRotatingAnalog_ = false;
|
||||
__CtrlSetAnalogX(0.0f, 0);
|
||||
__CtrlSetAnalogY(0.0f, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1163,6 +1172,12 @@ void EmuScreen::update() {
|
|||
if (invalid_)
|
||||
return;
|
||||
|
||||
if (autoRotatingAnalog_) {
|
||||
const float now = time_now_d();
|
||||
__CtrlSetAnalogX(cos(now*g_Config.fAnalogAutoRotSpeed), 0);
|
||||
__CtrlSetAnalogY(sin(now*g_Config.fAnalogAutoRotSpeed), 0);
|
||||
}
|
||||
|
||||
// This is here to support the iOS on screen back button.
|
||||
if (pauseTrigger_) {
|
||||
pauseTrigger_ = false;
|
||||
|
|
|
@ -106,4 +106,5 @@ private:
|
|||
UI::TextView *loadingTextView_ = nullptr;
|
||||
|
||||
UI::Button *cardboardDisableButton_ = nullptr;
|
||||
bool autoRotatingAnalog_ = false;
|
||||
};
|
||||
|
|
|
@ -641,6 +641,7 @@ void GameSettingsScreen::CreateViews() {
|
|||
#else
|
||||
controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fXInputAnalogSensitivity, 0.0f, 10.0f, co->T("Analog Axis Sensitivity", "Analog Axis Sensitivity"), 0.01f, screenManager(), "x"));
|
||||
#endif
|
||||
controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fAnalogAutoRotSpeed, -25.0f, 25.0f, co->T("Analog auto-rotation speed"), 1.0f, screenManager()));
|
||||
|
||||
controlsSettings->Add(new ItemHeader(co->T("Keyboard", "Keyboard Control Settings")));
|
||||
#if defined(USING_WIN_UI)
|
||||
|
|
|
@ -162,6 +162,10 @@ void FPSLimitButton::Touch(const TouchInput &input) {
|
|||
}
|
||||
}
|
||||
|
||||
bool FPSLimitButton::IsDown() {
|
||||
return PSP_CoreParameter().fpsLimit == limit_;
|
||||
}
|
||||
|
||||
void RapidFireButton::Touch(const TouchInput &input) {
|
||||
bool lastDown = pointerDownMask_ != 0;
|
||||
MultiTouchButton::Touch(input);
|
||||
|
@ -175,8 +179,31 @@ bool RapidFireButton::IsDown() {
|
|||
return __CtrlGetRapidFire();
|
||||
}
|
||||
|
||||
bool FPSLimitButton::IsDown() {
|
||||
return PSP_CoreParameter().fpsLimit == limit_;
|
||||
void AnalogRotationButton::Touch(const TouchInput &input) {
|
||||
bool lastDown = pointerDownMask_ != 0;
|
||||
MultiTouchButton::Touch(input);
|
||||
bool down = pointerDownMask_ != 0;
|
||||
if (down && !lastDown) {
|
||||
autoRotating_ = true;
|
||||
} else if (lastDown && !down) {
|
||||
autoRotating_ = false;
|
||||
__CtrlSetAnalogX(0.0f, 0);
|
||||
__CtrlSetAnalogY(0.0f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AnalogRotationButton::Update() {
|
||||
const float now = time_now();
|
||||
float delta = now - lastFrameTime_;
|
||||
if (delta > 0) {
|
||||
secondsWithoutTouch_ += delta;
|
||||
}
|
||||
lastFrameTime_ = now;
|
||||
|
||||
if (autoRotating_) {
|
||||
__CtrlSetAnalogX(cos(now*g_Config.fAnalogAutoRotSpeed), 0);
|
||||
__CtrlSetAnalogY(sin(now*g_Config.fAnalogAutoRotSpeed), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void PSPButton::Touch(const TouchInput &input) {
|
||||
|
@ -533,6 +560,7 @@ void InitPadLayout(float xres, float yres, float globalScale) {
|
|||
initTouchPos(g_Config.touchSpeed1Key, unthrottle_key_X, unthrottle_key_Y - 60 * scale);
|
||||
initTouchPos(g_Config.touchSpeed2Key, unthrottle_key_X + bottom_key_spacing * scale, unthrottle_key_Y - 60 * scale);
|
||||
initTouchPos(g_Config.touchRapidFireKey, unthrottle_key_X + 2*bottom_key_spacing * scale, unthrottle_key_Y - 60 * scale);
|
||||
initTouchPos(g_Config.touchAnalogRotationKey, unthrottle_key_X, unthrottle_key_Y - 120 * scale);
|
||||
|
||||
// L and R------------------------------------------------------------
|
||||
// Put them above the analog stick / above the buttons to the right.
|
||||
|
@ -661,6 +689,10 @@ UI::ViewGroup *CreatePadLayout(float xres, float yres, bool *pause) {
|
|||
rapidFire->SetAngle(90.0f, 180.0f);
|
||||
}
|
||||
|
||||
if (g_Config.touchAnalogRotationKey.show) {
|
||||
auto analogRotation = root->Add(new AnalogRotationButton(rectImage, ImageID("I_RECT"), ImageID("I_R"), g_Config.touchAnalogRotationKey.scale, buttonLayoutParams(g_Config.touchAnalogRotationKey)));
|
||||
}
|
||||
|
||||
FPSLimitButton *speed1 = addFPSLimitButton(FPSLimit::CUSTOM1, rectImage, ImageID("I_RECT"), ImageID("I_ARROW"), g_Config.touchSpeed1Key);
|
||||
if (speed1)
|
||||
speed1->SetAngle(170.0f, 180.0f);
|
||||
|
|
|
@ -106,6 +106,18 @@ public:
|
|||
bool IsDown() override;
|
||||
};
|
||||
|
||||
class AnalogRotationButton : public MultiTouchButton {
|
||||
public:
|
||||
AnalogRotationButton(ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
: MultiTouchButton(bgImg, bgDownImg, img, scale, layoutParams) {
|
||||
}
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
bool autoRotating_ = false;
|
||||
};
|
||||
|
||||
class PSPButton : public MultiTouchButton {
|
||||
public:
|
||||
PSPButton(int pspButtonBit, ImageID bgImg, ImageID bgDownImg, ImageID img, float scale, UI::LayoutParams *layoutParams)
|
||||
|
|
|
@ -454,6 +454,11 @@ void TouchControlLayoutScreen::CreateViews() {
|
|||
controls_.push_back(rapidFire);
|
||||
}
|
||||
|
||||
if (g_Config.touchAnalogRotationKey.show) {
|
||||
DragDropButton *analogRotation = new DragDropButton(g_Config.touchAnalogRotationKey, rectImage, ImageID("I_R"));
|
||||
controls_.push_back(analogRotation);
|
||||
}
|
||||
|
||||
if (g_Config.touchLKey.show) {
|
||||
controls_.push_back(new DragDropButton(g_Config.touchLKey, shoulderImage, ImageID("I_L")));
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ void TouchControlVisibilityScreen::CreateViews() {
|
|||
toggles_.push_back({ "Alt speed 1", &g_Config.touchSpeed1Key.show, ImageID::invalid() });
|
||||
toggles_.push_back({ "Alt speed 2", &g_Config.touchSpeed2Key.show, ImageID::invalid() });
|
||||
toggles_.push_back({ "RapidFire", &g_Config.touchRapidFireKey.show, ImageID::invalid() });
|
||||
toggles_.push_back({ "Auto Analog Rotation", &g_Config.touchAnalogRotationKey.show, ImageID::invalid() });
|
||||
|
||||
auto mc = GetI18NCategory("MappableControls");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue