2013-04-20 04:52:54 +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/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2013-06-25 04:34:14 +00:00
|
|
|
#include "input/keycodes.h" // keyboard keys
|
2013-07-03 18:37:31 +00:00
|
|
|
#include "../Core/HLE/sceCtrl.h" // psp keys
|
2013-04-20 04:52:54 +00:00
|
|
|
|
|
|
|
#define KEYMAP_ERROR_KEY_ALREADY_USED -1
|
|
|
|
#define KEYMAP_ERROR_UNKNOWN_KEY 0
|
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// KeyMap
|
|
|
|
// A translation layer for
|
|
|
|
// key assignment. Provides
|
|
|
|
// integration with Core's
|
|
|
|
// config state.
|
|
|
|
//
|
|
|
|
// Does not handle input
|
|
|
|
// state managment.
|
|
|
|
//
|
|
|
|
// Platform ports should
|
|
|
|
// map their platform's
|
|
|
|
// keys to KeyMap's keys.
|
|
|
|
// Then have KeyMap transform
|
|
|
|
// those into psp buttons.
|
2013-04-20 04:52:54 +00:00
|
|
|
namespace KeyMap {
|
2013-04-20 20:33:12 +00:00
|
|
|
// Use if you need to
|
|
|
|
// display the textual
|
|
|
|
// name
|
|
|
|
// These functions are not
|
|
|
|
// fast, do not call them
|
|
|
|
// a million times.
|
2013-06-25 04:34:14 +00:00
|
|
|
std::string GetKeyName(int);
|
2013-05-24 04:05:41 +00:00
|
|
|
std::string GetPspButtonName(int);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// Use if to translate
|
|
|
|
// KeyMap Keys to PSP
|
|
|
|
// buttons.
|
|
|
|
// You should have
|
|
|
|
// already translated
|
|
|
|
// your platform's keys
|
|
|
|
// to KeyMap keys.
|
|
|
|
//
|
|
|
|
// Returns KEYMAP_ERROR_UNKNOWN_KEY
|
|
|
|
// for any unmapped key
|
2013-06-25 04:34:14 +00:00
|
|
|
int KeyToPspButton(int);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-06-25 04:34:14 +00:00
|
|
|
bool IsMappedKey(int);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// Might be usful if you want
|
|
|
|
// to provide hints to users
|
|
|
|
// upon mapping conflicts
|
2013-06-25 04:34:14 +00:00
|
|
|
std::string NamePspButtonFromKey(int);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// Use for showing the existing
|
|
|
|
// key mapping.
|
2013-05-24 04:05:41 +00:00
|
|
|
std::string NameKeyFromPspButton(int);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// Configure the key mapping.
|
|
|
|
// Any configuration will
|
|
|
|
// be saved to the Core
|
|
|
|
// config.
|
|
|
|
//
|
|
|
|
// Returns KEYMAP_ERROR_KEY_ALREADY_USED
|
|
|
|
// for mapping conflicts. 0 otherwise.
|
2013-06-25 04:34:14 +00:00
|
|
|
int SetKeyMapping(int kb_key, int psp_key);
|
2013-04-20 04:52:54 +00:00
|
|
|
|
2013-04-20 20:33:12 +00:00
|
|
|
// Platform specific keymaps
|
|
|
|
// override KeyMap's defaults.
|
|
|
|
// They do not override user's
|
|
|
|
// configuration.
|
|
|
|
// A platform default keymap
|
|
|
|
// does not need to cover
|
|
|
|
// all psp buttons.
|
|
|
|
// Any buttons missing will
|
|
|
|
// fallback to KeyMap's keymap.
|
2013-05-24 04:05:41 +00:00
|
|
|
int RegisterPlatformDefaultKeyMap(std::map<int,int> *);
|
|
|
|
void DeregisterPlatformDefaultKeyMap(void);
|
2013-04-20 04:52:54 +00:00
|
|
|
}
|
|
|
|
|