2
* Custom keyboard shortcuts configuration
3
* Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
4
* Copyright (C) 2009-2010 The Mana Developers
5
* Copyright (C) 2011-2013 The ManaPlus Developers
7
* This file is part of The ManaPlus Client.
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU General Public License as published by
11
* the Free Software Foundation; either version 2 of the License, or
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
#ifndef INPUT_KEYBOARDCONFIG_H
24
#define INPUT_KEYBOARDCONFIG_H
26
#include <SDL_keyboard.h>
28
#include "sdlshared.h"
30
#include "input/inputevent.h"
36
class KeyboardConfig final
41
A_DELETE_COPY(KeyboardConfig)
44
* Initializes the keyboard config explicitly.
51
* Get the enable flag, which will stop the user from doing actions.
53
bool isEnabled() const A_WARN_UNUSED
57
* Get the key function index by providing the keys value.
59
int getKeyIndex(const SDL_Event &event,
60
const int grp = 1) const A_WARN_UNUSED;
63
* Set the enable flag, which will stop the user from doing actions.
65
void setEnabled(const bool flag)
69
* Takes a snapshot of all the active keys.
71
void refreshActiveKeys();
73
static std::string getKeyShortString(const std::string &key)
76
static SDLKey getKeyFromEvent(const SDL_Event &event) A_WARN_UNUSED;
78
int getKeyValueFromEvent(const SDL_Event &event) const A_WARN_UNUSED;
80
KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED;
82
KeysVector *getActionVectorByKey(const int i) A_WARN_UNUSED;
84
static std::string getKeyName(const int key)A_WARN_UNUSED;
86
bool isActionActive(const int index) const A_WARN_UNUSED;
90
void handleActicateKey(const SDL_Event &event);
92
void handleActicateKey(const int key);
94
void handleDeActicateKey(const SDL_Event &event);
96
void handleDeActicateKey(const int key);
98
int getActionId(const SDL_Event &event) A_WARN_UNUSED;
100
void handleRepeat(const int time);
102
void resetRepeat(const int key);
105
bool mEnabled; /**< Flag to respond to key input */
107
const uint8_t *mActiveKeys; /**< Stores a list of all the keys */
109
uint8_t *mActiveKeys2; /**< Stores a list of all the keys */
111
unsigned int mRepeatTime;
113
KeyToActionMap mKeyToAction;
117
KeyTimeMap mKeyTimeMap;
120
extern KeyboardConfig keyboard;
122
#endif // INPUT_KEYBOARDCONFIG_H