Skip to content

Commit

Permalink
InputHandler uses pointers to KeyBinding structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkie committed Mar 3, 2012
1 parent 5ab6357 commit c4ffcd7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/badger/input_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ namespace Badger {
*/
void registerEvent(const char* name,
int value,
KeyBinding primary,
KeyBinding secondary);
KeyBinding* primary,
KeyBinding* secondary);

/*
* Rebinds a key combination to the primary binding of the given event.
* The event must have been registered by registerEvent().
*/
void rebindPrimary(const char* name,
KeyBinding primary);
KeyBinding* primary);

/*
* Rebinds a key combination to the secondary binding of the given
* event. The event must have been registered by registerEvent().
*/
void rebindSecondary(const char* name,
KeyBinding secondary);
KeyBinding* secondary);

int yieldEvent(KeyBinding* binding);

Expand Down
16 changes: 8 additions & 8 deletions src/input_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,33 @@ Badger::InputHandler::~InputHandler() {

void Badger::InputHandler::registerEvent(const char* name,
int value,
Badger::KeyBinding primary,
Badger::KeyBinding secondary) {
Badger::KeyBinding* primary,
Badger::KeyBinding* secondary) {
Binding* binding = new Binding();

binding->name = name;
binding->value = value;
binding->primary = primary;
binding->secondary = secondary;
binding->primary = *primary;
binding->secondary = *secondary;

_bindings.push_back(binding);
}

void Badger::InputHandler::rebindPrimary(const char* name,
KeyBinding primary) {
KeyBinding* primary) {
for (unsigned int i = 0; i < _bindings.size(); i++) {
if (strncmp(_bindings[i]->name, name, 128) == 0) {
_bindings[i]->primary = primary;
_bindings[i]->primary = *primary;
return;
}
}
}

void Badger::InputHandler::rebindSecondary(const char* name,
KeyBinding secondary) {
KeyBinding* secondary) {
for (unsigned int i = 0; i < _bindings.size(); i++) {
if (strncmp(_bindings[i]->name, name, 128) == 0) {
_bindings[i]->secondary = secondary;
_bindings[i]->secondary = *secondary;
return;
}
}
Expand Down

0 comments on commit c4ffcd7

Please sign in to comment.