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>
|
2017-02-27 20:57:46 +00:00
|
|
|
#include <mutex>
|
2020-01-26 18:43:18 +00:00
|
|
|
#include <vector>
|
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:
|
2022-12-15 08:30:47 +00:00
|
|
|
explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}
|
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:
|
2013-08-17 22:41:19 +00:00
|
|
|
UI::EventReturn OnDefaultMapping(UI::EventParams ¶ms);
|
2013-08-17 08:34:38 +00:00
|
|
|
UI::EventReturn OnClearMapping(UI::EventParams ¶ms);
|
2014-05-19 21:29:35 +00:00
|
|
|
UI::EventReturn OnAutoConfigure(UI::EventParams ¶ms);
|
2021-08-28 20:57:22 +00:00
|
|
|
UI::EventReturn OnVisualizeMapping(UI::EventParams ¶ms);
|
2014-05-19 21:29:35 +00:00
|
|
|
|
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;
|
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:
|
2020-01-26 18:43:18 +00:00
|
|
|
explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
|
2022-12-15 08:30:47 +00:00
|
|
|
: PopupScreen(i18n->T("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_;
|
2013-08-17 08:34:38 +00:00
|
|
|
std::function<void(KeyDef)> callback_;
|
2021-10-08 01:45:15 +00:00
|
|
|
bool mapped_ = false; // Prevent double registrations
|
|
|
|
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:
|
2022-11-22 21:53:54 +00:00
|
|
|
KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, std::shared_ptr<I18NCategory> i18n)
|
2022-12-15 08:30:47 +00:00
|
|
|
: PopupScreen(i18n->T("Map Mouse"), "", ""), pspBtn_(btn), callback_(callback), mapped_(false) {}
|
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:
|
|
|
|
int pspBtn_;
|
|
|
|
std::function<void(KeyDef)> callback_;
|
|
|
|
bool mapped_; // Prevent double registrations
|
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-11-22 21:53:54 +00:00
|
|
|
class TouchTestScreen : public UIDialogScreenWithGameBackground {
|
2019-10-02 20:03:02 +00:00
|
|
|
public:
|
2022-11-22 21:53:54 +00:00
|
|
|
TouchTestScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {
|
2019-10-02 20:03:02 +00:00
|
|
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++) {
|
|
|
|
touches_[i].id = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-31 20:41:32 +00:00
|
|
|
void touch(const TouchInput &touch) override;
|
2019-10-02 20:03:02 +00:00
|
|
|
void render() override;
|
|
|
|
|
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;
|
2021-07-09 15:04:59 +00:00
|
|
|
|
2022-09-16 08:14:00 +00:00
|
|
|
const char *tag() const override { return "TouchTest"; }
|
|
|
|
|
2019-10-02 20:03:02 +00:00
|
|
|
protected:
|
|
|
|
struct TrackedTouch {
|
|
|
|
int id;
|
2019-10-03 16:31:20 +00:00
|
|
|
float x;
|
|
|
|
float y;
|
2019-10-02 20:03:02 +00:00
|
|
|
};
|
|
|
|
enum {
|
|
|
|
MAX_TOUCH_POINTS = 10,
|
|
|
|
};
|
|
|
|
TrackedTouch touches_[MAX_TOUCH_POINTS]{};
|
|
|
|
|
2021-07-09 15:04:59 +00:00
|
|
|
UI::TextView *lastKeyEvent_ = nullptr;
|
|
|
|
UI::TextView *lastLastKeyEvent_ = nullptr;
|
|
|
|
|
2020-05-09 21:06:54 +00:00
|
|
|
void CreateViews() override;
|
|
|
|
|
2019-10-02 20:03:02 +00:00
|
|
|
UI::EventReturn OnImmersiveModeChange(UI::EventParams &e);
|
2020-05-09 21:06:54 +00:00
|
|
|
UI::EventReturn OnRenderingBackend(UI::EventParams &e);
|
|
|
|
UI::EventReturn OnRecreateActivity(UI::EventParams &e);
|
2015-08-27 23:22:45 +00:00
|
|
|
};
|
2021-08-28 20:57:22 +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"; }
|
|
|
|
|
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);
|
2021-08-28 21:37:53 +00:00
|
|
|
void HandleKeyMapping(KeyDef 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
|
|
|
};
|