Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
a7381c4e
Commit
a7381c4e
authored
Jan 07, 2019
by
Matej Frančeškin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Android Joystick init behave in the same was as for SDL
parent
98643b5f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
JoystickAndroid.cc
src/Joystick/JoystickAndroid.cc
+3
-3
JoystickAndroid.h
src/Joystick/JoystickAndroid.h
+4
-2
JoystickManager.cc
src/Joystick/JoystickManager.cc
+5
-2
No files found.
src/Joystick/JoystickAndroid.cc
View file @
a7381c4e
...
...
@@ -76,8 +76,6 @@ QMap<QString, Joystick*> JoystickAndroid::discover(MultiVehicleManager* _multiVe
bool
joystickFound
=
false
;
static
QMap
<
QString
,
Joystick
*>
ret
;
_initStatic
();
//it's enough to run it once, should be in a static constructor
QMutexLocker
lock
(
&
m_mutex
);
QAndroidJniEnvironment
env
;
...
...
@@ -194,7 +192,7 @@ uint8_t JoystickAndroid::_getHat(int hat,int i) {
}
//helper method
void
JoystickAndroid
::
_initStatic
()
{
bool
JoystickAndroid
::
init
()
{
//this gets list of all possible buttons - this is needed to check how many buttons our gamepad supports
//instead of the whole logic below we could have just a simple array of hardcoded int values as these 'should' not change
...
...
@@ -229,5 +227,7 @@ void JoystickAndroid::_initStatic() {
ACTION_DOWN
=
QAndroidJniObject
::
getStaticField
<
jint
>
(
"android/view/KeyEvent"
,
"ACTION_DOWN"
);
ACTION_UP
=
QAndroidJniObject
::
getStaticField
<
jint
>
(
"android/view/KeyEvent"
,
"ACTION_UP"
);
return
true
;
}
src/Joystick/JoystickAndroid.h
View file @
a7381c4e
...
...
@@ -16,8 +16,11 @@ class JoystickAndroid : public Joystick, public QtAndroidPrivate::GenericMotionE
{
public:
JoystickAndroid
(
const
QString
&
name
,
int
axisCount
,
int
buttonCount
,
int
id
,
MultiVehicleManager
*
multiVehicleManager
);
~
JoystickAndroid
();
static
bool
init
();
static
QMap
<
QString
,
Joystick
*>
discover
(
MultiVehicleManager
*
_multiVehicleManager
);
private:
...
...
@@ -37,7 +40,6 @@ private:
bool
*
btnValue
;
int
*
axisValue
;
static
void
_initStatic
();
static
int
*
_androidBtnList
;
//list of all possible android buttons
static
int
_androidBtnListCount
;
...
...
src/Joystick/JoystickManager.cc
View file @
a7381c4e
...
...
@@ -60,8 +60,11 @@ void JoystickManager::init() {
_joystickCheckTimer
.
start
(
250
);
}
#elif defined(__android__)
if
(
JoystickAndroid
::
init
())
{
_setActiveJoystickFromSettings
();
//TODO: Investigate Android events for Joystick hot plugging & run _joystickCheckTimer if possible
connect
(
&
_joystickCheckTimer
,
&
QTimer
::
timeout
,
this
,
&
JoystickManager
::
_updateAvailableJoysticks
);
_joystickCheckTimer
.
start
(
250
);
}
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment