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
a410db1a
Commit
a410db1a
authored
Jan 12, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bit of cleanup in the Android driver
parent
74b33811
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
97 additions
and
89 deletions
+97
-89
SDLActivity.java
android-project/src/org/libsdl/app/SDLActivity.java
+0
-6
SDL_android.cpp
src/SDL_android.cpp
+10
-10
SDL_androidevents.c
src/video/android/SDL_androidevents.c
+1
-47
SDL_androidevents.h
src/video/android/SDL_androidevents.h
+0
-1
SDL_androidgl.c
src/video/android/SDL_androidgl.c
+1
-14
SDL_androidkeyboard.c
src/video/android/SDL_androidkeyboard.c
+52
-0
SDL_androidkeyboard.h
src/video/android/SDL_androidkeyboard.h
+30
-0
SDL_androidvideo.c
src/video/android/SDL_androidvideo.c
+3
-11
No files found.
android-project/src/org/libsdl/app/SDLActivity.java
View file @
a410db1a
...
@@ -158,12 +158,6 @@ public class SDLActivity extends Activity {
...
@@ -158,12 +158,6 @@ public class SDLActivity extends Activity {
}
}
}
}
}
}
}
}
...
...
src/SDL_android.cpp
View file @
a410db1a
...
@@ -21,6 +21,11 @@
...
@@ -21,6 +21,11 @@
*/
*/
#include "SDL_config.h"
#include "SDL_config.h"
extern
"C"
{
#include "events/SDL_events_c.h"
#include "video/android/SDL_androidkeyboard.h"
}
/*******************************************************************************
/*******************************************************************************
This file links the Java side of Android with libsdl
This file links the Java side of Android with libsdl
*******************************************************************************/
*******************************************************************************/
...
@@ -44,12 +49,8 @@ jmethodID midFlipBuffers;
...
@@ -44,12 +49,8 @@ jmethodID midFlipBuffers;
jmethodID
midEnableFeature
;
jmethodID
midEnableFeature
;
jmethodID
midUpdateAudio
;
jmethodID
midUpdateAudio
;
extern
"C"
int
Android_OnKeyDown
(
int
keycode
);
extern
"C"
int
Android_OnKeyUp
(
int
keycode
);
extern
"C"
void
Android_SetScreenResolution
(
int
width
,
int
height
);
extern
"C"
void
Android_SetScreenResolution
(
int
width
,
int
height
);
extern
"C"
void
Android_OnResize
(
int
width
,
int
height
,
int
format
);
extern
"C"
int
SDL_SendQuit
();
extern
"C"
int
SDL_SendQuit
();
extern
"C"
void
Android_EnableFeature
(
int
featureid
,
bool
enabled
);
//If we're not the active app, don't try to render
//If we're not the active app, don't try to render
bool
bRenderingEnabled
=
false
;
bool
bRenderingEnabled
=
false
;
...
@@ -102,22 +103,22 @@ extern "C" void SDL_Android_Init(JNIEnv* env)
...
@@ -102,22 +103,22 @@ extern "C" void SDL_Android_Init(JNIEnv* env)
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeKeyDown
(
JNIEnv
*
env
,
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeKeyDown
(
JNIEnv
*
env
,
jobject
obj
,
jint
keycode
)
jobject
obj
,
jint
keycode
)
{
{
int
r
=
Android_OnKeyDown
(
keycode
);
#ifdef DEBUG
#ifdef DEBUG
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: native key down %d
, %d
\n
"
,
keycode
,
r
);
"SDL: native key down %d
\n
"
,
keycode
);
#endif
#endif
Android_OnKeyDown
(
keycode
);
}
}
// Keyup
// Keyup
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeKeyUp
(
JNIEnv
*
env
,
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeKeyUp
(
JNIEnv
*
env
,
jobject
obj
,
jint
keycode
)
jobject
obj
,
jint
keycode
)
{
{
int
r
=
Android_OnKeyUp
(
keycode
);
#ifdef DEBUG
#ifdef DEBUG
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: native key up %d
, %d
\n
"
,
keycode
,
r
);
"SDL: native key up %d
\n
"
,
keycode
);
#endif
#endif
Android_OnKeyUp
(
keycode
);
}
}
// Touch
// Touch
...
@@ -158,7 +159,7 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
...
@@ -158,7 +159,7 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
JNIEnv
*
env
,
jobject
obj
,
jint
width
,
JNIEnv
*
env
,
jobject
obj
,
jint
width
,
jint
height
,
jint
format
)
jint
height
,
jint
format
)
{
{
Android_OnResize
(
width
,
height
,
format
);
/* FIXME: What is the relationship between this and the window? */
}
}
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeAccel
(
extern
"C"
void
Java_org_libsdl_app_SDLActivity_onNativeAccel
(
...
@@ -228,4 +229,3 @@ extern "C" void Android_UpdateAudioBuffer(unsigned char *buf, int len)
...
@@ -228,4 +229,3 @@ extern "C" void Android_UpdateAudioBuffer(unsigned char *buf, int len)
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: invoked
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: invoked
\n
"
);
}
}
src/video/android/SDL_androidevents.c
View file @
a410db1a
...
@@ -21,58 +21,12 @@
...
@@ -21,58 +21,12 @@
*/
*/
#include "SDL_config.h"
#include "SDL_config.h"
/* Being a null driver, there's no event stream. We just define stubs for
most of the API. */
#include <stdio.h>
#include <stdlib.h>
#include "../../events/SDL_sysevents.h"
#include "../../events/SDL_events_c.h"
#include "SDL_androidevents.h"
#include "SDL_androidevents.h"
void
Android_InitEvents
()
{
SDLKey
keymap
[
SDL_NUM_SCANCODES
];
/* Add default scancode to key mapping */
SDL_GetDefaultKeymap
(
keymap
);
SDL_SetKeymap
(
0
,
keymap
,
SDL_NUM_SCANCODES
);
}
void
void
Android_PumpEvents
(
_THIS
)
Android_PumpEvents
(
_THIS
)
{
{
/* No polling necessary */
//scanKeys();
/* TODO: defer click-age */
/*
if (keysDown() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_PRESSED, 0);
} else if (keysUp() & KEY_TOUCH) {
SDL_SendMouseButton(0, SDL_RELEASED, 0);
}
if (keysHeld() & KEY_TOUCH) {
touchPosition t = touchReadXY();
SDL_SendMouseMotion(0, 0, t.px, t.py, 1);
}
*/
}
void
Android_OnResize
(
int
width
,
int
height
,
int
format
){
}
int
Android_OnKeyDown
(
int
keycode
){
return
SDL_SendKeyboardKey
(
SDL_PRESSED
,
(
SDL_scancode
)
keycode
);
}
int
Android_OnKeyUp
(
int
keycode
){
return
SDL_SendKeyboardKey
(
SDL_RELEASED
,
(
SDL_scancode
)
keycode
);
}
}
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidevents.h
View file @
a410db1a
...
@@ -24,6 +24,5 @@
...
@@ -24,6 +24,5 @@
#include "SDL_androidvideo.h"
#include "SDL_androidvideo.h"
extern
void
Android_PumpEvents
(
_THIS
);
extern
void
Android_PumpEvents
(
_THIS
);
extern
void
Android_InitEvents
();
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidgl.c
View file @
a410db1a
...
@@ -21,17 +21,11 @@
...
@@ -21,17 +21,11 @@
*/
*/
#include "SDL_config.h"
#include "SDL_config.h"
/* Android SDL video driver implementation
/* Android SDL video driver implementation */
*/
#include "SDL_video.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "SDL_androidvideo.h"
#include "SDL_androidvideo.h"
#include "SDL_androidevents.h"
#include <android/log.h>
#include <android/log.h>
...
@@ -58,13 +52,6 @@ void Android_GL_UnloadLibrary(_THIS){
...
@@ -58,13 +52,6 @@ void Android_GL_UnloadLibrary(_THIS){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"[STUB] GL_UnloadLibrary
\n
"
);
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"[STUB] GL_UnloadLibrary
\n
"
);
}
}
/*
int *Android_GL_GetVisual(_THIS, Display * display, int screen){
__android_log_print(ANDROID_LOG_INFO, "SDL","[STUB] GL_GetVisual\n");
return 0;
}
*/
SDL_GLContext
Android_GL_CreateContext
(
_THIS
,
SDL_Window
*
window
){
SDL_GLContext
Android_GL_CreateContext
(
_THIS
,
SDL_Window
*
window
){
Android_CreateContext
();
Android_CreateContext
();
return
1
;
return
1
;
...
...
src/video/android/SDL_androidkeyboard.c
0 → 100644
View file @
a410db1a
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "../../events/SDL_events_c.h"
#include "SDL_androidkeyboard.h"
void
Android_InitKeyboard
()
{
SDLKey
keymap
[
SDL_NUM_SCANCODES
];
/* Add default scancode to key mapping */
SDL_GetDefaultKeymap
(
keymap
);
SDL_SetKeymap
(
0
,
keymap
,
SDL_NUM_SCANCODES
);
}
int
Android_OnKeyDown
(
int
keycode
)
{
/* FIXME: Need conversion from Android keycode to SDL scancode */
return
SDL_SendKeyboardKey
(
SDL_PRESSED
,
(
SDL_scancode
)
keycode
);
}
int
Android_OnKeyUp
(
int
keycode
)
{
/* FIXME: Need conversion from Android keycode to SDL scancode */
return
SDL_SendKeyboardKey
(
SDL_RELEASED
,
(
SDL_scancode
)
keycode
);
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidkeyboard.h
0 → 100644
View file @
a410db1a
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2010 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_androidvideo.h"
extern
void
Android_InitKeyboard
();
extern
int
Android_OnKeyDown
(
int
keycode
);
extern
int
Android_OnKeyUp
(
int
keycode
);
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidvideo.c
View file @
a410db1a
...
@@ -32,12 +32,12 @@
...
@@ -32,12 +32,12 @@
#include "SDL_androidvideo.h"
#include "SDL_androidvideo.h"
#include "SDL_androidevents.h"
#include "SDL_androidevents.h"
#include "SDL_androidkeyboard.h"
#define ANDROID_VID_DRIVER_NAME "Android"
#define ANDROID_VID_DRIVER_NAME "Android"
/* Initialization/Query functions */
/* Initialization/Query functions */
static
int
Android_VideoInit
(
_THIS
);
static
int
Android_VideoInit
(
_THIS
);
static
int
Android_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
);
static
void
Android_VideoQuit
(
_THIS
);
static
void
Android_VideoQuit
(
_THIS
);
/* GL functions (SDL_androidgl.c) */
/* GL functions (SDL_androidgl.c) */
...
@@ -93,9 +93,8 @@ Android_CreateDevice(int devindex)
...
@@ -93,9 +93,8 @@ Android_CreateDevice(int devindex)
/* Set the function pointers */
/* Set the function pointers */
device
->
VideoInit
=
Android_VideoInit
;
device
->
VideoInit
=
Android_VideoInit
;
device
->
VideoQuit
=
Android_VideoQuit
;
device
->
VideoQuit
=
Android_VideoQuit
;
device
->
SetDisplayMode
=
Android_SetDisplayMode
;
device
->
PumpEvents
=
Android_PumpEvents
;
device
->
PumpEvents
=
Android_PumpEvents
;
device
->
free
=
Android_DeleteDevice
;
device
->
free
=
Android_DeleteDevice
;
/* GL pointers */
/* GL pointers */
...
@@ -136,18 +135,12 @@ Android_VideoInit(_THIS)
...
@@ -136,18 +135,12 @@ Android_VideoInit(_THIS)
SDL_zero
(
mode
);
SDL_zero
(
mode
);
SDL_AddDisplayMode
(
&
_this
->
displays
[
0
],
&
mode
);
SDL_AddDisplayMode
(
&
_this
->
displays
[
0
],
&
mode
);
Android_Init
Events
();
Android_Init
Keyboard
();
/* We're done! */
/* We're done! */
return
0
;
return
0
;
}
}
static
int
Android_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
)
{
return
0
;
}
void
void
Android_VideoQuit
(
_THIS
)
Android_VideoQuit
(
_THIS
)
{
{
...
@@ -160,5 +153,4 @@ void Android_SetScreenResolution(int width, int height){
...
@@ -160,5 +153,4 @@ void Android_SetScreenResolution(int width, int height){
}
}
/* vi: set ts=4 sw=4 expandtab: */
/* vi: set ts=4 sw=4 expandtab: */
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