Mana
Loading...
Searching...
No Matches
keyboardconfig.h
Go to the documentation of this file.
1/*
2 * Custom keyboard shortcuts configuration
3 * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au>
4 * Copyright (C) 2008-2009 The Mana Development Team
5 * Copyright (C) 2009-2012 The Mana Developers
6 *
7 * This file is part of The Mana Client.
8 *
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
12 * any later version.
13 *
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.
18 *
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/>.
21 */
22
23#pragma once
24
25#include <cstdint>
26#include <string>
27
28#include <SDL.h>
29
34{
35 const char* configField;
37 SDL_Keycode value;
38};
39
40class Setup_Keyboard;
41
43{
44 public:
48 void init();
49
53 void retrieve();
54
58 void store();
59
63 void makeDefault();
64
68 bool hasConflicts();
69
73 void callbackNewKey();
74
78 int getKeyValue(int index) const
79 { return mKey[index].value; }
80
84 int getNewKeyIndex() const
85 { return mNewKeyIndex; }
86
90 bool isEnabled() const
91 { return mEnabled; }
92
96 const std::string &getKeyCaption(int index) const;
97
101 int getKeyIndex(SDL_Keycode keyValue) const;
102
106 std::string_view getKeyName(std::string_view configName) const;
107
111 int getKeyEmoteOffset(SDL_Keycode keyValue) const;
112
116 void setEnabled(bool flag)
117 { mEnabled = flag; }
118
122 void setNewKeyIndex(int value)
123 { mNewKeyIndex = value; }
124
128 void setNewKey(SDL_Keycode value)
129 { mKey[mNewKeyIndex].value = value; }
130
135 { mSetupKey = setupKey; }
136
140 bool isKeyActive(int index) const;
141
145 void refreshActiveKeys();
146
147 std::string getBindError() const
148 { return mBindError; }
149
228
229 private:
231 bool mEnabled;
239 std::string mBindError;
240};
241
std::string getBindError() const
int getKeyValue(int index) const
Obtain the value stored in memory.
void store()
Store the key values to config file.
int mNewKeyIndex
Index of new key to be assigned.
void setNewKey(SDL_Keycode value)
Set the value of the new key.
void refreshActiveKeys()
Takes a snapshot of all the active keys.
int getKeyEmoteOffset(SDL_Keycode keyValue) const
Get the key function index for an emote by providing the offset value.
int getNewKeyIndex() const
Get the index of the new key to be assigned.
void callbackNewKey()
Calls a function back so the key re-assignment(s) can be seen.
void makeDefault()
Make the keys their default values.
bool isEnabled() const
Get the enable flag, which will stop the user from doing actions.
int getKeyIndex(SDL_Keycode keyValue) const
Get the key function index by providing the keys value.
std::string mBindError
bool hasConflicts()
Determines if any key assignments are the same as each other.
bool mEnabled
Flag to respond to key input.
std::string_view getKeyName(std::string_view configName) const
Get the key name by providing the keys config name.
const uint8_t * mActiveKeys
Stores a list of all the keys.
void retrieve()
Retrieve the key values from config file.
bool isKeyActive(int index) const
Checks if the key is active, by providing the key function index.
KeyAction
All the key functions.
void init()
Initializes the keyboard config explicitly.
void setEnabled(bool flag)
Set the enable flag, which will stop the user from doing actions.
KeyFunction mKey[KEY_TOTAL]
Pointer to all the key data.
const std::string & getKeyCaption(int index) const
Get the key caption, providing more meaning to the user.
Setup_Keyboard * mSetupKey
Reference to setup window.
void setNewKeyIndex(int value)
Set the index of the new key to be assigned.
void setSetupKeyboard(Setup_Keyboard *setupKey)
Set a reference to the key setup window.
KeyboardConfig keyboard
Definition client.cpp:101
unsigned char uint8_t
Definition sha256.cpp:81
Each key represents a key function.
SDL_Keycode value
The actual value that is used.
int defaultValue
The default key value used.
const char * configField
Field index that is in the config file.