Skip to content

Commit

Permalink
Fixed issue #959: Joystick configuration lost if not plugged in
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian Behvandnejad authored and LMH0013 committed May 12, 2013
1 parent 1be16ee commit d0f85cb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/control/joystickkeyboardcontroller.cpp
Expand Up @@ -239,24 +239,27 @@ JoystickKeyboardController::read(const Reader& lisp)
continue;
}

bool js_available = joysticks.size() > 0;

if (map->get("button", button)) {
if(button < 0 || button >= max_joybuttons) {
if(js_available && (button < 0 || button >= max_joybuttons)) {
log_info << "Invalid button '" << button << "' in buttonmap" << std::endl;
continue;
}
bind_joybutton(0, button, Control(i));
}

if (map->get("axis", axis)) {
if (axis == 0 || abs(axis) > max_joyaxis) {
if (js_available && (axis == 0 || abs(axis) > max_joyaxis)) {
log_info << "Invalid axis '" << axis << "' in axismap" << std::endl;
continue;
}
bind_joyaxis(0, axis, Control(i));
}

if (map->get("hat", hat)) {
if (hat != SDL_HAT_UP &&
if (js_available &&
hat != SDL_HAT_UP &&
hat != SDL_HAT_DOWN &&
hat != SDL_HAT_LEFT &&
hat != SDL_HAT_RIGHT) {
Expand Down

0 comments on commit d0f85cb

Please sign in to comment.