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
c829c6f8
Commit
c829c6f8
authored
May 16, 2019
by
Matej Frančeškin
Committed by
Matej Frančeškin
May 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set Android Joystick native methods from JNI_OnLoad
parent
63778dc4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
JoystickAndroid.cc
src/Joystick/JoystickAndroid.cc
+2
-6
JoystickAndroid.h
src/Joystick/JoystickAndroid.h
+2
-2
main.cc
src/main.cc
+7
-2
No files found.
src/Joystick/JoystickAndroid.cc
View file @
c829c6f8
...
...
@@ -211,9 +211,7 @@ static JoystickManager *_manager = nullptr;
//helper method
bool
JoystickAndroid
::
init
(
JoystickManager
*
manager
)
{
if
(
_manager
==
nullptr
)
{
setNativeMethods
(
manager
);
}
_manager
=
manager
;
//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
...
...
@@ -267,12 +265,10 @@ static void jniUpdateAvailableJoysticks(JNIEnv *envA, jobject thizA)
}
}
void
JoystickAndroid
::
setNativeMethods
(
JoystickManager
*
manager
)
void
JoystickAndroid
::
setNativeMethods
()
{
qCDebug
(
JoystickLog
)
<<
"Registering Native Functions"
;
_manager
=
manager
;
// REGISTER THE C++ FUNCTION WITH JNI
JNINativeMethod
javaMethods
[]
{
{
"nativeUpdateAvailableJoysticks"
,
"()V"
,
reinterpret_cast
<
void
*>
(
jniUpdateAvailableJoysticks
)}
...
...
src/Joystick/JoystickAndroid.h
View file @
c829c6f8
...
...
@@ -21,14 +21,14 @@ public:
static
bool
init
(
JoystickManager
*
manager
);
static
void
setNativeMethods
();
static
QMap
<
QString
,
Joystick
*>
discover
(
MultiVehicleManager
*
_multiVehicleManager
);
private:
bool
handleKeyEvent
(
jobject
event
);
bool
handleGenericMotionEvent
(
jobject
event
);
static
void
setNativeMethods
(
JoystickManager
*
manager
);
virtual
bool
_open
();
virtual
void
_close
();
virtual
bool
_update
();
...
...
src/main.cc
View file @
c829c6f8
...
...
@@ -78,9 +78,12 @@ int WindowsCrtReportHook(int reportType, char* message, int* returnValue)
#endif
#if defined(__android__)
&& !defined(NO_SERIAL_LINK)
#if defined(__android__)
#include <jni.h>
#include "JoystickAndroid.h"
#if !defined(NO_SERIAL_LINK)
#include "qserialport.h"
#endif
jint
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
)
{
...
...
@@ -90,8 +93,10 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved)
if
(
vm
->
GetEnv
(
reinterpret_cast
<
void
**>
(
&
env
),
JNI_VERSION_1_6
)
!=
JNI_OK
)
{
return
-
1
;
}
#if !defined(NO_SERIAL_LINK)
QSerialPort
::
setNativeMethods
();
#endif
JoystickAndroid
::
setNativeMethods
();
return
JNI_VERSION_1_6
;
}
...
...
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