ManaPlus
keyinput.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2019 The ManaPlus Developers
4  * Copyright (C) 2019-2021 Andrei Karas
5  *
6  * This file is part of The ManaPlus Client.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 /* _______ __ __ __ ______ __ __ _______ __ __
23  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
24  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
25  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
26  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
27  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
28  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
29  *
30  * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
31  *
32  *
33  * Per Larsson a.k.a finalman
34  * Olof Naessén a.k.a jansem/yakslem
35  *
36  * Visit: http://guichan.sourceforge.net
37  *
38  * License: (BSD)
39  * Redistribution and use in source and binary forms, with or without
40  * modification, are permitted provided that the following conditions
41  * are met:
42  * 1. Redistributions of source code must retain the above copyright
43  * notice, this list of conditions and the following disclaimer.
44  * 2. Redistributions in binary form must reproduce the above copyright
45  * notice, this list of conditions and the following disclaimer in
46  * the documentation and/or other materials provided with the
47  * distribution.
48  * 3. Neither the name of Guichan nor the names of its contributors may
49  * be used to endorse or promote products derived from this software
50  * without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
53  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
54  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
55  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
56  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
57  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
58  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
59  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
60  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
61  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
62  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
63  */
64 
65 #ifndef INPUT_KEYINPUT_H
66 #define INPUT_KEYINPUT_H
67 
69 
71 
72 #include "input/key.h"
73 
74 #ifdef USE_SDL2
75 #include <string>
76 #endif // USE_SDL2
77 
78 #include "localconsts.h"
79 
81 {
82  public:
84  mKey(0),
86 #ifdef USE_SDL2
87  mText(),
88 #endif // USE_SDL2
90  { }
91 
93  mKey(k.mKey),
94  mType(k.mType),
95 #ifdef USE_SDL2
96  mText(k.mText),
97 #endif // USE_SDL2
98  mActionId(k.mActionId)
99  {
100  }
101 
103 
104  KeyInput &operator=(const KeyInput &k) noexcept2
105  {
106  mKey = k.mKey;
107  mType = k.mType;
108 #ifdef USE_SDL2
109  mText = k.mText;
110 #endif // USE_SDL2
111  mActionId = k.mActionId;
112  return *this;
113  }
114 
116  { }
117 
119  {
120  mType = type;
121  }
122 
124  {
125  return mType;
126  }
127 
128  void setKey(const Key& key) noexcept2
129  {
130  mKey = key;
131  }
132 
133  const Key& getKey() const noexcept2
134  {
135  return mKey;
136  }
137 
139  {
140  mActionId = n;
141  }
142 
144  {
145  return mActionId;
146  }
147 
148 #ifdef USE_SDL2
149  void setText(const std::string &text) noexcept2
150  {
151  mText = text;
152  }
153 
154  std::string getText() const noexcept2
155  {
156  return mText;
157  }
158 #endif // USE_SDL2
159 
160  protected:
165 
170 
171 #ifdef USE_SDL2
172  std::string mText;
173 #endif // USE_SDL2
174 
176 };
177 
178 #endif // INPUT_KEYINPUT_H
~KeyInput()
Definition: keyinput.h:115
InputActionT mActionId
Definition: keyinput.h:175
void setKey(const Key &key)
Definition: keyinput.h:128
KeyEventTypeT mType
Definition: keyinput.h:169
Key mKey
Definition: keyinput.h:164
const Key & getKey() const
Definition: keyinput.h:133
KeyEventTypeT getType() const
Definition: keyinput.h:123
KeyInput()
Definition: keyinput.h:83
KeyInput(const KeyInput &k)
Definition: keyinput.h:92
void setType(KeyEventTypeT type)
Definition: keyinput.h:118
InputActionT getActionId() const
Definition: keyinput.h:143
void setActionId(const InputActionT n)
Definition: keyinput.h:138
Definition: key.h:81
InputAction ::T InputActionT
Definition: inputaction.h:717
KeyEventType ::T KeyEventTypeT
Definition: keyeventtype.h:75
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define noexcept2
Definition: localconsts.h:50
#define final
Definition: localconsts.h:46
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:41