Mercurial > sdl-ios-xcode
annotate src/video/android/SDL_androidevents.c @ 4938:2af0032520d8
Fixed compiling on Android
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 31 Dec 2010 16:51:03 -0800 |
parents | f2c2a33a1a38 |
children | d9fdff945ec9 |
rev | line source |
---|---|
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
1 /* |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
3 Copyright (C) 1997-2010 Sam Lantinga |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
4 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
9 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
14 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
18 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
19 Sam Lantinga |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
20 slouken@libsdl.org |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
21 */ |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
23 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
24 /* Being a null driver, there's no event stream. We just define stubs for |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
25 most of the API. */ |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
26 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
27 #include <stdio.h> |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
28 #include <stdlib.h> |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
29 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
30 #include "../../events/SDL_sysevents.h" |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
31 #include "../../events/SDL_events_c.h" |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
32 |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
33 #include "SDL_androidevents.h" |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
34 |
4938
2af0032520d8
Fixed compiling on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4716
diff
changeset
|
35 void Android_InitEvents() |
2af0032520d8
Fixed compiling on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4716
diff
changeset
|
36 { |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
37 SDLKey keymap[SDL_NUM_SCANCODES]; |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
38 |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
39 /* Add default scancode to key mapping */ |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
40 SDL_GetDefaultKeymap(keymap); |
4938
2af0032520d8
Fixed compiling on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4716
diff
changeset
|
41 SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES); |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
42 } |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
43 |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
44 void |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
45 Android_PumpEvents(_THIS) |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
46 { |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
47 |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
48 //scanKeys(); |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
49 /* TODO: defer click-age */ |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
50 /* |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
51 if (keysDown() & KEY_TOUCH) { |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
52 SDL_SendMouseButton(0, SDL_PRESSED, 0); |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
53 } else if (keysUp() & KEY_TOUCH) { |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
54 SDL_SendMouseButton(0, SDL_RELEASED, 0); |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
55 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
56 if (keysHeld() & KEY_TOUCH) { |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
57 touchPosition t = touchReadXY(); |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
58 SDL_SendMouseMotion(0, 0, t.px, t.py, 1); |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
59 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
60 */ |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
61 } |
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
62 |
4716
f2c2a33a1a38
Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents:
4713
diff
changeset
|
63 |
f2c2a33a1a38
Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents:
4713
diff
changeset
|
64 void Android_OnResize(int width, int height, int format){ |
f2c2a33a1a38
Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents:
4713
diff
changeset
|
65 |
f2c2a33a1a38
Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents:
4713
diff
changeset
|
66 } |
f2c2a33a1a38
Added resize hander stub and initial screen size setter
Paul Hunkin <paul@bieh.net>
parents:
4713
diff
changeset
|
67 |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
68 int |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
69 Android_OnKeyDown(int keycode){ |
4938
2af0032520d8
Fixed compiling on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4716
diff
changeset
|
70 return SDL_SendKeyboardKey(SDL_PRESSED, (SDL_scancode)keycode); |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
71 } |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
72 |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
73 int |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
74 Android_OnKeyUp(int keycode){ |
4938
2af0032520d8
Fixed compiling on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4716
diff
changeset
|
75 return SDL_SendKeyboardKey(SDL_RELEASED, (SDL_scancode)keycode); |
4713
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
76 } |
ba38983b10c2
Added preliminary keyboard event support
Paul Hunkin <paul@bieh.net>
parents:
4701
diff
changeset
|
77 |
4701
d40bb3165d2b
Added (partially implemented) android video backend and associated files needed to build
Paul Hunkin <paul@bieh.net>
parents:
diff
changeset
|
78 /* vi: set ts=4 sw=4 expandtab: */ |