2013-08-16 16:48:43 +02: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 11:29:44 -04:00
|
|
|
#pragma once
|
|
|
|
|
2016-10-12 11:32:24 +02:00
|
|
|
#include <functional>
|
2020-01-26 10:43:18 -08:00
|
|
|
#include <memory>
|
2023-04-01 17:50:17 +02:00
|
|
|
#include <set>
|
2017-02-27 21:57:46 +01:00
|
|
|
#include <mutex>
|
2020-01-26 10:43:18 -08:00
|
|
|
#include <vector>
|
2023-07-06 11:48:25 +02:00
|
|
|
#include <string>
|
2016-10-12 11:32:24 +02:00
|
|
|
|
2020-10-04 20:48:47 +02:00
|
|
|
#include "Common/UI/View.h"
|
|
|
|
#include "Common/UI/UIScreen.h"
|
2020-10-01 13:05:04 +02:00
|
|
|
#include "Common/Data/Text/I18n.h"
|
2021-07-09 13:10:16 +02:00
|
|
|
|
|
|
|
#include "Core/ControlMapper.h"
|
|
|
|
|
2013-08-17 10:34:38 +02:00
|
|
|
#include "UI/MiscScreens.h"
|
|
|
|
|
2021-07-09 00:05:47 +02:00
|
|
|
class SingleControlMapper;
|
2014-06-08 15:38:13 +02:00
|
|
|
|
2022-11-22 22:53:54 +01:00
|
|
|
class ControlMappingScreen : public UIDialogScreenWithGameBackground {
|
2013-08-16 16:48:43 +02:00
|
|
|
public:
|
2022-12-15 09:30:47 +01:00
|
|
|
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "ControlMapping"; }
|
2017-12-02 11:45:59 -08:00
|
|
|
|
2013-08-17 10:34:38 +02:00
|
|
|
protected:
|
2021-08-29 08:02:52 -07:00
|
|
|
void CreateViews() override;
|
|
|
|
void update() override;
|
|
|
|
|
2013-08-17 10:34:38 +02:00
|
|
|
private:
|
2013-08-18 00:41:19 +02:00
|
|
|
UI::EventReturn OnDefaultMapping(UI::EventParams ¶ms);
|
2013-08-17 10:34:38 +02:00
|
|
|
UI::EventReturn OnClearMapping(UI::EventParams ¶ms);
|
2014-05-19 23:29:35 +02:00
|
|
|
UI::EventReturn OnAutoConfigure(UI::EventParams ¶ms);
|
2021-08-28 13:57:22 -07:00
|
|
|
UI::EventReturn OnVisualizeMapping(UI::EventParams ¶ms);
|
2014-05-19 23:29:35 +02:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
2014-06-08 15:38:13 +02:00
|
|
|
|
2022-12-15 09:30:47 +01:00
|
|
|
UI::ScrollView *rightScroll_ = nullptr;
|
2021-07-09 00:05:47 +02:00
|
|
|
std::vector<SingleControlMapper *> mappers_;
|
2021-08-29 08:02:52 -07:00
|
|
|
int keyMapGeneration_ = -1;
|
2013-08-16 16:48:43 +02:00
|
|
|
};
|
|
|
|
|
2013-08-16 17:16:11 +02:00
|
|
|
class KeyMappingNewKeyDialog : public PopupScreen {
|
2013-08-16 16:48:43 +02:00
|
|
|
public:
|
2023-04-06 00:34:50 +02: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 17:16:11 +02:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "KeyMappingNewKey"; }
|
|
|
|
|
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 21:44:52 +01:00
|
|
|
void axis(const AxisInput &axis) override;
|
2013-08-16 16:48:43 +02:00
|
|
|
|
2021-10-07 18:45:15 -07:00
|
|
|
void SetDelay(float t);
|
|
|
|
|
2013-08-16 16:48:43 +02:00
|
|
|
protected:
|
2014-06-15 13:04:59 +02:00
|
|
|
void CreatePopupContents(UI::ViewGroup *parent) override;
|
2013-08-16 17:16:11 +02:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
bool FillVertical() const override { return false; }
|
|
|
|
bool ShowButtons() const override { return true; }
|
|
|
|
void OnCompleted(DialogResult result) override {}
|
2013-08-17 10:34:38 +02:00
|
|
|
|
2013-08-16 16:48:43 +02:00
|
|
|
private:
|
|
|
|
int pspBtn_;
|
2023-04-01 00:12:14 +02:00
|
|
|
std::function<void(KeyMap::MultiInputMapping)> callback_;
|
2023-04-01 17:50:17 +02:00
|
|
|
|
|
|
|
KeyMap::MultiInputMapping mapping_;
|
|
|
|
|
2023-07-07 10:33:27 +02:00
|
|
|
UI::View *comboMappingsNotEnabled_ = nullptr;
|
|
|
|
|
2023-04-01 17:50:17 +02:00
|
|
|
// We need to do our own detection for axis "keyup" here.
|
|
|
|
std::set<InputMapping> triggeredAxes_;
|
|
|
|
|
2021-10-07 18:45:15 -07:00
|
|
|
double delayUntil_ = 0.0f;
|
2013-08-16 16:48:43 +02:00
|
|
|
};
|
2014-09-05 23:21:07 +02:00
|
|
|
|
2017-04-27 11:12:11 +02:00
|
|
|
class KeyMappingNewMouseKeyDialog : public PopupScreen {
|
|
|
|
public:
|
2023-04-06 00:34:50 +02:00
|
|
|
KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyMap::MultiInputMapping)> callback, I18NCat i18n)
|
2023-04-06 16:45:24 +02:00
|
|
|
: PopupScreen(T(i18n, "Map Mouse"), "", ""), pspBtn_(btn), callback_(callback) {}
|
2017-04-27 11:12:11 +02:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "KeyMappingNewMouseKey"; }
|
|
|
|
|
2021-07-09 17:04:59 +02:00
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 21:44:52 +01:00
|
|
|
void axis(const AxisInput &axis) override;
|
2017-04-27 11:12:11 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void CreatePopupContents(UI::ViewGroup *parent) override;
|
|
|
|
|
2021-07-09 17:04:59 +02:00
|
|
|
bool FillVertical() const override { return false; }
|
|
|
|
bool ShowButtons() const override { return true; }
|
|
|
|
void OnCompleted(DialogResult result) override {}
|
2017-04-27 11:12:11 +02:00
|
|
|
|
|
|
|
private:
|
2023-04-06 22:01:14 -07:00
|
|
|
int pspBtn_;
|
2023-04-01 00:12:14 +02:00
|
|
|
std::function<void(KeyMap::MultiInputMapping)> callback_;
|
2023-04-06 16:45:24 +02:00
|
|
|
bool mapped_ = false; // Prevent double registrations
|
2017-04-27 11:12:11 +02:00
|
|
|
};
|
|
|
|
|
2021-07-09 13:10:16 +02:00
|
|
|
class JoystickHistoryView;
|
|
|
|
|
2022-11-22 22:53:54 +01:00
|
|
|
class AnalogSetupScreen : public UIDialogScreenWithGameBackground {
|
2014-09-05 23:21:07 +02:00
|
|
|
public:
|
2022-11-22 22:53:54 +01:00
|
|
|
AnalogSetupScreen(const Path &gamePath);
|
2014-09-05 23:21:07 +02:00
|
|
|
|
2015-01-03 17:55:15 +01:00
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 21:44:52 +01:00
|
|
|
void axis(const AxisInput &axis) override;
|
2015-01-03 17:55:15 +01:00
|
|
|
|
2021-07-09 13:10:16 +02:00
|
|
|
void update() override;
|
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "AnalogSetup"; }
|
|
|
|
|
2014-09-05 23:21:07 +02:00
|
|
|
protected:
|
2021-07-09 17:13:08 +02:00
|
|
|
void CreateViews() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
UI::EventReturn OnResetToDefaults(UI::EventParams &e);
|
2015-01-03 17:55:15 +01:00
|
|
|
|
2021-07-09 13:10:16 +02:00
|
|
|
ControlMapper mapper_;
|
|
|
|
|
|
|
|
float analogX_[2]{};
|
|
|
|
float analogY_[2]{};
|
|
|
|
float rawX_[2]{};
|
|
|
|
float rawY_[2]{};
|
|
|
|
|
2021-07-09 17:04:59 +02:00
|
|
|
JoystickHistoryView *stickView_[2]{};
|
2019-10-02 22:03:02 +02:00
|
|
|
};
|
|
|
|
|
2022-11-22 22:53:54 +01:00
|
|
|
class TouchTestScreen : public UIDialogScreenWithGameBackground {
|
2019-10-02 22:03:02 +02:00
|
|
|
public:
|
2022-11-22 22:53:54 +01:00
|
|
|
TouchTestScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
2019-10-02 22:03:02 +02:00
|
|
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
|
|
|
touches_[i].id = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-31 21:41:32 +01:00
|
|
|
void touch(const TouchInput &touch) override;
|
2019-10-02 22:03:02 +02:00
|
|
|
void render() override;
|
|
|
|
|
2021-07-09 17:04:59 +02:00
|
|
|
bool key(const KeyInput &key) override;
|
2022-12-31 21:44:52 +01:00
|
|
|
void axis(const AxisInput &axis) override;
|
2021-07-09 17:04:59 +02:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "TouchTest"; }
|
|
|
|
|
2019-10-02 22:03:02 +02:00
|
|
|
protected:
|
|
|
|
struct TrackedTouch {
|
|
|
|
int id;
|
2019-10-03 18:31:20 +02:00
|
|
|
float x;
|
|
|
|
float y;
|
2019-10-02 22:03:02 +02:00
|
|
|
};
|
|
|
|
enum {
|
|
|
|
MAX_TOUCH_POINTS = 10,
|
|
|
|
};
|
|
|
|
TrackedTouch touches_[MAX_TOUCH_POINTS]{};
|
|
|
|
|
2023-07-06 11:48:25 +02:00
|
|
|
std::vector<std::string> keyEventLog_;
|
|
|
|
|
|
|
|
UI::TextView *lastKeyEvents_ = nullptr;
|
2021-07-09 17:04:59 +02:00
|
|
|
|
2020-05-09 14:06:54 -07:00
|
|
|
void CreateViews() override;
|
2023-07-06 11:48:25 +02:00
|
|
|
void UpdateLogView();
|
2020-05-09 14:06:54 -07:00
|
|
|
|
2019-10-02 22:03:02 +02:00
|
|
|
UI::EventReturn OnImmersiveModeChange(UI::EventParams &e);
|
2020-05-09 14:06:54 -07:00
|
|
|
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
|
|
|
|
UI::EventReturn OnRecreateActivity(UI::EventParams &e);
|
2015-08-28 01:22:45 +02:00
|
|
|
};
|
2021-08-28 13:57:22 -07:00
|
|
|
|
2021-08-28 15:04:16 -07:00
|
|
|
class MockPSP;
|
|
|
|
|
2022-11-22 22:53:54 +01:00
|
|
|
class VisualMappingScreen : public UIDialogScreenWithGameBackground {
|
2021-08-28 13:57:22 -07:00
|
|
|
public:
|
2022-11-22 22:53:54 +01:00
|
|
|
VisualMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
2021-08-28 13:57:22 -07:00
|
|
|
|
2022-09-16 10:14:00 +02:00
|
|
|
const char *tag() const override { return "VisualMapping"; }
|
|
|
|
|
2023-01-28 17:42:23 -08:00
|
|
|
bool key(const KeyInput &key) override;
|
|
|
|
void axis(const AxisInput &axis) override;
|
|
|
|
|
2021-08-28 13:57:22 -07:00
|
|
|
protected:
|
|
|
|
void CreateViews() override;
|
2021-08-28 14:24:12 -07:00
|
|
|
|
2021-08-28 14:37:53 -07:00
|
|
|
void dialogFinished(const Screen *dialog, DialogResult result) override;
|
2021-08-28 15:23:46 -07:00
|
|
|
void resized() override;
|
2021-08-28 14:37:53 -07:00
|
|
|
|
2021-08-28 14:24:12 -07:00
|
|
|
private:
|
|
|
|
UI::EventReturn OnMapButton(UI::EventParams &e);
|
2021-08-28 15:04:16 -07:00
|
|
|
UI::EventReturn OnBindAll(UI::EventParams &e);
|
2023-04-01 00:12:14 +02:00
|
|
|
void HandleKeyMapping(KeyMap::MultiInputMapping key);
|
2021-10-07 18:45:15 -07:00
|
|
|
void MapNext(bool successive);
|
2021-08-28 14:37:53 -07:00
|
|
|
|
2021-08-28 15:04:16 -07:00
|
|
|
MockPSP *psp_ = nullptr;
|
2021-08-28 14:37:53 -07:00
|
|
|
int nextKey_ = 0;
|
2021-08-28 15:04:16 -07:00
|
|
|
int bindAll_ = -1;
|
|
|
|
bool replace_ = false;
|
2021-08-28 13:57:22 -07:00
|
|
|
};
|