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>
|
2014-06-08 13:38:13 +00:00
|
|
|
#include <vector>
|
2017-02-27 20:57:46 +00:00
|
|
|
#include <mutex>
|
2016-10-12 09:32:24 +00:00
|
|
|
|
2017-08-17 20:47:46 +00:00
|
|
|
#include "i18n/i18n.h"
|
2013-08-16 14:48:43 +00:00
|
|
|
#include "ui/view.h"
|
|
|
|
#include "ui/ui_screen.h"
|
|
|
|
|
2013-08-17 08:34:38 +00:00
|
|
|
#include "UI/MiscScreens.h"
|
|
|
|
|
2014-06-08 13:38:13 +00:00
|
|
|
class ControlMapper;
|
|
|
|
|
2013-08-17 10:09:50 +00:00
|
|
|
class ControlMappingScreen : public UIDialogScreenWithBackground {
|
2013-08-16 14:48:43 +00:00
|
|
|
public:
|
2013-08-17 08:34:38 +00:00
|
|
|
ControlMappingScreen() {}
|
2014-06-08 13:38:13 +00:00
|
|
|
void KeyMapped(int pspkey); // Notification to let us refocus the same one after recreating views.
|
2017-12-02 19:45:59 +00:00
|
|
|
std::string tag() const override { return "control mapping"; }
|
|
|
|
|
2013-08-17 08:34:38 +00:00
|
|
|
protected:
|
2014-06-15 11:04:59 +00:00
|
|
|
virtual void CreateViews() 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);
|
2014-09-05 21:21:07 +00:00
|
|
|
UI::EventReturn OnTestAnalogs(UI::EventParams ¶ms);
|
2014-05-19 21:29:35 +00:00
|
|
|
|
|
|
|
virtual void dialogFinished(const Screen *dialog, DialogResult result) override;
|
2014-06-08 13:38:13 +00:00
|
|
|
|
|
|
|
UI::ScrollView *rightScroll_;
|
|
|
|
std::vector<ControlMapper *> mappers_;
|
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:
|
2017-08-17 20:47:46 +00:00
|
|
|
explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, I18NCategory *i18n)
|
|
|
|
: PopupScreen(i18n->T("Map Key"), "Cancel", ""), callback_(callback), mapped_(false) {
|
2013-08-16 14:48:43 +00:00
|
|
|
pspBtn_ = btn;
|
|
|
|
}
|
2013-08-16 15:16:11 +00:00
|
|
|
|
2014-06-15 11:04:59 +00:00
|
|
|
virtual bool key(const KeyInput &key) override;
|
|
|
|
virtual bool axis(const AxisInput &axis) override;
|
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
|
|
|
|
2014-06-15 11:04:59 +00:00
|
|
|
virtual bool FillVertical() const override { return false; }
|
|
|
|
virtual bool ShowButtons() const override { return true; }
|
|
|
|
virtual 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_;
|
2014-06-08 13:38:13 +00:00
|
|
|
bool mapped_; // Prevent double registrations
|
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:
|
2017-08-17 20:47:46 +00:00
|
|
|
explicit KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyDef)> callback, I18NCategory *i18n)
|
|
|
|
: PopupScreen(i18n->T("Map Mouse"), "", ""), callback_(callback), mapped_(false) {
|
2017-04-27 09:12:11 +00:00
|
|
|
pspBtn_ = btn;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool key(const KeyInput &key) override;
|
|
|
|
virtual bool axis(const AxisInput &axis) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void CreatePopupContents(UI::ViewGroup *parent) override;
|
|
|
|
|
|
|
|
virtual bool FillVertical() const override { return false; }
|
|
|
|
virtual bool ShowButtons() const override { return true; }
|
|
|
|
virtual void OnCompleted(DialogResult result) override {}
|
|
|
|
|
|
|
|
private:
|
|
|
|
int pspBtn_;
|
|
|
|
std::function<void(KeyDef)> callback_;
|
|
|
|
bool mapped_; // Prevent double registrations
|
|
|
|
};
|
|
|
|
|
2014-09-05 21:21:07 +00:00
|
|
|
class AnalogTestScreen : public UIDialogScreenWithBackground {
|
|
|
|
public:
|
|
|
|
AnalogTestScreen() {}
|
|
|
|
|
2015-01-03 16:55:15 +00:00
|
|
|
bool key(const KeyInput &key) override;
|
2015-08-27 23:22:45 +00:00
|
|
|
bool axis(const AxisInput &axis) override;
|
2015-01-03 16:55:15 +00:00
|
|
|
|
2014-09-05 21:21:07 +00:00
|
|
|
protected:
|
|
|
|
virtual void CreateViews() override;
|
2015-01-03 16:55:15 +00:00
|
|
|
|
|
|
|
UI::TextView *lastKeyEvent_;
|
2015-09-17 20:46:59 +00:00
|
|
|
UI::TextView *lastLastKeyEvent_;
|
2015-08-27 23:22:45 +00:00
|
|
|
};
|