CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/UI/ControlMappingScreen.h
Views: 1401
// Copyright (c) 2013- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <functional>20#include <memory>21#include <set>22#include <mutex>23#include <vector>24#include <string>2526#include "Common/UI/View.h"27#include "Common/UI/UIScreen.h"28#include "Common/Data/Text/I18n.h"2930#include "Core/ControlMapper.h"3132#include "UI/MiscScreens.h"3334class SingleControlMapper;3536class ControlMappingScreen : public UIDialogScreenWithGameBackground {37public:38explicit ControlMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {39categoryToggles_[0] = true;40categoryToggles_[1] = true;41categoryToggles_[2] = true;42categoryToggles_[3] = false;43}44const char *tag() const override { return "ControlMapping"; }4546protected:47void CreateViews() override;48void update() override;4950private:51UI::EventReturn OnAutoConfigure(UI::EventParams ¶ms);5253void dialogFinished(const Screen *dialog, DialogResult result) override;5455UI::ScrollView *rightScroll_ = nullptr;56std::vector<SingleControlMapper *> mappers_;57int keyMapGeneration_ = -1;5859bool categoryToggles_[10]{};60};6162class KeyMappingNewKeyDialog : public PopupScreen {63public:64explicit KeyMappingNewKeyDialog(int btn, bool replace, std::function<void(KeyMap::MultiInputMapping)> callback, I18NCat i18n)65: PopupScreen(T(i18n, "Map Key"), "Cancel", ""), pspBtn_(btn), callback_(callback) {}6667const char *tag() const override { return "KeyMappingNewKey"; }6869bool key(const KeyInput &key) override;70void axis(const AxisInput &axis) override;7172void SetDelay(float t);7374protected:75void CreatePopupContents(UI::ViewGroup *parent) override;7677bool FillVertical() const override { return false; }78bool ShowButtons() const override { return true; }79void OnCompleted(DialogResult result) override {}8081private:82int pspBtn_;83std::function<void(KeyMap::MultiInputMapping)> callback_;8485KeyMap::MultiInputMapping mapping_;8687UI::View *comboMappingsNotEnabled_ = nullptr;8889// We need to do our own detection for axis "keyup" here.90std::set<InputMapping> triggeredAxes_;9192double delayUntil_ = 0.0f;93};9495class KeyMappingNewMouseKeyDialog : public PopupScreen {96public:97KeyMappingNewMouseKeyDialog(int btn, bool replace, std::function<void(KeyMap::MultiInputMapping)> callback, I18NCat i18n)98: PopupScreen(T(i18n, "Map Mouse"), "", ""), pspBtn_(btn), callback_(callback) {}99100const char *tag() const override { return "KeyMappingNewMouseKey"; }101102bool key(const KeyInput &key) override;103void axis(const AxisInput &axis) override;104105protected:106void CreatePopupContents(UI::ViewGroup *parent) override;107108bool FillVertical() const override { return false; }109bool ShowButtons() const override { return true; }110void OnCompleted(DialogResult result) override {}111112private:113int pspBtn_;114std::function<void(KeyMap::MultiInputMapping)> callback_;115bool mapped_ = false; // Prevent double registrations116};117118class JoystickHistoryView;119120class AnalogSetupScreen : public UIDialogScreenWithGameBackground {121public:122AnalogSetupScreen(const Path &gamePath);123124bool key(const KeyInput &key) override;125void axis(const AxisInput &axis) override;126127void update() override;128129const char *tag() const override { return "AnalogSetup"; }130131protected:132void CreateViews() override;133134private:135UI::EventReturn OnResetToDefaults(UI::EventParams &e);136137ControlMapper mapper_;138139float analogX_[2]{};140float analogY_[2]{};141float rawX_[2]{};142float rawY_[2]{};143144JoystickHistoryView *stickView_[2]{};145};146147class MockPSP;148149class VisualMappingScreen : public UIDialogScreenWithGameBackground {150public:151VisualMappingScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) {}152153const char *tag() const override { return "VisualMapping"; }154155bool key(const KeyInput &key) override;156void axis(const AxisInput &axis) override;157158protected:159void CreateViews() override;160161void dialogFinished(const Screen *dialog, DialogResult result) override;162void resized() override;163164private:165UI::EventReturn OnMapButton(UI::EventParams &e);166UI::EventReturn OnBindAll(UI::EventParams &e);167void HandleKeyMapping(const KeyMap::MultiInputMapping &key);168void MapNext(bool successive);169170MockPSP *psp_ = nullptr;171int nextKey_ = 0;172int bindAll_ = -1;173bool replace_ = false;174};175176177