]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/linux/gamecontroller.cpp
Use default member initializers and defaulted default constructors
[libs/gui.git] / source / input / linux / gamecontroller.cpp
index f0139e96baeb4b04f150bf463c5fa7f84701a83f..06008bcf90b0adcd2abd89d6e05eac457b049992 100644 (file)
@@ -1,3 +1,5 @@
+#include "gamecontroller.h"
+#include "gamecontroller_platform.h"
 #include <fcntl.h>
 #include <linux/joystick.h>
 #include <msp/core/algorithm.h>
@@ -5,8 +7,6 @@
 #include <msp/fs/dir.h>
 #include <msp/io/handle_private.h>
 #include <msp/strings/format.h>
-#include "gamecontroller.h"
-#include "gamecontroller_platform.h"
 
 using namespace std;
 
@@ -16,7 +16,7 @@ namespace Input {
 vector<string> GameController::Private::detected_controllers;
 
 GameController::GameController(unsigned index):
-       event_disp(0)
+       Device(GAME_CONTROLLER)
 {
        if(!detect_done)
                detect();
@@ -45,9 +45,9 @@ unsigned GameController::detect()
        FS::Path dev_input = "/dev/input";
        vector<string> devices = FS::list_filtered(dev_input, "^js[0-9]+");
        sort(devices);
-       for(vector<string>::const_iterator i=devices.begin(); i!=devices.end(); ++i)
+       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();
@@ -79,11 +79,11 @@ void GameController::tick()
                unsigned count = len/sizeof(js_event);
                for(unsigned i=0; i<count; ++i)
                {
-                       unsigned type = events[i].type&0x7F;
+                       unsigned etype = events[i].type&0x7F;
                        bool init = events[i].type&JS_EVENT_INIT;
-                       if(type==JS_EVENT_AXIS)
+                       if(etype==JS_EVENT_AXIS)
                                set_axis_value(events[i].number, events[i].value/32768.0f, !init);
-                       else if(type==JS_EVENT_BUTTON)
+                       else if(etype==JS_EVENT_BUTTON)
                                set_button_state(events[i].number, events[i].value, !init);
                }