Skip to content

Commit

Permalink
SDL backend: re-init controllers in Lua after reloading.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinw committed Feb 18, 2020
1 parent 62eb034 commit cd29129
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/am_backend_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ int main( int argc, char *argv[] )
}
if (windows.size() == 0) goto quit;

if (restart_triggered) {
// re "attach" the controllers on the lua side after reloading the
// world.
for (int index = 0; index < MAX_CONTROLLERS; ++index) {
if (controller_infos[index].active) {
lua_pushinteger(L, index);
lua_pushinteger(L, controller_infos[index].joyid);
am_call_amulet(L, "_controller_attached", 2, 0);
}
}
}

restart_triggered = false;

t0 = am_get_current_time();
Expand Down

0 comments on commit cd29129

Please sign in to comment.