Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joystick: Cleanup Joystick #11985

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,156 changes: 610 additions & 546 deletions src/Joystick/Joystick.cc

Large diffs are not rendered by default.

547 changes: 265 additions & 282 deletions src/Joystick/Joystick.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Joystick/JoystickAndroid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool JoystickAndroid::handleGenericMotionEvent(jobject event)
return true;
}

int JoystickAndroid::_getAndroidHatAxis(int axisHatCode)
int JoystickAndroid::_getAndroidHatAxis(int axisHatCode) const
{
for (int i = 0; i < _axisCount; i++) {
if (axisCode[i] == axisHatCode) {
Expand All @@ -201,7 +201,7 @@ int JoystickAndroid::_getAndroidHatAxis(int axisHatCode)
return 0;
}

bool JoystickAndroid::_getHat(int hat, int i)
bool JoystickAndroid::_getHat(int hat, int i) const
{
// Android supports only one hat button
if (hat != 0) {
Expand Down
8 changes: 4 additions & 4 deletions src/Joystick/JoystickAndroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class JoystickAndroid : public Joystick, public QtAndroidPrivate::GenericMotionE
void _close() final {}
bool _update() final { return true; }

bool _getButton(int i) final { return btnValue[i]; }
int _getAxis(int i) final { return axisValue[i]; }
bool _getHat(int hat, int i) final;
bool _getButton(int i) const final { return btnValue[i]; }
int _getAxis(int i) const final { return axisValue[i]; }
bool _getHat(int hat, int i) const final;

int _getAndroidHatAxis(int axisHatCode);
int _getAndroidHatAxis(int axisHatCode) const;

bool handleKeyEvent(jobject event);
bool handleGenericMotionEvent(jobject event);
Expand Down
6 changes: 3 additions & 3 deletions src/Joystick/JoystickSDL.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ bool JoystickSDL::_update()
return true;
}

bool JoystickSDL::_getButton(int i)
bool JoystickSDL::_getButton(int i) const
{
int button = -1;

Expand All @@ -174,7 +174,7 @@ bool JoystickSDL::_getButton(int i)
return (button == 1);
}

int JoystickSDL::_getAxis(int i)
int JoystickSDL::_getAxis(int i) const
{
int axis = -1;

Expand All @@ -187,7 +187,7 @@ int JoystickSDL::_getAxis(int i)
return axis;
}

bool JoystickSDL::_getHat(int hat, int i)
bool JoystickSDL::_getHat(int hat, int i) const
{
static constexpr uint8_t hatButtons[] = {SDL_HAT_UP, SDL_HAT_DOWN, SDL_HAT_LEFT, SDL_HAT_RIGHT};

Expand Down
6 changes: 3 additions & 3 deletions src/Joystick/JoystickSDL.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ class JoystickSDL : public Joystick
void _close() final;
bool _update() final;

bool _getButton(int i) final;
int _getAxis(int i) final;
bool _getHat(int hat, int i) final;
bool _getButton(int i) const final;
int _getAxis(int i) const final;
bool _getHat(int hat, int i) const final;

static void _loadGameControllerMappings();

Expand Down
7 changes: 4 additions & 3 deletions src/MAVLink/QGCMAVLink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ QGCMAVLink::QGCMAVLink(QObject *parent)
{
// qCDebug(StatusTextHandlerLog) << Q_FUNC_INFO << this;

qRegisterMetaType<mavlink_message_t>("mavlink_message_t");
qRegisterMetaType<MAV_TYPE>("MAV_TYPE");
qRegisterMetaType<MAV_AUTOPILOT>("MAV_AUTOPILOT");
(void) qRegisterMetaType<mavlink_message_t>("mavlink_message_t");
(void) qRegisterMetaType<MAV_TYPE>("MAV_TYPE");
(void) qRegisterMetaType<MAV_AUTOPILOT>("MAV_AUTOPILOT");
(void) qRegisterMetaType<GRIPPER_ACTIONS>("GRIPPER_ACTIONS");
}

QGCMAVLink::~QGCMAVLink()
Expand Down
1 change: 1 addition & 0 deletions src/MAVLink/QGCMAVLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,4 @@ class QGCMAVLink : public QObject

static mavlink_status_t* getChannelStatus(mavlink_channel_t channel) { return mavlink_get_channel_status(static_cast<uint8_t>(channel)); }
};
Q_DECLARE_METATYPE(GRIPPER_ACTIONS)
Loading