X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Flinux%2Fgamecontroller.cpp;h=06008bcf90b0adcd2abd89d6e05eac457b049992;hb=HEAD;hp=c00379d4c70e9e595c0c1257a7ac92881f574861;hpb=7262f1e7e9ea88a021c14de9dc06ebe76112afd7;p=libs%2Fgui.git diff --git a/source/input/linux/gamecontroller.cpp b/source/input/linux/gamecontroller.cpp index c00379d..06008bc 100644 --- a/source/input/linux/gamecontroller.cpp +++ b/source/input/linux/gamecontroller.cpp @@ -1,11 +1,12 @@ +#include "gamecontroller.h" +#include "gamecontroller_platform.h" #include #include +#include #include #include #include #include -#include "gamecontroller.h" -#include "gamecontroller_platform.h" using namespace std; @@ -15,7 +16,7 @@ namespace Input { vector GameController::Private::detected_controllers; GameController::GameController(unsigned index): - event_disp(0) + Device(GAME_CONTROLLER) { if(!detect_done) detect(); @@ -42,10 +43,11 @@ unsigned GameController::detect() Private::detected_controllers.clear(); FS::Path dev_input = "/dev/input"; - list devices = FS::list_filtered(dev_input, "^js[0-9]+"); - for(list::const_iterator i=devices.begin(); i!=devices.end(); ++i) + vector devices = FS::list_filtered(dev_input, "^js[0-9]+"); + sort(devices); + for(const string &f: devices) // TODO check permissions - Private::detected_controllers.push_back((dev_input / *i).str()); + Private::detected_controllers.push_back((dev_input/f).str()); detect_done = true; n_detected_controllers = Private::detected_controllers.size(); @@ -77,11 +79,11 @@ void GameController::tick() unsigned count = len/sizeof(js_event); for(unsigned i=0; i