Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
70c916a4
Commit
70c916a4
authored
14 years ago
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up internal accelerometer interface
parent
0ce43244
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
19 deletions
+35
-19
SDL_android.cpp
src/SDL_android.cpp
+9
-1
SDL_android.h
src/SDL_android.h
+8
-7
SDL_sysjoystick.c
src/joystick/android/SDL_sysjoystick.c
+18
-11
No files found.
src/SDL_android.cpp
View file @
70c916a4
...
...
@@ -57,7 +57,7 @@ static jmethodID midAudioWriteByteBuffer;
static
jmethodID
midAudioQuit
;
// Accelerometer data storage
float
fLastAccelerometer
[
3
];
static
float
fLastAccelerometer
[
3
];
/*******************************************************************************
...
...
@@ -184,6 +184,14 @@ extern "C" void Android_JNI_SetActivityTitle(const char *title)
}
}
extern
"C"
void
Android_JNI_GetAccelerometerValues
(
float
values
[
3
])
{
int
i
;
for
(
i
=
0
;
i
<
3
;
++
i
)
{
values
[
i
]
=
fLastAccelerometer
[
i
];
}
}
//
// Audio support
//
...
...
This diff is collapsed.
Click to expand it.
src/SDL_android.h
View file @
70c916a4
...
...
@@ -29,15 +29,16 @@ extern "C" {
#endif
/* Interface from the SDL library into the Android Java activity */
void
Android_JNI_CreateContext
();
void
Android_JNI_SwapWindow
();
void
Android_JNI_SetActivityTitle
(
const
char
*
title
);
extern
void
Android_JNI_CreateContext
();
extern
void
Android_JNI_SwapWindow
();
extern
void
Android_JNI_SetActivityTitle
(
const
char
*
title
);
extern
void
Android_JNI_GetAccelerometerValues
(
float
values
[
3
]);
// Audio support
int
Android_JNI_OpenAudioDevice
(
int
sampleRate
,
int
is16Bit
,
int
channelCount
,
int
desiredBufferFrames
);
void
*
Android_JNI_GetAudioBuffer
();
void
Android_JNI_WriteAudioBuffer
();
void
Android_JNI_CloseAudioDevice
();
extern
int
Android_JNI_OpenAudioDevice
(
int
sampleRate
,
int
is16Bit
,
int
channelCount
,
int
desiredBufferFrames
);
extern
void
*
Android_JNI_GetAudioBuffer
();
extern
void
Android_JNI_WriteAudioBuffer
();
extern
void
Android_JNI_CloseAudioDevice
();
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
...
...
This diff is collapsed.
Click to expand it.
src/joystick/android/SDL_sysjoystick.c
View file @
70c916a4
...
...
@@ -32,10 +32,9 @@
#include "SDL_joystick.h"
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
#include "../../SDL_android.h"
extern
float
fLastAccelerometer
[
3
];
const
char
*
accelerometerName
=
"Android accelerometer"
;
static
const
char
*
accelerometerName
=
"Android accelerometer"
;
/* Function to scan the system for joysticks.
* This function should set SDL_numjoysticks to the number of available
...
...
@@ -47,17 +46,19 @@ SDL_SYS_JoystickInit(void)
{
SDL_numjoysticks
=
1
;
return
(
1
);
return
(
1
);
}
/* Function to get the device-dependent name of a joystick */
const
char
*
SDL_SYS_JoystickName
(
int
index
)
{
if
(
!
index
)
if
(
index
==
0
)
{
return
accelerometerName
;
SDL_SetError
(
"No joystick available with that index"
);
return
(
NULL
);
}
else
{
SDL_SetError
(
"No joystick available with that index"
);
return
(
NULL
);
}
}
/* Function to open a joystick for use.
...
...
@@ -82,12 +83,16 @@ SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
* but instead should call SDL_PrivateJoystick*() to deliver events
* and update joystick device state.
*/
void
void
SDL_SYS_JoystickUpdate
(
SDL_Joystick
*
joystick
)
{
int
i
=
0
;
for
(
i
=
0
;
i
<
3
;
i
++
){
SDL_PrivateJoystickAxis
(
joystick
,
i
,
fLastAccelerometer
[
i
]);
int
i
;
float
values
[
3
];
Android_JNI_GetAccelerometerValues
(
values
);
for
(
i
=
0
;
i
<
3
;
i
++
)
{
SDL_PrivateJoystickAxis
(
joystick
,
i
,
values
[
i
]);
}
}
...
...
@@ -104,3 +109,5 @@ SDL_SYS_JoystickQuit(void)
}
#endif
/* SDL_JOYSTICK_NDS */
/* vi: set ts=4 sw=4 expandtab: */
This diff is collapsed.
Click to expand it.
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