forked from teamnwah/openmw-tes3coop
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 "dispatch_map.hpp"
|
||||||
#include "func_binder.hpp"
|
#include "func_binder.hpp"
|
||||||
#include <mangle/input/event.hpp>
|
#include <mangle/input/event.hpp>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
namespace OEngine {
|
namespace OEngine {
|
||||||
namespace Input {
|
namespace Input {
|
||||||
|
@ -19,8 +20,16 @@ struct Dispatcher : Mangle::Input::Event
|
||||||
*/
|
*/
|
||||||
Dispatcher(int actions) : funcs(actions) {}
|
Dispatcher(int actions) : funcs(actions) {}
|
||||||
|
|
||||||
void bind(int action, int key) { map.bind(key, action); }
|
void bind(unsigned int action, int key)
|
||||||
void unbind(int action, int key) { map.unbind(key, action); }
|
{
|
||||||
|
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); }
|
bool isBound(int key) const { return map.isBound(key); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -50,6 +50,8 @@ public:
|
||||||
*/
|
*/
|
||||||
FuncBinder(int number) : bindings(number) {}
|
FuncBinder(int number) : bindings(number) {}
|
||||||
|
|
||||||
|
unsigned int getSize() { return bindings.size(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Bind an action to an index.
|
Bind an action to an index.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue