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 KEYBOARDCONFIG_H
24
#define KEYBOARDCONFIG_H
26
#include <SDL_types.h>
27
#include <SDL_keyboard.h>
29
#include "inputevent.h"
30
#include "sdlshared.h"
38
class KeyboardConfig final
43
A_DELETE_COPY(KeyboardConfig)
46
* Initializes the keyboard config explicitly.
53
* Get the enable flag, which will stop the user from doing actions.
55
bool isEnabled() const A_WARN_UNUSED
59
* Get the key function index by providing the keys value.
61
int getKeyIndex(const SDL_Event &event,
62
const int grp = 1) const A_WARN_UNUSED;
65
* Set the enable flag, which will stop the user from doing actions.
67
void setEnabled(const bool flag)
71
* Takes a snapshot of all the active keys.
73
void refreshActiveKeys();
75
static std::string getKeyShortString(const std::string &key)
78
static SDLKey getKeyFromEvent(const SDL_Event &event) A_WARN_UNUSED;
80
int getKeyValueFromEvent(const SDL_Event &event) const A_WARN_UNUSED;
82
KeysVector *getActionVector(const SDL_Event &event) A_WARN_UNUSED;
84
KeysVector *getActionVectorByKey(const int i) A_WARN_UNUSED;
86
static std::string getKeyName(const int key)A_WARN_UNUSED;
88
bool isActionActive(const int index) const A_WARN_UNUSED;
92
void handleActicateKey(const SDL_Event &event);
94
void handleActicateKey(const int key);
96
void handleDeActicateKey(const SDL_Event &event);
98
void handleDeActicateKey(const int key);
100
int getActionId(const SDL_Event &event) A_WARN_UNUSED;
102
void handleRepeat(const int time);
104
void resetRepeat(const int key);
107
bool mEnabled; /**< Flag to respond to key input */
109
const uint8_t *mActiveKeys; /**< Stores a list of all the keys */
111
uint8_t *mActiveKeys2; /**< Stores a list of all the keys */
113
unsigned int mRepeatTime;
115
KeyToActionMap mKeyToAction;
119
KeyTimeMap mKeyTimeMap;
122
extern KeyboardConfig keyboard;
124
#endif // KEYBOARDCONFIG_H