2013-08-16 14:48:43 +00:00
|
|
|
// Copyright (c) 2013- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-09-07 15:29:44 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-10-12 09:32:24 +00:00
|
|
|
#include <functional>
|
2020-01-26 18:43:18 +00:00
|
|
|
#include <memory>
|
2023-04-01 15:50:17 +00:00
|
|
|
#include <set>
|
2017-02-27 20:57:46 +00:00
|
|
|
#include <mutex>
|
2020-01-26 18:43:18 +00:00
|
|
|
#include <vector>
|
2023-07-06 09:48:25 +00:00
|
|
|
#include <string>
|
2016-10-12 09:32:24 +00:00
|
|
|
|
2020-10-04 18:48:47 +00:00
|
|
|
#include "Common/UI/View.h"
|
|
|
|
#include "Common/UI/UIScreen.h"
|
2020-10-01 11:05:04 +00:00
|
|
|
#include "Common/Data/Text/I18n.h"
|
2021-07-09 11:10:16 +00:00
|
|
|
|
|
|
|
#include "Core/ControlMapper.h"
|
|
|
|
|
2013-08-17 08:34:38 +00:00
|
|
|
#include "UI/MiscScreens.h"
|
|
|
|
|
2021-07-08 22:05:47 +00:00
|
|
|
class SingleControlMapper;
|
2014-06-08 13:38:13 +00:00
|
|
|
|
2022-11-22 21:53:54 +00:00
|
|
|
class ControlMappingScreen : public UIDialogScreenWithGameBackground {
|
2013-08-16 14:48:43 +00:00
|
|
|
public:
|
2023-12-20 15:20:26 +00:00
|
|
|
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
|
|
|
categoryToggles_[0] = true;
|
|
|
|
categoryToggles_[1] = true;
|
2024-01-29 16:57:01 +00:00
|
|
|
categoryToggles_[2] = true;
|
|
|
|
categoryToggles_[3] = false;
|
2023-12-20 15:20:26 +00:00
|
|
|
}
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "ControlMapping"; }
|
2017-12-02 19:45:59 +00:00
|
|
|
|
2013-08-17 08:34:38 +00:00
|
|
|
protected:
|
2021-08-29 15:02:52 +00:00
|
|
|
void CreateViews() override;
|
|
|
|
void update() override;
|
|
|
|
|
2013-08-17 08:34:38 +00:00
|
|
|
private:
|
2014-05-19 21:29:35 +00:00
|
|
|
UI::EventReturn OnAutoConfigure(UI::EventParams ¶ms);
|
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
2014-06-08 13:38:13 +00:00
|
|
|
|
2022-12-15 08:30:47 +00:00
|
|
|
UI::ScrollView *rightScroll_ = nullptr;
|
2021-07-08 22:05:47 +00:00
|
|
|
std::vector<SingleControlMapper *> mappers_;
|
2021-08-29 15:02:52 +00:00
|
|
|
int keyMapGeneration_ = -1;
|
2023-12-20 15:20:26 +00:00
|
|
|
|
|
|
|
bool categoryToggles_[10]{};
|
2013-08-16 14:48:43 +00:00
|
|
|
};
|
|
|
|
|
2013-08-16 15:16:11 +00:00
|
|
|
class KeyMappingNewKeyDialog : public PopupScreen {
|
2013-08-16 14:48:43 +00:00
|
|
|
public:
|
2023-04-05 22:34:50 +00:00
|
|
|
explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyMap::MultiInputMapping)> callback, I18NCat i18n)
|
|
|
|
: PopupScreen(T(i18n, "Map Key"), "Cancel", ""), pspBtn_(btn), callback_(callback) {}
|
2013-08-16 15:16:11 +00:00
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "KeyMappingNewKey"; }
|
|
|
|
|
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 20:44:52 +00:00
|
|
|
void axis(const AxisInput &axis) override;
|
2013-08-16 14:48:43 +00:00
|
|
|
|
2021-10-08 01:45:15 +00:00
|
|
|
void SetDelay(float t);
|
|
|
|
|
2013-08-16 14:48:43 +00:00
|
|
|
protected:
|
2014-06-15 11:04:59 +00:00
|
|
|
void CreatePopupContents(UI::ViewGroup *parent) override;
|
2013-08-16 15:16:11 +00:00
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
bool FillVertical() const override { return false; }
|
|
|
|
bool ShowButtons() const override { return true; }
|
|
|
|
void OnCompleted(DialogResult result) override {}
|
2013-08-17 08:34:38 +00:00
|
|
|
|
2013-08-16 14:48:43 +00:00
|
|
|
private:
|
|
|
|
int pspBtn_;
|
2023-03-31 22:12:14 +00:00
|
|
|
std::function<void(KeyMap::MultiInputMapping)> callback_;
|
2023-04-01 15:50:17 +00:00
|
|
|
|
|
|
|
KeyMap::MultiInputMapping mapping_;
|
|
|
|
|
2023-07-07 08:33:27 +00:00
|
|
|
UI::View *comboMappingsNotEnabled_ = nullptr;
|
|
|
|
|
2023-04-01 15:50:17 +00:00
|
|
|
// We need to do our own detection for axis "keyup" here.
|
|
|
|
std::set<InputMapping> triggeredAxes_;
|
|
|
|
|
2021-10-08 01:45:15 +00:00
|
|
|
double delayUntil_ = 0.0f;
|
2013-08-16 14:48:43 +00:00
|
|
|
};
|
2014-09-05 21:21:07 +00:00
|
|
|
|
2017-04-27 09:12:11 +00:00
|
|
|
class KeyMappingNewMouseKeyDialog : public PopupScreen {
|
|
|
|
public:
|
2023-04-05 22:34:50 +00:00
|
|
|
KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyMap::MultiInputMapping)> callback, I18NCat i18n)
|
2023-04-06 14:45:24 +00:00
|
|
|
: PopupScreen(T(i18n, "Map Mouse"), "", ""), pspBtn_(btn), callback_(callback) {}
|
2017-04-27 09:12:11 +00:00
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "KeyMappingNewMouseKey"; }
|
|
|
|
|
2021-07-09 15:04:59 +00:00
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 20:44:52 +00:00
|
|
|
void axis(const AxisInput &axis) override;
|
2017-04-27 09:12:11 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void CreatePopupContents(UI::ViewGroup *parent) override;
|
|
|
|
|
2021-07-09 15:04:59 +00:00
|
|
|
bool FillVertical() const override { return false; }
|
|
|
|
bool ShowButtons() const override { return true; }
|
|
|
|
void OnCompleted(DialogResult result) override {}
|
2017-04-27 09:12:11 +00:00
|
|
|
|
|
|
|
private:
|
2023-04-07 05:01:14 +00:00
|
|
|
int pspBtn_;
|
2023-03-31 22:12:14 +00:00
|
|
|
std::function<void(KeyMap::MultiInputMapping)> callback_;
|
2023-04-06 14:45:24 +00:00
|
|
|
bool mapped_ = false; // Prevent double registrations
|
2017-04-27 09:12:11 +00:00
|
|
|
};
|
|
|
|
|
2021-07-09 11:10:16 +00:00
|
|
|
class JoystickHistoryView;
|
|
|
|
|
2022-11-22 21:53:54 +00:00
|
|
|
class AnalogSetupScreen : public UIDialogScreenWithGameBackground {
|
2014-09-05 21:21:07 +00:00
|
|
|
public:
|
2022-11-22 21:53:54 +00:00
|
|
|
AnalogSetupScreen(const Path &gamePath);
|
2014-09-05 21:21:07 +00:00
|
|
|
|
2015-01-03 16:55:15 +00:00
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 20:44:52 +00:00
|
|
|
void axis(const AxisInput &axis) override;
|
2015-01-03 16:55:15 +00:00
|
|
|
|
2021-07-09 11:10:16 +00:00
|
|
|
void update() override;
|
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "AnalogSetup"; }
|
|
|
|
|
2014-09-05 21:21:07 +00:00
|
|
|
protected:
|
2021-07-09 15:13:08 +00:00
|
|
|
void CreateViews() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
UI::EventReturn OnResetToDefaults(UI::EventParams &e);
|
2015-01-03 16:55:15 +00:00
|
|
|
|
2021-07-09 11:10:16 +00:00
|
|
|
ControlMapper mapper_;
|
|
|
|
|
|
|
|
float analogX_[2]{};
|
|
|
|
float analogY_[2]{};
|
|
|
|
float rawX_[2]{};
|
|
|
|
float rawY_[2]{};
|
|
|
|
|
2021-07-09 15:04:59 +00:00
|
|
|
JoystickHistoryView *stickView_[2]{};
|
2019-10-02 20:03:02 +00:00
|
|
|
};
|
|
|
|
|
2021-08-28 22:04:16 +00:00
|
|
|
class MockPSP;
|
|
|
|
|
2022-11-22 21:53:54 +00:00
|
|
|
class VisualMappingScreen : public UIDialogScreenWithGameBackground {
|
2021-08-28 20:57:22 +00:00
|
|
|
public:
|
2022-11-22 21:53:54 +00:00
|
|
|
VisualMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
2021-08-28 20:57:22 +00:00
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "VisualMapping"; }
|
|
|
|
|
2023-01-29 01:42:23 +00:00
|
|
|
bool key(const KeyInput &key) override;
|
|
|
|
void axis(const AxisInput &axis) override;
|
|
|
|
|
2021-08-28 20:57:22 +00:00
|
|
|
protected:
|
|
|
|
void CreateViews() override;
|
2021-08-28 21:24:12 +00:00
|
|
|
|
2021-08-28 21:37:53 +00:00
|
|
|
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
2021-08-28 22:23:46 +00:00
|
|
|
void resized() override;
|
2021-08-28 21:37:53 +00:00
|
|
|
|
2021-08-28 21:24:12 +00:00
|
|
|
private:
|
|
|
|
UI::EventReturn OnMapButton(UI::EventParams &e);
|
2021-08-28 22:04:16 +00:00
|
|
|
UI::EventReturn OnBindAll(UI::EventParams &e);
|
2023-12-14 11:23:31 +00:00
|
|
|
void HandleKeyMapping(const KeyMap::MultiInputMapping &key);
|
2021-10-08 01:45:15 +00:00
|
|
|
void MapNext(bool successive);
|
2021-08-28 21:37:53 +00:00
|
|
|
|
2021-08-28 22:04:16 +00:00
|
|
|
MockPSP *psp_ = nullptr;
|
2021-08-28 21:37:53 +00:00
|
|
|
int nextKey_ = 0;
|
2021-08-28 22:04:16 +00:00
|
|
|
int bindAll_ = -1;
|
|
|
|
bool replace_ = false;
|
2021-08-28 20:57:22 +00:00
|
|
|
};
|