Commit 92422bd5 authored by Gregory Dymarek's avatar Gregory Dymarek

Improving coding style

parent 6e33df1a
...@@ -221,14 +221,14 @@ float Joystick::_adjustRange(int value, Calibration_t calibration) ...@@ -221,14 +221,14 @@ float Joystick::_adjustRange(int value, Calibration_t calibration)
void Joystick::run(void) void Joystick::run(void)
{ {
open(); _open();
while (!_exitThread) { while (!_exitThread) {
update(); _update();
// Update axes // Update axes
for (int axisIndex=0; axisIndex<_axisCount; axisIndex++) { for (int axisIndex=0; axisIndex<_axisCount; axisIndex++) {
int newAxisValue = getAxis(axisIndex); int newAxisValue = _getAxis(axisIndex);
// Calibration code requires signal to be emitted even if value hasn't changed // Calibration code requires signal to be emitted even if value hasn't changed
_rgAxisValues[axisIndex] = newAxisValue; _rgAxisValues[axisIndex] = newAxisValue;
emit rawAxisValueChanged(axisIndex, newAxisValue); emit rawAxisValueChanged(axisIndex, newAxisValue);
...@@ -236,7 +236,7 @@ void Joystick::run(void) ...@@ -236,7 +236,7 @@ void Joystick::run(void)
// Update buttons // Update buttons
for (int buttonIndex=0; buttonIndex<_buttonCount; buttonIndex++) { for (int buttonIndex=0; buttonIndex<_buttonCount; buttonIndex++) {
bool newButtonValue = getButton(buttonIndex); bool newButtonValue = _getButton(buttonIndex);
if (newButtonValue != _rgButtonValues[buttonIndex]) { if (newButtonValue != _rgButtonValues[buttonIndex]) {
_rgButtonValues[buttonIndex] = newButtonValue; _rgButtonValues[buttonIndex] = newButtonValue;
emit rawButtonPressedChanged(buttonIndex, newButtonValue); emit rawButtonPressedChanged(buttonIndex, newButtonValue);
...@@ -321,7 +321,7 @@ void Joystick::run(void) ...@@ -321,7 +321,7 @@ void Joystick::run(void)
QGC::SLEEP::msleep(40); QGC::SLEEP::msleep(40);
} }
close(); _close();
} }
void Joystick::startPolling(Vehicle* vehicle) void Joystick::startPolling(Vehicle* vehicle)
......
...@@ -132,12 +132,12 @@ protected: ...@@ -132,12 +132,12 @@ protected:
bool _validButton(int button); bool _validButton(int button);
private: private:
virtual bool open() = 0; virtual bool _open() = 0;
virtual void close() = 0; virtual void _close() = 0;
virtual bool update() = 0; virtual bool _update() = 0;
virtual bool getButton(int i) = 0; virtual bool _getButton(int i) = 0;
virtual int getAxis(int i) = 0; virtual int _getAxis(int i) = 0;
// Override from QThread // Override from QThread
virtual void run(void); virtual void run(void);
......
...@@ -42,7 +42,7 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl ...@@ -42,7 +42,7 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
return ret; return ret;
} }
bool JoystickSDL::open(void) { bool JoystickSDL::_open(void) {
sdlJoystick = SDL_JoystickOpen(_index); sdlJoystick = SDL_JoystickOpen(_index);
if (!sdlJoystick) { if (!sdlJoystick) {
...@@ -53,21 +53,21 @@ bool JoystickSDL::open(void) { ...@@ -53,21 +53,21 @@ bool JoystickSDL::open(void) {
return true; return true;
} }
void JoystickSDL::close(void) { void JoystickSDL::_close(void) {
SDL_JoystickClose(sdlJoystick); SDL_JoystickClose(sdlJoystick);
} }
bool JoystickSDL::update(void) bool JoystickSDL::_update(void)
{ {
SDL_JoystickUpdate(); SDL_JoystickUpdate();
return true; return true;
} }
bool JoystickSDL::getButton(int i) { bool JoystickSDL::_getButton(int i) {
return !!SDL_JoystickGetButton(sdlJoystick, i); return !!SDL_JoystickGetButton(sdlJoystick, i);
} }
int JoystickSDL::getAxis(int i) { int JoystickSDL::_getAxis(int i) {
return SDL_JoystickGetAxis(sdlJoystick, i); return SDL_JoystickGetAxis(sdlJoystick, i);
} }
...@@ -20,12 +20,12 @@ public: ...@@ -20,12 +20,12 @@ public:
static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager); static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager);
private: private:
virtual bool open(); bool _open() final;
virtual void close(); void _close() final;
virtual bool update(); bool _update() final;
virtual bool getButton(int i); bool _getButton(int i) final;
virtual int getAxis(int i); int _getAxis(int i) final;
SDL_Joystick *sdlJoystick; SDL_Joystick *sdlJoystick;
int _index; ///< Index for SDL_JoystickOpen int _index; ///< Index for SDL_JoystickOpen
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment