Audacity  2.2.2
Classes | Functions
Keyboard.h File Reference
#include <wx/defs.h>
#include <wx/event.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

struct  NormalizedKeyString
 

Functions

bool operator== (const NormalizedKeyString &a, const NormalizedKeyString &b)
 
bool operator!= (const NormalizedKeyString &a, const NormalizedKeyString &b)
 
bool operator< (const NormalizedKeyString &a, const NormalizedKeyString &b)
 
NormalizedKeyString KeyEventToKeyString (const wxKeyEvent &keyEvent)
 

Function Documentation

NormalizedKeyString KeyEventToKeyString ( const wxKeyEvent &  keyEvent)

Definition at line 78 of file Keyboard.cpp.

Referenced by CommandManager::FilterKeyEvent(), KeyConfigPrefs::OnFilterKeyDown(), and KeyConfigPrefs::OnHotkeyKeyDown().

79 {
80  wxString newStr = wxT("");
81 
82  long key = event.GetKeyCode();
83 
84  if (event.ControlDown())
85  newStr += wxT("Ctrl+");
86 
87  if (event.AltDown())
88  newStr += wxT("Alt+");
89 
90  if (event.ShiftDown())
91  newStr += wxT("Shift+");
92 
93 #if defined(__WXMAC__)
94  if (event.RawControlDown())
95  newStr += wxT("RawCtrl+");
96 #endif
97 
98  if (event.RawControlDown() && key >= 1 && key <= 26)
99  newStr += (wxChar)(64 + key);
100  else if (key >= 33 && key <= 255 && key != 127)
101  newStr += (wxChar)key;
102  else
103  {
104  switch(key)
105  {
106  case WXK_BACK:
107  newStr += wxT("Backspace");
108  break;
109  case WXK_DELETE:
110  newStr += wxT("Delete");
111  break;
112  case WXK_SPACE:
113  newStr += wxT("Space");
114  break;
115  case WXK_TAB:
116  newStr += wxT("Tab");
117  break;
118  case WXK_RETURN:
119  newStr += wxT("Return");
120  break;
121  case WXK_PAGEUP:
122  newStr += wxT("PageUp");
123  break;
124  case WXK_PAGEDOWN:
125  newStr += wxT("PageDown");
126  break;
127  case WXK_END:
128  newStr += wxT("End");
129  break;
130  case WXK_HOME:
131  newStr += wxT("Home");
132  break;
133  case WXK_LEFT:
134  newStr += wxT("Left");
135  break;
136  case WXK_UP:
137  newStr += wxT("Up");
138  break;
139  case WXK_RIGHT:
140  newStr += wxT("Right");
141  break;
142  case WXK_DOWN:
143  newStr += wxT("Down");
144  break;
145  case WXK_ESCAPE:
146  newStr += wxT("Escape");
147  break;
148  case WXK_INSERT:
149  newStr += wxT("Insert");
150  break;
151  case WXK_NUMPAD0:
152  newStr += wxT("NUMPAD0");
153  break;
154  case WXK_NUMPAD1:
155  newStr += wxT("NUMPAD1");
156  break;
157  case WXK_NUMPAD2:
158  newStr += wxT("NUMPAD2");
159  break;
160  case WXK_NUMPAD3:
161  newStr += wxT("NUMPAD3");
162  break;
163  case WXK_NUMPAD4:
164  newStr += wxT("NUMPAD4");
165  break;
166  case WXK_NUMPAD5:
167  newStr += wxT("NUMPAD5");
168  break;
169  case WXK_NUMPAD6:
170  newStr += wxT("NUMPAD6");
171  break;
172  case WXK_NUMPAD7:
173  newStr += wxT("NUMPAD7");
174  break;
175  case WXK_NUMPAD8:
176  newStr += wxT("NUMPAD8");
177  break;
178  case WXK_NUMPAD9:
179  newStr += wxT("NUMPAD9");
180  break;
181  case WXK_MULTIPLY:
182  newStr += wxT("*");
183  break;
184  case WXK_ADD:
185  newStr += wxT("+");
186  break;
187  case WXK_SUBTRACT:
188  newStr += wxT("-");
189  break;
190  case WXK_DECIMAL:
191  newStr += wxT(".");
192  break;
193  case WXK_DIVIDE:
194  newStr += wxT("/");
195  break;
196  case WXK_F1:
197  newStr += wxT("F1");
198  break;
199  case WXK_F2:
200  newStr += wxT("F2");
201  break;
202  case WXK_F3:
203  newStr += wxT("F3");
204  break;
205  case WXK_F4:
206  newStr += wxT("F4");
207  break;
208  case WXK_F5:
209  newStr += wxT("F5");
210  break;
211  case WXK_F6:
212  newStr += wxT("F6");
213  break;
214  case WXK_F7:
215  newStr += wxT("F7");
216  break;
217  case WXK_F8:
218  newStr += wxT("F8");
219  break;
220  case WXK_F9:
221  newStr += wxT("F9");
222  break;
223  case WXK_F10:
224  newStr += wxT("F10");
225  break;
226  case WXK_F11:
227  newStr += wxT("F11");
228  break;
229  case WXK_F12:
230  newStr += wxT("F12");
231  break;
232  case WXK_F13:
233  newStr += wxT("F13");
234  break;
235  case WXK_F14:
236  newStr += wxT("F14");
237  break;
238  case WXK_F15:
239  newStr += wxT("F15");
240  break;
241  case WXK_F16:
242  newStr += wxT("F16");
243  break;
244  case WXK_F17:
245  newStr += wxT("F17");
246  break;
247  case WXK_F18:
248  newStr += wxT("F18");
249  break;
250  case WXK_F19:
251  newStr += wxT("F19");
252  break;
253  case WXK_F20:
254  newStr += wxT("F20");
255  break;
256  case WXK_F21:
257  newStr += wxT("F21");
258  break;
259  case WXK_F22:
260  newStr += wxT("F22");
261  break;
262  case WXK_F23:
263  newStr += wxT("F23");
264  break;
265  case WXK_F24:
266  newStr += wxT("F24");
267  break;
268  case WXK_NUMPAD_ENTER:
269  newStr += wxT("NUMPAD_ENTER");
270  break;
271  case WXK_NUMPAD_F1:
272  newStr += wxT("NUMPAD_F1");
273  break;
274  case WXK_NUMPAD_F2:
275  newStr += wxT("NUMPAD_F2");
276  break;
277  case WXK_NUMPAD_F3:
278  newStr += wxT("NUMPAD_F3");
279  break;
280  case WXK_NUMPAD_F4:
281  newStr += wxT("NUMPAD_F4");
282  break;
283  case WXK_NUMPAD_HOME:
284  newStr += wxT("NUMPAD_HOME");
285  break;
286  case WXK_NUMPAD_LEFT:
287  newStr += wxT("NUMPAD_LEFT");
288  break;
289  case WXK_NUMPAD_UP:
290  newStr += wxT("NUMPAD_UP");
291  break;
292  case WXK_NUMPAD_RIGHT:
293  newStr += wxT("NUMPAD_RIGHT");
294  break;
295  case WXK_NUMPAD_DOWN:
296  newStr += wxT("NUMPAD_DOWN");
297  break;
298  case WXK_NUMPAD_PAGEUP:
299  newStr += wxT("NUMPAD_PAGEUP");
300  break;
301  case WXK_NUMPAD_PAGEDOWN:
302  newStr += wxT("NUMPAD_PAGEDOWN");
303  break;
304  case WXK_NUMPAD_END:
305  newStr += wxT("NUMPAD_END");
306  break;
307  case WXK_NUMPAD_BEGIN:
308  newStr += wxT("NUMPAD_HOME");
309  break;
310  case WXK_NUMPAD_INSERT:
311  newStr += wxT("NUMPAD_INSERT");
312  break;
313  case WXK_NUMPAD_DELETE:
314  newStr += wxT("NUMPAD_DELETE");
315  break;
316  case WXK_NUMPAD_EQUAL:
317  newStr += wxT("NUMPAD_EQUAL");
318  break;
319  case WXK_NUMPAD_MULTIPLY:
320  newStr += wxT("NUMPAD_MULTIPLY");
321  break;
322  case WXK_NUMPAD_ADD:
323  newStr += wxT("NUMPAD_ADD");
324  break;
325  case WXK_NUMPAD_SUBTRACT:
326  newStr += wxT("NUMPAD_SUBTRACT");
327  break;
328  case WXK_NUMPAD_DECIMAL:
329  newStr += wxT("NUMPAD_DECIMAL");
330  break;
331  case WXK_NUMPAD_DIVIDE:
332  newStr += wxT("NUMPAD_DIVIDE");
333  break;
334  default:
335  return {}; // Don't do anything if we don't recognize the key
336  }
337  }
338 
339  return NormalizedKeyString{ newStr };
340 }
bool operator!= ( const NormalizedKeyString a,
const NormalizedKeyString b 
)
inline

Definition at line 40 of file Keyboard.h.

References NormalizedKeyString::Raw().

41 { return a.Raw () != b.Raw(); }
const wxString & Raw() const
Definition: Keyboard.h:27
bool operator< ( const NormalizedKeyString a,
const NormalizedKeyString b 
)
inline

Definition at line 44 of file Keyboard.h.

References NormalizedKeyString::Raw().

45 { return a.Raw () < b.Raw(); }
const wxString & Raw() const
Definition: Keyboard.h:27
bool operator== ( const NormalizedKeyString a,
const NormalizedKeyString b 
)
inline

Definition at line 36 of file Keyboard.h.

References NormalizedKeyString::Raw().

37 { return a.Raw () == b.Raw(); }
const wxString & Raw() const
Definition: Keyboard.h:27