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
cab4e065
Commit
cab4e065
authored
Jan 14, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added "mouse" support for the Android touch screen
parent
70c916a4
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
8 deletions
+108
-8
SDL_android.cpp
src/SDL_android.cpp
+2
-7
SDL_mouse_c.h
src/events/SDL_mouse_c.h
+1
-1
SDL_androidtouch.c
src/video/android/SDL_androidtouch.c
+60
-0
SDL_androidtouch.h
src/video/android/SDL_androidtouch.h
+28
-0
SDL_androidvideo.c
src/video/android/SDL_androidvideo.c
+7
-0
SDL_androidvideo.h
src/video/android/SDL_androidvideo.h
+1
-0
SDL_androidwindow.c
src/video/android/SDL_androidwindow.c
+9
-0
No files found.
src/SDL_android.cpp
View file @
cab4e065
...
...
@@ -26,6 +26,7 @@
extern
"C"
{
#include "events/SDL_events_c.h"
#include "video/android/SDL_androidkeyboard.h"
#include "video/android/SDL_androidtouch.h"
#include "video/android/SDL_androidvideo.h"
/* Impelemented in audio/android/SDL_androidaudio.c */
...
...
@@ -124,13 +125,7 @@ extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
JNIEnv
*
env
,
jclass
jcls
,
jint
action
,
jfloat
x
,
jfloat
y
,
jfloat
p
)
{
#ifdef DEBUG
__android_log_print
(
ANDROID_LOG_INFO
,
"SDL"
,
"SDL: native touch event %d @ %f/%f, pressure %f
\n
"
,
action
,
x
,
y
,
p
);
#endif
//TODO: Pass this off to the SDL multitouch stuff
Android_OnTouch
(
action
,
x
,
y
,
p
);
}
// Accelerometer
...
...
src/events/SDL_mouse_c.h
View file @
cab4e065
...
...
@@ -26,7 +26,7 @@
struct
SDL_Cursor
{
SDL_Cursor
*
next
;
struct
SDL_Cursor
*
next
;
void
*
driverdata
;
};
...
...
src/video/android/SDL_androidtouch.c
0 → 100644
View file @
cab4e065
/*
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 <android/log.h>
#include "SDL_events.h"
#include "../../events/SDL_mouse_c.h"
#include "SDL_androidtouch.h"
#define ACTION_DOWN 0
#define ACTION_UP 1
#define ACTION_MOVE 2
#define ACTION_CANCEL 3
#define ACTION_OUTSIDE 4
void
Android_OnTouch
(
int
action
,
float
x
,
float
y
,
float
p
)
{
if
(
!
Android_Window
)
{
return
;
}
if
((
action
!=
ACTION_CANCEL
)
&&
(
action
!=
ACTION_OUTSIDE
))
{
SDL_SetMouseFocus
(
Android_Window
);
SDL_SendMouseMotion
(
Android_Window
,
0
,
(
int
)
x
,
(
int
)
y
);
switch
(
action
)
{
case
ACTION_DOWN
:
SDL_SendMouseButton
(
Android_Window
,
SDL_PRESSED
,
SDL_BUTTON_LEFT
);
break
;
case
ACTION_UP
:
SDL_SendMouseButton
(
Android_Window
,
SDL_RELEASED
,
SDL_BUTTON_LEFT
);
break
;
}
}
else
{
SDL_SetMouseFocus
(
NULL
);
}
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidtouch.h
0 → 100644
View file @
cab4e065
/*
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_OnTouch
(
int
action
,
float
x
,
float
y
,
float
p
);
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidvideo.c
View file @
cab4e065
...
...
@@ -29,6 +29,7 @@
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_windowevents_c.h"
#include "SDL_androidvideo.h"
#include "SDL_androidevents.h"
...
...
@@ -63,6 +64,8 @@ int Android_ScreenWidth = 0;
int
Android_ScreenHeight
=
0
;
Uint32
Android_ScreenFormat
=
SDL_PIXELFORMAT_UNKNOWN
;
/* Currently only one window */
SDL_Window
*
Android_Window
=
NULL
;
static
int
Android_Available
(
void
)
...
...
@@ -158,6 +161,10 @@ Android_SetScreenResolution(int width, int height, Uint32 format)
Android_ScreenWidth
=
width
;
Android_ScreenHeight
=
height
;
Android_ScreenFormat
=
format
;
if
(
Android_Window
)
{
SDL_SendWindowEvent
(
Android_Window
,
SDL_WINDOWEVENT_RESIZED
,
width
,
height
);
}
}
/* vi: set ts=4 sw=4 expandtab: */
src/video/android/SDL_androidvideo.h
View file @
cab4e065
...
...
@@ -34,6 +34,7 @@ extern void Android_SetScreenResolution(int width, int height, Uint32 format);
extern
int
Android_ScreenWidth
;
extern
int
Android_ScreenHeight
;
extern
Uint32
Android_ScreenFormat
;
extern
SDL_Window
*
Android_Window
;
#endif
/* _SDL_androidvideo_h */
...
...
src/video/android/SDL_androidwindow.c
View file @
cab4e065
...
...
@@ -29,6 +29,12 @@
int
Android_CreateWindow
(
_THIS
,
SDL_Window
*
window
)
{
if
(
Android_Window
)
{
SDL_SetError
(
"Android only supports one window"
);
return
-
1
;
}
Android_Window
=
window
;
/* Adjust the window data to match the screen */
window
->
x
=
0
;
window
->
y
=
0
;
...
...
@@ -47,6 +53,9 @@ Android_SetWindowTitle(_THIS, SDL_Window * window)
void
Android_DestroyWindow
(
_THIS
,
SDL_Window
*
window
)
{
if
(
window
==
Android_Window
)
{
Android_Window
=
NULL
;
}
}
/* 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