]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/control.cpp
Use nullptr in place of 0 or NULL
[libs/gui.git] / source / input / control.cpp
index 3e2398d15860471dd8dc8eee9cad89ce1596e9c5..4f093573baeaf2418a2faf25ca881934b94aecae 100644 (file)
@@ -1,7 +1,7 @@
+#include "control.h"
 #include <sigc++/bind_return.h>
 #include <msp/strings/lexicalcast.h>
 #include "binarycontrol.h"
-#include "control.h"
 #include "device.h"
 
 using namespace std;
@@ -9,19 +9,13 @@ using namespace std;
 namespace Msp {
 namespace Input {
 
-ControlSource::ControlSource():
-       dev(0),
-       type(NONE),
-       index(0)
-{ }
-
 ControlSource::ControlSource(Device &d, ControlSrcType t, unsigned i):
        dev(&d),
        type(t),
        index(i)
 { }
 
-std::string ControlSource::str() const
+string ControlSource::str() const
 {
        if(type==BUTTON)
                return dev->get_button_name(index);
@@ -29,37 +23,19 @@ std::string ControlSource::str() const
                return dev->get_axis_name(index)+" +";
        else if(type==AXIS_NEG)
                return dev->get_axis_name(index)+" -";
-       else if(type==NONE)
+       else if(type==NO_SOURCE)
                return "None";
 
        return lexical_cast<string>(index);
 }
 
 
-Control::Control():
-       capture_dev(0),
-       activator(0),
-       origin(0),
-       rising_edge(false),
-       falling_edge(false)
-{ }
-
 Control::Control(const ControlSource &s):
-       src(s),
-       capture_dev(0),
-       activator(0),
-       origin(0),
-       rising_edge(false),
-       falling_edge(false)
+       src(s)
 { }
 
 Control::Control(Device &d, ControlSrcType t, unsigned i):
-       src(d, t, i),
-       capture_dev(0),
-       activator(0),
-       origin(0),
-       rising_edge(false),
-       falling_edge(false)
+       src(d, t, i)
 {
        connect_signals();
 }
@@ -78,7 +54,7 @@ void Control::capture(Device &d)
 void Control::cancel_capture()
 {
        notify_callbacks();
-       capture_dev = 0;
+       capture_dev = nullptr;
        connect_signals();
 }
 
@@ -111,7 +87,7 @@ void Control::connect_signals()
 {
        switch(src.type)
        {
-       case NONE:
+       case NO_SOURCE:
                break;
        case BUTTON:
                src.dev->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Control::button_press), false));
@@ -136,7 +112,7 @@ void Control::button_press(unsigned i)
                src.index = i;
 
                notify_callbacks();
-               capture_dev = 0;
+               capture_dev = nullptr;
                connect_signals();
                signal_capture_complete.emit();
        }
@@ -154,20 +130,20 @@ void Control::axis_motion(unsigned i, float v, float r)
 {
        if(capture_dev)
        {
-               ControlSrcType type = NONE;
+               ControlSrcType type = NO_SOURCE;
                if(v<-0.9)
                        type = AXIS_NEG;
                else if(v>0.9)
                        type = AXIS_POS;
 
-               if(type!=NONE)
+               if(type!=NO_SOURCE)
                {
                        src.dev = capture_dev;
                        src.type = type;
                        src.index = i;
 
                        notify_callbacks();
-                       capture_dev = 0;
+                       capture_dev = nullptr;
                        connect_signals();
                        signal_capture_complete.emit();
                }