Debian Codegraph @

src/plan/Keymap.cpp

raw
1 /*
2 * Copyright (C) 2004 Ivo Danihelka ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9 #include "Keymap.h"
10
11 #include "Log.h"
12
13 //-----------------------------------------------------------------
14 void
15 Keymap::registerKey(const KeyStroke &stroke, const KeyDesc &desc)
16 {
17 m_keys.insert(std::pair<KeyStroke,KeyDesc>(stroke, desc));
18 }
19 //-----------------------------------------------------------------
20 /**
21 * Return index of pressed key.
22 * @return index or -1
23 */
24 int
25 Keymap::indexPressed(const KeyStroke &stroke) const
26 {
27 int result = -1;
28 t_keys::const_iterator it = m_keys.find(stroke);
29 if (m_keys.end() != it) {
30 result = it->second.getIndex();
31 }
32 return result;
33 }
34