scummvm/backends/keymapper/action.cpp

58 lines
1.6 KiB
C++
Raw Normal View History

2011-04-16 14:08:33 +02:00
/* ScummVM - Graphic Adventure Engine
2014-04-05 18:18:42 +02:00
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
2009-10-04 10:23:44 +00:00
#include "backends/keymapper/action.h"
#ifdef ENABLE_KEYMAPPER
#include "backends/keymapper/keymap.h"
namespace Common {
2012-02-22 17:21:09 +01:00
Action::Action(Keymap *boss, const char *i, String des)
2012-03-25 11:41:48 +02:00
: _boss(boss), description(des), _hwInput(0) {
2009-10-04 10:23:44 +00:00
assert(i);
assert(_boss);
2011-04-10 21:59:04 +02:00
Common::strlcpy(id, i, ACTION_ID_SIZE);
2009-10-04 10:23:44 +00:00
_boss->addAction(this);
}
2012-03-25 11:41:48 +02:00
void Action::mapInput(const HardwareInput *input) {
if (_hwInput)
2009-10-04 10:23:44 +00:00
_boss->unregisterMapping(this);
2012-03-25 11:41:48 +02:00
_hwInput = input;
2009-10-04 10:23:44 +00:00
2012-03-25 11:41:48 +02:00
if (_hwInput)
_boss->registerMapping(this, _hwInput);
2009-10-04 10:23:44 +00:00
}
2012-03-25 11:41:48 +02:00
const HardwareInput *Action::getMappedInput() const {
return _hwInput;
2009-10-04 10:23:44 +00:00
}
2010-01-21 19:25:03 +00:00
} // End of namespace Common
2009-10-04 10:23:44 +00:00
#endif // #ifdef ENABLE_KEYMAPPER