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
088b7581
Commit
088b7581
authored
Jul 27, 2010
by
Paul Hunkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added resize hander stub and initial screen size setter
parent
27d80262
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
18 deletions
+76
-18
app-android.cpp
android/testproject/jni/app-android.cpp
+42
-15
lesson05.c
android/testproject/jni/lesson05.c
+1
-1
SDLActivity.java
android/testproject/src/org/libsdl/android/SDLActivity.java
+14
-0
SDL_androidevents.c
src/video/android/SDL_androidevents.c
+5
-0
SDL_androidvideo.c
src/video/android/SDL_androidvideo.c
+14
-2
No files found.
android/testproject/jni/app-android.cpp
View file @
088b7581
...
...
@@ -38,6 +38,8 @@ jmethodID midFlipBuffers;
extern
"C"
int
SDL_main
();
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_OnResize
(
int
width
,
int
height
,
int
format
);
extern
"C"
int
SDL_SendQuit
();
//If we're not the active app, don't try to render
...
...
@@ -47,18 +49,7 @@ bool bRenderingEnabled = false;
Functions called by JNI
*******************************************************************************/
extern
"C"
void
Java_org_libsdl_android_SDLActivity_nativeInit
(
JNIEnv
*
env
,
jobject
obj
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Native Init"
);
mEnv
=
env
;
bRenderingEnabled
=
true
;
SDL_main
();
}
//Library init
extern
"C"
jint
JNI_OnLoad
(
JavaVM
*
vm
,
void
*
reserved
){
JNIEnv
*
env
=
NULL
;
...
...
@@ -86,7 +77,21 @@ extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved){
return
JNI_VERSION_1_4
;
}
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeKeyDown
(
JNIEnv
*
env
,
//Start up the SDL app
extern
"C"
void
Java_org_libsdl_android_SDLActivity_nativeInit
(
JNIEnv
*
env
,
jobject
obj
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Native Init"
);
mEnv
=
env
;
bRenderingEnabled
=
true
;
SDL_main
();
}
//Keydown
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeKeyDown
(
JNIEnv
*
env
,
jobject
obj
,
jint
keycode
){
int
r
=
Android_OnKeyDown
(
keycode
);
...
...
@@ -95,7 +100,8 @@ extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyDown(JNIEnv* env
}
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeKeyUp
(
JNIEnv
*
env
,
//Keyup
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeKeyUp
(
JNIEnv
*
env
,
jobject
obj
,
jint
keycode
){
int
r
=
Android_OnKeyUp
(
keycode
);
...
...
@@ -104,15 +110,19 @@ extern "C" void Java_org_libsdl_android_SDLActivity_onNativeKeyUp(JNIEnv* env,
}
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeTouch
(
JNIEnv
*
env
,
//Touch
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeTouch
(
JNIEnv
*
env
,
jobject
obj
,
jint
action
,
jfloat
x
,
jfloat
y
,
jfloat
p
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: native touch event %d @ %f/%f, pressure %f
\n
"
,
action
,
x
,
y
,
p
);
//TODO: Pass this off to the SDL multitouch stuff
}
//Quit
extern
"C"
void
Java_org_libsdl_android_SDLActivity_nativeQuit
(
JNIEnv
*
env
,
jobject
obj
){
...
...
@@ -125,6 +135,23 @@ extern "C" void Java_org_libsdl_android_SDLActivity_nativeQuit( JNIEnv* env,
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Native quit %d"
,
r
);
}
//Screen size
extern
"C"
void
Java_org_libsdl_android_SDLActivity_nativeSetScreenSize
(
JNIEnv
*
env
,
jobject
obj
,
jint
width
,
jint
height
){
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: Set screen size on init: %d/%d
\n
"
,
width
,
height
);
Android_SetScreenResolution
(
width
,
height
);
}
//Resize
extern
"C"
void
Java_org_libsdl_android_SDLActivity_onNativeResize
(
JNIEnv
*
env
,
jobject
obj
,
jint
width
,
jint
height
,
jint
format
){
Android_OnResize
(
width
,
height
,
format
);
}
/*******************************************************************************
...
...
android/testproject/jni/lesson05.c
View file @
088b7581
...
...
@@ -27,7 +27,7 @@
/* screen width, height, and bit depth */
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 4
8
0
#define SCREEN_HEIGHT 4
3
0
#define SCREEN_BPP 16
/* Define our booleans */
...
...
android/testproject/src/org/libsdl/android/SDLActivity.java
View file @
088b7581
...
...
@@ -62,10 +62,12 @@ public class SDLActivity extends Activity {
//C functions we call
public
static
native
void
nativeInit
();
public
static
native
void
nativeQuit
();
public
static
native
void
nativeSetScreenSize
(
int
width
,
int
height
);
public
static
native
void
onNativeKeyDown
(
int
keycode
);
public
static
native
void
onNativeKeyUp
(
int
keycode
);
public
static
native
void
onNativeTouch
(
int
action
,
float
x
,
float
y
,
float
p
);
public
static
native
void
onNativeResize
(
int
x
,
int
y
,
int
format
);
...
...
@@ -95,6 +97,8 @@ class SDLRunner implements Runnable{
public
void
run
(){
//Runs SDL_main()
SDLActivity
.
nativeInit
();
Log
.
v
(
"SDL"
,
"SDL thread terminated"
);
}
}
...
...
@@ -132,6 +136,14 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
public
void
surfaceCreated
(
SurfaceHolder
holder
)
{
Log
.
v
(
"SDL"
,
"Surface created"
);
int
width
=
getWidth
();
int
height
=
getHeight
();
//Set the width and height variables in C before we start SDL so we have
//it available on init
SDLActivity
.
nativeSetScreenSize
(
width
,
height
);
//Now start up the C app thread
mSDLThread
=
new
Thread
(
new
SDLRunner
(),
"SDLThread"
);
mSDLThread
.
start
();
}
...
...
@@ -147,6 +159,8 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
public
void
surfaceChanged
(
SurfaceHolder
holder
,
int
format
,
int
width
,
int
height
)
{
Log
.
v
(
"SDL"
,
"Surface resized"
);
SDLActivity
.
onNativeResize
(
width
,
height
,
format
);
}
//unused
...
...
src/video/android/SDL_androidevents.c
View file @
088b7581
...
...
@@ -67,6 +67,11 @@ Android_PumpEvents(_THIS)
*/
}
void
Android_OnResize
(
int
width
,
int
height
,
int
format
){
}
int
Android_OnKeyDown
(
int
keycode
){
return
SDL_SendKeyboardKey
(
0
,
SDL_PRESSED
,
(
SDL_scancode
)
keycode
);
...
...
src/video/android/SDL_androidvideo.c
View file @
088b7581
...
...
@@ -57,6 +57,12 @@ extern void Android_GL_DeleteContext(_THIS, SDL_GLContext context);
/* Android driver bootstrap functions */
//These are filled in with real values in Android_SetScreenResolution on
//init (before SDL_Main())
static
int
iScreenWidth
=
320
;
static
int
iScreenHeight
=
240
;
static
int
Android_Available
(
void
)
{
...
...
@@ -120,8 +126,8 @@ Android_VideoInit(_THIS)
/* Use a fake 32-bpp desktop mode */
mode
.
format
=
SDL_PIXELFORMAT_RGB888
;
mode
.
w
=
320
;
mode
.
h
=
480
;
mode
.
w
=
iScreenWidth
;
mode
.
h
=
iScreenHeight
;
mode
.
refresh_rate
=
0
;
mode
.
driverdata
=
NULL
;
if
(
SDL_AddBasicVideoDisplay
(
&
mode
)
<
0
)
{
...
...
@@ -150,5 +156,11 @@ Android_VideoQuit(_THIS)
}
void
Android_SetScreenResolution
(
int
width
,
int
height
){
iScreenWidth
=
width
;
iScreenHeight
=
height
;
}
/* 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