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>
|
|
|
|
|
|
|
|
#define KEYMAP_ERROR_KEY_ALREADY_USED -1
|
|
|
|
#define KEYMAP_ERROR_UNKNOWN_KEY 0
|
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
namespace KeyMap {
|
|
|
|
enum Key {
|
|
|
|
/* Lower class latin */
|
|
|
|
KEY_q = 1, // top row
|
|
|
|
KEY_w,
|
|
|
|
KEY_e,
|
|
|
|
KEY_r,
|
|
|
|
KEY_t,
|
|
|
|
KEY_y,
|
|
|
|
KEY_u,
|
|
|
|
KEY_i,
|
|
|
|
KEY_o,
|
|
|
|
KEY_p,
|
|
|
|
|
|
|
|
KE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,
|
|
|
|
|
|
|
|
/* Extra keys
|
|
|
|
* Use for platform specific keys.
|
|
|
|
* Example: android's back btn */
|
|
|
|
KEY_EXTRA1,
|
|
|
|
KEY_EXTRA2,
|
|
|
|
KEY_EXTRA3,
|
|
|
|
KEY_EXTRA4,
|
|
|
|
KEY_EXTRA5,
|
|
|
|
KEY_EXTRA6,
|
|
|
|
KEY_EXTRA7,
|
|
|
|
KEY_EXTRA8,
|
|
|
|
KEY_EXTRA9,
|
|
|
|
KEY_EXTRA0,
|
|
|
|
|
2013-04-20 18:54:40 +00:00
|
|
|
// TODO: Add second set of joysticks
|
2013-04-20 04:52:54 +00:00
|
|
|
// TODO: Add fastforward key
|
|
|
|
// TODO: Add any missing keys.
|
|
|
|
// Many can be found in the
|
|
|
|
// window's port's keyboard
|
|
|
|
// files.
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Use if you need to
|
|
|
|
* display the textual
|
|
|
|
* name
|
|
|
|
* These functions are not
|
|
|
|
* fast, do not call them
|
|
|
|
* a million times. */
|
|
|
|
static std::string GetKeyName(Key);
|
|
|
|
static std::string GetPspButtonName(int);
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
static int KeyToPspButton(Key);
|
|
|
|
|
|
|
|
static bool IsMappedKey(Key);
|
|
|
|
|
|
|
|
/* Might be usful if you want
|
|
|
|
* to provide hints to users
|
|
|
|
* upon mapping conflicts */
|
|
|
|
static std::string NamePspButtonFromKey(Key);
|
|
|
|
|
|
|
|
/* Use for showing the existing
|
|
|
|
* key mapping. */
|
|
|
|
static std::string NameKeyFromPspButton(int);
|
|
|
|
|
|
|
|
/* Configure the key mapping.
|
|
|
|
* Any configuration will
|
|
|
|
* be saved to the Core
|
|
|
|
* config.
|
|
|
|
*
|
|
|
|
* Returns KEYMAP_ERROR_KEY_ALREADY_USED
|
|
|
|
* for mapping conflicts. 0 otherwise. */
|
|
|
|
static int SetKeyMapping(Key, int);
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
static int RegisterPlatformDefaultKeyMap(std::map<int,int> *);
|
2013-04-20 19:01:15 +00:00
|
|
|
static void DeregisterPlatformDefaultKeyMap(void);
|
2013-04-20 04:52:54 +00:00
|
|
|
}
|
|
|
|
|