mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Added more safety asserts to input dispatcher
This commit is contained in:
parent
0e30756ba1
commit
69a56e8677
2 changed files with 13 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "dispatch_map.hpp"
|
||||
#include "func_binder.hpp"
|
||||
#include <mangle/input/event.hpp>
|
||||
#include <assert.h>
|
||||
|
||||
namespace OEngine {
|
||||
namespace Input {
|
||||
|
@ -19,8 +20,16 @@ struct Dispatcher : Mangle::Input::Event
|
|||
*/
|
||||
Dispatcher(int actions) : funcs(actions) {}
|
||||
|
||||
void bind(int action, int key) { map.bind(key, action); }
|
||||
void unbind(int action, int key) { map.unbind(key, action); }
|
||||
void bind(unsigned int action, int key)
|
||||
{
|
||||
assert(action < funcs.getSize());
|
||||
map.bind(key, action);
|
||||
}
|
||||
void unbind(unsigned int action, int key)
|
||||
{
|
||||
assert(action < funcs.getSize());
|
||||
map.unbind(key, action);
|
||||
}
|
||||
bool isBound(int key) const { return map.isBound(key); }
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
*/
|
||||
FuncBinder(int number) : bindings(number) {}
|
||||
|
||||
unsigned int getSize() { return bindings.size(); }
|
||||
|
||||
/**
|
||||
Bind an action to an index.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue