Compare commits
485 Commits
python3_te
...
sdl2_andro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d480cc0484 | ||
|
|
5b4e368938 | ||
|
|
a2285e949c | ||
|
|
c50c43db6f | ||
|
|
7566e05ee6 | ||
|
|
39d55b5d19 | ||
|
|
fed2b2469b | ||
|
|
d2c77299ff | ||
|
|
57a23c6a56 | ||
|
|
315dec4b42 | ||
|
|
ec0b9d5ebe | ||
|
|
61ec755987 | ||
|
|
4a82d315d5 | ||
|
|
0ce5f5dee3 | ||
|
|
99393e2dbe | ||
|
|
17c547a43f | ||
|
|
d611b7655b | ||
|
|
a0bded0cce | ||
|
|
015fb7ad45 | ||
|
|
d0558f22d9 | ||
|
|
32046e051c | ||
|
|
487062dd11 | ||
|
|
4741fe77bb | ||
|
|
d9267a1653 | ||
|
|
9fd75f119e | ||
|
|
6962dd59fa | ||
|
|
99effe98c4 | ||
|
|
712e3b1624 | ||
|
|
817c0ac596 | ||
|
|
2ecfbd1189 | ||
|
|
c6950836a0 | ||
|
|
39f7b7d6ef | ||
|
|
702329a932 | ||
|
|
abb3f4196b | ||
|
|
5936ff80b5 | ||
|
|
4fab6dc422 | ||
|
|
e6823997de | ||
|
|
068d7dba9e | ||
|
|
21e930fb6b | ||
|
|
a1516f415e | ||
|
|
7c23b880c7 | ||
|
|
29a26e824d | ||
|
|
1d6b705ff3 | ||
|
|
3a57177042 | ||
|
|
e00fcf1afe | ||
|
|
2bce9d6854 | ||
|
|
29fcb570f8 | ||
|
|
07952badae | ||
|
|
e02d772173 | ||
|
|
b7607f9618 | ||
|
|
807ad3113c | ||
|
|
13f410df61 | ||
|
|
b30a5bdf47 | ||
|
|
602ceec9ed | ||
|
|
4717519311 | ||
|
|
7203affdc7 | ||
|
|
9440f2227d | ||
|
|
a617b46dec | ||
|
|
72cba7bfd5 | ||
|
|
9731a00c15 | ||
|
|
5544e91d05 | ||
|
|
8e53731b2a | ||
|
|
6ffc00e13b | ||
|
|
9c2adfdcc8 | ||
|
|
fd6e3a02cd | ||
|
|
6b7505dc1f | ||
|
|
70f933c12a | ||
|
|
b60e0a1956 | ||
|
|
58b42e93aa | ||
|
|
af2fc34eb5 | ||
|
|
b0c05e67da | ||
|
|
517eb7572c | ||
|
|
409b173e25 | ||
|
|
6282c041cf | ||
|
|
83c8c657d4 | ||
|
|
4ea94c197d | ||
|
|
71d79c3703 | ||
|
|
2a58d4a24b | ||
|
|
d809f372a8 | ||
|
|
bb09438e1b | ||
|
|
610e43e388 | ||
|
|
ee825d7cee | ||
|
|
ddd9b70af3 | ||
|
|
2133b4bdbf | ||
|
|
1610fbf5b2 | ||
|
|
d49291b64e | ||
|
|
b340f77972 | ||
|
|
bc8d652517 | ||
|
|
2b0d961f8b | ||
|
|
bb387b5f07 | ||
|
|
a64f771e39 | ||
|
|
954676633e | ||
|
|
14692c5794 | ||
|
|
690ab0fdc4 | ||
|
|
9e879a3758 | ||
|
|
4081383cd4 | ||
|
|
4a13c9b8d1 | ||
|
|
7207c9cbaa | ||
|
|
341ea4820e | ||
|
|
de0a2aa094 | ||
|
|
12ee2980ed | ||
|
|
f3490e5a97 | ||
|
|
6d8fc056b7 | ||
|
|
a1f3b803f3 | ||
|
|
74283b9a01 | ||
|
|
3b33a27350 | ||
|
|
f1b5cb5eef | ||
|
|
30ca76a91b | ||
|
|
cd7d7f23b1 | ||
|
|
1aaf5fecb8 | ||
|
|
ae4e375c8e | ||
|
|
12a164f19c | ||
|
|
7d1d1dcce3 | ||
|
|
d00a448056 | ||
|
|
84c3b8f4d9 | ||
|
|
e34e808c15 | ||
|
|
24dbe40bd9 | ||
|
|
d25053ce9f | ||
|
|
720c08d15a | ||
|
|
97c152e6a6 | ||
|
|
428f6b89d7 | ||
|
|
99882fa19e | ||
|
|
8b8597fbc3 | ||
|
|
c2d67139f7 | ||
|
|
11acddec22 | ||
|
|
c4ae2ef53c | ||
|
|
924a106e01 | ||
|
|
3926496d5f | ||
|
|
249f602165 | ||
|
|
d30158b7dd | ||
|
|
769a99cbd8 | ||
|
|
ae4f496106 | ||
|
|
34f00a6c54 | ||
|
|
e32502ed64 | ||
|
|
117074777f | ||
|
|
32442641dc | ||
|
|
b5012d86ad | ||
|
|
5b2b990b29 | ||
|
|
b3e81dfab1 | ||
|
|
9bbfbd2131 | ||
|
|
6d3990058b | ||
|
|
5458d5ffe3 | ||
|
|
7c88857742 | ||
|
|
01dc04fe17 | ||
|
|
5e9c45f330 | ||
|
|
91bfe0b6c4 | ||
|
|
a967016781 | ||
|
|
1e71441946 | ||
|
|
5413bfb6f3 | ||
|
|
63f9c475c1 | ||
|
|
ce74e0fee3 | ||
|
|
b7084f90e1 | ||
|
|
a46c43f459 | ||
|
|
4e8bf7a5ae | ||
|
|
1157101b4b | ||
|
|
43810f8585 | ||
|
|
a07c617cbf | ||
|
|
747e660578 | ||
|
|
3f8e0ea9a9 | ||
|
|
f2074457a4 | ||
|
|
8cc60c9d4b | ||
|
|
4527f9f619 | ||
|
|
d2495a80ce | ||
|
|
7c74e86010 | ||
|
|
0dd74132ab | ||
|
|
959a7a8c66 | ||
|
|
697ba47bf8 | ||
|
|
31f306976f | ||
|
|
cde94796a7 | ||
|
|
dcdcaa2c1a | ||
|
|
f89164b152 | ||
|
|
dd184b184e | ||
|
|
ff8594202d | ||
|
|
63e5356a5b | ||
|
|
89ecc43d8f | ||
|
|
8c34faa475 | ||
|
|
65fe44f66a | ||
|
|
f0ff49906c | ||
|
|
2ff9d7cb2c | ||
|
|
d0f0e4cfea | ||
|
|
7662f2acae | ||
|
|
3bed7f054e | ||
|
|
f78c911f0a | ||
|
|
90f5ab5684 | ||
|
|
20d59c5920 | ||
|
|
b5a391b0dd | ||
|
|
20eef1b149 | ||
|
|
f0425aa9af | ||
|
|
d9ce299843 | ||
|
|
9c3259a969 | ||
|
|
bb46839637 | ||
|
|
22a34468d2 | ||
|
|
ab3e3aa1a7 | ||
|
|
56ae8d528e | ||
|
|
15ee9faf9b | ||
|
|
4d6a8dcd88 | ||
|
|
639a2e7e69 | ||
|
|
054ac50e0a | ||
|
|
9397c0079c | ||
|
|
e887896edf | ||
|
|
8be8471285 | ||
|
|
2f49dd6e30 | ||
|
|
657ab95852 | ||
|
|
3425c4b372 | ||
|
|
5ba2b00a1e | ||
|
|
d431337433 | ||
|
|
1f32270a80 | ||
|
|
0186aa0786 | ||
|
|
8c632cd6e0 | ||
|
|
b5fec3dd68 | ||
|
|
6b1bd79e2f | ||
|
|
da55d86723 | ||
|
|
63178dd22b | ||
|
|
f3ee09e047 | ||
|
|
5b778604b5 | ||
|
|
264f7aa43f | ||
|
|
eec2e53f0f | ||
|
|
bf0eb74ea8 | ||
|
|
969d785ec1 | ||
|
|
76d93ca1fa | ||
|
|
61c5b7352b | ||
|
|
68d6923357 | ||
|
|
fd5babab77 | ||
|
|
71a72389e3 | ||
|
|
2b18728ed5 | ||
|
|
4be95b0d36 | ||
|
|
d1554371a5 | ||
|
|
51790527e9 | ||
|
|
de301f6c59 | ||
|
|
37ad3763ab | ||
|
|
f9a91856ec | ||
|
|
f0a8e491e9 | ||
|
|
b0f344098f | ||
|
|
9087c622ae | ||
|
|
16d326c1c5 | ||
|
|
8333b99596 | ||
|
|
c3f89273e3 | ||
|
|
0c172d10fb | ||
|
|
bef5f545c5 | ||
|
|
aa7919811f | ||
|
|
d169cf6d89 | ||
|
|
b66d0f6af0 | ||
|
|
286b105fc5 | ||
|
|
2f0fa55d2e | ||
|
|
35400851ca | ||
|
|
0299387ea8 | ||
|
|
40b87eb9ac | ||
|
|
e61973a837 | ||
|
|
61a08630ed | ||
|
|
1fe8654d71 | ||
|
|
2c182128c6 | ||
|
|
98062856c6 | ||
|
|
0dd82bd0f7 | ||
|
|
a5a7fea8a7 | ||
|
|
659bf32161 | ||
|
|
1950b85d8b | ||
|
|
4527235f0e | ||
|
|
11090a082e | ||
|
|
9b9768ed8d | ||
|
|
372a73207b | ||
|
|
7f4b9162ba | ||
|
|
d4afed131a | ||
|
|
52cda7c82f | ||
|
|
d74fcef25b | ||
|
|
fc7e6e63b2 | ||
|
|
d98d33b244 | ||
|
|
e700d64cfb | ||
|
|
d9d6289924 | ||
|
|
ed9446c4a3 | ||
|
|
8c64964f4b | ||
|
|
98a442e80d | ||
|
|
f391b0b3ca | ||
|
|
a328e741aa | ||
|
|
c475fbf816 | ||
|
|
65520b847e | ||
|
|
88ab438ba1 | ||
|
|
9865a6dcfe | ||
|
|
cff1d6b9b9 | ||
|
|
853e3f3307 | ||
|
|
b0b78fbf0b | ||
|
|
19ad345143 | ||
|
|
3988790916 | ||
|
|
114f1541c3 | ||
|
|
4a0abd4561 | ||
|
|
059c60acc2 | ||
|
|
49664669ab | ||
|
|
83690c7843 | ||
|
|
836173c6bd | ||
|
|
54daeba17c | ||
|
|
ab388c164b | ||
|
|
451189dd41 | ||
|
|
5857572dc9 | ||
|
|
d7a074409e | ||
|
|
93c3984615 | ||
|
|
16f944d3c6 | ||
|
|
781877ebb6 | ||
|
|
5e0cf567cb | ||
|
|
5452ff026f | ||
|
|
0c407de81c | ||
|
|
d705fee605 | ||
|
|
e4d00b6202 | ||
|
|
73d25fe6cc | ||
|
|
c12c63c66d | ||
|
|
e9843f8a61 | ||
|
|
da45b67d94 | ||
|
|
816ce71085 | ||
|
|
fb816c7a6a | ||
|
|
5d05a7cff2 | ||
|
|
4503bcbc56 | ||
|
|
d359e80b9b | ||
|
|
4b3a2136c7 | ||
|
|
f7b1b69008 | ||
|
|
2face2a79a | ||
|
|
30b7f93467 | ||
|
|
671d537df9 | ||
|
|
38663832d2 | ||
|
|
91735433b1 | ||
|
|
c22928a018 | ||
|
|
eab9c26fa3 | ||
|
|
e000bf3ea4 | ||
|
|
fba592f1c5 | ||
|
|
a5c932a0fa | ||
|
|
ad4a0bc52c | ||
|
|
fd8735fe6f | ||
|
|
334e7114d8 | ||
|
|
49c47093c0 | ||
|
|
fc1bedf1ca | ||
|
|
4c73f4c220 | ||
|
|
1d3e4fce94 | ||
|
|
c582c7e40e | ||
|
|
3116b316bb | ||
|
|
eadd178cfc | ||
|
|
76053bb69f | ||
|
|
6459e79ea9 | ||
|
|
dcad4c156c | ||
|
|
da05e8dfc6 | ||
|
|
3af69bf25c | ||
|
|
f31a9b10cb | ||
|
|
a67e53fe48 | ||
|
|
fd79ad08d2 | ||
|
|
3556067039 | ||
|
|
cdf1c7347d | ||
|
|
1cf8c094a3 | ||
|
|
4799ff9e9f | ||
|
|
96b9a2e36d | ||
|
|
3b65df4624 | ||
|
|
3165576211 | ||
|
|
b176328777 | ||
|
|
6a76b40436 | ||
|
|
b9538af7c3 | ||
|
|
d0f7f72bd7 | ||
|
|
144f485758 | ||
|
|
9a2e67c05d | ||
|
|
bc94fe76d6 | ||
|
|
e15c2ff3d6 | ||
|
|
7301ae0c62 | ||
|
|
d416f94ce4 | ||
|
|
374dbd86b3 | ||
|
|
66f7cc1cfd | ||
|
|
e0d9c99a7c | ||
|
|
4c182a5370 | ||
|
|
7aa2cd0726 | ||
|
|
df9ffa1c2b | ||
|
|
e618b3a2d0 | ||
|
|
0fd27781c6 | ||
|
|
9f5414c407 | ||
|
|
f02e93636f | ||
|
|
9f486346f1 | ||
|
|
49fb9a98e8 | ||
|
|
7d7b6e7997 | ||
|
|
169a2bf551 | ||
|
|
b12fc6e402 | ||
|
|
b742ebaf72 | ||
|
|
9c86e109dd | ||
|
|
f5570a7dae | ||
|
|
2a60bdec8a | ||
|
|
b3b9730c19 | ||
|
|
212e761d33 | ||
|
|
25a86103ec | ||
|
|
54c1b4b0b8 | ||
|
|
95ebb73426 | ||
|
|
d378ee692f | ||
|
|
70b37b6565 | ||
|
|
637eb27e07 | ||
|
|
bb08c6ab43 | ||
|
|
0aba1e43d7 | ||
|
|
5cda8aa8be | ||
|
|
6fe05d83e3 | ||
|
|
ef3c4cf714 | ||
|
|
7babe228b6 | ||
|
|
6356415030 | ||
|
|
af61cce12a | ||
|
|
173d4f193b | ||
|
|
c66e3d5ae1 | ||
|
|
4b47ea502c | ||
|
|
8d9f655db9 | ||
|
|
1ae4bbbfc8 | ||
|
|
a6f20b699b | ||
|
|
a209bee64f | ||
|
|
1db6fb623c | ||
|
|
4336c5e9b8 | ||
|
|
18837e9b8c | ||
|
|
d8b6a2d088 | ||
|
|
bc9842ee59 | ||
|
|
5af764f5ff | ||
|
|
fb9d42b6f5 | ||
|
|
3a9b31a41f | ||
|
|
b8c5dd1d70 | ||
|
|
209a16fd9f | ||
|
|
bd36a07c7b | ||
|
|
4701548e01 | ||
|
|
5223f423d8 | ||
|
|
7953493704 | ||
|
|
5d82a28be3 | ||
|
|
468791d212 | ||
|
|
34824e3300 | ||
|
|
0d524669d0 | ||
|
|
457c6c32af | ||
|
|
91d27beb04 | ||
|
|
3b7eed55a5 | ||
|
|
32488523e1 | ||
|
|
efbdcb1a71 | ||
|
|
2cc2d7bca5 | ||
|
|
6850c719d4 | ||
|
|
bc5f26d089 | ||
|
|
a322e85cd7 | ||
|
|
75eddb701a | ||
|
|
8e87817255 | ||
|
|
90b8790fc0 | ||
|
|
2920b61519 | ||
|
|
d738bd6f53 | ||
|
|
181532e165 | ||
|
|
630d0fb234 | ||
|
|
ca601438d7 | ||
|
|
8fbefc99de | ||
|
|
c985b70f59 | ||
|
|
a6db262f17 | ||
|
|
eafba393be | ||
|
|
b224a4d100 | ||
|
|
5132ae8020 | ||
|
|
35e838c20d | ||
|
|
d89960517c | ||
|
|
2efd15f6b5 | ||
|
|
a361998ee2 | ||
|
|
55194b43e3 | ||
|
|
cdb6e76177 | ||
|
|
132988b141 | ||
|
|
5ab39a579a | ||
|
|
d179d4d2c7 | ||
|
|
39b5b5efb5 | ||
|
|
b42a8623df | ||
|
|
8f54771340 | ||
|
|
d94bfa11f7 | ||
|
|
360fc0b112 | ||
|
|
9e2035c21d | ||
|
|
0eaf0356fc | ||
|
|
74c2b15e22 | ||
|
|
a26e52ca94 | ||
|
|
4fcb4fce72 | ||
|
|
2b0ad6e7d3 | ||
|
|
c398280513 | ||
|
|
f432fb316b | ||
|
|
46e4118ba8 | ||
|
|
78d3c8ca27 | ||
|
|
5497773f96 | ||
|
|
28015f4cca | ||
|
|
f37cf67a7e | ||
|
|
ecb29827af | ||
|
|
d4897280f0 | ||
|
|
485d66ea25 | ||
|
|
09f8a53a22 | ||
|
|
d7ea0a43fb | ||
|
|
bf211679e1 | ||
|
|
32f1ca882e | ||
|
|
4e9dad66bb | ||
|
|
2b64c864f0 | ||
|
|
58beecc25a | ||
|
|
69137dfa78 | ||
|
|
4ab58838d1 | ||
|
|
5edfb74432 | ||
|
|
2d9acc5aee | ||
|
|
7629e64762 | ||
|
|
c67f348338 | ||
|
|
f4727eb466 | ||
|
|
9aa0a1ae36 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,6 +11,7 @@
|
||||
/project/jni/Settings.mk
|
||||
/project/jni/application/*/libapplication*.so
|
||||
/project/jni/application/src
|
||||
/project/jni/boost_*
|
||||
/project/res/drawable-xhdpi/ouya_icon.png
|
||||
/project/res/drawable/app_icon.png
|
||||
/project/proguard-project.txt
|
||||
@@ -19,3 +20,6 @@
|
||||
/project/jni/android-support
|
||||
/project/res/drawable/banner.png
|
||||
/project/res/drawable-xhdpi/ouya_icon.png
|
||||
/project/app/build.gradle
|
||||
/project/app/.gradle
|
||||
/project/app/build
|
||||
|
||||
79
.gitmodules
vendored
79
.gitmodules
vendored
@@ -1,81 +1,86 @@
|
||||
[submodule "project/jni/application/NewRAW"]
|
||||
path = project/jni/application/NewRAW
|
||||
url = git@github.com:usineur/android-newraw.git
|
||||
url = https://github.com/usineur/android-newraw.git
|
||||
[submodule "project/jni/boost/src"]
|
||||
path = project/jni/boost/src
|
||||
url = git@github.com:pelya/Boost-for-Android.git
|
||||
branch = master2
|
||||
url = https://github.com/moritz-wundke/Boost-for-Android.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/commandergenius/commandergenius"]
|
||||
path = project/jni/application/commandergenius/commandergenius
|
||||
url = git@github.com:gerstrong/Commander-Genius.git
|
||||
url = https://github.com/gerstrong/Commander-Genius.git
|
||||
[submodule "project/jni/application/openarena/engine"]
|
||||
path = project/jni/application/openarena/engine
|
||||
url = git@github.com:pelya/openarena-engine.git
|
||||
[submodule "project/jni/application/scummvm/scummvm"]
|
||||
path = project/jni/application/scummvm/scummvm
|
||||
url = git@github.com:scummvm/scummvm.git
|
||||
url = https://github.com/pelya/openarena-engine.git
|
||||
[submodule "project/jni/application/openarena/vm"]
|
||||
path = project/jni/application/openarena/vm
|
||||
url = git@github.com:pelya/openarena-vm
|
||||
url = https://github.com/pelya/openarena-vm
|
||||
[submodule "project/jni/application/teeworlds/src"]
|
||||
path = project/jni/application/teeworlds/src
|
||||
url = git@github.com:pelya/teeworlds.git
|
||||
[submodule "project/jni/application/c-dogs/src"]
|
||||
path = project/jni/application/c-dogs/src
|
||||
url = git@github.com:cxong/cdogs-sdl.git
|
||||
url = https://github.com/pelya/teeworlds.git
|
||||
[submodule "project/jni/application/xserver/xserver"]
|
||||
path = project/jni/application/xserver/xserver
|
||||
url = git@github.com:pelya/xserver.git
|
||||
branch = xsdl2
|
||||
url = https://github.com/pelya/xserver.git
|
||||
branch = xsdl-1.20
|
||||
update = merge
|
||||
[submodule "android-shmem"]
|
||||
path = project/jni/shmem
|
||||
url = git@github.com:pelya/android-shmem.git
|
||||
url = https://github.com/pelya/android-shmem.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/hid-pc-keyboard/src"]
|
||||
path = project/jni/application/hid-pc-keyboard/src
|
||||
url = git@github.com:pelya/android-keyboard-gadget.git
|
||||
url = https://github.com/pelya/android-keyboard-gadget.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/iconv/src"]
|
||||
path = project/jni/iconv/src
|
||||
url = git@github.com:pelya/libiconv-libicu-android.git
|
||||
[submodule "project/jni/icuuc/src"]
|
||||
path = project/jni/icuuc/src
|
||||
url = git@github.com:pelya/libiconv-libicu-android.git
|
||||
url = https://github.com/pelya/libiconv-libicu-android.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/openttd/src"]
|
||||
path = project/jni/application/openttd/src
|
||||
url = git@github.com:pelya/openttd-android.git
|
||||
url = https://github.com/pelya/openttd-android.git
|
||||
branch = 1.10
|
||||
[submodule "project/jni/application/uae4all2"]
|
||||
path = project/jni/application/uae4all2
|
||||
url = git@github.com:lubomyr/uae4all2.git
|
||||
url = https://github.com/lubomyr/uae4all2.git
|
||||
[submodule "project/jni/application/basiliskii/basiliskii"]
|
||||
path = project/jni/application/basiliskii/basiliskii
|
||||
url = git@github.com:pelya/BasiliskII-android.git
|
||||
url = https://github.com/pelya/BasiliskII-android.git
|
||||
[submodule "project/jni/vncserver/src"]
|
||||
path = project/jni/vncserver/src
|
||||
url = git@github.com:LibVNC/libvncserver.git
|
||||
url = https://github.com/LibVNC/libvncserver.git
|
||||
[submodule "project/jni/application/vice/vice"]
|
||||
path = project/jni/application/vice/vice
|
||||
url = git@github.com:lubomyr/vice-2.4.git
|
||||
url = https://github.com/lubomyr/vice-2.4.git
|
||||
[submodule "project/jni/application/xserver/pulseaudio"]
|
||||
path = project/jni/application/xserver/pulseaudio
|
||||
url = git@github.com:pelya/pulseaudio-android.git
|
||||
[submodule "project/jni/application/bochs/bochs"]
|
||||
path = project/jni/application/bochs/bochs
|
||||
url = git@github.com:lubomyr/bochs.git
|
||||
url = https://github.com/pelya/pulseaudio-android.git
|
||||
branch = master
|
||||
[submodule "project/jni/application/supertux/supertux"]
|
||||
path = project/jni/application/supertux/supertux
|
||||
url = git@github.com:pelya/supertux.git
|
||||
url = https://github.com/pelya/supertux.git
|
||||
[submodule "project/jni/application/fheroes2/fheroes2"]
|
||||
path = project/jni/application/fheroes2/fheroes2
|
||||
url = http://github.com/gerstrong/fheroes2plus.git
|
||||
url = https://github.com/gerstrong/fheroes2plus.git
|
||||
[submodule "project/jni/application/ninslash/src"]
|
||||
path = project/jni/application/ninslash/src
|
||||
url = git@github.com:pelya/Ninslash.git
|
||||
[submodule "project/jni/python3/python3-android"]
|
||||
path = project/jni/python3/python3-android
|
||||
url = http://github.com/gerstrong/python3-android.git
|
||||
|
||||
url = https://github.com/pelya/Ninslash.git
|
||||
branch = master
|
||||
update = merge
|
||||
[submodule "project/jni/application/openttd-jgrpp/src"]
|
||||
path = project/jni/application/openttd-jgrpp/src
|
||||
url = https://github.com/pelya/OpenTTD-JGR-patchpack.git
|
||||
branch = android-desktop
|
||||
[submodule "project/jni/application/liero/src"]
|
||||
path = project/jni/application/liero/src
|
||||
url = https://github.com/pelya/liero-android.git
|
||||
[submodule "project/jni/application/openlierox/src"]
|
||||
path = project/jni/application/openlierox/src
|
||||
url = https://github.com/albertz/openlierox.git
|
||||
branch = half-assed-android-port
|
||||
[submodule "project/jni/application/xserver-debian/debian-image"]
|
||||
path = project/jni/application/xserver-debian/debian-image
|
||||
url = https://github.com/pelya/debian-noroot
|
||||
branch = master
|
||||
|
||||
107
aar2jar.py
107
aar2jar.py
@@ -1,107 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# aar2jar.py (c) kak2 <doanngocbao@gmail.com>
|
||||
# https://github.com/kak2/aar2jar
|
||||
|
||||
import sys, getopt, os
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
mswindows = (sys.platform == "win32")
|
||||
def main(argv):
|
||||
project_name = ''
|
||||
output_dir = ''
|
||||
if len(argv) == 0:
|
||||
help()
|
||||
sys.exit(2)
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,"hi:o:",["iname=","odir="])
|
||||
except getopt.GetoptError:
|
||||
help()
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
help()
|
||||
sys.exit()
|
||||
elif opt in ("-i", "--iname"):
|
||||
project_name = arg
|
||||
elif opt in ("-o", "--odir"):
|
||||
output_dir = arg
|
||||
|
||||
convert(project_name, output_dir)
|
||||
|
||||
def help():
|
||||
print 'convert.py -i <your-project-name-without-aar> -o <output-dir>'
|
||||
|
||||
def convert(project_name, output_dir):
|
||||
if not existProject(project_name):
|
||||
print project_name, " is not existed in current directory"
|
||||
sys.exit(2)
|
||||
createOrCleanOutputDir(output_dir)
|
||||
|
||||
# Convert your project first
|
||||
convert_project(project_name, output_dir)
|
||||
# Move all jar and convert other aar files
|
||||
files = os.listdir(os.curdir)
|
||||
for file in files:
|
||||
file_name, extension = os.path.splitext(file)
|
||||
print file_name, extension
|
||||
if extension == '.jar':
|
||||
shutil.move(file, os.path.join(output_dir, project_name, 'libs', file))
|
||||
elif extension == '.aar':
|
||||
if file_name != project_name:
|
||||
convert_project(file_name, output_dir)
|
||||
|
||||
|
||||
def convert_project(project_name, output_dir):
|
||||
# Extract your project's file
|
||||
your_file_dest_path = os.path.join(output_dir, project_name)
|
||||
os.makedirs(your_file_dest_path)
|
||||
with zipfile.ZipFile(project_name + '.aar' , "r") as z:
|
||||
z.extractall(your_file_dest_path)
|
||||
#
|
||||
# Make it into ant library project
|
||||
#
|
||||
if not os.path.exists(os.path.join(your_file_dest_path, 'src')):
|
||||
os.makedirs(os.path.join(your_file_dest_path, 'src')) # Make src directory in project, but leave it empty
|
||||
if not os.path.exists(os.path.join(your_file_dest_path, 'libs')):
|
||||
os.makedirs(os.path.join(your_file_dest_path, 'libs')) # Make lib directory in project if it does not exists
|
||||
# Rename classes.jar to project_name.jar and move it into libs directory
|
||||
os.rename(os.path.join(your_file_dest_path, 'classes.jar'), os.path.join(your_file_dest_path, project_name + '.jar'))
|
||||
shutil.move(os.path.join(your_file_dest_path, project_name + '.jar'), os.path.join(your_file_dest_path, 'libs/' + project_name + '.jar'))
|
||||
# Call android update. So we have to install android first, then add it into PATH
|
||||
command = "android update lib-project -p " + os.path.join(output_dir, project_name) + " -t android-25"
|
||||
os.system(command)
|
||||
# Update project.properties file
|
||||
with open(os.path.join(output_dir, project_name, 'project.properties'), "a") as myfile:
|
||||
myfile.write("android.library=true\n")
|
||||
|
||||
def createOrCleanOutputDir(output_dir):
|
||||
files = os.listdir(os.curdir)
|
||||
if os.path.exists(output_dir):
|
||||
deleteDir(output_dir)
|
||||
os.makedirs(output_dir)
|
||||
|
||||
def remove_readonly(fn, path, excinfo):
|
||||
#removes readonly tag from files/folders so they can be deleted
|
||||
if fn is os.rmdir:
|
||||
os.chmod(path, stat.S_IWRITE)
|
||||
os.rmdir(path)
|
||||
elif fn is os.remove:
|
||||
os.chmod(path, stat.S_IWRITE)
|
||||
os.remove(path)
|
||||
|
||||
def deleteDir(directory):
|
||||
shutil.rmtree(directory, onerror=remove_readonly)
|
||||
|
||||
def existProject(project_name):
|
||||
project_file = project_name + ".aar"
|
||||
files = os.listdir(os.curdir)
|
||||
try:
|
||||
files.index(project_file)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[1:])
|
||||
35
app2sd.sh
35
app2sd.sh
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
APK=$1
|
||||
if [ -z "$APK" ] ; then
|
||||
APK=project/bin/MainActivity-debug.apk
|
||||
fi
|
||||
|
||||
echo Moving shared libraries on $APK to SD card
|
||||
APK=`pwd`/$APK
|
||||
|
||||
[ -e $APK ] || { echo File $APK does not exist; exit 1; }
|
||||
|
||||
TMPDIR=app2sd-$$
|
||||
|
||||
mkdir -p $TMPDIR
|
||||
cd $TMPDIR
|
||||
|
||||
unzip $APK "lib/armeabi/*" || { echo "This apk file has already been app2sd-ed, or improperly compiled"; exit 1; }
|
||||
|
||||
zip -j bindata.zip lib/armeabi/*
|
||||
mkdir assets
|
||||
split -b 1048576 -d -a 1 bindata.zip assets/bindata
|
||||
rm bindata.zip
|
||||
|
||||
zip -d $APK "lib/armeabi/*" "META-INF/*"
|
||||
|
||||
zip -0 $APK assets/bindata*
|
||||
|
||||
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass "android" $APK androiddebugkey
|
||||
|
||||
zipalign 4 $APK $APK-tmp
|
||||
mv -f $APK-tmp $APK
|
||||
|
||||
cd ..
|
||||
rm -rf $TMPDIR
|
||||
4
bugs.txt
4
bugs.txt
@@ -29,3 +29,7 @@ Requested features, might never get implemented, see todo.txt for features that
|
||||
- OpenArena: Shift and Ctrl keys on USB keyboard do not work for text input.
|
||||
|
||||
- OpenArena: When entering with USB keyboard into chatbox, first 't' disappears.
|
||||
|
||||
- USB Keyboard: options for camera feed size and for redefining remote menu hotkey.
|
||||
|
||||
- UQM HD: add fonts from http://mosc-portal.bursa.ru/showthread.php?t=206 and switch back to joystick controls, set 4:3 aspect ratio as default.
|
||||
|
||||
85
build.sh
85
build.sh
@@ -79,23 +79,14 @@ NDK_TOOLCHAIN_VERSION=$GCCVER
|
||||
# export PATH=$PATH:~/src/endless_space/android-ndk-r7
|
||||
NDKBUILDPATH=$PATH
|
||||
export `grep "AppFullName=" AndroidAppSettings.cfg`
|
||||
if ( grep "package $AppFullName;" project/src/Globals.java > /dev/null 2>&1 && \
|
||||
[ "`readlink AndroidAppSettings.cfg`" -ot "project/src/Globals.java" ] && \
|
||||
[ -z "`find project/java/* project/AndroidManifestTemplate.xml -cnewer project/src/Globals.java`" ] ) ; then true ; else
|
||||
if [ -e project/local.properties ] && \
|
||||
( grep "package $AppFullName;" project/src/Globals.java > /dev/null 2>&1 && \
|
||||
[ "`readlink AndroidAppSettings.cfg`" -ot "project/src/Globals.java" ] && \
|
||||
[ -z "`find project/java/* project/AndroidManifestTemplate.xml -cnewer project/src/Globals.java`" ] ) ; then true ; else
|
||||
./changeAppSettings.sh -a || exit 1
|
||||
sleep 1
|
||||
touch project/src/Globals.java
|
||||
fi
|
||||
if $build_release ; then
|
||||
sed -i 's/android:debuggable="true"/android:debuggable="false"/g' project/AndroidManifest.xml
|
||||
else
|
||||
sed -i 's/android:debuggable="false"/android:debuggable="true"/g' project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
[ -e project/local.properties ] || {
|
||||
android update project -p project -t android-23 || exit 1
|
||||
rm -f project/src/Globals.java
|
||||
}
|
||||
|
||||
MYARCH=linux-x86_64
|
||||
if [ -z "$NCPU" ]; then
|
||||
@@ -120,12 +111,6 @@ $quick_rebuild || rm -r -f project/bin/* # New Android SDK introduced some lame-
|
||||
}
|
||||
|
||||
strip_libs() {
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
echo Stripping libapplication-armeabi.so by hand && \
|
||||
rm obj/local/armeabi/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi.so obj/local/armeabi/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi.so libs/armeabi/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "y\\|all\\|armeabi-v7a" > /dev/null && \
|
||||
echo Stripping libapplication-armeabi-v7a.so by hand && \
|
||||
@@ -133,13 +118,6 @@ strip_libs() {
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|mips" > /dev/null && \
|
||||
echo Stripping libapplication-mips.so by hand && \
|
||||
rm obj/local/mips/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips.so obj/local/mips/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips.so libs/mips/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/mipsel-linux-android-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/mipsel-linux-android-strip --strip-unneeded libs/mips/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|x86" > /dev/null && \
|
||||
echo Stripping libapplication-x86.so by hand && \
|
||||
@@ -161,48 +139,53 @@ strip_libs() {
|
||||
cp jni/application/src/libapplication-arm64-v8a.so obj/local/arm64-v8a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-arm64-v8a.so libs/arm64-v8a/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/aarch64-linux-android-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/aarch64-linux-android-strip --strip-unneeded libs/arm64-v8a/libapplication.so
|
||||
grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|mips64" > /dev/null && \
|
||||
echo Stripping libapplication-mips64.so by hand && \
|
||||
rm obj/local/mips64/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips64.so obj/local/mips64/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips64.so libs/mips64/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/mips64el-linux-android-${NDK_TOOLCHAIN_VERSION}/prebuilt/$MYARCH/bin/mips64el-linux-android-strip --strip-unneeded libs/mips64/libapplication.so
|
||||
return 0
|
||||
}
|
||||
|
||||
cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU nice -n19 ndk-build -j$NCPU V=1 $QUICK_REBUILD_ARGS && \
|
||||
# Fix Gradle compilation error
|
||||
[ -z "$ANDROID_NDK_HOME" ] && export ANDROID_NDK_HOME="`which ndk-build | sed 's@/ndk-build@@'`"
|
||||
|
||||
cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU ndk-build -j$NCPU V=1 $QUICK_REBUILD_ARGS && \
|
||||
strip_libs && \
|
||||
cd .. && ./copyAssets.sh && cd project && \
|
||||
{ if $build_release ; then \
|
||||
$quick_rebuild && { \
|
||||
ln -s -f libs lib ; \
|
||||
zip -u -r bin/MainActivity-release-unsigned.apk lib assets || exit 1 ; \
|
||||
} || ant release || exit 1 ; \
|
||||
zip -u -r app/build/outputs/apk/release/app-release-unsigned.apk lib assets || exit 1 ; \
|
||||
} || ./gradlew assembleRelease || exit 1 ; \
|
||||
[ '!' -x jni/application/src/AndroidPostBuild.sh ] || {
|
||||
cd jni/application/src ; \
|
||||
./AndroidPostBuild.sh `pwd`/../../../bin/MainActivity-release-unsigned.apk || exit 1 ; \
|
||||
./AndroidPostBuild.sh `pwd`/../../../app/build/outputs/apk/release/app-release-unsigned.apk || exit 1 ; \
|
||||
cd ../../.. ; \
|
||||
} || exit 1 ; \
|
||||
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -sigalg MD5withRSA -digestalg SHA1 bin/MainActivity-release-unsigned.apk androiddebugkey || exit 1 ; \
|
||||
rm -f bin/MainActivity-debug.apk ; \
|
||||
zipalign 4 bin/MainActivity-release-unsigned.apk bin/MainActivity-debug.apk || exit 1 ; \
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/release/app-release-unsigned.apk ; \
|
||||
rm -f app/build/outputs/apk/release/app-release.apk ; \
|
||||
zipalign 4 app/build/outputs/apk/release/app-release-unsigned.apk app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
else \
|
||||
$quick_rebuild && { \
|
||||
ln -s -f libs lib ; \
|
||||
zip -u -r bin/MainActivity-debug-unaligned.apk lib assets || exit 1 ; \
|
||||
jarsigner -verbose -keystore ~/.android/debug.keystore -storepass android -sigalg MD5withRSA -digestalg SHA1 bin/MainActivity-debug-unaligned.apk androiddebugkey || exit 1 ; \
|
||||
rm -f bin/MainActivity-debug.apk ; \
|
||||
zipalign 4 bin/MainActivity-debug-unaligned.apk bin/MainActivity-debug.apk || exit 1 ; \
|
||||
} || ant debug || exit 1 ; \
|
||||
./gradlew assembleDebug || exit 1 ; \
|
||||
[ '!' -x jni/application/src/AndroidPostBuild.sh ] || {
|
||||
cd jni/application/src ; \
|
||||
./AndroidPostBuild.sh `pwd`/../../../app/build/outputs/apk/debug/app-debug.apk || exit 1 ; \
|
||||
cd ../../.. ; \
|
||||
} || exit 1 ; \
|
||||
mkdir -p app/build/outputs/apk/release ; \
|
||||
../copyAssets.sh pack-binaries app/build/outputs/apk/debug/app-debug.apk && \
|
||||
rm -f app/build/outputs/apk/release/app-release.apk && \
|
||||
zipalign 4 app/build/outputs/apk/debug/app-debug.apk app/build/outputs/apk/release/app-release.apk &&
|
||||
apksigner sign --ks ~/.android/debug.keystore --ks-key-alias androiddebugkey --ks-pass pass:android app/build/outputs/apk/release/app-release.apk || exit 1 ; \
|
||||
fi ; } && \
|
||||
{ if $sign_apk; then cd .. && ./sign.sh && cd project ; else true ; fi ; } && \
|
||||
{ $install_apk && [ -n "`adb devices | tail -n +2`" ] && \
|
||||
{ cd bin && adb install -r MainActivity-debug.apk | grep 'Failure' && \
|
||||
adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; } ; \
|
||||
{ if $sign_apk; then \
|
||||
APPNAME=`grep AppName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---'` ; \
|
||||
APPVER=`grep AppVersionName ../AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' | tr " '/" '---'` ; \
|
||||
adb install -r ../$APPNAME-$APPVER.apk ; \
|
||||
else \
|
||||
adb install -r app/build/outputs/apk/release/app-release.apk ; \
|
||||
fi ; } ; \
|
||||
true ; } && \
|
||||
{ $run_apk && { \
|
||||
ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" ; \
|
||||
ActivityName="`grep AppFullName ../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity" ; \
|
||||
RUN_APK="adb shell am start -n $ActivityName" ; \
|
||||
echo "Running $ActivityName on the USB-connected device:" ; \
|
||||
echo "$RUN_APK" ; \
|
||||
|
||||
1320
build/envsetup.sh
1320
build/envsetup.sh
File diff suppressed because it is too large
Load Diff
@@ -68,11 +68,16 @@ if [ "$AppUsesJoystick" != "y" ]; then
|
||||
AppUsesSecondJoystick=n
|
||||
fi
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ]; then
|
||||
echo Patch of settings menu not supported in SDL 2.0
|
||||
else
|
||||
MenuOptionsAvailable=
|
||||
for FF in Menu MenuMisc MenuMouse MenuKeyboard ; do
|
||||
MenuOptionsAvailable1=`grep 'extends Menu' $JAVA_SRC_PATH/Settings$FF.java | sed "s/.* class \(.*\) extends .*/Settings$FF.\1/" | tr '\n' ' '`
|
||||
MenuOptionsAvailable="$MenuOptionsAvailable $MenuOptionsAvailable1"
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
FirstStartMenuOptionsDefault='new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()'
|
||||
|
||||
@@ -81,7 +86,7 @@ if [ -z "$CompatibilityHacksForceScreenUpdate" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$CompatibilityHacksForceScreenUpdateMouseClick" ]; then
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=y
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=n
|
||||
fi
|
||||
|
||||
if [ -z "$TouchscreenKeysTheme" ]; then
|
||||
@@ -146,11 +151,13 @@ echo "# Application user-visible version name (string)" >> AndroidAppSettings.cf
|
||||
echo AppVersionName=\"$AppVersionName\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'" >> AndroidAppSettings.cfg
|
||||
echo "# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu" >> AndroidAppSettings.cfg
|
||||
echo "# If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled" >> AndroidAppSettings.cfg
|
||||
echo "# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped" >> AndroidAppSettings.cfg
|
||||
echo "# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -" >> AndroidAppSettings.cfg
|
||||
echo "# these files are put inside .apk package by build system" >> AndroidAppSettings.cfg
|
||||
echo "# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version, first associated with the file" >> AndroidAppSettings.cfg
|
||||
echo "# If the URL does not contain 'http://' or 'https://', it is treated as file from 'project/jni/application/src/AndroidData' dir -" >> AndroidAppSettings.cfg
|
||||
echo "# these files are put inside .apk package by the build system" >> AndroidAppSettings.cfg
|
||||
echo "# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for obb file" >> AndroidAppSettings.cfg
|
||||
echo "# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries" >> AndroidAppSettings.cfg
|
||||
echo "# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip" >> AndroidAppSettings.cfg
|
||||
echo AppDataDownloadUrl=\"$AppDataDownloadUrl\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Reset SDL config when updating application to the new version (y) / (n)" >> AndroidAppSettings.cfg
|
||||
@@ -310,15 +317,21 @@ echo "# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording
|
||||
echo "# This option will add additional permission to Android manifest (y)/(n)" >> AndroidAppSettings.cfg
|
||||
echo AppRecordsAudio=$AppRecordsAudio >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs to access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo "# Application needs read/write access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo AccessSdCard=$AccessSdCard >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs to read it's own OBB file. Enable this if you are using Play Store expansion files. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo ReadObbFile=$ReadObbFile >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo AccessInternet=$AccessInternet >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)" >> AndroidAppSettings.cfg
|
||||
echo ImmersiveMode=$ImmersiveMode >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor" >> AndroidAppSettings.cfg
|
||||
echo HideSystemMousePointer=$HideSystemMousePointer >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Application implements Android-specific routines to put to background, and will not draw anything to screen" >> AndroidAppSettings.cfg
|
||||
echo "# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them" >> AndroidAppSettings.cfg
|
||||
echo "# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)" >> AndroidAppSettings.cfg
|
||||
@@ -355,9 +368,18 @@ echo "# 9 = Nintendo64 from RetroArch" >> AndroidAppSettings.cfg
|
||||
echo TouchscreenKeysTheme=$TouchscreenKeysTheme >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine gamepad keys to SDL keysyms, button order is:" >> AndroidAppSettings.cfg
|
||||
echo "# A B X Y L1 R1 L2 R2 LThumb RThumb" >> AndroidAppSettings.cfg
|
||||
echo "# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysGamepad=\"$RedefinedKeysGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the second gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysSecondGamepad=\"$RedefinedKeysSecondGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the third gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysThirdGamepad=\"$RedefinedKeysThirdGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Redefine keys for the fourth gamepad, same as the first gamepad if not set:" >> AndroidAppSettings.cfg
|
||||
echo RedefinedKeysFourthGamepad=\"$RedefinedKeysFourthGamepad\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# How long to show startup menu button, in msec, 0 to disable startup menu" >> AndroidAppSettings.cfg
|
||||
echo StartupMenuButtonTimeout=$StartupMenuButtonTimeout >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
@@ -378,17 +400,17 @@ echo "# GCC version, or 'clang' for CLANG" >> AndroidAppSettings.cfg
|
||||
echo NDK_TOOLCHAIN_VERSION=$NDK_TOOLCHAIN_VERSION >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Android platform version." >> AndroidAppSettings.cfg
|
||||
echo "# android-9 = Android 2.3, the earliest supported version." >> AndroidAppSettings.cfg
|
||||
echo "# android-16 = Android 4.1, the earliest supported version in NDK r18." >> AndroidAppSettings.cfg
|
||||
echo "# android-18 = Android 4.3, the first version supporting GLES3." >> AndroidAppSettings.cfg
|
||||
echo "# android-21 = Android 5.1, the first version with SO_REUSEPORT defined." >> AndroidAppSettings.cfg
|
||||
echo APP_PLATFORM=$APP_PLATFORM >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Specify architectures to compile, 'all' or 'y' to compile for all architectures." >> AndroidAppSettings.cfg
|
||||
echo "# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a" >> AndroidAppSettings.cfg
|
||||
echo "# Available architectures: armeabi-v7a arm64-v8a x86 x86_64" >> AndroidAppSettings.cfg
|
||||
echo MultiABI=\'$MultiABI\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# Optional shared libraries to compile - removing some of them will save space" >> AndroidAppSettings.cfg
|
||||
echo "# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed" >> AndroidAppSettings.cfg
|
||||
echo "# MP3 patents are expired, but libmad license is GPL, not LGPL" >> AndroidAppSettings.cfg
|
||||
grep 'Available' project/jni/SettingsTemplate.mk >> AndroidAppSettings.cfg
|
||||
echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
@@ -432,6 +454,9 @@ echo >> AndroidAppSettings.cfg
|
||||
echo "# Google Play Game Services application ID, required for cloud saves to work" >> AndroidAppSettings.cfg
|
||||
echo GooglePlayGameServicesId=$GooglePlayGameServicesId >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
echo "# The app will open files with following extension, file path will be added to commandline params" >> AndroidAppSettings.cfg
|
||||
echo AppOpenFileExtension=\'$AppOpenFileExtension\' >> AndroidAppSettings.cfg
|
||||
echo >> AndroidAppSettings.cfg
|
||||
fi
|
||||
|
||||
AppShortName=`echo $AppName | sed 's/ //g'`
|
||||
@@ -476,12 +501,6 @@ else
|
||||
InhibitSuspend=false
|
||||
fi
|
||||
|
||||
if [ "$CreateService" = "y" ] ; then
|
||||
CreateService=true
|
||||
else
|
||||
CreateService=false
|
||||
fi
|
||||
|
||||
if [ "$NeedDepthBuffer" = "y" ] ; then
|
||||
NeedDepthBuffer=true
|
||||
else
|
||||
@@ -699,24 +718,54 @@ done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysGamepad; do
|
||||
RedefinedKeycodesGamepad="$RedefinedKeycodesGamepad -DSDL_ANDROID_GAMEPAD_KEYCODE_$KEY2=$KEY"
|
||||
RedefinedKeycodesGamepad="$RedefinedKeycodesGamepad -DSDL_ANDROID_GAMEPAD_0_KEYCODE_$KEY2=$KEY"
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysSecondGamepad; do
|
||||
RedefinedKeycodesGamepad="$RedefinedKeycodesGamepad -DSDL_ANDROID_GAMEPAD_1_KEYCODE_$KEY2=$KEY"
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysThirdGamepad; do
|
||||
RedefinedKeycodesGamepad="$RedefinedKeycodesGamepad -DSDL_ANDROID_GAMEPAD_2_KEYCODE_$KEY2=$KEY"
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
KEY2=0
|
||||
for KEY in $RedefinedKeysFourthGamepad; do
|
||||
RedefinedKeycodesGamepad="$RedefinedKeycodesGamepad -DSDL_ANDROID_GAMEPAD_3_KEYCODE_$KEY2=$KEY"
|
||||
KEY2=`expr $KEY2 '+' 1`
|
||||
done
|
||||
|
||||
if [ "$APP_PLATFORM" = "" ]; then
|
||||
APP_PLATFORM=android-18
|
||||
APP_PLATFORM=android-16
|
||||
fi
|
||||
|
||||
if [ "$MultiABI" = "y" ] ; then
|
||||
MultiABI="all"
|
||||
elif [ "$MultiABI" = "n" ] ; then
|
||||
MultiABI="armeabi"
|
||||
MultiABI="armeabi-v7a"
|
||||
else
|
||||
MultiABI="$MultiABI"
|
||||
fi
|
||||
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"sdl-$LibSdlVersion\\\""
|
||||
StaticLibraries=`grep 'APP_AVAILABLE_STATIC_LIBS' project/jni/SettingsTemplate.mk | sed 's/.*=\(.*\)/\1/'`
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"SDL2\\\""
|
||||
else
|
||||
LibrariesToLoad="\\\"sdl_native_helpers\\\", \\\"sdl-$LibSdlVersion\\\""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
StaticLibraries="`echo '
|
||||
include project/jni/SettingsTemplate.mk
|
||||
all:
|
||||
@echo $(APP_AVAILABLE_STATIC_LIBS)
|
||||
.PHONY: all' | make -s -f -`"
|
||||
for lib in $CompiledLibraries; do
|
||||
process=true
|
||||
for lib1 in $StaticLibraries; do
|
||||
@@ -765,6 +814,7 @@ fi
|
||||
rm -rf project/src
|
||||
mkdir -p project/src
|
||||
cd $JAVA_SRC_PATH
|
||||
|
||||
for F in *.java; do
|
||||
echo '// DO NOT EDIT THIS FILE - it is automatically generated, ALL YOUR CHANGES WILL BE OVERWRITTEN, edit the file under $JAVA_SRC_PATH dir' | cat - $F > ../src/$F
|
||||
done
|
||||
@@ -773,26 +823,41 @@ if [ -e ../jni/application/src/java.diff ]; then patch -d ../src --no-backup-if-
|
||||
if [ -e ../jni/application/src/java.patch ]; then patch -d ../src --no-backup-if-mismatch < ../jni/application/src/java.patch || exit 1 ; fi
|
||||
if ls ../jni/application/src/*.java > /dev/null 2>&1; then cp -f ../jni/application/src/*.java ../src ; fi
|
||||
|
||||
for F in ../src/*.java; do
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
echo Patching java with SDL 2.0 not supported
|
||||
else
|
||||
for F in ../src/*.java; do
|
||||
echo Patching $F
|
||||
$SEDI "s/^package .*;/package $AppFullName;/" $F
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
cd ../..
|
||||
|
||||
# In case we use SDL2 let simlink the SDLActivity source file
|
||||
|
||||
echo Patching project/AndroidManifest.xml
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
ln -s ../jni/sdl-2.0/android-project/src/org/libsdl/app/SDLActivity.java project/src/SDLActivity.java
|
||||
cat project/AndroidManifestTemplateSDL2.xml | \
|
||||
sed "s/package=.*/package=\"$AppFullName\"/" | \
|
||||
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
|
||||
project/AndroidManifest.xml
|
||||
else
|
||||
cat project/AndroidManifestTemplate.xml | \
|
||||
sed "s/package=.*/package=\"$AppFullName\"/" | \
|
||||
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
|
||||
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
|
||||
project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
echo Copying some SDL 2.0 resources
|
||||
cp -pr project/jni/sdl-2.0/android-project/app/src/main/res/* project/res/
|
||||
fi
|
||||
|
||||
|
||||
echo Patching project/AndroidManifest.xml
|
||||
cat project/AndroidManifestTemplate.xml | \
|
||||
sed "s/package=.*/package=\"$AppFullName\"/" | \
|
||||
sed "s/android:screenOrientation=.*/android:screenOrientation=\"$ScreenOrientation1\"/" | \
|
||||
sed "s^android:versionCode=.*^android:versionCode=\"$AppVersionCode\"^" | \
|
||||
sed "s^android:versionName=.*^android:versionName=\"$AppVersionName\"^" > \
|
||||
project/AndroidManifest.xml
|
||||
if [ "$AdmobPublisherId" = "n" -o -z "$AdmobPublisherId" ] ; then
|
||||
$SEDI "/==ADMOB==/ d" project/AndroidManifest.xml
|
||||
AdmobPublisherId=""
|
||||
@@ -803,7 +868,12 @@ else
|
||||
cat $F | sed "s/^package .*;/package $AppFullName;/" >> project/src/Advertisement.java
|
||||
fi
|
||||
|
||||
cat project/app/build-template.gradle | \
|
||||
sed 's/applicationId .*/applicationId "'"$AppFullName"'"/' > \
|
||||
project/app/build.gradle
|
||||
|
||||
echo "-keep class $AppFullName.** { *; }" > project/proguard-local.cfg
|
||||
echo "-keep class org.libsdl.app.** { *; }" >> project/proguard-local.cfg
|
||||
|
||||
if [ "$AppRecordsAudio" = "n" -o -z "$AppRecordsAudio" ] ; then
|
||||
$SEDI "/==RECORD_AUDIO==/ d" project/AndroidManifest.xml
|
||||
@@ -826,20 +896,47 @@ esac
|
||||
|
||||
if [ "$AccessSdCard" = "y" ]; then
|
||||
$SEDI "/==NOT_EXTERNAL_STORAGE==/ d" project/AndroidManifest.xml
|
||||
$SEDI "/==READ_OBB==/ d" project/AndroidManifest.xml
|
||||
else
|
||||
$SEDI "/==EXTERNAL_STORAGE==/ d" project/AndroidManifest.xml # Disabled by default
|
||||
if [ "$ReadObbFile" = "y" ]; then
|
||||
$SEDI "/==EXTERNAL_STORAGE==/ d" project/AndroidManifest.xml # Disabled by default
|
||||
$SEDI "/==NOT_EXTERNAL_STORAGE==/ d" project/AndroidManifest.xml
|
||||
else
|
||||
$SEDI "/==EXTERNAL_STORAGE==/ d" project/AndroidManifest.xml # Disabled by default
|
||||
$SEDI "/==READ_OBB==/ d" project/AndroidManifest.xml
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$AccessInternet" = "n" ]; then
|
||||
$SEDI "/==INTERNET==/ d" project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
if [ -z "$AppOpenFileExtension" ]; then
|
||||
$SEDI "/==OPENFILE==/ d" project/AndroidManifest.xml
|
||||
else
|
||||
EXTS="`for EXT in $AppOpenFileExtension; do echo -n '\\\\1'$EXT'\\\\2' ; done`"
|
||||
$SEDI "s/\(.*\)==OPENFILE-EXT==\(.*\)/$EXTS/g" project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
if [ "$ImmersiveMode" = "n" ]; then
|
||||
ImmersiveMode=false
|
||||
else
|
||||
ImmersiveMode=true
|
||||
fi
|
||||
|
||||
if [ "$HideSystemMousePointer" = "n" ]; then
|
||||
HideSystemMousePointer=false
|
||||
else
|
||||
HideSystemMousePointer=true
|
||||
fi
|
||||
|
||||
if [ "$CreateService" = "y" ] ; then
|
||||
CreateService=true
|
||||
else
|
||||
CreateService=false
|
||||
$SEDI "/==FOREGROUND_SERVICE==/ d" project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
GLESLib=-lGLESv1_CM
|
||||
GLESVersion=-DSDL_VIDEO_OPENGL_ES_VERSION=1
|
||||
|
||||
@@ -861,6 +958,26 @@ else
|
||||
$SEDI "/==GLES3==/ d" project/AndroidManifest.xml
|
||||
fi
|
||||
|
||||
|
||||
if [ "$LibSdlVersion" = "2.0" ] ; then
|
||||
echo Patching java files not fully supported in SDL 2.0 yet.
|
||||
ACTIVITY="${AppShortName}Activity"
|
||||
sed -i -e "s|\"SDLActivity\"|\"$ACTIVITY\"|g" project/AndroidManifest.xml
|
||||
|
||||
echo Creating $JAVA_SRC_PATH/$ACTIVITY.java ...
|
||||
|
||||
# Fill in a default Activity
|
||||
cat >"$JAVA_SRC_PATH/$ACTIVITY.java" <<__EOF__
|
||||
package $AppFullName;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
|
||||
public class $ACTIVITY extends SDLActivity
|
||||
{
|
||||
}
|
||||
__EOF__
|
||||
|
||||
else
|
||||
echo Patching project/src/Globals.java
|
||||
$SEDI "s/public static String ApplicationName = .*;/public static String ApplicationName = \"$AppShortName\";/" project/src/Globals.java
|
||||
$SEDI "s/public static final boolean Using_SDL_1_3 = .*;/public static final boolean Using_SDL_1_3 = $UsingSdl13;/" project/src/Globals.java
|
||||
@@ -909,6 +1026,7 @@ $SEDI "s/public static boolean AppUsesMultitouch = .*;/public static boolean App
|
||||
$SEDI "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean ImmersiveMode = .*;/public static boolean ImmersiveMode = $ImmersiveMode;/" project/src/Globals.java
|
||||
$SEDI "s/public static boolean HideSystemMousePointer = .*;/public static boolean HideSystemMousePointer = $HideSystemMousePointer;/" project/src/Globals.java
|
||||
$SEDI "s|public static String DeleteFilesOnUpgrade = .*;|public static String DeleteFilesOnUpgrade = \"$DeleteFilesOnUpgrade\";|" project/src/Globals.java
|
||||
$SEDI "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" project/src/Globals.java
|
||||
$SEDI "s@public static String\\[\\] AppTouchscreenKeyboardKeysNames = .*;@public static String[] AppTouchscreenKeyboardKeysNames = \"$RedefinedKeysScreenKbNames\".split(\" \");@" project/src/Globals.java
|
||||
@@ -925,12 +1043,21 @@ $SEDI "s/public static String AdmobBannerSize = .*/public static String AdmobBan
|
||||
$SEDI "s%public static String GooglePlayGameServicesId = .*%public static String GooglePlayGameServicesId = \"$GooglePlayGameServicesId\";%" project/src/Globals.java
|
||||
$SEDI "s/public static String AppLibraries.*/public static String AppLibraries[] = { $LibrariesToLoad };/" project/src/Globals.java
|
||||
$SEDI "s/public static String AppMainLibraries.*/public static String AppMainLibraries[] = { $MainLibrariesToLoad };/" project/src/Globals.java
|
||||
fi
|
||||
|
||||
|
||||
# TODO: We should not build png, jpeg if SDL2_image is used
|
||||
if [ "$LibSdlVersion" = "2.0" ]; then
|
||||
APP_MODULES_BASE="SDL2"
|
||||
else
|
||||
APP_MODULES_BASE="sdl-$LibSdlVersion sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype"
|
||||
fi
|
||||
|
||||
|
||||
echo Patching project/jni/Settings.mk
|
||||
echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk
|
||||
cat project/jni/SettingsTemplate.mk | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := sdl-$LibSdlVersion sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype $CompiledLibraries application/" | \
|
||||
sed "s/APP_MODULES := .*/APP_MODULES := $APP_MODULES_BASE $CompiledLibraries application/" | \
|
||||
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \
|
||||
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
|
||||
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
|
||||
@@ -965,23 +1092,26 @@ echo Patching strings.xml
|
||||
rm -rf project/res/values*/strings.xml
|
||||
cd $JAVA_SRC_PATH/translations
|
||||
for F in */strings.xml; do
|
||||
mkdir -p ../../res/`dirname $F`
|
||||
cat $F | \
|
||||
sed "s^[<]string name=\"app_name\"[>].*^<string name=\"app_name\">$AppName</string>^" > \
|
||||
../../res/$F
|
||||
mkdir -p ../../res/`dirname $F`
|
||||
cat $F | \
|
||||
sed "s^[<]string name=\"app_name\"[>].*^<string name=\"app_name\">$AppName</string>^" > \
|
||||
../../res/$F
|
||||
done
|
||||
|
||||
cd ../../..
|
||||
|
||||
|
||||
|
||||
SDK_DIR=`grep '^sdk.dir' project/local.properties | sed 's/.*=//'`
|
||||
[ -z "$SDK_DIR" ] && SDK_DIR=`which android | sed 's@/tools/android$@@'`
|
||||
mkdir -p project/libs
|
||||
echo "sdk.dir=$SDK_DIR" > project/local.properties
|
||||
echo 'proguard.config=proguard.cfg;proguard-local.cfg' >> project/local.properties
|
||||
|
||||
if [ "$GooglePlayGameServicesId" = "n" -o -z "$GooglePlayGameServicesId" ] ; then
|
||||
$SEDI "/==GOOGLEPLAYGAMESERVICES==/ d" project/AndroidManifest.xml
|
||||
$SEDI "/==GOOGLEPLAYGAMESERVICES==/ d" project/app/build.gradle
|
||||
GooglePlayGameServicesId=""
|
||||
grep '=play-services' project/local.properties > /dev/null && {
|
||||
$SEDI 's/.*=play-services.*//g' project/local.properties
|
||||
rm -f project/libs/android-support-v4.jar
|
||||
}
|
||||
else
|
||||
for F in $JAVA_SRC_PATH/googleplaygameservices/*.java; do
|
||||
OUT=`echo $F | sed 's@.*/@@'` # basename tool is not available everywhere
|
||||
@@ -990,76 +1120,43 @@ else
|
||||
cat $F | sed "s/^package .*;/package $AppFullName;/" >> project/src/$OUT
|
||||
done
|
||||
|
||||
PLAY_SERVICES_VER=9.4.0
|
||||
rm -rf project/play-services
|
||||
|
||||
CURDIR=`pwd`
|
||||
cd $SDK_DIR/extras/google/m2repository/com/google/android/gms/play-services-games/$PLAY_SERVICES_VER || exit 1
|
||||
$CURDIR/aar2jar.py -o $CURDIR/project/play-services/games -i play-services-games-$PLAY_SERVICES_VER || exit 1
|
||||
cd $SDK_DIR/extras/google/m2repository/com/google/android/gms/play-services-drive/$PLAY_SERVICES_VER || exit 1
|
||||
$CURDIR/aar2jar.py -o $CURDIR/project/play-services/drive -i play-services-drive-$PLAY_SERVICES_VER || exit 1
|
||||
cd $SDK_DIR/extras/google/m2repository/com/google/android/gms/play-services-base/$PLAY_SERVICES_VER || exit 1
|
||||
$CURDIR/aar2jar.py -o $CURDIR/project/play-services/base -i play-services-base-$PLAY_SERVICES_VER || exit 1
|
||||
cd $SDK_DIR/extras/google/m2repository/com/google/android/gms/play-services-tasks/$PLAY_SERVICES_VER || exit 1
|
||||
$CURDIR/aar2jar.py -o $CURDIR/project/play-services/tasks -i play-services-tasks-$PLAY_SERVICES_VER || exit 1
|
||||
cd $SDK_DIR/extras/google/m2repository/com/google/android/gms/play-services-basement/$PLAY_SERVICES_VER || exit 1
|
||||
$CURDIR/aar2jar.py -o $CURDIR/project/play-services/basement -i play-services-basement-$PLAY_SERVICES_VER || exit 1
|
||||
cd $CURDIR
|
||||
|
||||
$SEDI "s/==GOOGLEPLAYGAMESERVICES_APP_ID==/$GooglePlayGameServicesId/g" project/res/values/strings.xml
|
||||
grep 'play-services' project/local.properties > /dev/null || {
|
||||
|
||||
PROGUARD=`which android`
|
||||
PROGUARD=`dirname $PROGUARD`/proguard/lib/proguard.jar
|
||||
java -jar $PROGUARD | grep 'ProGuard, version 5.3.2' || {
|
||||
echo "Error: ProGuard is too old"
|
||||
echo "You need to update ProGuard. Download it here:"
|
||||
echo "https://sourceforge.net/projects/proguard/files/proguard/5.3/proguard5.3.2.tar.gz"
|
||||
echo "Unpack it, then place file proguard.jar to $PROGUARD"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Ant is way too smart, and adds current project path in front of the ${sdk.dir}
|
||||
echo "android.library.reference.1=play-services/games/play-services-games-$PLAY_SERVICES_VER" >> project/local.properties
|
||||
echo "android.library.reference.2=play-services/drive/play-services-drive-$PLAY_SERVICES_VER" >> project/local.properties
|
||||
echo "android.library.reference.3=play-services/base/play-services-base-$PLAY_SERVICES_VER" >> project/local.properties
|
||||
echo "android.library.reference.4=play-services/tasks/play-services-tasks-$PLAY_SERVICES_VER" >> project/local.properties
|
||||
echo "android.library.reference.5=play-services/basement/play-services-basement-$PLAY_SERVICES_VER" >> project/local.properties
|
||||
#echo 'android.library.reference.6=../../../../../../../../../../../../../../${sdk.dir}/extras/android/compatibility/v7/mediarouter' >> project/local.properties
|
||||
#echo 'android.library.reference.7=../../../../../../../../../../../../../../${sdk.dir}/extras/android/compatibility/v7/appcompat' >> project/local.properties
|
||||
#echo 'android.library.reference.8=../../../../../../../../../../../../../../${sdk.dir}/extras/android/compatibility/v7/palette' >> project/local.properties
|
||||
echo 'proguard.config=proguard.cfg;proguard-local.cfg' >> project/local.properties
|
||||
ln -s -f $SDK_DIR/extras/android/compatibility/v4/android-support-v4.jar project/libs
|
||||
PROGUARD=`which android`
|
||||
[ -z "$PROGUARD" ] && PROGUARD=$ANDROID_SDK_ROOT/tools/android
|
||||
PROGUARD=`dirname $PROGUARD`/proguard/lib/proguard.jar
|
||||
java -jar $PROGUARD | grep 'ProGuard, version 5.3' || {
|
||||
echo "Error: ProGuard is too old"
|
||||
echo "You need to update ProGuard. Download it here:"
|
||||
echo "https://sourceforge.net/projects/proguard/files/proguard/5.3/proguard5.3.3.zip"
|
||||
echo "Unpack it, then place file proguard.jar to $PROGUARD"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
if [ -e project/jni/application/src/project.patch ]; then patch -p1 --dry-run -f -R < project/jni/application/src/project.patch > /dev/null 2>&1 || patch -p1 --no-backup-if-mismatch < project/jni/application/src/project.patch || exit 1 ; fi
|
||||
|
||||
rm -f project/lib
|
||||
ln -s -f libs project/lib
|
||||
|
||||
echo Cleaning up dependencies
|
||||
|
||||
rm -rf project/libs/*/* project/gen
|
||||
for OUT in obj; do
|
||||
rm -rf project/$OUT/local/*/objs*/sdl_main/* project/$OUT/local/*/libsdl_main.so
|
||||
rm -rf project/$OUT/local/*/libsdl-*.so
|
||||
rm -rf project/$OUT/local/*/libsdl_*.so
|
||||
rm -rf project/$OUT/local/*/objs*/sdl-*/src/*/android
|
||||
rm -rf project/$OUT/local/*/objs*/sdl-*/src/video/SDL_video.o
|
||||
rm -rf project/$OUT/local/*/objs*/sdl-*/SDL_renderer_gles.o
|
||||
rm -rf project/$OUT/local/*/objs*/sdl_*
|
||||
rm -rf project/obj/local/*/objs*/sdl_main/* project/$OUT/local/*/libsdl_main.so
|
||||
rm -rf project/obj/local/*/libsdl-*.so
|
||||
rm -rf project/obj/local/*/libsdl_*.so
|
||||
rm -rf project/obj/local/*/objs*/sdl-*/src/*/android
|
||||
rm -rf project/obj/local/*/objs*/sdl-*/src/video/SDL_video.o
|
||||
rm -rf project/obj/local/*/objs*/sdl-*/SDL_renderer_gles.o
|
||||
rm -rf project/obj/local/*/objs*/sdl_*
|
||||
rm -rf project/obj/local/*/objs*/lzma/src/XZInputStream.o
|
||||
rm -rf project/obj/local/*/objs*/liblzma.so
|
||||
# Do not rebuild several huge libraries that do not depend on SDL version
|
||||
for LIB in freetype intl jpeg png lua mad tremor xerces xml2 curl lua mikmod \
|
||||
boost boost_signals boost_thread boost_filesystem boost_date_time boost_system boost_regex boost_iostreams boost_program_options \
|
||||
ffmpeg swscale avcodec avdevice avresample avutil avfilter swresample avformat; do
|
||||
for ARCH in armeabi armeabi-v7a; do
|
||||
if [ -e "project/$OUT/local/$ARCH/objs*/$LIB" ] ; then
|
||||
find project/$OUT/local/$ARCH/objs*/$LIB -name "*.o" | xargs touch -c
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
rm -rf project/jni/application/src/AndroidData/lib
|
||||
|
||||
rm -rf project/bin/classes
|
||||
rm -rf project/bin/res
|
||||
rm -rf project/app/build
|
||||
|
||||
# Generate OUYA icon, for that one user who still got an OUYA in his living room and won't throw it away just because someone else decides that it's dead
|
||||
rm -rf project/res/drawable-xhdpi/ouya_icon.png
|
||||
@@ -1073,8 +1170,6 @@ fi
|
||||
./copyAssets.sh || exit 1
|
||||
|
||||
rm -rf project/jni/android-support
|
||||
echo "$NDK_TOOLCHAIN_VERSION" | grep 'clang' > /dev/null || \
|
||||
ln -s "`which ndk-build | sed 's@/ndk-build@@'`/sources/android/support" project/jni/android-support
|
||||
|
||||
rm -rf project/res/drawable/banner.png
|
||||
if [ -e project/jni/application/src/banner.png ]; then
|
||||
@@ -1089,6 +1184,16 @@ fi
|
||||
|
||||
echo Compiling prebuilt libraries
|
||||
|
||||
make -C project/jni -f Makefile.prebuilt
|
||||
if echo "$CompiledLibraries" | grep -E 'crypto|ssl' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt openssl
|
||||
fi
|
||||
|
||||
if echo "$CompiledLibraries" | grep -E 'iconv|charset|icu|harfbuzz' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt icu
|
||||
fi
|
||||
|
||||
if echo "$CompiledLibraries" | grep 'boost_' > /dev/null; then
|
||||
make -C project/jni -f Makefile.prebuilt boost
|
||||
fi
|
||||
|
||||
echo Done
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
#!/bin/sh
|
||||
|
||||
ARCHES="arm64-v8a armeabi-v7a x86 x86_64"
|
||||
|
||||
if [ "$1" = "pack-binaries" -o "$1" = "pack-binaries-bundle" ]; then
|
||||
[ -e jni/application/src/AndroidData/lib ] || exit 0
|
||||
[ -e jni/application/src/AndroidData/binaries*.zip ] && {
|
||||
echo "Error: binaries.zip no longer supported in Android 10"
|
||||
echo "Copy your executable binaries to AndroidData/lib/arm64-v8a"
|
||||
echo "Then execute them using \$LIBDIR or getenv(\"LIBDIR\")"
|
||||
exit 0
|
||||
}
|
||||
APK="`pwd`/$2"
|
||||
echo "Copying binaries to .apk file"
|
||||
cd jni/application/src/AndroidData/ || exit 1
|
||||
if [ "$1" = "pack-binaries-bundle" ]; then
|
||||
rm -rf base
|
||||
mkdir -p base
|
||||
mv lib base/
|
||||
zip -r "$APK" base || exit 1
|
||||
mv base/lib ./
|
||||
rm -rf base
|
||||
else
|
||||
zip -r "$APK" lib || exit 1
|
||||
fi
|
||||
cd ../../../../
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Copying app data files from project/jni/application/src/AndroidData to project/assets"
|
||||
mkdir -p project/assets
|
||||
rm -f -r project/assets/*
|
||||
if [ -d "project/jni/application/src/AndroidData" ] ; then
|
||||
cp -L -r project/jni/application/src/AndroidData/* project/assets/
|
||||
exit 0 # Do not split assets, this was needed only for Andorid 2.3 with it's stupid limitations
|
||||
for F in project/assets/*; do
|
||||
if [ `cat $F | wc -c` -gt 1000000 ] ; then
|
||||
echo "The file $F is bigger than 1 megabyte - splitting it into smaller chunks"
|
||||
split -b 1000000 -a 3 -d $F $F && rm $F || { echo "Error: 'split' command not installed" ; exit 1 ; }
|
||||
fi
|
||||
done
|
||||
rm -rf project/assets/lib
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -5,16 +5,19 @@ APPVER=`grep AppVersionName AndroidAppSettings.cfg | sed 's/.*=//' | tr -d '"' |
|
||||
|
||||
ARCHIVER=gzip
|
||||
EXT=gz
|
||||
which xz > /dev/null && ARCHIVER="xz -z" && EXT=xz
|
||||
which pxz > /dev/null && ARCHIVER=pxz && EXT=xz || echo "Install pxz for faster archiving: sudo apt-get isntall pxz"
|
||||
which xz > /dev/null && ARCHIVER="xz -z -T 0" && EXT=xz
|
||||
#which pxz > /dev/null && ARCHIVER=pxz && EXT=xz || echo "Install pxz for faster archiving: sudo apt-get install pxz"
|
||||
|
||||
# TODO: Boost, Python and ffmpeg are stored in repository as precompiled binaries, the proper way to fix that is to build them using scripts, and remove that binaries
|
||||
# --exclude="*.a" --exclude="*.so"
|
||||
tar -c --exclude-vcs --exclude="*.o" --exclude="*.d" --exclude="*.dep" \
|
||||
--exclude="libboost_*.a" --exclude="libcharset.so" --exclude="libiconv.so" \
|
||||
--exclude="libicu*.a" --exclude="libharfbuzz.a" --exclude="libcrypto.so*" --exclude="libssl.so*" \
|
||||
`git ls-files --exclude-standard | grep -v '^project/jni/application/.*'` \
|
||||
`find project/jni/application -maxdepth 1 -type f -o -type l` \
|
||||
project/jni/application/src \
|
||||
project/jni/application/`readlink project/jni/application/src` \
|
||||
project/AndroidManifest.xml project/src \
|
||||
project/obj/local/armeabi-v7a/*.so project/obj/local/x86/*.so \
|
||||
project/obj/local/armeabi-v7a/*.so project/obj/local/arm64-v8a/*.so project/obj/local/x86/*.so project/obj/local/x86_64/*.so \
|
||||
project/app/build/outputs/mapping/release/mapping.txt \
|
||||
"$@" | $ARCHIVER > $APPNAME-$APPVER-src.tar.$EXT
|
||||
|
||||
3
project/.gitignore
vendored
Normal file
3
project/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/.gradle
|
||||
/build
|
||||
|
||||
@@ -7,10 +7,12 @@
|
||||
>
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:debuggable="true"
|
||||
android:allowBackup="true"
|
||||
android:banner="@drawable/banner"
|
||||
android:isGame="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
>
|
||||
<activity android:name=".MainActivity"
|
||||
android:label="@string/app_name"
|
||||
@@ -27,6 +29,18 @@
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" /> <!-- Android TV requires this -->
|
||||
<category android:name="tv.ouya.intent.category.GAME" /> <!-- For that one user who still got an OUYA in his living room and won't throw it away just because someone else decides that it's dead -->
|
||||
</intent-filter>
|
||||
<!-- ==OPENFILE== --> <intent-filter>
|
||||
<!-- ==OPENFILE== --> <action android:name="android.intent.action.VIEW" />
|
||||
<!-- ==OPENFILE== --> <category android:name="android.intent.category.DEFAULT" />
|
||||
<!-- ==OPENFILE== --> <category android:name="android.intent.category.BROWSABLE" />
|
||||
<!-- ==OPENFILE== --> <data android:scheme="file" />
|
||||
<!-- ==OPENFILE== --> <data android:mimeType="*/*" />
|
||||
<!-- ==OPENFILE== --> <data android:host="*" />
|
||||
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\.==OPENFILE-EXT==" />
|
||||
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\.==OPENFILE-EXT==" />
|
||||
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\.==OPENFILE-EXT==" />
|
||||
<!-- ==OPENFILE== --> <data android:pathPattern=".*\\..*\\..*\\..*\\.==OPENFILE-EXT==" />
|
||||
<!-- ==OPENFILE== --> </intent-filter>
|
||||
</activity>
|
||||
<!-- ==ADMOB== --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"/>
|
||||
<!-- ==ADMOB== --> <meta-data android:name="com.google.android.gms.version" android:value="4323000" /> <!-- Change this value to the actual Google Play SDK version -->
|
||||
@@ -48,20 +62,29 @@
|
||||
/>
|
||||
</application>
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25"/>
|
||||
<!-- ==INTERNET== --> <uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- App has write access to it's own dir on SD card without this permission on Android 4.4 and above -->
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- App has write access to it's own dir on SD card without this permission on Android 4.4 and above -->
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" /> <!-- OBB file requires explicit permission before Marshmallow -->
|
||||
<!-- ==RECORD_AUDIO== --> <uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<!-- ==ADMOB== --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!-- ==FOREGROUND_SERVICE== --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<!-- <uses-permission android:name="android.permission.VIBRATE"></uses-permission> --> <!-- Vibrator not supported yet by SDL -->
|
||||
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" /> <!-- Allow TV boxes -->
|
||||
<uses-feature android:name="android.hardware.faketouch" android:required="false"/> <!-- Allow TV boxes -->
|
||||
<uses-feature android:name="android.software.leanback" android:required="false" /> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.microphone" android:required="false" /> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.gamepad" android:required="false"/> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.telephony" android:required="false"/> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.nfc" android:required="false"/> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.location.gps" android:required="false"/> <!-- Android TV requires this -->
|
||||
<uses-feature android:name="android.hardware.sensor" android:required="false"/> <!-- Android TV requires this -->
|
||||
<!-- ==SCREEN-SIZE-SMALL== --> <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
|
||||
<!-- ==SCREEN-SIZE-NORMAL== --> <supports-screens android:smallScreens="false" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" />
|
||||
<!-- ==SCREEN-SIZE-LARGE== --> <supports-screens android:smallScreens="false" android:normalScreens="false" android:largeScreens="true" android:xlargeScreens="true" />
|
||||
|
||||
103
project/AndroidManifestTemplateSDL2.xml
Normal file
103
project/AndroidManifestTemplateSDL2.xml
Normal file
@@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Replace com.test.game with the identifier of your game below, e.g.
|
||||
com.gamemaker.game
|
||||
-->
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.libsdl.app"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0"
|
||||
android:installLocation="auto">
|
||||
|
||||
<!-- OpenGL ES 2.0 -->
|
||||
<uses-feature android:glEsVersion="0x00020000" />
|
||||
|
||||
<!-- Touchscreen support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Game controller support -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.gamepad"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.usb.host"
|
||||
android:required="false" />
|
||||
|
||||
<!-- External mouse input events -->
|
||||
<uses-feature
|
||||
android:name="android.hardware.type.pc"
|
||||
android:required="false" />
|
||||
|
||||
<!-- Audio recording support -->
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-feature
|
||||
android:name="android.hardware.microphone"
|
||||
android:required="false" /> -->
|
||||
|
||||
<!-- Allow writing to external storage -->
|
||||
<!--
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
-->
|
||||
<!-- Allow access to Bluetooth devices -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH" />
|
||||
<!-- Allow access to the vibrator -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<!-- ==INTERNET== --> <uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- ==EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==NOT_EXTERNAL_STORAGE== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- App has write access to it's own dir on SD card without this permission on Android 4.4 and above -->
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18" />
|
||||
<!-- ==READ_OBB== --> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" /> <!-- OBB file requires explicit permission before Marshmallow -->
|
||||
<!-- ==RECORD_AUDIO== --> <uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<!-- ==ADMOB== --> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<!-- ==FOREGROUND_SERVICE== --> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
|
||||
|
||||
<!-- if you want to capture audio, uncomment this. -->
|
||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
||||
|
||||
<!-- Create a Java class extending SDLActivity and place it in a
|
||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||
|
||||
then replace "SDLActivity" with the name of your class (e.g. "MyGame")
|
||||
in the XML below.
|
||||
|
||||
An example Java class can be found in README-android.md
|
||||
-->
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@drawable/icon"
|
||||
android:allowBackup="true"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:hardwareAccelerated="true" >
|
||||
|
||||
<!-- Example of setting SDL hints from AndroidManifest.xml:
|
||||
<meta-data android:name="SDL_ENV.SDL_ACCELEROMETER_AS_JOYSTICK" android:value="0"/>
|
||||
-->
|
||||
|
||||
<activity android:name="SDLActivity"
|
||||
android:label="@string/app_name"
|
||||
android:alwaysRetainTaskState="true"
|
||||
android:launchMode="singleInstance"
|
||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation"
|
||||
>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<!-- Drop file event -->
|
||||
<!--
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:mimeType="*/*" />
|
||||
</intent-filter>
|
||||
-->
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
26
project/app/build-template.gradle
Normal file
26
project/app/build-template.gradle
Normal file
@@ -0,0 +1,26 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "30.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "net.olofson.ballfield"
|
||||
minSdkVersion 16 // Must match version numbers in project/AndroidManifestTemplate.xml
|
||||
targetSdkVersion 29
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), '../proguard-local.cfg', '../proguard.cfg'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies { compile 'com.google.android.gms:play-services-games:19.0.0' } // ==GOOGLEPLAYGAMESERVICES==
|
||||
dependencies { compile 'com.google.android.gms:play-services-drive:17.0.0' } // ==GOOGLEPLAYGAMESERVICES==
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
}
|
||||
1
project/app/src/main/AndroidManifest.xml
Symbolic link
1
project/app/src/main/AndroidManifest.xml
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../AndroidManifest.xml
|
||||
1
project/app/src/main/assets
Symbolic link
1
project/app/src/main/assets
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../assets
|
||||
1
project/app/src/main/java
Symbolic link
1
project/app/src/main/java
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../src/
|
||||
1
project/app/src/main/jniLibs
Symbolic link
1
project/app/src/main/jniLibs
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../libs/
|
||||
1
project/app/src/main/res
Symbolic link
1
project/app/src/main/res
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../res
|
||||
25
project/build.gradle
Normal file
25
project/build.gradle
Normal file
@@ -0,0 +1,25 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.0.0"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="MainActivity" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties" />
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties" />
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env" />
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME" />
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties" />
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true" />
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml" />
|
||||
|
||||
</project>
|
||||
19
project/gradle.properties
Normal file
19
project/gradle.properties
Normal file
@@ -0,0 +1,19 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
BIN
project/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
project/gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
project/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
project/gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
#Tue Jul 07 20:59:38 EEST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
172
project/gradlew
vendored
Executable file
172
project/gradlew
vendored
Executable file
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
84
project/gradlew.bat
vendored
Normal file
84
project/gradlew.bat
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -29,6 +29,7 @@ import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Environment;
|
||||
import android.view.View;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.net.URLConnection;
|
||||
@@ -186,7 +187,8 @@ class DataDownloader extends Thread
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Parent.keyListener = new BackKeyListener(Parent);
|
||||
Parent.getVideoLayout().setOnKeyListener(new BackKeyListener(Parent));
|
||||
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
int total = 0;
|
||||
int count = 0;
|
||||
@@ -217,7 +219,7 @@ class DataDownloader extends Thread
|
||||
}
|
||||
}
|
||||
DownloadComplete = true;
|
||||
Parent.keyListener = null;
|
||||
Parent.getVideoLayout().setOnKeyListener(null);
|
||||
initParent();
|
||||
}
|
||||
|
||||
@@ -287,7 +289,7 @@ class DataDownloader extends Thread
|
||||
Log.i("SDL", "Downloading data to: '" + outFilesDir + "'");
|
||||
try {
|
||||
File outDir = new File( outFilesDir );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
if( !outDir.exists() )
|
||||
outDir.mkdirs();
|
||||
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
|
||||
out.flush();
|
||||
@@ -803,7 +805,7 @@ class DataDownloader extends Thread
|
||||
Parent.getPackageName() + "/" + url.substring("obb:".length()) + "." + Parent.getPackageName() + ".obb";
|
||||
}
|
||||
|
||||
public class BackKeyListener implements MainActivity.KeyEventsListener
|
||||
public class BackKeyListener implements View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
public BackKeyListener(MainActivity _p)
|
||||
@@ -811,7 +813,8 @@ class DataDownloader extends Thread
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
if( DownloadFailed )
|
||||
System.exit(1);
|
||||
@@ -844,6 +847,7 @@ class DataDownloader extends Thread
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,8 @@ import android.inputmethodservice.Keyboard;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.widget.RemoteViews;
|
||||
import android.os.Build;
|
||||
import android.app.NotificationChannel;
|
||||
|
||||
public class DummyService extends Service
|
||||
{
|
||||
@@ -110,13 +112,29 @@ public class DummyService extends Service
|
||||
System.exit(0);
|
||||
}
|
||||
Log.v("SDL", "Starting dummy service - displaying notification");
|
||||
Notification ntf = new Notification();
|
||||
ntf.icon = R.drawable.icon;
|
||||
ntf.flags |= Notification.FLAG_NO_CLEAR;
|
||||
Notification.Builder builder;
|
||||
if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O )
|
||||
{
|
||||
String channelId = "app_running_ntf";
|
||||
NotificationChannel channel = new NotificationChannel(channelId,
|
||||
getString(R.string.notification_app_is_running, getString(getApplicationInfo().labelRes)),
|
||||
NotificationManager.IMPORTANCE_LOW);
|
||||
NotificationManager mgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mgr.createNotificationChannel(channel);
|
||||
builder = new Notification.Builder(this, channelId);
|
||||
}
|
||||
else
|
||||
{
|
||||
builder = new Notification.Builder(this);
|
||||
}
|
||||
Notification ntf = builder
|
||||
.setSmallIcon(R.drawable.icon)
|
||||
.setTicker(getString(getApplicationInfo().labelRes))
|
||||
.setOngoing(true)
|
||||
.build();
|
||||
PendingIntent killIntent = PendingIntent.getService(this, 5, new Intent(Intent.ACTION_DELETE, null, this, DummyService.class), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
PendingIntent showIntent = PendingIntent.getActivity(this, 0, new Intent("", null, this, MainActivity.class), PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
ntf.deleteIntent = killIntent;
|
||||
ntf.tickerText = getString(getApplicationInfo().labelRes);
|
||||
RemoteViews view = new RemoteViews(getPackageName(), R.layout.notification);
|
||||
view.setCharSequence(R.id.notificationText, "setText", getString(R.string.notification_app_is_running, getString(getApplicationInfo().labelRes)));
|
||||
view.setOnClickPendingIntent(R.id.notificationText, showIntent);
|
||||
|
||||
@@ -1015,7 +1015,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
|
||||
mRenderMode = RENDERMODE_CONTINUOUSLY;
|
||||
mRenderer = renderer;
|
||||
mRenderer.setSwapBuffersCallback(this);
|
||||
setName("GLThread");
|
||||
setName("SDLVideoThread");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,7 +32,13 @@ class Globals
|
||||
public static String ApplicationName = "CommanderGenius";
|
||||
public static String AppLibraries[] = { "sdl-1.2", };
|
||||
public static String AppMainLibraries[] = { "application", "sdl_main" };
|
||||
public static String LibraryNamesMap[][] = { { "crypto", "crypto.so.sdl.1" }, { "ssl", "ssl.so.sdl.1" }, { "curl", "curl-sdl" } }; // Because some libraries are named differently to not clash with system libs
|
||||
public static String LibraryNamesMap[][] = {
|
||||
{ "crypto", "crypto.so.sdl.1" },
|
||||
{ "ssl", "ssl.so.sdl.1" },
|
||||
{ "curl", "curl-sdl" },
|
||||
{ "expat", "expat-sdl" },
|
||||
{ "sqlite3", "sqlite3-sdl" },
|
||||
}; // Because some libraries are named differently to not clash with system libs
|
||||
public static final boolean Using_SDL_1_3 = false;
|
||||
public static final boolean Using_SDL_2_0 = false;
|
||||
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
|
||||
@@ -42,7 +48,7 @@ class Globals
|
||||
public static boolean NeedGles2 = false;
|
||||
public static boolean NeedGles3 = false;
|
||||
public static boolean CompatibilityHacksVideo = false;
|
||||
public static boolean CompatibilityHacksForceScreenUpdateMouseClick = true;
|
||||
public static boolean CompatibilityHacksForceScreenUpdateMouseClick = false;
|
||||
public static boolean CompatibilityHacksStaticInit = false;
|
||||
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
|
||||
public static int TextInputKeyboard = 0;
|
||||
@@ -85,13 +91,14 @@ class Globals
|
||||
public static boolean HorizontalOrientation = true;
|
||||
public static boolean AutoDetectOrientation = false;
|
||||
public static boolean ImmersiveMode = true;
|
||||
public static boolean HideSystemMousePointer = false;
|
||||
public static boolean DownloadToSdcard = true;
|
||||
public static boolean PhoneHasArrowKeys = false;
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = true;
|
||||
public static int TouchscreenKeyboardSize = 1;
|
||||
public static final int TOUCHSCREEN_KEYBOARD_CUSTOM = 4;
|
||||
public static int TouchscreenKeyboardDrawSize = 1;
|
||||
public static int TouchscreenKeyboardDrawSize = 2;
|
||||
public static int TouchscreenKeyboardTheme = 2;
|
||||
public static int TouchscreenKeyboardTransparency = 2;
|
||||
public static boolean FloatingScreenJoystick = false;
|
||||
|
||||
@@ -97,6 +97,8 @@ import android.app.UiModeManager;
|
||||
import android.Manifest;
|
||||
import android.content.pm.PermissionInfo;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class MainActivity extends Activity
|
||||
@@ -177,6 +179,9 @@ public class MainActivity extends Activity
|
||||
}
|
||||
|
||||
setContentView(_videoLayout);
|
||||
_videoLayout.setFocusable(true);
|
||||
_videoLayout.setFocusableInTouchMode(true);
|
||||
_videoLayout.requestFocus();
|
||||
|
||||
class Callback implements Runnable
|
||||
{
|
||||
@@ -205,7 +210,12 @@ public class MainActivity extends Activity
|
||||
loaded.release();
|
||||
loadedLibraries.release();
|
||||
if( _btn != null )
|
||||
{
|
||||
_btn.setEnabled(true);
|
||||
_btn.setFocusable(true);
|
||||
_btn.setFocusableInTouchMode(true);
|
||||
_btn.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
Callback2 cb = new Callback2();
|
||||
@@ -392,7 +402,7 @@ public class MainActivity extends Activity
|
||||
layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
|
||||
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
|
||||
ImageView borderLeft = new ImageView(this);
|
||||
borderLeft.setId(R.drawable.b1); // Any random ID
|
||||
borderLeft.setId(R.id.left); // Any random ID
|
||||
borderLeft.setImageResource(R.drawable.tv_border_left);
|
||||
borderLeft.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
view.addView(borderLeft, layout);
|
||||
@@ -401,7 +411,7 @@ public class MainActivity extends Activity
|
||||
layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
|
||||
layout.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
|
||||
ImageView borderRight = new ImageView(this);
|
||||
borderRight.setId(R.drawable.b2);
|
||||
borderRight.setId(R.id.right);
|
||||
borderRight.setImageResource(R.drawable.tv_border_left);
|
||||
borderRight.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
borderRight.setScaleX(-1f);
|
||||
@@ -412,7 +422,7 @@ public class MainActivity extends Activity
|
||||
layout.addRule(RelativeLayout.RIGHT_OF, borderLeft.getId());
|
||||
layout.addRule(RelativeLayout.LEFT_OF, borderRight.getId());
|
||||
ImageView borderTop = new ImageView(this);
|
||||
borderTop.setId(R.drawable.b3);
|
||||
borderTop.setId(R.id.top);
|
||||
borderTop.setImageResource(R.drawable.tv_border_top);
|
||||
borderTop.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
view.addView(borderTop, layout);
|
||||
@@ -422,7 +432,7 @@ public class MainActivity extends Activity
|
||||
layout.addRule(RelativeLayout.RIGHT_OF, borderLeft.getId());
|
||||
layout.addRule(RelativeLayout.LEFT_OF, borderRight.getId());
|
||||
ImageView borderBottom = new ImageView(this);
|
||||
borderBottom.setId(R.drawable.b4);
|
||||
borderBottom.setId(R.id.bottom);
|
||||
borderBottom.setImageResource(R.drawable.tv_border_top);
|
||||
borderBottom.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
borderBottom.setScaleY(-1f);
|
||||
@@ -443,9 +453,11 @@ public class MainActivity extends Activity
|
||||
{
|
||||
_videoLayout.addView(mGLView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
|
||||
}
|
||||
mGLView.setFocusableInTouchMode(true);
|
||||
mGLView.setFocusable(true);
|
||||
mGLView.requestFocus();
|
||||
mGLView.captureMouse(true);
|
||||
if( Globals.HideSystemMousePointer && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N )
|
||||
{
|
||||
mGLView.setPointerIcon(android.view.PointerIcon.getSystemIcon(this, android.view.PointerIcon.TYPE_NULL));
|
||||
}
|
||||
|
||||
|
||||
if( _ad.getView() != null )
|
||||
@@ -540,9 +552,13 @@ public class MainActivity extends Activity
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
Log.i("SDL", "libSDL: onWindowFocusChanged: " + hasFocus + " - sending onPause/onResume");
|
||||
if (hasFocus == false)
|
||||
{
|
||||
onPause();
|
||||
}
|
||||
else
|
||||
{
|
||||
onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPaused()
|
||||
@@ -585,6 +601,7 @@ public class MainActivity extends Activity
|
||||
public void onActivityResult(int request, int response, Intent data) {
|
||||
super.onActivityResult(request, response, data);
|
||||
cloudSave.onActivityResult(request, response, data);
|
||||
SettingsMenuMisc.StorageAccessConfig.onActivityResult(this, request, response, data);
|
||||
}
|
||||
|
||||
private int TextInputKeyboardList[][] =
|
||||
@@ -604,6 +621,7 @@ public class MainActivity extends Activity
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
mGLView.captureMouse(false);
|
||||
if (keyboard == 0)
|
||||
{
|
||||
_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
@@ -678,9 +696,9 @@ public class MainActivity extends Activity
|
||||
if (key > 100000)
|
||||
{
|
||||
key -= 100000;
|
||||
MainActivity.this.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
mGLView.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
}
|
||||
MainActivity.this.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key));
|
||||
mGLView.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key));
|
||||
}
|
||||
public void onRelease(int key)
|
||||
{
|
||||
@@ -694,9 +712,9 @@ public class MainActivity extends Activity
|
||||
{
|
||||
builtinKeyboard.shift = ! builtinKeyboard.shift;
|
||||
if (builtinKeyboard.shift && !builtinKeyboard.alt)
|
||||
MainActivity.this.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
mGLView.onKeyDown(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
else
|
||||
MainActivity.this.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
mGLView.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
builtinKeyboard.ChangeKeyboard();
|
||||
return;
|
||||
}
|
||||
@@ -704,7 +722,7 @@ public class MainActivity extends Activity
|
||||
{
|
||||
builtinKeyboard.alt = ! builtinKeyboard.alt;
|
||||
if (builtinKeyboard.alt)
|
||||
MainActivity.this.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
mGLView.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
else
|
||||
builtinKeyboard.shift = false;
|
||||
builtinKeyboard.ChangeKeyboard();
|
||||
@@ -719,12 +737,12 @@ public class MainActivity extends Activity
|
||||
if (k.on)
|
||||
{
|
||||
builtinKeyboard.stickyKeys.add(key);
|
||||
MainActivity.this.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key));
|
||||
mGLView.onKeyDown(key, new KeyEvent(KeyEvent.ACTION_DOWN, key));
|
||||
}
|
||||
else
|
||||
{
|
||||
builtinKeyboard.stickyKeys.remove(key);
|
||||
MainActivity.this.onKeyUp(key, new KeyEvent(KeyEvent.ACTION_UP, key));
|
||||
mGLView.onKeyUp(key, new KeyEvent(KeyEvent.ACTION_UP, key));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -737,11 +755,11 @@ public class MainActivity extends Activity
|
||||
shifted = true;
|
||||
}
|
||||
|
||||
MainActivity.this.onKeyUp(key, new KeyEvent(KeyEvent.ACTION_UP, key));
|
||||
mGLView.onKeyUp(key, new KeyEvent(KeyEvent.ACTION_UP, key));
|
||||
|
||||
if (shifted)
|
||||
{
|
||||
MainActivity.this.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
mGLView.onKeyUp(KeyEvent.KEYCODE_SHIFT_LEFT, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_SHIFT_LEFT));
|
||||
builtinKeyboard.stickyKeys.remove(KeyEvent.KEYCODE_SHIFT_LEFT);
|
||||
for (Keyboard.Key k: builtinKeyboard.getKeyboard().getKeys())
|
||||
{
|
||||
@@ -763,6 +781,7 @@ public class MainActivity extends Activity
|
||||
_screenKeyboard = builtinKeyboard;
|
||||
FrameLayout.LayoutParams layout = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
|
||||
_videoLayout.addView(_screenKeyboard, layout);
|
||||
_videoLayout.bringChildToFront(_screenKeyboard);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -783,6 +802,7 @@ public class MainActivity extends Activity
|
||||
_inputManager.hideSoftInputFromWindow(mGLView.getWindowToken(), 0);
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
//DimSystemStatusBar.get().dim(mGLView);
|
||||
mGLView.captureMouse(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -794,6 +814,7 @@ public class MainActivity extends Activity
|
||||
if(Globals.CompatibilityHacksTextInputEmulatesHwKeyboard)
|
||||
{
|
||||
showScreenKeyboardWithoutTextInputField(Globals.TextInputKeyboard);
|
||||
mGLView.captureMouse(false);
|
||||
return;
|
||||
}
|
||||
if(_screenKeyboard != null)
|
||||
@@ -820,6 +841,7 @@ public class MainActivity extends Activity
|
||||
_parent.hideScreenKeyboard();
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_CLEAR)
|
||||
{
|
||||
// EditText deletes two characters at a time, here's a hacky fix
|
||||
@@ -842,41 +864,33 @@ public class MainActivity extends Activity
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//Log.i("SDL", "Key " + keyCode + " flags " + event.getFlags() + " action " + event.getAction());
|
||||
return false;
|
||||
}
|
||||
};
|
||||
EditText screenKeyboard = new EditText(this);
|
||||
// This code does not work
|
||||
/*
|
||||
screenKeyboard.setMaxLines(100);
|
||||
ViewGroup.LayoutParams layout = _screenKeyboard.getLayoutParams();
|
||||
if( layout != null )
|
||||
{
|
||||
layout.width = ViewGroup.LayoutParams.FILL_PARENT;
|
||||
layout.height = ViewGroup.LayoutParams.FILL_PARENT;
|
||||
screenKeyboard.setLayoutParams(layout);
|
||||
}
|
||||
screenKeyboard.setGravity(android.view.Gravity.BOTTOM | android.view.Gravity.LEFT);
|
||||
*/
|
||||
EditText screenKeyboard = new EditText(this, null,
|
||||
android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP ? android.R.style.TextAppearance_Material_Widget_EditText : android.R.style.TextAppearance_Widget_EditText);
|
||||
String hint = _screenKeyboardHintMessage;
|
||||
screenKeyboard.setHint(hint != null ? hint : getString(R.string.text_edit_click_here));
|
||||
screenKeyboard.setText(oldText);
|
||||
screenKeyboard.setSelection(screenKeyboard.getText().length());
|
||||
screenKeyboard.setOnKeyListener(new simpleKeyListener(this));
|
||||
screenKeyboard.setBackgroundColor(Color.BLACK); // Full opaque - do not show semi-transparent edit box, it's confusing
|
||||
screenKeyboard.setTextColor(Color.WHITE); // Just to be sure about gamma
|
||||
screenKeyboard.setBackgroundColor(this.getResources().getColor(android.R.color.primary_text_light));
|
||||
screenKeyboard.setTextColor(this.getResources().getColor(android.R.color.background_light));
|
||||
if( isRunningOnOUYA() && Globals.TvBorders )
|
||||
screenKeyboard.setPadding(100, 100, 100, 100); // Bad bad HDMI TVs all have cropped borders
|
||||
else
|
||||
screenKeyboard.setPadding(20, 20, 20, 20); // Account for rounded screen corners
|
||||
_screenKeyboard = screenKeyboard;
|
||||
_videoLayout.addView(_screenKeyboard);
|
||||
//_screenKeyboard.setKeyListener(new TextKeyListener(TextKeyListener.Capitalize.NONE, false));
|
||||
screenKeyboard.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
screenKeyboard.setFocusableInTouchMode(true);
|
||||
screenKeyboard.setFocusable(true);
|
||||
screenKeyboard.requestFocus();
|
||||
_inputManager.showSoftInput(screenKeyboard, InputMethodManager.SHOW_IMPLICIT);
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
mGLView.captureMouse(false);
|
||||
//_inputManager.showSoftInput(screenKeyboard, InputMethodManager.SHOW_IMPLICIT);
|
||||
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
// Hack to try to force on-screen keyboard
|
||||
final EditText keyboard = screenKeyboard;
|
||||
keyboard.postDelayed( new Runnable()
|
||||
@@ -884,8 +898,7 @@ public class MainActivity extends Activity
|
||||
public void run()
|
||||
{
|
||||
keyboard.requestFocus();
|
||||
//_inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
|
||||
_inputManager.showSoftInput(keyboard, InputMethodManager.SHOW_FORCED);
|
||||
//_inputManager.showSoftInput(keyboard, InputMethodManager.SHOW_FORCED);
|
||||
// Hack from Stackoverflow, to force text input on Ouya
|
||||
keyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN , 0, 0, 0));
|
||||
keyboard.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP , 0, 0, 0));
|
||||
@@ -893,17 +906,21 @@ public class MainActivity extends Activity
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
keyboard.requestFocus();
|
||||
keyboard.setSelection(keyboard.getText().length());
|
||||
}
|
||||
}, 100 );
|
||||
}
|
||||
}, 500 );
|
||||
}, 300 );
|
||||
};
|
||||
|
||||
public void hideScreenKeyboard()
|
||||
{
|
||||
if( keyboardWithoutTextInputShown )
|
||||
{
|
||||
showScreenKeyboardWithoutTextInputField(Globals.TextInputKeyboard);
|
||||
mGLView.captureMouse(true);
|
||||
}
|
||||
|
||||
if(_screenKeyboard == null || ! (_screenKeyboard instanceof EditText))
|
||||
return;
|
||||
@@ -920,9 +937,7 @@ public class MainActivity extends Activity
|
||||
_inputManager.hideSoftInputFromWindow(_screenKeyboard.getWindowToken(), 0);
|
||||
_videoLayout.removeView(_screenKeyboard);
|
||||
_screenKeyboard = null;
|
||||
mGLView.setFocusableInTouchMode(true);
|
||||
mGLView.setFocusable(true);
|
||||
mGLView.requestFocus();
|
||||
mGLView.captureMouse(true);
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
|
||||
_videoLayout.postDelayed( new Runnable()
|
||||
@@ -938,7 +953,7 @@ public class MainActivity extends Activity
|
||||
{
|
||||
return _screenKeyboard != null;
|
||||
};
|
||||
|
||||
|
||||
public void setScreenKeyboardHintMessage(String s)
|
||||
{
|
||||
_screenKeyboardHintMessage = s;
|
||||
@@ -1044,169 +1059,12 @@ public class MainActivity extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||
{
|
||||
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||
DemoGLSurfaceView.nativeMouseButtonsPressed(2, 1);
|
||||
return true;
|
||||
}
|
||||
else if( keyboardWithoutTextInputShown )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if( _screenKeyboard != null && _screenKeyboard.onKeyDown(keyCode, event) )
|
||||
return true;
|
||||
|
||||
if( mGLView != null )
|
||||
{
|
||||
if( mGLView.nativeKey( keyCode, 1, event.getUnicodeChar() ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
else
|
||||
if( keyListener != null )
|
||||
{
|
||||
keyListener.onKeyEvent(keyCode);
|
||||
}
|
||||
else
|
||||
if( _btn != null )
|
||||
return _btn.onKeyDown(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||
{
|
||||
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||
DemoGLSurfaceView.nativeMouseButtonsPressed(2, 0);
|
||||
return true;
|
||||
}
|
||||
else if( keyboardWithoutTextInputShown )
|
||||
{
|
||||
showScreenKeyboardWithoutTextInputField(0); // Hide keyboard
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if( _screenKeyboard != null && _screenKeyboard.onKeyUp(keyCode, event) )
|
||||
return true;
|
||||
|
||||
if( mGLView != null )
|
||||
{
|
||||
if( mGLView.nativeKey( keyCode, 0, event.getUnicodeChar() ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU )
|
||||
{
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
//DimSystemStatusBar.get().dim(mGLView);
|
||||
}
|
||||
}
|
||||
else
|
||||
if( _btn != null )
|
||||
return _btn.onKeyUp(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
|
||||
{
|
||||
if( _screenKeyboard != null )
|
||||
{
|
||||
_screenKeyboard.onKeyMultiple(keyCode, repeatCount, event);
|
||||
return true;
|
||||
}
|
||||
else if( mGLView != null && event.getCharacters() != null )
|
||||
{
|
||||
// International text input
|
||||
for(int i = 0; i < event.getCharacters().length(); i++ )
|
||||
{
|
||||
mGLView.nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i) );
|
||||
mGLView.nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i) );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyLongPress (int keyCode, KeyEvent event)
|
||||
{
|
||||
if( _screenKeyboard != null )
|
||||
{
|
||||
_screenKeyboard.onKeyLongPress(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
//Log.i("SDL", "dispatchTouchEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
|
||||
if(_screenKeyboard != null && _screenKeyboard.dispatchTouchEvent(ev))
|
||||
return true;
|
||||
|
||||
if( _ad.getView() != null && // User clicked the advertisement, ignore when user moved finger from game screen to advertisement or touches screen with several fingers
|
||||
((ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN ||
|
||||
(ev.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) &&
|
||||
_ad.getView().getLeft() <= (int)ev.getX() &&
|
||||
_ad.getView().getRight() > (int)ev.getX() &&
|
||||
_ad.getView().getTop() <= (int)ev.getY() &&
|
||||
_ad.getView().getBottom() > (int)ev.getY() )
|
||||
return super.dispatchTouchEvent(ev);
|
||||
else
|
||||
if(mGLView != null)
|
||||
mGLView.onTouchEvent(ev);
|
||||
else
|
||||
if( _btn != null )
|
||||
return _btn.dispatchTouchEvent(ev);
|
||||
else
|
||||
if( touchListener != null )
|
||||
touchListener.onTouchEvent(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchGenericMotionEvent (MotionEvent ev)
|
||||
{
|
||||
//Log.i("SDL", "dispatchGenericMotionEvent: " + ev.getAction() + " coords " + ev.getX() + ":" + ev.getY() );
|
||||
// This code fails to run for Android 1.6, so there will be no generic motion event for Andorid screen keyboard
|
||||
/*
|
||||
if(_screenKeyboard != null)
|
||||
_screenKeyboard.dispatchGenericMotionEvent(ev);
|
||||
else
|
||||
*/
|
||||
if(mGLView != null)
|
||||
mGLView.onGenericMotionEvent(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
//private Configuration oldConfig = null;
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig)
|
||||
{
|
||||
super.onConfigurationChanged(newConfig);
|
||||
updateScreenOrientation();
|
||||
/*
|
||||
if (oldConfig != null)
|
||||
{
|
||||
int diff = newConfig.diff(oldConfig);
|
||||
Log.i("SDL", "onConfigurationChanged(): " + " diff " + diff +
|
||||
((diff & ActivityInfo.CONFIG_ORIENTATION) == ActivityInfo.CONFIG_ORIENTATION ? " orientation" : "") +
|
||||
((diff & ActivityInfo.CONFIG_SCREEN_SIZE) == ActivityInfo.CONFIG_SCREEN_SIZE ? " screen size" : "") +
|
||||
((diff & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) == ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE ? " smallest screen size" : "") +
|
||||
" " + newConfig.toString());
|
||||
}
|
||||
oldConfig = new Configuration(newConfig);
|
||||
*/
|
||||
}
|
||||
|
||||
public void updateScreenOrientation()
|
||||
@@ -1265,6 +1123,15 @@ public class MainActivity extends Activity
|
||||
Log.i("SDL", "libSDL: Cannot load GLESv3 or GLESv2 lib");
|
||||
}
|
||||
|
||||
String [] SupportedAbis = { android.os.Build.CPU_ABI };
|
||||
if (android.os.Build.CPU_ABI2 != null && !android.os.Build.CPU_ABI2.equals(""))
|
||||
{
|
||||
SupportedAbis = new String [] { android.os.Build.CPU_ABI, android.os.Build.CPU_ABI2 };
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
|
||||
{
|
||||
SupportedAbis = android.os.Build.SUPPORTED_ABIS;
|
||||
}
|
||||
// Load all libraries
|
||||
try
|
||||
{
|
||||
@@ -1275,166 +1142,99 @@ public class MainActivity extends Activity
|
||||
{
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(getFilesDir().getAbsolutePath() + "/../lib/" + libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
//Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
System.load(libpath.getPath());
|
||||
Log.i("SDL", "libSDL: loaded lib " + libpath.getAbsolutePath());
|
||||
}
|
||||
catch( UnsatisfiedLinkError e )
|
||||
{
|
||||
Log.i("SDL", "libSDL: error loading lib " + l + ": " + e.toString());
|
||||
//Log.i("SDL", "libSDL: error loading lib " + l + ": " + e.toString());
|
||||
try
|
||||
{
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(getFilesDir().getAbsolutePath() + "/" + libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
//Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
System.load(libpath.getPath());
|
||||
Log.i("SDL", "libSDL: loaded lib " + libpath.getAbsolutePath());
|
||||
}
|
||||
catch( UnsatisfiedLinkError ee )
|
||||
{
|
||||
Log.i("SDL", "libSDL: error loading lib " + l + ": " + ee.toString());
|
||||
//Log.i("SDL", "libSDL: error loading lib " + l + ": " + ee.toString());
|
||||
System.loadLibrary(l);
|
||||
Log.i("SDL", "libSDL: loaded lib " + l + " from System.loadLibrary(l)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( UnsatisfiedLinkError e )
|
||||
{
|
||||
try {
|
||||
Log.i("SDL", "libSDL: Extracting APP2SD-ed libs");
|
||||
|
||||
InputStream in = null;
|
||||
try
|
||||
{
|
||||
for( int i = 0; ; i++ )
|
||||
{
|
||||
InputStream in2 = getAssets().open("bindata" + String.valueOf(i));
|
||||
if( in == null )
|
||||
in = in2;
|
||||
else
|
||||
in = new SequenceInputStream( in, in2 );
|
||||
}
|
||||
}
|
||||
catch( IOException ee ) { }
|
||||
|
||||
if( in == null )
|
||||
throw new RuntimeException("libSDL: Extracting APP2SD-ed libs failed, the .apk file packaged incorrectly");
|
||||
|
||||
ZipInputStream zip = new ZipInputStream(in);
|
||||
|
||||
File libDir = getFilesDir();
|
||||
try {
|
||||
libDir.mkdirs();
|
||||
} catch( SecurityException ee ) { };
|
||||
|
||||
byte[] buf = new byte[16384];
|
||||
while(true)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
entry = zip.getNextEntry();
|
||||
/*
|
||||
if( entry != null )
|
||||
Log.i("SDL", "Extracting lib " + entry.getName());
|
||||
*/
|
||||
if( entry == null )
|
||||
{
|
||||
Log.i("SDL", "Extracting libs finished");
|
||||
break;
|
||||
}
|
||||
if( entry.isDirectory() )
|
||||
{
|
||||
File outDir = new File( libDir.getAbsolutePath() + "/" + entry.getName() );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
continue;
|
||||
}
|
||||
|
||||
OutputStream out = null;
|
||||
String path = libDir.getAbsolutePath() + "/" + entry.getName();
|
||||
try {
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException eeeee ) { };
|
||||
|
||||
Log.i("SDL", "Saving to file '" + path + "'");
|
||||
|
||||
out = new FileOutputStream( path );
|
||||
int len = zip.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = zip.read(buf);
|
||||
}
|
||||
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
for(String l_unmapped : Globals.AppLibraries)
|
||||
{
|
||||
String l = GetMappedLibraryName(l_unmapped);
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(libDir, libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getPath());
|
||||
System.load(libpath.getPath());
|
||||
libpath.delete();
|
||||
}
|
||||
}
|
||||
catch ( Exception ee )
|
||||
{
|
||||
Log.i("SDL", "libSDL: Error: " + ee.toString());
|
||||
}
|
||||
Log.i("SDL", "libSDL: Error: " + e.toString());
|
||||
}
|
||||
|
||||
String [] binaryZipNames = { "binaries-" + android.os.Build.CPU_ABI + ".zip", "binaries-" + android.os.Build.CPU_ABI2 + ".zip", "binaries.zip" };
|
||||
if ( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN )
|
||||
binaryZipNames = new String[] { "binaries-" + android.os.Build.CPU_ABI + "-pie.zip", "binaries-" + android.os.Build.CPU_ABI2 + "-pie.zip", "binaries-" + android.os.Build.CPU_ABI + ".zip", "binaries-" + android.os.Build.CPU_ABI2 + ".zip", "binaries.zip" };
|
||||
for(String binaryZip: binaryZipNames)
|
||||
ZipFile myApk = null;
|
||||
try
|
||||
{
|
||||
myApk = new ZipFile(getPackageResourcePath());
|
||||
}
|
||||
catch( IOException eeeeeeeee ) {}
|
||||
|
||||
ArrayList<String> a = new ArrayList<String>();
|
||||
for( String arch: SupportedAbis )
|
||||
{
|
||||
a.add("binaries-" + arch + ".zip");
|
||||
}
|
||||
a.add("binaries.zip");
|
||||
String [] binaryZipNames = a.toArray(new String[0]);
|
||||
|
||||
for( String binaryZip: binaryZipNames )
|
||||
{
|
||||
try {
|
||||
Log.i("SDL", "libSDL: Trying to extract binaries from assets " + binaryZip);
|
||||
|
||||
InputStream in = null;
|
||||
try
|
||||
{
|
||||
for( int i = 0; ; i++ )
|
||||
{
|
||||
InputStream in2 = getAssets().open(binaryZip + String.format("%02d", i));
|
||||
if( in == null )
|
||||
in = in2;
|
||||
else
|
||||
in = new SequenceInputStream( in, in2 );
|
||||
}
|
||||
//Log.i("SDL", "libSDL: Trying to extract binaries from assets/" + binaryZip);
|
||||
if( in == null )
|
||||
in = getAssets().open(binaryZip);
|
||||
Log.i("SDL", "libSDL: Found binaries at assets/" + binaryZip);
|
||||
}
|
||||
catch( IOException ee )
|
||||
catch( Exception eee ) {}
|
||||
|
||||
if( binaryZip.equals("binaries.zip") )
|
||||
{
|
||||
try
|
||||
for( String arch: SupportedAbis )
|
||||
{
|
||||
if( in == null )
|
||||
in = getAssets().open(binaryZip);
|
||||
try
|
||||
{
|
||||
if( in == null && myApk != null )
|
||||
{
|
||||
//Log.i("SDL", "libSDL: Trying to extract binaries from lib/" + arch + "/" + binaryZip);
|
||||
in = myApk.getInputStream(myApk.getEntry("lib/" + arch + "/" + binaryZip));
|
||||
Log.i("SDL", "libSDL: Found binaries at lib/" + arch + "/" + binaryZip);
|
||||
}
|
||||
}
|
||||
catch( Exception eeee ) {}
|
||||
}
|
||||
catch( IOException eee ) {}
|
||||
}
|
||||
|
||||
if( in == null )
|
||||
throw new RuntimeException("libSDL: Extracting binaries failed, the .apk file packaged incorrectly");
|
||||
throw new RuntimeException("libSDL: Extracting binaries failed");
|
||||
|
||||
ZipInputStream zip = new ZipInputStream(in);
|
||||
|
||||
File libDir = getFilesDir();
|
||||
try {
|
||||
try
|
||||
{
|
||||
libDir.mkdirs();
|
||||
} catch( SecurityException ee ) { };
|
||||
}
|
||||
catch( SecurityException ee ) { };
|
||||
|
||||
byte[] buf = new byte[16384];
|
||||
while(true)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
entry = zip.getNextEntry();
|
||||
/*
|
||||
if( entry != null )
|
||||
Log.i("SDL", "Extracting lib " + entry.getName());
|
||||
*/
|
||||
//if( entry != null )
|
||||
// Log.i("SDL", "Extracting binary " + entry.getName());
|
||||
if( entry == null )
|
||||
{
|
||||
Log.i("SDL", "Extracting binaries finished");
|
||||
@@ -1450,13 +1250,16 @@ public class MainActivity extends Activity
|
||||
|
||||
OutputStream out = null;
|
||||
String path = libDir.getAbsolutePath() + "/" + entry.getName();
|
||||
try {
|
||||
try
|
||||
{
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException eeeeeee ) { };
|
||||
}
|
||||
catch( SecurityException eeeeeee ) { };
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) > 0 ) {};
|
||||
check.close();
|
||||
@@ -1494,6 +1297,12 @@ public class MainActivity extends Activity
|
||||
//Log.i("SDL", "libSDL: Error: " + eee.toString());
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
if (myApk != null)
|
||||
myApk.close();
|
||||
}
|
||||
catch( IOException eeeeeeeeee ) {}
|
||||
};
|
||||
|
||||
public static String GetMappedLibraryName(final String s)
|
||||
@@ -1511,27 +1320,31 @@ public class MainActivity extends Activity
|
||||
Settings.nativeChdir(Globals.DataDir);
|
||||
for(String l: Globals.AppMainLibraries)
|
||||
{
|
||||
Log.i("SDL", "libSDL: loading library " + l);
|
||||
try
|
||||
{
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(context.getFilesDir().getAbsolutePath() + "/../lib/" + libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
//Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
System.load(libpath.getPath());
|
||||
Log.i("SDL", "libSDL: loaded library " + libpath.getPath());
|
||||
}
|
||||
catch( UnsatisfiedLinkError e )
|
||||
{
|
||||
Log.i("SDL", "libSDL: error loading lib " + l + ": " + e.toString());
|
||||
//Log.i("SDL", "libSDL: error loading lib " + l + ": " + e.toString());
|
||||
try
|
||||
{
|
||||
String libname = System.mapLibraryName(l);
|
||||
File libpath = new File(context.getFilesDir().getAbsolutePath() + "/" + libname);
|
||||
Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
//Log.i("SDL", "libSDL: loading lib " + libpath.getAbsolutePath());
|
||||
System.load(libpath.getPath());
|
||||
Log.i("SDL", "libSDL: loaded library " + libpath.getPath());
|
||||
}
|
||||
catch( UnsatisfiedLinkError ee )
|
||||
{
|
||||
Log.i("SDL", "libSDL: error loading lib " + l + ": " + ee.toString());
|
||||
//Log.i("SDL", "libSDL: error loading lib " + l + ": " + ee.toString());
|
||||
System.loadLibrary(l);
|
||||
Log.i("SDL", "libSDL: loaded library " + l);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1614,6 +1427,14 @@ public class MainActivity extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public void setSystemMousePointerVisible(int visible)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N)
|
||||
{
|
||||
mGLView.setPointerIcon(android.view.PointerIcon.getSystemIcon(this, (visible == 0) ? android.view.PointerIcon.TYPE_NULL : android.view.PointerIcon.TYPE_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
public FrameLayout getVideoLayout() { return _videoLayout; }
|
||||
|
||||
DemoGLSurfaceView mGLView = null;
|
||||
@@ -1629,24 +1450,12 @@ public class MainActivity extends Activity
|
||||
public ProgressDialog loadingDialog = null;
|
||||
|
||||
FrameLayout _videoLayout = null;
|
||||
private View _screenKeyboard = null;
|
||||
public View _screenKeyboard = null;
|
||||
private String _screenKeyboardHintMessage = null;
|
||||
static boolean keyboardWithoutTextInputShown = false;
|
||||
private boolean sdlInited = false;
|
||||
public static boolean ApplicationLibraryLoaded = false;
|
||||
|
||||
public interface TouchEventsListener
|
||||
{
|
||||
public void onTouchEvent(final MotionEvent ev);
|
||||
}
|
||||
|
||||
public interface KeyEventsListener
|
||||
{
|
||||
public void onKeyEvent(final int keyCode);
|
||||
}
|
||||
|
||||
public TouchEventsListener touchListener = null;
|
||||
public KeyEventsListener keyListener = null;
|
||||
boolean _isPaused = false;
|
||||
private InputMethodManager _inputManager = null;
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ import android.widget.Toast;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
|
||||
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
||||
@@ -85,6 +86,7 @@ public class Settings
|
||||
static boolean settingsLoaded = false;
|
||||
static boolean settingsChanged = false;
|
||||
static final int SETTINGS_FILE_VERSION = 5;
|
||||
static boolean convertButtonSizeFromOldSdlVersion = false;
|
||||
|
||||
static void Save(final MainActivity p)
|
||||
{
|
||||
@@ -187,6 +189,8 @@ public class Settings
|
||||
out.writeBoolean(Globals.AutoDetectOrientation);
|
||||
out.writeBoolean(Globals.TvBorders);
|
||||
out.writeBoolean(Globals.ForceHardwareMouse);
|
||||
convertButtonSizeFromOldSdlVersion = false;
|
||||
out.writeBoolean(convertButtonSizeFromOldSdlVersion);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
@@ -270,6 +274,7 @@ public class Settings
|
||||
// ICS update sends events in a proper way
|
||||
Globals.RemapHwKeycode[112] = SDL_1_2_Keycodes.SDLK_UNKNOWN;
|
||||
}
|
||||
convertButtonSizeFromOldSdlVersion = false;
|
||||
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
@@ -281,6 +286,7 @@ public class Settings
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
convertButtonSizeFromOldSdlVersion = true; // Will be changed to false if we read the remainder of the config file
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
settingsFile.readInt();
|
||||
@@ -381,6 +387,7 @@ public class Settings
|
||||
Globals.AutoDetectOrientation = settingsFile.readBoolean();
|
||||
Globals.TvBorders = settingsFile.readBoolean();
|
||||
Globals.ForceHardwareMouse = settingsFile.readBoolean();
|
||||
convertButtonSizeFromOldSdlVersion = settingsFile.readBoolean();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
@@ -403,12 +410,18 @@ public class Settings
|
||||
return;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "libSDL: settings file not found: " + e);
|
||||
Log.i("SDL", "libSDL: settings file not found: " + e);
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be opened: " + e);
|
||||
} catch ( IOException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be read: " + e);
|
||||
Log.i("SDL", "libSDL: settings file cannot be opened: " + e);
|
||||
} catch( IOException e ) {
|
||||
Log.i("SDL", "libSDL: settings file cannot be read: " + e);
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if (convertButtonSizeFromOldSdlVersion && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize ++; // New default button size is bigger, but we are keeping old button size for existing installations
|
||||
//if (Globals.AppTouchscreenKeyboardKeysAmount <= 4 && Globals.TouchscreenKeyboardSize + 1 < Globals.TOUCHSCREEN_KEYBOARD_CUSTOM)
|
||||
// Globals.TouchscreenKeyboardSize ++; // If there are only 4 buttons they are even bigger
|
||||
}
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
@@ -593,7 +606,8 @@ public class Settings
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.TouchscreenKeyboardTransparency,
|
||||
Globals.FloatingScreenJoystick ? 1 : 0 );
|
||||
Globals.FloatingScreenJoystick ? 1 : 0,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i]]);
|
||||
@@ -629,9 +643,10 @@ public class Settings
|
||||
Log.i("SDL", "libSDL: setting envvar LANGUAGE to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
nativeSetEnv( "LANGUAGE", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
nativeSetEnv( "ARCH", android.os.Build.CPU_ABI );
|
||||
nativeSetEnv( "APPDIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "SECURE_STORAGE_DIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "LIBDIR", p.getApplicationInfo().nativeLibraryDir );
|
||||
nativeSetEnv( "DATADIR", Globals.DataDir );
|
||||
nativeSetEnv( "UNSECURE_STORAGE_DIR", Globals.DataDir );
|
||||
SdcardAppPath.get().setEnv(p);
|
||||
@@ -646,9 +661,19 @@ public class Settings
|
||||
nativeSetEnv( "ANDROID_PACKAGE_NAME", p.getPackageName() );
|
||||
nativeSetEnv( "ANDROID_PACKAGE_PATH", p.getPackageCodePath() );
|
||||
nativeSetEnv( "ANDROID_MY_OWN_APP_FILE", p.getPackageResourcePath() ); // This may be different from p.getPackageCodePath() on multi-user systems, but should still be the same .apk file
|
||||
nativeSetEnv( "ANDROID_OBB_DIR", Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/obb/" + p.getPackageName() );
|
||||
try {
|
||||
nativeSetEnv( "ANDROID_OBB_DIR", p.getObbDir().getAbsolutePath() );
|
||||
} catch (Exception eeeeeee) {}
|
||||
try {
|
||||
nativeSetEnv( "ANDROID_APP_NAME", p.getString(p.getApplicationInfo().labelRes) );
|
||||
} catch (Exception eeeeee) {}
|
||||
try {
|
||||
PackageInfo pInfo = p.getPackageManager().getPackageInfo(p.getPackageName(), 0);
|
||||
nativeSetEnv( "ANDROID_PACKAGE_VERSION_NAME", pInfo.versionName );
|
||||
nativeSetEnv( "ANDROID_PACKAGE_VERSION_CODE", String.valueOf(pInfo.versionCode) );
|
||||
} catch (PackageManager.NameNotFoundException eeeeeeee) {
|
||||
}
|
||||
Log.d("SDL", "libSDL: Is running on OUYA: " + p.isRunningOnOUYA());
|
||||
if( p.isRunningOnOUYA() )
|
||||
{
|
||||
@@ -967,7 +992,7 @@ public class Settings
|
||||
private static native void nativeSetCompatibilityHacks();
|
||||
private static native void nativeSetVideoMultithreaded();
|
||||
private static native void nativeSetVideoForceSoftwareMode();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int transparency, int floatingScreenJoystick);
|
||||
public static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int transparency, int floatingScreenJoystick, int buttonAmount);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
private static native int nativeGetKeymapKey(int key);
|
||||
@@ -976,10 +1001,11 @@ public class Settings
|
||||
private static native void nativeSetKeymapKeyScreenKb(int keynum, int key);
|
||||
private static native void nativeSetScreenKbKeyUsed(int keynum, int used);
|
||||
private static native void nativeSetScreenKbKeyLayout(int keynum, int x1, int y1, int x2, int y2);
|
||||
public static native int nativeGetScreenKeyboardButtonLayout(int button, int coord);
|
||||
private static native int nativeGetKeymapKeyMultitouchGesture(int keynum);
|
||||
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
|
||||
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
|
||||
private static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
|
||||
public static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
public static native int nativeChmod(final String name, int mode);
|
||||
public static native void nativeChdir(final String dir);
|
||||
|
||||
@@ -248,6 +248,7 @@ class SettingsMenu
|
||||
new SettingsMenuKeyboard.ScreenGesturesConfig(),
|
||||
new SettingsMenuMisc.VideoSettingsConfig(),
|
||||
new SettingsMenuMisc.CommandlineConfig(),
|
||||
new SettingsMenuMisc.StorageAccessConfig(),
|
||||
new SettingsMenuMisc.ResetToDefaultsConfig(),
|
||||
new OkButton(),
|
||||
};
|
||||
|
||||
@@ -57,6 +57,7 @@ import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.view.Gravity;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
@@ -276,10 +277,10 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||
p.keyListener = new KeyRemapTool(p);
|
||||
p.getVideoLayout().setOnKeyListener(new KeyRemapTool(p));
|
||||
}
|
||||
|
||||
public static class KeyRemapTool implements MainActivity.KeyEventsListener
|
||||
public static class KeyRemapTool implements View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
public KeyRemapTool(MainActivity _p)
|
||||
@@ -287,9 +288,10 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
p.keyListener = null;
|
||||
p.getVideoLayout().setOnKeyListener(null);
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
@@ -336,6 +338,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
return true;
|
||||
}
|
||||
public void ShowAllKeys(final int KeyIndex)
|
||||
{
|
||||
@@ -623,13 +626,19 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||
if (Globals.ImmersiveMode)
|
||||
DimSystemStatusBar.get().dim(p.getVideoLayout());
|
||||
p.getVideoLayout().getHandler().postDelayed(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
static class CustomizeScreenKbLayoutTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
static class CustomizeScreenKbLayoutTool implements View.OnTouchListener, View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
FrameLayout layout = null;
|
||||
@@ -658,6 +667,11 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p = _p;
|
||||
layout = new FrameLayout(p);
|
||||
p.getVideoLayout().addView(layout);
|
||||
layout.setFocusable(true);
|
||||
layout.setFocusableInTouchMode(true);
|
||||
layout.requestFocus();
|
||||
layout.setOnTouchListener(this);
|
||||
layout.setOnKeyListener(this);
|
||||
boundary = new ImageView(p);
|
||||
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
@@ -665,30 +679,27 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
boundary.setImageBitmap(boundaryBmp);
|
||||
layout.addView(boundary);
|
||||
currentButton = -1;
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
{
|
||||
buttons = new int[] {
|
||||
R.drawable.sun_dpad,
|
||||
R.drawable.sun_keyboard,
|
||||
R.drawable.sun_b1,
|
||||
R.drawable.sun_b2,
|
||||
R.drawable.sun_b3,
|
||||
R.drawable.sun_b4,
|
||||
R.drawable.sun_b5,
|
||||
R.drawable.sun_b6,
|
||||
R.drawable.sun_dpad,
|
||||
R.drawable.sun_dpad
|
||||
};
|
||||
}
|
||||
|
||||
int displayX = 800;
|
||||
int displayY = 480;
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
displayX = dm.widthPixels;
|
||||
displayY = dm.heightPixels;
|
||||
} catch (Exception eeeee) {}
|
||||
final int displayX = p.getVideoLayout().getWidth();
|
||||
final int displayY = p.getVideoLayout().getHeight();
|
||||
|
||||
if( Globals.TouchscreenKeyboardSize != Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
{
|
||||
DemoRenderer.nativeResize(displayX, displayY, 0);
|
||||
Settings.nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.TouchscreenKeyboardTransparency,
|
||||
Globals.FloatingScreenJoystick ? 1 : 0,
|
||||
Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] = Settings.nativeGetScreenKeyboardButtonLayout(i, 0);
|
||||
Globals.ScreenKbControlsLayout[i][1] = Settings.nativeGetScreenKeyboardButtonLayout(i, 1);
|
||||
Globals.ScreenKbControlsLayout[i][2] = Settings.nativeGetScreenKeyboardButtonLayout(i, 2);
|
||||
Globals.ScreenKbControlsLayout[i][3] = Settings.nativeGetScreenKeyboardButtonLayout(i, 3);
|
||||
}
|
||||
}
|
||||
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
@@ -696,37 +707,7 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
continue;
|
||||
if( currentButton == -1 )
|
||||
currentButton = i;
|
||||
//Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
// Check if the button is off screen edge or shrunk to zero
|
||||
if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
|
||||
Globals.ScreenKbControlsLayout[i][0] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][2] > displayX )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
|
||||
Globals.ScreenKbControlsLayout[i][2] = displayX;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
|
||||
Globals.ScreenKbControlsLayout[i][1] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][3] > displayY )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
|
||||
Globals.ScreenKbControlsLayout[i][3] = displayY;
|
||||
}
|
||||
//Log.i("SDL", "After bounds check coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
|
||||
imgs[i] = new ImageView(p);
|
||||
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
@@ -744,9 +725,34 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
}
|
||||
boundary.bringToFront();
|
||||
if( currentButton == -1 )
|
||||
onKeyEvent( KeyEvent.KEYCODE_BACK ); // All buttons disabled - do not show anything
|
||||
onKey( null, KeyEvent.KEYCODE_BACK, null ); // All buttons disabled - do not show anything
|
||||
else
|
||||
setupButton(currentButton);
|
||||
|
||||
final Button backButton = new Button(p);
|
||||
backButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
backButton.setText(android.R.string.ok);
|
||||
//backButton.setTop(displayY / 30);
|
||||
//backButton.setLeft(displayX / 2);
|
||||
backButton.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
p.getVideoLayout().removeView(layout);
|
||||
layout = null;
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
layout.addView(backButton, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.TOP | Gravity.CENTER_HORIZONTAL));
|
||||
layout.getHandler().postDelayed(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
//backButton.setLeft(displayX / 2 - backButton.getWidth() / 2);
|
||||
//backButton.setLeft(displayX / 2);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
|
||||
void setupButton(int i)
|
||||
@@ -777,7 +783,8 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent ev)
|
||||
{
|
||||
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
@@ -842,18 +849,19 @@ class SettingsMenuKeyboard extends SettingsMenu
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
boundary.setImageMatrix(m);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
p.getVideoLayout().removeView(layout);
|
||||
layout = null;
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
goBack(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
String readmes[] = Globals.ReadmeText.split("\\^");
|
||||
String lang = new String(Locale.getDefault().getLanguage()) + ":";
|
||||
if( p.isRunningOnOUYA() )
|
||||
lang = "ouya:";
|
||||
lang = "tv:";
|
||||
String readme = readmes[0];
|
||||
String buttonName = "", buttonUrl = "";
|
||||
for( String r: readmes )
|
||||
@@ -469,10 +469,14 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
text.setPadding(0, 5, 0, 20);
|
||||
text.setTextSize(20.0f);
|
||||
text.setGravity(Gravity.CENTER);
|
||||
text.setFocusable(false);
|
||||
text.setFocusableInTouchMode(false);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
ScrollView scroll = new ScrollView(p);
|
||||
scroll.setFocusable(false);
|
||||
scroll.setFocusableInTouchMode(false);
|
||||
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
Button ok = new Button(p);
|
||||
final Button ok = new Button(p);
|
||||
final AlertDialog alertDismiss[] = new AlertDialog[1];
|
||||
ok.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@@ -485,7 +489,6 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
LinearLayout layout = new LinearLayout(p);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.addView(scroll);
|
||||
//layout.addView(text);
|
||||
layout.addView(ok);
|
||||
if( buttonName.length() > 0 )
|
||||
{
|
||||
@@ -539,6 +542,42 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
}
|
||||
}
|
||||
|
||||
public static class StorageAccessConfig extends Menu
|
||||
{
|
||||
public static int REQUEST_STORAGE_ID = 42;
|
||||
|
||||
public static void onActivityResult(final MainActivity p, final int requestCode, final int resultCode, final Intent resultData)
|
||||
{
|
||||
if (requestCode == REQUEST_STORAGE_ID)
|
||||
{
|
||||
if (resultCode == Activity.RESULT_OK)
|
||||
{
|
||||
Uri treeUri = resultData.getData();
|
||||
p.getContentResolver().takePersistableUriPermission(treeUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
Log.i("SDL", "Storage write permission granted to path " + treeUri.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "Storage write permission rejected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.storage_access);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP)
|
||||
{
|
||||
p.startActivityForResult(new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE), REQUEST_STORAGE_ID);
|
||||
}
|
||||
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class CommandlineConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
@@ -554,12 +593,10 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
if (Globals.CommandLine.length() == 0)
|
||||
Globals.CommandLine = "SDL_app";
|
||||
if (Globals.CommandLine.indexOf(" ") == -1)
|
||||
Globals.CommandLine += " ";
|
||||
edit.setText(Globals.CommandLine.substring(Globals.CommandLine.indexOf(" ")).replace(" ", "\n").replace(" ", " "));
|
||||
Globals.CommandLine = "App";
|
||||
edit.setText(Globals.CommandLine.replace(" ", "\n").replace(" ", " "));
|
||||
edit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
edit.setMinLines(2);
|
||||
edit.setMinLines(1);
|
||||
//edit.setMaxLines(100);
|
||||
builder.setView(edit);
|
||||
|
||||
@@ -567,17 +604,22 @@ class SettingsMenuMisc extends SettingsMenu
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.CommandLine = "SDL_app";
|
||||
Globals.CommandLine = "";
|
||||
String args[] = edit.getText().toString().split("\n");
|
||||
boolean firstArg = true;
|
||||
for( String arg: args )
|
||||
if( args.length == 1 )
|
||||
{
|
||||
Globals.CommandLine += " ";
|
||||
if( firstArg )
|
||||
Globals.CommandLine += arg;
|
||||
else
|
||||
Globals.CommandLine = args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean firstArg = true;
|
||||
for( String arg: args )
|
||||
{
|
||||
if( !firstArg )
|
||||
Globals.CommandLine += " ";
|
||||
Globals.CommandLine += arg.replace(" ", " ");
|
||||
firstArg = false;
|
||||
firstArg = false;
|
||||
}
|
||||
}
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
|
||||
@@ -267,7 +267,7 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
dialog.dismiss();
|
||||
Globals.LeftClickMethod = item;
|
||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
||||
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, true));
|
||||
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
||||
showLeftClickTimeoutConfig(p);
|
||||
else
|
||||
@@ -343,7 +343,7 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
Globals.RightClickMethod = item;
|
||||
dialog.dismiss();
|
||||
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, false);
|
||||
p.getVideoLayout().setOnKeyListener(new KeyRemapToolMouseClick(p, false));
|
||||
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
|
||||
showRightClickTimeoutConfig(p);
|
||||
else
|
||||
@@ -393,7 +393,7 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyRemapToolMouseClick implements MainActivity.KeyEventsListener
|
||||
public static class KeyRemapToolMouseClick implements View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
boolean leftClick;
|
||||
@@ -404,9 +404,10 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
this.leftClick = leftClick;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
p.keyListener = null;
|
||||
p.getVideoLayout().setOnKeyListener(null);
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
@@ -419,6 +420,7 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
Globals.RightClickKey = keyIndex;
|
||||
|
||||
goBack(p);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,10 +688,10 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
||||
p.touchListener = new TouchMeasurementTool(p);
|
||||
p.getVideoLayout().setOnTouchListener(new TouchMeasurementTool(p));
|
||||
}
|
||||
|
||||
public static class TouchMeasurementTool implements MainActivity.TouchEventsListener
|
||||
public static class TouchMeasurementTool implements View.OnTouchListener
|
||||
{
|
||||
MainActivity p;
|
||||
ArrayList<Integer> force = new ArrayList<Integer>();
|
||||
@@ -701,7 +703,8 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent ev)
|
||||
{
|
||||
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
||||
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
||||
@@ -712,12 +715,13 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
|
||||
if( force.size() >= maxEventAmount )
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.getVideoLayout().setOnTouchListener(null);
|
||||
Globals.ClickScreenPressure = getAverageForce();
|
||||
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
||||
Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize);
|
||||
goBack(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int getAverageForce()
|
||||
@@ -756,11 +760,11 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
Globals.TouchscreenCalibration[2] = 0;
|
||||
Globals.TouchscreenCalibration[3] = 0;
|
||||
ScreenEdgesCalibrationTool tool = new ScreenEdgesCalibrationTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
p.getVideoLayout().setOnTouchListener(tool);
|
||||
p.getVideoLayout().setOnKeyListener(tool);
|
||||
}
|
||||
|
||||
static class ScreenEdgesCalibrationTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
static class ScreenEdgesCalibrationTool implements View.OnTouchListener, View.OnKeyListener
|
||||
{
|
||||
MainActivity p;
|
||||
ImageView img;
|
||||
@@ -783,7 +787,8 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
p.getVideoLayout().addView(img);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent ev)
|
||||
{
|
||||
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
||||
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
||||
@@ -808,14 +813,17 @@ class SettingsMenuMouse extends SettingsMenu
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event)
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
p.getVideoLayout().setOnTouchListener(null);
|
||||
p.getVideoLayout().setOnKeyListener(null);
|
||||
p.getVideoLayout().removeView(img);
|
||||
goBack(p);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ import android.view.Display;
|
||||
import android.net.Uri;
|
||||
import android.Manifest;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.input.InputManager;
|
||||
|
||||
|
||||
class Mouse
|
||||
@@ -107,6 +108,10 @@ abstract class DifferentTouchInput
|
||||
public abstract void processGenericEvent(final MotionEvent event);
|
||||
|
||||
public static int ExternalMouseDetected = Mouse.MOUSE_HW_INPUT_FINGER;
|
||||
public static int buttonState = 0;
|
||||
|
||||
public static float capturedMouseX = 0;
|
||||
public static float capturedMouseY = 0;
|
||||
|
||||
public static DifferentTouchInput touchInput = getInstance();
|
||||
|
||||
@@ -318,6 +323,12 @@ abstract class DifferentTouchInput
|
||||
int hwMouseEvent = ((event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE || Globals.ForceHardwareMouse) ? Mouse.MOUSE_HW_INPUT_MOUSE :
|
||||
((event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) ? Mouse.MOUSE_HW_INPUT_STYLUS :
|
||||
Mouse.MOUSE_HW_INPUT_FINGER;
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
|
||||
{
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE )
|
||||
hwMouseEvent = Mouse.MOUSE_HW_INPUT_MOUSE;
|
||||
}
|
||||
|
||||
if( ExternalMouseDetected != hwMouseEvent )
|
||||
{
|
||||
ExternalMouseDetected = hwMouseEvent;
|
||||
@@ -361,12 +372,10 @@ abstract class DifferentTouchInput
|
||||
}
|
||||
private static class IcsTouchInput extends GingerbreadTouchInput
|
||||
{
|
||||
float hatX = 0.0f, hatY = 0.0f;
|
||||
private static class Holder
|
||||
{
|
||||
private static final IcsTouchInput sInstance = new IcsTouchInput();
|
||||
}
|
||||
private int buttonState = 0;
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
//Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY() + " buttons " + buttonState + " source " + event.getSource());
|
||||
@@ -388,37 +397,16 @@ abstract class DifferentTouchInput
|
||||
}
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very few devices have it
|
||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||
{
|
||||
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, on Nvidia Shield and some other joysticks
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX )
|
||||
{
|
||||
hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
|
||||
if( hatX == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1, 0);
|
||||
}
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY )
|
||||
{
|
||||
hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
|
||||
if( hatY == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1, 0);
|
||||
}
|
||||
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||
event.getAxisValue(MotionEvent.AXIS_LTRIGGER), event.getAxisValue(MotionEvent.AXIS_RTRIGGER),
|
||||
(hatX == 0.0f && hatY == 0.0f) ? 0 : 1 );
|
||||
event.getAxisValue(MotionEvent.AXIS_LTRIGGER), event.getAxisValue(MotionEvent.AXIS_RTRIGGER),
|
||||
event.getAxisValue(MotionEvent.AXIS_HAT_X), event.getAxisValue(MotionEvent.AXIS_HAT_Y),
|
||||
processGamepadDeviceId(event.getDevice()) );
|
||||
return;
|
||||
}
|
||||
// Process mousewheel
|
||||
@@ -573,6 +561,78 @@ abstract class DifferentTouchInput
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int gamepadIds[] = new int[4]; // Maximum 4 gamepads at the moment
|
||||
|
||||
public static int processGamepadDeviceId(InputDevice device)
|
||||
{
|
||||
if( device == null )
|
||||
return 0;
|
||||
int source = device.getSources();
|
||||
if( (source & InputDevice.SOURCE_CLASS_JOYSTICK) != InputDevice.SOURCE_CLASS_JOYSTICK &&
|
||||
(source & InputDevice.SOURCE_GAMEPAD) != InputDevice.SOURCE_GAMEPAD )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int deviceId = device.getId();
|
||||
for( int i = 0; i < gamepadIds.length; i++ )
|
||||
{
|
||||
if (gamepadIds[i] == deviceId)
|
||||
return i + 1;
|
||||
}
|
||||
for( int i = 0; i < gamepadIds.length; i++ )
|
||||
{
|
||||
if (gamepadIds[i] == 0)
|
||||
{
|
||||
Log.i("SDL", "libSDL: gamepad added: deviceId " + deviceId + " gamepadId " + (i + 1));
|
||||
gamepadIds[i] = deviceId;
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void registerInputManagerCallbacks(Context context)
|
||||
{
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN )
|
||||
{
|
||||
JellyBeanInputManager.Holder.sInstance.register(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static class JellyBeanInputManager
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final JellyBeanInputManager sInstance = new JellyBeanInputManager();
|
||||
}
|
||||
private static class Listener implements InputManager.InputDeviceListener
|
||||
{
|
||||
public void onInputDeviceAdded(int deviceId)
|
||||
{
|
||||
}
|
||||
public void onInputDeviceChanged(int deviceId)
|
||||
{
|
||||
onInputDeviceRemoved(deviceId);
|
||||
}
|
||||
public void onInputDeviceRemoved(int deviceId)
|
||||
{
|
||||
for( int i = 0; i < gamepadIds.length; i++ )
|
||||
{
|
||||
if (gamepadIds[i] == deviceId)
|
||||
{
|
||||
Log.i("SDL", "libSDL: gamepad removed: deviceId " + deviceId + " gamepadId "+ (i + 1));
|
||||
gamepadIds[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void register(Context context)
|
||||
{
|
||||
InputManager manager = (InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
||||
manager.registerInputDeviceListener(new Listener(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
@@ -613,6 +673,9 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
mHeight = h - h % 2;
|
||||
mGl = gl;
|
||||
nativeResize(mWidth, mHeight, Globals.KeepAspectRatio ? 1 : 0);
|
||||
if( Globals.TouchscreenCalibration[2] > Globals.TouchscreenCalibration[0] )
|
||||
Settings.nativeSetTouchscreenCalibration(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
}
|
||||
|
||||
int mLastPendingResize = 0;
|
||||
@@ -644,30 +707,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
if (mWidth != 0 && mHeight != 0 && (mWidth != ww || mHeight != hh))
|
||||
{
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onWindowResize(): screen size changed from " + mWidth + "x" + mHeight + " to " + ww + "x" + hh);
|
||||
if (Globals.SwVideoMode &&
|
||||
(Math.abs(display.getWidth() - ww) > display.getWidth() / 10 ||
|
||||
Math.abs(display.getHeight() - hh) > display.getHeight() / 10))
|
||||
{
|
||||
Log.i("SDL", "Multiwindow detected - enabling screen orientation autodetection");
|
||||
Globals.AutoDetectOrientation = true;
|
||||
context.setScreenOrientation();
|
||||
DemoRenderer.super.ResetVideoSurface();
|
||||
DemoRenderer.super.onWindowResize(ww, hh);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "System button bar hidden - re-init video to avoid black bar at the top");
|
||||
DemoRenderer.super.ResetVideoSurface();
|
||||
DemoRenderer.super.onWindowResize(ww, hh);
|
||||
}
|
||||
}
|
||||
if (mWidth == 0 && mHeight == 0)
|
||||
{
|
||||
if ((ww > hh) != (display.getWidth() > display.getHeight()))
|
||||
{
|
||||
Log.i("SDL", "Multiwindow detected - app window size " + ww + "x" + hh + " but display dimensions are " + display.getWidth() + "x" + display.getHeight());
|
||||
Globals.AutoDetectOrientation = true;
|
||||
}
|
||||
DemoRenderer.super.ResetVideoSurface();
|
||||
DemoRenderer.super.onWindowResize(ww, hh);
|
||||
}
|
||||
if (Globals.AutoDetectOrientation && (ww > hh) != (mWidth > mHeight))
|
||||
Globals.HorizontalOrientation = (ww > hh);
|
||||
@@ -710,9 +751,16 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
// Tweak video thread priority, if user selected big audio buffer
|
||||
if( Globals.AudioBufferConfig >= 2 )
|
||||
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
|
||||
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
String commandline = Globals.CommandLine;
|
||||
if( context.getIntent() != null && context.getIntent().getScheme() != null &&
|
||||
context.getIntent().getScheme().compareTo(android.content.ContentResolver.SCHEME_FILE) == 0 &&
|
||||
context.getIntent().getData() != null && context.getIntent().getData().getPath() != null )
|
||||
{
|
||||
commandline += " " + context.getIntent().getData().getPath();
|
||||
}
|
||||
nativeInit( Globals.DataDir,
|
||||
Globals.CommandLine,
|
||||
commandline,
|
||||
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
|
||||
0 );
|
||||
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
|
||||
@@ -722,13 +770,6 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
{
|
||||
if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers )
|
||||
{
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -739,13 +780,6 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
}
|
||||
|
||||
// Unblock event processing thread only after we've finished rendering
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
if( context.isScreenKeyboardShown() && !context.keyboardWithoutTextInputShown )
|
||||
{
|
||||
try {
|
||||
@@ -836,6 +870,12 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
Clipboard.get().set(context, s);
|
||||
}
|
||||
|
||||
public void setCapturedMousePosition(int x, int y) // Called from native code
|
||||
{
|
||||
DifferentTouchInput.capturedMouseX = x;
|
||||
DifferentTouchInput.capturedMouseY = y;
|
||||
}
|
||||
|
||||
public void exitApp()
|
||||
{
|
||||
nativeDone();
|
||||
@@ -936,6 +976,11 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
}
|
||||
}
|
||||
|
||||
public void setSystemMousePointerVisible(int visible)
|
||||
{
|
||||
context.setSystemMousePointerVisible(visible);
|
||||
}
|
||||
|
||||
public void restartMyself(String restartParams)
|
||||
{
|
||||
Intent intent = new Intent(context, RestartMainActivity.class);
|
||||
@@ -959,7 +1004,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
|
||||
private native void nativeInitJavaCallbacks();
|
||||
private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo, int unused);
|
||||
private native void nativeResize(int w, int h, int keepAspectRatio);
|
||||
public static native void nativeResize(int w, int h, int keepAspectRatio);
|
||||
private native void nativeDone();
|
||||
private native void nativeGlContextLost();
|
||||
public native void nativeGlContextRecreated();
|
||||
@@ -983,32 +1028,117 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
public int mWidth = 0;
|
||||
public int mHeight = 0;
|
||||
int mOrientationFrameHackyCounter = 0;
|
||||
|
||||
public static final boolean mRatelimitTouchEvents = true; //(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
|
||||
public DemoGLSurfaceView(MainActivity context) {
|
||||
super(context);
|
||||
mParent = context;
|
||||
setEGLConfigChooser(Globals.VideoDepthBpp, Globals.NeedDepthBuffer, Globals.NeedStencilBuffer, Globals.NeedGles2, Globals.NeedGles3);
|
||||
mRenderer = new DemoRenderer(context);
|
||||
setRenderer(mRenderer);
|
||||
DifferentTouchInput.registerInputManagerCallbacks(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event)
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onKeyDown(): keyCode " + keyCode + " event.getSource() " + event.getSource());
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
boolean mouseInput = false;
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||
mouseInput = true;
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
|
||||
{
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE )
|
||||
mouseInput = true;
|
||||
}
|
||||
if( mouseInput )
|
||||
{
|
||||
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||
nativeMouseButtonsPressed(2, 1);
|
||||
return true;
|
||||
}
|
||||
else if( mParent.keyboardWithoutTextInputShown )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( nativeKey( keyCode, 1, event.getUnicodeChar(), DifferentTouchInput.processGamepadDeviceId(event.getDevice()) ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
boolean mouseInput = false;
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE )
|
||||
mouseInput = true;
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
|
||||
{
|
||||
if( (event.getSource() & InputDevice.SOURCE_MOUSE_RELATIVE) == InputDevice.SOURCE_MOUSE_RELATIVE )
|
||||
mouseInput = true;
|
||||
}
|
||||
if( mouseInput )
|
||||
{
|
||||
// Stupid Samsung and stupid Acer remaps right mouse button to BACK key
|
||||
nativeMouseButtonsPressed(2, 0);
|
||||
return true;
|
||||
}
|
||||
else if( mParent.keyboardWithoutTextInputShown )
|
||||
{
|
||||
mParent.showScreenKeyboardWithoutTextInputField(0); // Hide keyboard
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( nativeKey( keyCode, 0, event.getUnicodeChar(), DifferentTouchInput.processGamepadDeviceId(event.getDevice()) ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
|
||||
//if( keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU )
|
||||
// DimSystemStatusBar.get().dim(mParent._videoLayout);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyMultiple(int keyCode, int repeatCount, final KeyEvent event)
|
||||
{
|
||||
if( event.getCharacters() != null )
|
||||
{
|
||||
// Non-English text input
|
||||
for( int i = 0; i < event.getCharacters().length(); i++ )
|
||||
{
|
||||
nativeKey( event.getKeyCode(), 1, event.getCharacters().codePointAt(i), 0 );
|
||||
nativeKey( event.getKeyCode(), 0, event.getCharacters().codePointAt(i), 0 );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
if( mParent.keyboardWithoutTextInputShown && mParent._screenKeyboard != null &&
|
||||
mParent._screenKeyboard.getY() <= event.getY() )
|
||||
{
|
||||
event.offsetLocation(-mParent._screenKeyboard.getX(), -mParent._screenKeyboard.getY());
|
||||
mParent._screenKeyboard.onTouchEvent(event);
|
||||
return true;
|
||||
}
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
|
||||
{
|
||||
if (getX() != 0)
|
||||
event.offsetLocation(-getX(), -getY());
|
||||
}
|
||||
DifferentTouchInput.touchInput.process(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -1016,33 +1146,42 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public boolean onGenericMotionEvent (final MotionEvent event)
|
||||
{
|
||||
DifferentTouchInput.touchInput.processGenericEvent(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void limitEventRate(final MotionEvent event)
|
||||
|
||||
@Override
|
||||
public boolean onCapturedPointerEvent (final MotionEvent event)
|
||||
{
|
||||
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
||||
// With Froyo the rate of touch events seems to be limited by OS, but they are arriving faster then we're redrawing anyway
|
||||
if((event.getAction() == MotionEvent.ACTION_MOVE ||
|
||||
event.getAction() == MotionEvent.ACTION_HOVER_MOVE))
|
||||
{
|
||||
synchronized(mRenderer)
|
||||
{
|
||||
try
|
||||
{
|
||||
mRenderer.wait(300L); // And sometimes the app decides not to render at all, so this timeout should not be big.
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Log.v("SDL", "DemoGLSurfaceView::limitEventRate(): Who dared to interrupt my slumber?");
|
||||
Thread.interrupted();
|
||||
}
|
||||
}
|
||||
}
|
||||
DifferentTouchInput.capturedMouseX += event.getX();
|
||||
DifferentTouchInput.capturedMouseY += event.getY();
|
||||
if (DifferentTouchInput.capturedMouseX < 0)
|
||||
DifferentTouchInput.capturedMouseX = 0;
|
||||
if (DifferentTouchInput.capturedMouseY < 0)
|
||||
DifferentTouchInput.capturedMouseY = 0;
|
||||
if (DifferentTouchInput.capturedMouseX >= this.getWidth())
|
||||
DifferentTouchInput.capturedMouseX = this.getWidth() - 1;
|
||||
if (DifferentTouchInput.capturedMouseY >= this.getHeight())
|
||||
DifferentTouchInput.capturedMouseY = this.getHeight() - 1;
|
||||
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onCapturedPointerEvent(): X " + DifferentTouchInput.capturedMouseX + " Y " + DifferentTouchInput.capturedMouseY +
|
||||
// " W " + this.getWidth() + " H " + this.getHeight() + " getX " + event.getX() + " getY " + event.getY() +
|
||||
// " RelX " + event.getAxisValue(MotionEvent.AXIS_RELATIVE_X) + " RelY " + event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y) );
|
||||
|
||||
event.setLocation(DifferentTouchInput.capturedMouseX, DifferentTouchInput.capturedMouseY);
|
||||
event.setAction(MotionEvent.ACTION_HOVER_MOVE);
|
||||
|
||||
//Log.v("SDL", "DemoGLSurfaceView::onCapturedPointerEvent(): XY " + event.getX() + " " + event.getY() + " action " + event.getAction());
|
||||
|
||||
return this.onTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPointerCaptureChange (boolean hasCapture)
|
||||
{
|
||||
Log.v("SDL", "DemoGLSurfaceView::onPointerCaptureChange(): " + hasCapture);
|
||||
super.onPointerCaptureChange(hasCapture);
|
||||
DifferentTouchInput.capturedMouseX = this.getWidth() / 2;
|
||||
DifferentTouchInput.capturedMouseY = this.getHeight() / 2;
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
@@ -1076,17 +1215,53 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
mRenderer.nativeGlContextRecreated();
|
||||
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||
mRenderer.accelerometer.start();
|
||||
captureMouse(true);
|
||||
};
|
||||
|
||||
public void captureMouse(boolean capture)
|
||||
{
|
||||
if( capture )
|
||||
{
|
||||
setFocusableInTouchMode(true);
|
||||
setFocusable(true);
|
||||
requestFocus();
|
||||
if( Globals.HideSystemMousePointer && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
|
||||
{
|
||||
postDelayed( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Log.v("SDL", "captureMouse::requestPointerCapture() delayed");
|
||||
requestPointerCapture();
|
||||
}
|
||||
}, 50 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Globals.HideSystemMousePointer && android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O )
|
||||
{
|
||||
postDelayed( new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Log.v("SDL", "captureMouse::releasePointerCapture()");
|
||||
releasePointerCapture();
|
||||
}
|
||||
}, 50 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DemoRenderer mRenderer;
|
||||
MainActivity mParent;
|
||||
|
||||
public static native void nativeMotionEvent( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native int nativeKey( int keyCode, int down, int unicode );
|
||||
public static native int nativeKey( int keyCode, int down, int unicode, int gamepadId );
|
||||
public static native void nativeHardwareMouseDetected( int detected );
|
||||
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
||||
public static native void nativeMouseWheel( int scrollX, int scrollY );
|
||||
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float ltrigger, float rtrigger, int usingHat );
|
||||
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float ltrigger, float rtrigger, float dpadx, float dpady, int gamepadId );
|
||||
public static native void nativeScreenVisibleRect( int x, int y, int w, int h );
|
||||
public static native void nativeScreenKeyboardShown( int shown );
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
|
||||
// The game helper object. This class is mainly a wrapper around this object.
|
||||
protected GameHelper mHelper;
|
||||
public int REQUEST_CLOUD_SAVE_ID = 38;
|
||||
|
||||
MainActivity parent;
|
||||
|
||||
@@ -72,6 +73,8 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
boolean createNewSave = false;
|
||||
public void onActivityResult(int request, int response, Intent intent)
|
||||
{
|
||||
if (request != REQUEST_CLOUD_SAVE_ID)
|
||||
return;
|
||||
Log.d("SDL", "CloudSave: onActivityResult() response " + response + " intent " + (intent != null));
|
||||
try
|
||||
{
|
||||
@@ -119,7 +122,7 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
parent.startActivityForResult(snapshotIntent, 0);
|
||||
parent.startActivityForResult(snapshotIntent, REQUEST_CLOUD_SAVE_ID);
|
||||
}
|
||||
});
|
||||
semaphore.acquireUninterruptibly();
|
||||
@@ -192,7 +195,7 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
parent.startActivityForResult(snapshotIntent, 0);
|
||||
parent.startActivityForResult(snapshotIntent, REQUEST_CLOUD_SAVE_ID);
|
||||
}
|
||||
});
|
||||
semaphore.acquireUninterruptibly();
|
||||
@@ -361,10 +364,6 @@ public class CloudSave implements GameHelper.GameHelperListener {
|
||||
mHelper.enableDebugLog(enabled);
|
||||
}
|
||||
|
||||
public String getInvitationId() {
|
||||
return mHelper.getInvitationId();
|
||||
}
|
||||
|
||||
public void reconnectClient() {
|
||||
mHelper.reconnectClient();
|
||||
}
|
||||
|
||||
@@ -37,12 +37,6 @@ import com.google.android.gms.drive.Drive;
|
||||
import com.google.android.gms.games.Games;
|
||||
import com.google.android.gms.games.Games.GamesOptions;
|
||||
import com.google.android.gms.games.GamesActivityResultCodes;
|
||||
import com.google.android.gms.games.multiplayer.Invitation;
|
||||
import com.google.android.gms.games.multiplayer.Multiplayer;
|
||||
import com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch;
|
||||
import com.google.android.gms.games.request.GameRequest;
|
||||
//import com.google.android.gms.plus.Plus;
|
||||
//import com.google.android.gms.plus.Plus.PlusOptions;
|
||||
|
||||
public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
GoogleApiClient.OnConnectionFailedListener {
|
||||
@@ -121,11 +115,9 @@ public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
// Client request flags
|
||||
public final static int CLIENT_NONE = 0x00;
|
||||
public final static int CLIENT_GAMES = 0x01;
|
||||
//public final static int CLIENT_PLUS = 0x02;
|
||||
public final static int CLIENT_APPSTATE = 0x04;
|
||||
public final static int CLIENT_SNAPSHOT = 0x05;
|
||||
public final static int CLIENT_ALL = CLIENT_GAMES //| CLIENT_PLUS
|
||||
| CLIENT_APPSTATE | CLIENT_SNAPSHOT;
|
||||
public final static int CLIENT_ALL = CLIENT_GAMES | CLIENT_APPSTATE | CLIENT_SNAPSHOT;
|
||||
|
||||
// What clients were requested? (bit flags)
|
||||
int mRequestedClients = CLIENT_NONE;
|
||||
@@ -157,24 +149,6 @@ public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
|
||||
Handler mHandler;
|
||||
|
||||
/*
|
||||
* If we got an invitation when we connected to the games client, it's here.
|
||||
* Otherwise, it's null.
|
||||
*/
|
||||
Invitation mInvitation;
|
||||
|
||||
/*
|
||||
* If we got turn-based match when we connected to the games client, it's
|
||||
* here. Otherwise, it's null.
|
||||
*/
|
||||
TurnBasedMatch mTurnBasedMatch;
|
||||
|
||||
/*
|
||||
* If we have incoming requests when we connected to the games client, they
|
||||
* are here. Otherwise, it's null.
|
||||
*/
|
||||
ArrayList<GameRequest> mRequests;
|
||||
|
||||
// Listener
|
||||
GameHelperListener mListener = null;
|
||||
|
||||
@@ -414,101 +388,6 @@ public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
mActivity = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the invitation ID received through an invitation notification.
|
||||
* This should be called from your GameHelperListener's
|
||||
*
|
||||
* @link{GameHelperListener#onSignInSucceeded method, to check if there's an
|
||||
* invitation available. In that
|
||||
* case, accept the invitation.
|
||||
* @return The id of the invitation, or null if none was received.
|
||||
*/
|
||||
public String getInvitationId() {
|
||||
if (!mGoogleApiClient.isConnected()) {
|
||||
Log.w(TAG,
|
||||
"Warning: getInvitationId() should only be called when signed in, "
|
||||
+ "that is, after getting onSignInSuceeded()");
|
||||
}
|
||||
return mInvitation == null ? null : mInvitation.getInvitationId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the invitation received through an invitation notification. This
|
||||
* should be called from your GameHelperListener's
|
||||
*
|
||||
* @link{GameHelperListener#onSignInSucceeded method, to check if there's an
|
||||
* invitation available. In that
|
||||
* case, accept the invitation.
|
||||
* @return The invitation, or null if none was received.
|
||||
*/
|
||||
public Invitation getInvitation() {
|
||||
if (!mGoogleApiClient.isConnected()) {
|
||||
Log.w(TAG,
|
||||
"Warning: getInvitation() should only be called when signed in, "
|
||||
+ "that is, after getting onSignInSuceeded()");
|
||||
}
|
||||
return mInvitation;
|
||||
}
|
||||
|
||||
public boolean hasInvitation() {
|
||||
return mInvitation != null;
|
||||
}
|
||||
|
||||
public boolean hasTurnBasedMatch() {
|
||||
return mTurnBasedMatch != null;
|
||||
}
|
||||
|
||||
public boolean hasRequests() {
|
||||
return mRequests != null;
|
||||
}
|
||||
|
||||
public void clearInvitation() {
|
||||
mInvitation = null;
|
||||
}
|
||||
|
||||
public void clearTurnBasedMatch() {
|
||||
mTurnBasedMatch = null;
|
||||
}
|
||||
|
||||
public void clearRequests() {
|
||||
mRequests = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tbmp match received through an invitation notification. This
|
||||
* should be called from your GameHelperListener's
|
||||
*
|
||||
* @link{GameHelperListener#onSignInSucceeded method, to check if there's a
|
||||
* match available.
|
||||
* @return The match, or null if none was received.
|
||||
*/
|
||||
public TurnBasedMatch getTurnBasedMatch() {
|
||||
if (!mGoogleApiClient.isConnected()) {
|
||||
Log.w(TAG,
|
||||
"Warning: getTurnBasedMatch() should only be called when signed in, "
|
||||
+ "that is, after getting onSignInSuceeded()");
|
||||
}
|
||||
return mTurnBasedMatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the requests received through the onConnected bundle. This should
|
||||
* be called from your GameHelperListener's
|
||||
*
|
||||
* @link{GameHelperListener#onSignInSucceeded method, to check if there are
|
||||
* incoming requests that must be
|
||||
* handled.
|
||||
* @return The requests, or null if none were received.
|
||||
*/
|
||||
public ArrayList<GameRequest> getRequests() {
|
||||
if (!mGoogleApiClient.isConnected()) {
|
||||
Log.w(TAG, "Warning: getRequests() should only be called "
|
||||
+ "when signed in, "
|
||||
+ "that is, after getting onSignInSuceeded()");
|
||||
}
|
||||
return mRequests;
|
||||
}
|
||||
|
||||
/** Enables debug logging */
|
||||
public void enableDebugLog(boolean enabled) {
|
||||
mDebugLog = enabled;
|
||||
@@ -686,8 +565,6 @@ public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
}
|
||||
debugLog("Starting connection.");
|
||||
mConnecting = true;
|
||||
mInvitation = null;
|
||||
mTurnBasedMatch = null;
|
||||
mGoogleApiClient.connect();
|
||||
}
|
||||
|
||||
@@ -712,27 +589,6 @@ public class GameHelper implements GoogleApiClient.ConnectionCallbacks,
|
||||
|
||||
if (connectionHint != null) {
|
||||
debugLog("onConnected: connection hint provided. Checking for invite.");
|
||||
Invitation inv = connectionHint
|
||||
.getParcelable(Multiplayer.EXTRA_INVITATION);
|
||||
if (inv != null && inv.getInvitationId() != null) {
|
||||
// retrieve and cache the invitation ID
|
||||
debugLog("onConnected: connection hint has a room invite!");
|
||||
mInvitation = inv;
|
||||
debugLog("Invitation ID: " + mInvitation.getInvitationId());
|
||||
}
|
||||
|
||||
// Do we have any requests pending?
|
||||
mRequests = Games.Requests
|
||||
.getGameRequestsFromBundle(connectionHint);
|
||||
if (!mRequests.isEmpty()) {
|
||||
// We have requests in onConnected's connectionHint.
|
||||
debugLog("onConnected: connection hint has " + mRequests.size()
|
||||
+ " request(s)");
|
||||
}
|
||||
|
||||
debugLog("onConnected: connection hint provided. Checking for TBMP game.");
|
||||
mTurnBasedMatch = connectionHint
|
||||
.getParcelable(Multiplayer.EXTRA_TURN_BASED_MATCH);
|
||||
}
|
||||
|
||||
// we're good to go
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<string name="storage_phone">Внутреннее хранение - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куда сохранять данные приложения</string>
|
||||
<string name="storage_access">Разрешение на запись на SD карту</string>
|
||||
<string name="optional_downloads">Дополнительные загрузки</string>
|
||||
<string name="ok">Продолжить</string>
|
||||
<string name="controls_arrows">Стрелки / джойстик / Dpad</string>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<string name="storage_phone">Внутрішнє зберігання - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куди зберігати дані програми</string>
|
||||
<string name="storage_access">Дозвіл на запис на SD карту</string>
|
||||
<string name="optional_downloads">Додаткові завантаження</string>
|
||||
<string name="ok">ОК</string>
|
||||
<string name="controls_arrows">Стрілки / джойстік / Dpad</string>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
<string name="init">初始化中</string>
|
||||
<string name="please_wait">正在下载数据,请稍等</string>
|
||||
<string name="please_wait">正在下载数据,请稍候</string>
|
||||
|
||||
<string name="device_config">设备配置</string>
|
||||
<string name="device_change_cfg">更改设备配置</string>
|
||||
@@ -26,7 +26,7 @@
|
||||
<string name="storage_question">数据文件安装位置</string>
|
||||
<string name="optional_downloads">下载</string>
|
||||
<string name="downloads">下载</string>
|
||||
<string name="ok">好</string>
|
||||
<string name="ok">完成</string>
|
||||
<string name="cancel">取消</string>
|
||||
|
||||
<string name="controls_arrows">箭头 / 操纵杆 / 方向键</string>
|
||||
@@ -163,6 +163,7 @@
|
||||
|
||||
<string name="display_size_mouse">鼠标仿真模式</string>
|
||||
<string name="display_size">显示仿真鼠标的大小</string>
|
||||
<string name="display_size_desktop">桌面版,无仿真</string>
|
||||
<string name="display_size_large">大(适用于平板电脑)</string>
|
||||
<string name="display_size_small">小,放大镜</string>
|
||||
<string name="display_size_small_touchpad">小,触摸模式</string>
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Commander Genius</string>
|
||||
|
||||
|
||||
@@ -24,6 +26,7 @@
|
||||
<string name="storage_custom">Specify directory</string>
|
||||
<string name="storage_commandline">Command line parameters, one argument per line</string>
|
||||
<string name="storage_question">Data installation location</string>
|
||||
<string name="storage_access">Permission to write to SD card</string>
|
||||
<string name="optional_downloads">Downloads</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Vibrator;
|
||||
import android.hardware.SensorManager;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.util.Log;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
class AccelerometerReader implements SensorEventListener
|
||||
{
|
||||
|
||||
private SensorManager _manager = null;
|
||||
public boolean openedBySDL = false;
|
||||
public static final GyroscopeListener gyro = new GyroscopeListener();
|
||||
|
||||
public AccelerometerReader(Activity context)
|
||||
{
|
||||
_manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
}
|
||||
|
||||
public synchronized void stop()
|
||||
{
|
||||
if( _manager != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: stopping accelerometer/gyroscope");
|
||||
_manager.unregisterListener(this);
|
||||
_manager.unregisterListener(gyro);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start()
|
||||
{
|
||||
if( (Globals.UseAccelerometerAsArrowKeys || Globals.AppUsesAccelerometer) &&
|
||||
_manager != null && _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER) != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: starting accelerometer");
|
||||
_manager.registerListener(this, _manager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
if( Globals.AppUsesGyroscope && _manager != null && _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null )
|
||||
{
|
||||
Log.i("SDL", "libSDL: starting gyroscope");
|
||||
_manager.registerListener(gyro, _manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
}
|
||||
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
if( Globals.HorizontalOrientation )
|
||||
nativeAccelerometer(event.values[1], -event.values[0], event.values[2]);
|
||||
else
|
||||
nativeAccelerometer(event.values[0], event.values[1], event.values[2]); // TODO: not tested!
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
|
||||
static class GyroscopeListener implements SensorEventListener
|
||||
{
|
||||
public float x1, x2, xc, y1, y2, yc, z1, z2, zc;
|
||||
public GyroscopeListener()
|
||||
{
|
||||
}
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
// TODO: vertical orientation
|
||||
//if( Globals.HorizontalOrientation )
|
||||
if( event.values[0] < x1 || event.values[0] > x2 ||
|
||||
event.values[1] < y1 || event.values[1] > y2 ||
|
||||
event.values[2] < z1 || event.values[2] > z2 )
|
||||
nativeGyroscope(event.values[0] - xc, event.values[1] - yc, event.values[2] - zc);
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
public boolean available(Activity context)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
return ( manager != null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null );
|
||||
}
|
||||
public void registerListener(Activity context, SensorEventListener l)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
if ( manager == null && manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) == null )
|
||||
return;
|
||||
manager.registerListener(l, manager.getDefaultSensor(Sensor.TYPE_GYROSCOPE), SensorManager.SENSOR_DELAY_GAME);
|
||||
}
|
||||
public void unregisterListener(Activity context,SensorEventListener l)
|
||||
{
|
||||
SensorManager manager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
|
||||
if ( manager == null )
|
||||
return;
|
||||
manager.unregisterListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
private static native void nativeAccelerometer(float accX, float accY, float accZ);
|
||||
private static native void nativeGyroscope(float X, float Y, float Z);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
|
||||
class Advertisement
|
||||
{
|
||||
MainActivity parent;
|
||||
|
||||
public Advertisement(MainActivity p)
|
||||
{
|
||||
parent = p;
|
||||
}
|
||||
|
||||
public View getView()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void requestNewAd()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.media.AudioTrack;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioRecord;
|
||||
import android.media.MediaRecorder.AudioSource;
|
||||
import java.io.*;
|
||||
import android.util.Log;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
|
||||
|
||||
class AudioThread
|
||||
{
|
||||
|
||||
private MainActivity mParent;
|
||||
private AudioTrack mAudio;
|
||||
private byte[] mAudioBuffer;
|
||||
private int mVirtualBufSize;
|
||||
|
||||
public AudioThread(MainActivity parent)
|
||||
{
|
||||
mParent = parent;
|
||||
mAudio = null;
|
||||
mAudioBuffer = null;
|
||||
//nativeAudioInitJavaCallbacks();
|
||||
}
|
||||
|
||||
public int fillBuffer()
|
||||
{
|
||||
if( mParent.isPaused() )
|
||||
{
|
||||
try{
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if( Globals.AudioBufferConfig == 0 ) // Gives too much spam to logcat, makes things worse
|
||||
// mAudio.flush();
|
||||
|
||||
mAudio.write( mAudioBuffer, 0, mVirtualBufSize );
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudio(int rate, int channels, int encoding, int bufSize)
|
||||
{
|
||||
if( mAudio == null )
|
||||
{
|
||||
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||
AudioFormat.ENCODING_PCM_8BIT;
|
||||
|
||||
mVirtualBufSize = bufSize;
|
||||
|
||||
if( AudioTrack.getMinBufferSize( rate, channels, encoding ) > bufSize )
|
||||
bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
|
||||
|
||||
if(Globals.AudioBufferConfig != 0) { // application's choice - use minimal buffer
|
||||
bufSize = (int)((float)bufSize * (((float)(Globals.AudioBufferConfig - 1) * 2.5f) + 1.0f));
|
||||
mVirtualBufSize = bufSize;
|
||||
}
|
||||
mAudioBuffer = new byte[bufSize];
|
||||
|
||||
mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
rate,
|
||||
channels,
|
||||
encoding,
|
||||
bufSize,
|
||||
AudioTrack.MODE_STREAM );
|
||||
mAudio.play();
|
||||
}
|
||||
return mVirtualBufSize;
|
||||
}
|
||||
|
||||
public byte[] getBuffer()
|
||||
{
|
||||
return mAudioBuffer;
|
||||
}
|
||||
|
||||
public int deinitAudio()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.stop();
|
||||
mAudio.release();
|
||||
mAudio = null;
|
||||
}
|
||||
mAudioBuffer = null;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int initAudioThread()
|
||||
{
|
||||
// Make audio thread priority higher so audio thread won't get underrun
|
||||
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int pauseAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.pause();
|
||||
}
|
||||
if( mRecordThread != null )
|
||||
{
|
||||
mRecordThread.pauseRecording();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int resumeAudioPlayback()
|
||||
{
|
||||
if( mAudio != null )
|
||||
{
|
||||
mAudio.play();
|
||||
}
|
||||
if( mRecordThread != null )
|
||||
{
|
||||
mRecordThread.resumeRecording();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
private native int nativeAudioInitJavaCallbacks();
|
||||
|
||||
// ----- Audio recording -----
|
||||
|
||||
private RecordingThread mRecordThread = null;
|
||||
private AudioRecord mRecorder = null;
|
||||
private int mRecorderBufferSize = 0;
|
||||
|
||||
private byte[] startRecording(int rate, int channels, int encoding, int bufsize)
|
||||
{
|
||||
if( mRecordThread == null )
|
||||
{
|
||||
mRecordThread = new RecordingThread();
|
||||
mRecordThread.start();
|
||||
}
|
||||
if( !mRecordThread.isStopped() )
|
||||
{
|
||||
Log.i("SDL", "SDL: error: application already opened audio recording device");
|
||||
return null;
|
||||
}
|
||||
|
||||
mRecordThread.init(bufsize);
|
||||
|
||||
int channelConfig = ( channels == 1 ) ? AudioFormat.CHANNEL_IN_MONO :
|
||||
AudioFormat.CHANNEL_IN_STEREO;
|
||||
int encodingConfig = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
|
||||
AudioFormat.ENCODING_PCM_8BIT;
|
||||
|
||||
int minBufDevice = AudioRecord.getMinBufferSize(rate, channelConfig, encodingConfig);
|
||||
int minBufferSize = Math.max(bufsize * 8, minBufDevice + (bufsize - (minBufDevice % bufsize)));
|
||||
Log.i("SDL", "SDL: app opened recording device, rate " + rate + " channels " + channels + " sample size " + (encoding+1) + " bufsize " + bufsize + " internal bufsize " + minBufferSize);
|
||||
if( mRecorder == null || mRecorder.getSampleRate() != rate ||
|
||||
mRecorder.getChannelCount() != channels ||
|
||||
mRecorder.getAudioFormat() != encodingConfig ||
|
||||
mRecorderBufferSize != minBufferSize )
|
||||
{
|
||||
if( mRecorder != null )
|
||||
mRecorder.release();
|
||||
mRecorder = null;
|
||||
try {
|
||||
mRecorder = new AudioRecord(AudioSource.DEFAULT, rate, channelConfig, encodingConfig, minBufferSize);
|
||||
mRecorderBufferSize = minBufferSize;
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.i("SDL", "SDL: error: failed to open recording device!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "SDL: reusing old recording device");
|
||||
}
|
||||
mRecordThread.startRecording();
|
||||
return mRecordThread.mRecordBuffer;
|
||||
}
|
||||
|
||||
private void stopRecording()
|
||||
{
|
||||
if( mRecordThread == null || mRecordThread.isStopped() )
|
||||
{
|
||||
Log.i("SDL", "SDL: error: application already closed audio recording device");
|
||||
return;
|
||||
}
|
||||
mRecordThread.stopRecording();
|
||||
Log.i("SDL", "SDL: app closed recording device");
|
||||
}
|
||||
|
||||
private class RecordingThread extends Thread
|
||||
{
|
||||
private boolean stopped = true;
|
||||
byte[] mRecordBuffer;
|
||||
private Semaphore waitStarted = new Semaphore(0);
|
||||
private boolean sleep = false;
|
||||
|
||||
RecordingThread()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
void init(int bufsize)
|
||||
{
|
||||
if( mRecordBuffer == null || mRecordBuffer.length != bufsize )
|
||||
mRecordBuffer = new byte[bufsize];
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
waitStarted.acquireUninterruptibly();
|
||||
waitStarted.drainPermits();
|
||||
stopped = false;
|
||||
sleep = false;
|
||||
|
||||
while( !sleep )
|
||||
{
|
||||
int got = mRecorder.read(mRecordBuffer, 0, mRecordBuffer.length);
|
||||
if( got != mRecordBuffer.length )
|
||||
{
|
||||
// Audio is stopped here, sleep a bit.
|
||||
try{
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback with len " + mRecordBuffer.length);
|
||||
nativeAudioRecordCallback();
|
||||
//Log.i("SDL", "SDL: nativeAudioRecordCallback returned");
|
||||
}
|
||||
}
|
||||
|
||||
stopped = true;
|
||||
mRecorder.stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void startRecording()
|
||||
{
|
||||
mRecorder.startRecording();
|
||||
waitStarted.release();
|
||||
}
|
||||
public void stopRecording()
|
||||
{
|
||||
sleep = true;
|
||||
while( !stopped )
|
||||
{
|
||||
try{
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
public void pauseRecording()
|
||||
{
|
||||
if( !stopped )
|
||||
mRecorder.stop();
|
||||
}
|
||||
public void resumeRecording()
|
||||
{
|
||||
if( !stopped )
|
||||
mRecorder.startRecording();
|
||||
}
|
||||
public boolean isStopped()
|
||||
{
|
||||
return stopped;
|
||||
}
|
||||
}
|
||||
|
||||
private native void nativeAudioRecordCallback();
|
||||
}
|
||||
@@ -1,758 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Environment;
|
||||
|
||||
import android.widget.TextView;
|
||||
import org.apache.http.client.methods.*;
|
||||
import org.apache.http.*;
|
||||
import org.apache.http.params.BasicHttpParams;
|
||||
import org.apache.http.conn.*;
|
||||
import org.apache.http.conn.params.*;
|
||||
import org.apache.http.conn.scheme.*;
|
||||
import org.apache.http.conn.ssl.*;
|
||||
import org.apache.http.impl.*;
|
||||
import org.apache.http.impl.client.*;
|
||||
import org.apache.http.impl.conn.SingleClientConnManager;
|
||||
import java.security.cert.*;
|
||||
import java.security.SecureRandom;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.util.zip.*;
|
||||
import java.io.*;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.text.SpannedString;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
||||
|
||||
class CountingInputStream extends BufferedInputStream
|
||||
{
|
||||
|
||||
private long bytesReadMark = 0;
|
||||
private long bytesRead = 0;
|
||||
|
||||
public CountingInputStream(InputStream in, int size) {
|
||||
|
||||
super(in, size);
|
||||
}
|
||||
|
||||
public CountingInputStream(InputStream in) {
|
||||
|
||||
super(in);
|
||||
}
|
||||
|
||||
public long getBytesRead() {
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
public synchronized int read() throws IOException {
|
||||
|
||||
int read = super.read();
|
||||
if (read >= 0) {
|
||||
bytesRead++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized int read(byte[] b, int off, int len) throws IOException {
|
||||
|
||||
int read = super.read(b, off, len);
|
||||
if (read >= 0) {
|
||||
bytesRead += read;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public synchronized long skip(long n) throws IOException {
|
||||
|
||||
long skipped = super.skip(n);
|
||||
if (skipped >= 0) {
|
||||
bytesRead += skipped;
|
||||
}
|
||||
return skipped;
|
||||
}
|
||||
|
||||
public synchronized void mark(int readlimit) {
|
||||
|
||||
super.mark(readlimit);
|
||||
bytesReadMark = bytesRead;
|
||||
}
|
||||
|
||||
public synchronized void reset() throws IOException {
|
||||
|
||||
super.reset();
|
||||
bytesRead = bytesReadMark;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DataDownloader extends Thread
|
||||
{
|
||||
|
||||
public static final String DOWNLOAD_FLAG_FILENAME = "libsdl-DownloadFinished-";
|
||||
|
||||
class StatusWriter
|
||||
{
|
||||
private TextView Status;
|
||||
private MainActivity Parent;
|
||||
private SpannedString oldText = new SpannedString("");
|
||||
|
||||
public StatusWriter( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
}
|
||||
public void setParent( TextView _Status, MainActivity _Parent )
|
||||
{
|
||||
synchronized(DataDownloader.this) {
|
||||
Status = _Status;
|
||||
Parent = _Parent;
|
||||
setText( oldText.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(final String str)
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public TextView Status;
|
||||
public SpannedString text;
|
||||
public void run()
|
||||
{
|
||||
Status.setText(text);
|
||||
}
|
||||
}
|
||||
synchronized(DataDownloader.this) {
|
||||
Callback cb = new Callback();
|
||||
oldText = new SpannedString(str);
|
||||
cb.text = new SpannedString(str);
|
||||
cb.Status = Status;
|
||||
if( Parent != null && Status != null )
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public DataDownloader( MainActivity _Parent, TextView _Status )
|
||||
{
|
||||
Parent = _Parent;
|
||||
Status = new StatusWriter( _Status, _Parent );
|
||||
//Status.setText( "Connecting to " + Globals.DataDownloadUrl );
|
||||
outFilesDir = Globals.DataDir;
|
||||
DownloadComplete = false;
|
||||
this.start();
|
||||
}
|
||||
|
||||
public void setStatusField(TextView _Status)
|
||||
{
|
||||
synchronized(this) {
|
||||
Status.setParent( _Status, Parent );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Parent.keyListener = new BackKeyListener(Parent);
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
int total = 0;
|
||||
int count = 0;
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
total += 1;
|
||||
}
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].length() > 0 &&
|
||||
( Globals.OptionalDataDownload.length > i && Globals.OptionalDataDownload[i] ) ||
|
||||
( Globals.OptionalDataDownload.length <= i && downloadFiles[i].indexOf("!") == 0 ) )
|
||||
{
|
||||
if( ! DownloadDataFile(downloadFiles[i], DOWNLOAD_FLAG_FILENAME + String.valueOf(i) + ".flag", count+1, total, i) )
|
||||
{
|
||||
DownloadFailed = true;
|
||||
return;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
DownloadComplete = true;
|
||||
Parent.keyListener = null;
|
||||
initParent();
|
||||
}
|
||||
|
||||
public boolean DownloadDataFile(final String DataDownloadUrl, final String DownloadFlagFileName, int downloadCount, int downloadTotal, int downloadIndex)
|
||||
{
|
||||
DownloadCanBeResumed = false;
|
||||
Resources res = Parent.getResources();
|
||||
|
||||
String [] downloadUrls = DataDownloadUrl.split("[|]");
|
||||
if( downloadUrls.length < 2 )
|
||||
{
|
||||
Log.i("SDL", "Error: download string invalid: '" + DataDownloadUrl + "', your AndroidAppSettigns.cfg is broken");
|
||||
Status.setText( res.getString(R.string.error_dl_from, DataDownloadUrl) );
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean forceOverwrite = false;
|
||||
String path = getOutFilePath(DownloadFlagFileName);
|
||||
InputStream checkFile = null;
|
||||
try {
|
||||
checkFile = new FileInputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) { };
|
||||
if( checkFile != null )
|
||||
{
|
||||
try {
|
||||
byte b[] = new byte[ Globals.DataDownloadUrl[downloadIndex].getBytes("UTF-8").length + 1 ];
|
||||
int readed = checkFile.read(b);
|
||||
String compare = "";
|
||||
if( readed > 0 )
|
||||
compare = new String( b, 0, readed, "UTF-8" );
|
||||
boolean matched = false;
|
||||
//Log.i("SDL", "Read URL: '" + compare + "'");
|
||||
for( int i = 1; i < downloadUrls.length; i++ )
|
||||
{
|
||||
//Log.i("SDL", "Comparing: '" + downloadUrls[i] + "'");
|
||||
if( compare.compareTo(downloadUrls[i]) == 0 )
|
||||
matched = true;
|
||||
}
|
||||
//Log.i("SDL", "Matched: " + String.valueOf(matched));
|
||||
if( ! matched )
|
||||
throw new IOException();
|
||||
Status.setText( res.getString(R.string.download_unneeded) );
|
||||
return true;
|
||||
} catch ( IOException e ) {
|
||||
forceOverwrite = true;
|
||||
new File(path).delete();
|
||||
}
|
||||
}
|
||||
checkFile = null;
|
||||
|
||||
// Create output directory (not necessary for phone storage)
|
||||
Log.i("SDL", "Downloading data to: '" + outFilesDir + "'");
|
||||
try {
|
||||
File outDir = new File( outFilesDir );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
OutputStream out = new FileOutputStream( getOutFilePath(".nomedia") );
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
catch( SecurityException e ) {}
|
||||
catch( FileNotFoundException e ) {}
|
||||
catch( IOException e ) {};
|
||||
|
||||
HttpResponse response = null, responseError = null;
|
||||
HttpGet request;
|
||||
long totalLen = 0;
|
||||
CountingInputStream stream;
|
||||
byte[] buf = new byte[16384];
|
||||
boolean DoNotUnzip = false;
|
||||
boolean FileInAssets = false;
|
||||
String url = "";
|
||||
long partialDownloadLen = 0;
|
||||
|
||||
int downloadUrlIndex = 1;
|
||||
while( downloadUrlIndex < downloadUrls.length )
|
||||
{
|
||||
Log.i("SDL", "Processing download " + downloadUrls[downloadUrlIndex]);
|
||||
url = new String(downloadUrls[downloadUrlIndex]);
|
||||
DoNotUnzip = false;
|
||||
if(url.indexOf(":") == 0)
|
||||
{
|
||||
path = getOutFilePath(url.substring( 1, url.indexOf(":", 1) ));
|
||||
url = url.substring( url.indexOf(":", 1) + 1 );
|
||||
DoNotUnzip = true;
|
||||
DownloadCanBeResumed = true;
|
||||
File partialDownload = new File( path );
|
||||
if( partialDownload.exists() && !partialDownload.isDirectory() && !forceOverwrite )
|
||||
partialDownloadLen = partialDownload.length();
|
||||
}
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.connecting_to, url) );
|
||||
if( url.indexOf("http://") == -1 && url.indexOf("https://") == -1 ) // File inside assets
|
||||
{
|
||||
InputStream stream1 = null;
|
||||
try {
|
||||
stream1 = Parent.getAssets().open(url);
|
||||
stream1.close();
|
||||
} catch( Exception e ) {
|
||||
try {
|
||||
stream1 = Parent.getAssets().open(url + "000");
|
||||
stream1.close();
|
||||
} catch( Exception ee ) {
|
||||
Log.i("SDL", "Failed to open file in assets: " + url);
|
||||
downloadUrlIndex++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
FileInAssets = true;
|
||||
Log.i("SDL", "Fetching file from assets: " + url);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "Connecting to: " + url);
|
||||
request = new HttpGet(url);
|
||||
request.addHeader("Accept", "*/*");
|
||||
if( partialDownloadLen > 0 ) {
|
||||
request.addHeader("Range", "bytes=" + partialDownloadLen + "-");
|
||||
Log.i("SDL", "Trying to resume download at pos " + partialDownloadLen);
|
||||
}
|
||||
try {
|
||||
DefaultHttpClient client = HttpWithDisabledSslCertCheck();
|
||||
client.getParams().setBooleanParameter("http.protocol.handle-redirects", true);
|
||||
response = client.execute(request);
|
||||
} catch (IOException e) {
|
||||
Log.i("SDL", "Failed to connect to " + url);
|
||||
downloadUrlIndex++;
|
||||
};
|
||||
if( response != null )
|
||||
{
|
||||
if( response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 206 )
|
||||
{
|
||||
Log.i("SDL", "Failed to connect to " + url + " with error " + response.getStatusLine().getStatusCode() + " " + response.getStatusLine().getReasonPhrase());
|
||||
responseError = response;
|
||||
response = null;
|
||||
downloadUrlIndex++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( FileInAssets )
|
||||
{
|
||||
int multipartCounter = 0;
|
||||
InputStream multipart = null;
|
||||
while( true )
|
||||
{
|
||||
try {
|
||||
// Make string ".zip000", ".zip001" etc for multipart archives
|
||||
String url1 = url + String.format("%03d", multipartCounter);
|
||||
CountingInputStream stream1 = new CountingInputStream(Parent.getAssets().open(url1), 8192);
|
||||
while( stream1.skip(65536) > 0 ) { };
|
||||
totalLen += stream1.getBytesRead();
|
||||
stream1.close();
|
||||
InputStream s = Parent.getAssets().open(url1);
|
||||
if( multipart == null )
|
||||
multipart = s;
|
||||
else
|
||||
multipart = new SequenceInputStream(multipart, s);
|
||||
Log.i("SDL", "Multipart archive found: " + url1);
|
||||
} catch( IOException e ) {
|
||||
break;
|
||||
}
|
||||
multipartCounter += 1;
|
||||
}
|
||||
if( multipart != null )
|
||||
stream = new CountingInputStream(multipart, 8192);
|
||||
else
|
||||
{
|
||||
try {
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
while( stream.skip(65536) > 0 ) { };
|
||||
totalLen += stream.getBytesRead();
|
||||
stream.close();
|
||||
stream = new CountingInputStream(Parent.getAssets().open(url), 8192);
|
||||
} catch( IOException e ) {
|
||||
Log.i("SDL", "Unpacking from assets '" + url + "' - error: " + e.toString());
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( response == null )
|
||||
{
|
||||
Log.i("SDL", "Error connecting to " + url);
|
||||
Status.setText( res.getString(R.string.failed_connecting_to, url) + (responseError == null ? "" : ": " + responseError.getStatusLine().getStatusCode() + " " + responseError.getStatusLine().getReasonPhrase()) );
|
||||
return false;
|
||||
}
|
||||
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_from, url) );
|
||||
totalLen = response.getEntity().getContentLength();
|
||||
try {
|
||||
stream = new CountingInputStream(response.getEntity().getContent(), 8192);
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
long updateStatusTime = 0;
|
||||
|
||||
if(DoNotUnzip)
|
||||
{
|
||||
Log.i("SDL", "Saving file '" + path + "'");
|
||||
OutputStream out = null;
|
||||
try {
|
||||
try {
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
|
||||
if( partialDownloadLen > 0 )
|
||||
{
|
||||
try {
|
||||
Header[] range = response.getHeaders("Content-Range");
|
||||
if( range.length > 0 && range[0].getValue().indexOf("bytes") == 0 )
|
||||
{
|
||||
//Log.i("SDL", "Resuming download of file '" + path + "': Content-Range: " + range[0].getValue());
|
||||
String[] skippedBytes = range[0].getValue().split("/")[0].split("-")[0].split(" ");
|
||||
if( skippedBytes.length >= 2 && Long.parseLong(skippedBytes[1]) == partialDownloadLen )
|
||||
{
|
||||
out = new FileOutputStream( path, true );
|
||||
Log.i("SDL", "Resuming download of file '" + path + "' at pos " + partialDownloadLen);
|
||||
}
|
||||
}
|
||||
else
|
||||
Log.i("SDL", "Server does not support partial downloads. " + (range.length == 0 ? "" : range[0].getValue()));
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
if( out == null )
|
||||
{
|
||||
out = new FileOutputStream( path );
|
||||
partialDownloadLen = 0;
|
||||
}
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString());
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file: " + e.toString());
|
||||
};
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error creating output file");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int len = stream.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = stream.read(buf);
|
||||
|
||||
float percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = (stream.getBytesRead() + partialDownloadLen) * 100.0f / (totalLen + partialDownloadLen);
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error writing: " + e.toString());
|
||||
return false;
|
||||
}
|
||||
Log.i("SDL", "Saving file '" + path + "' done");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i("SDL", "Reading from zip file '" + url + "'");
|
||||
ZipInputStream zip = new ZipInputStream(stream);
|
||||
|
||||
while(true)
|
||||
{
|
||||
ZipEntry entry = null;
|
||||
try {
|
||||
entry = zip.getNextEntry();
|
||||
if( entry != null )
|
||||
Log.i("SDL", "Reading from zip file '" + url + "' entry '" + entry.getName() + "'");
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_dl_from, url) );
|
||||
Log.i("SDL", "Error reading from zip file '" + url + "': " + e.toString());
|
||||
return false;
|
||||
}
|
||||
if( entry == null )
|
||||
{
|
||||
Log.i("SDL", "Reading from zip file '" + url + "' finished");
|
||||
break;
|
||||
}
|
||||
if( entry.isDirectory() )
|
||||
{
|
||||
Log.i("SDL", "Creating dir '" + getOutFilePath(entry.getName()) + "'");
|
||||
try {
|
||||
File outDir = new File( getOutFilePath(entry.getName()) );
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
continue;
|
||||
}
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(entry.getName());
|
||||
float percent = 0.0f;
|
||||
|
||||
Log.i("SDL", "Saving file '" + path + "'");
|
||||
|
||||
try {
|
||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||
outDir.mkdirs();
|
||||
} catch( SecurityException e ) { };
|
||||
|
||||
try {
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( check.read(buf, 0, buf.length) >= 0 ) {};
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
throw new Exception();
|
||||
}
|
||||
Log.i("SDL", "File '" + path + "' exists and passed CRC check - not overwriting it");
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
continue;
|
||||
} catch( Exception e ) { }
|
||||
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
} catch( FileNotFoundException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString());
|
||||
} catch( SecurityException e ) {
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file: " + e.toString());
|
||||
};
|
||||
if( out == null )
|
||||
{
|
||||
Status.setText( res.getString(R.string.error_write, path) );
|
||||
Log.i("SDL", "Saving file '" + path + "' - cannot create file");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
|
||||
try {
|
||||
int len = zip.read(buf);
|
||||
while (len >= 0)
|
||||
{
|
||||
if(len > 0)
|
||||
out.write(buf, 0, len);
|
||||
len = zip.read(buf);
|
||||
|
||||
percent = 0.0f;
|
||||
if( totalLen > 0 )
|
||||
percent = stream.getBytesRead() * 100.0f / totalLen;
|
||||
if( System.currentTimeMillis() > updateStatusTime + 1000 )
|
||||
{
|
||||
updateStatusTime = System.currentTimeMillis();
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_progress, percent, path) );
|
||||
}
|
||||
}
|
||||
out.flush();
|
||||
out.close();
|
||||
out = null;
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
Log.i("SDL", "Saving file '" + path + "' - error writing or downloading: " + e.toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
long count = 0, ret = 0;
|
||||
CheckedInputStream check = new CheckedInputStream( new FileInputStream(path), new CRC32() );
|
||||
while( ret >= 0 )
|
||||
{
|
||||
count += ret;
|
||||
ret = check.read(buf, 0, buf.length);
|
||||
}
|
||||
check.close();
|
||||
if( check.getChecksum().getValue() != entry.getCrc() || count != entry.getSize() )
|
||||
{
|
||||
File ff = new File(path);
|
||||
ff.delete();
|
||||
Log.i("SDL", "Saving file '" + path + "' - CRC check failed, ZIP: " +
|
||||
String.format("%x", entry.getCrc()) + " actual file: " + String.format("%x", check.getChecksum().getValue()) +
|
||||
" file size in ZIP: " + entry.getSize() + " actual size " + count );
|
||||
throw new Exception();
|
||||
}
|
||||
} catch( Exception e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
return false;
|
||||
}
|
||||
Log.i("SDL", "Saving file '" + path + "' done");
|
||||
}
|
||||
};
|
||||
|
||||
OutputStream out = null;
|
||||
path = getOutFilePath(DownloadFlagFileName);
|
||||
try {
|
||||
out = new FileOutputStream( path );
|
||||
out.write(downloadUrls[downloadUrlIndex].getBytes("UTF-8"));
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch( java.io.IOException e ) {
|
||||
Status.setText( res.getString(R.string.error_write, path) + ": " + e.getMessage() );
|
||||
return false;
|
||||
};
|
||||
Status.setText( downloadCount + "/" + downloadTotal + ": " + res.getString(R.string.dl_finished) );
|
||||
|
||||
try {
|
||||
stream.close();
|
||||
} catch( java.io.IOException e ) {
|
||||
};
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
private void initParent()
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity Parent;
|
||||
public void run()
|
||||
{
|
||||
Parent.initSDL();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
synchronized(this) {
|
||||
cb.Parent = Parent;
|
||||
if(Parent != null)
|
||||
Parent.runOnUiThread(cb);
|
||||
}
|
||||
}
|
||||
|
||||
private String getOutFilePath(final String filename)
|
||||
{
|
||||
return outFilesDir + "/" + filename;
|
||||
};
|
||||
|
||||
private static DefaultHttpClient HttpWithDisabledSslCertCheck()
|
||||
{
|
||||
return new DefaultHttpClient();
|
||||
// This code does not work
|
||||
/*
|
||||
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
|
||||
|
||||
DefaultHttpClient client = new DefaultHttpClient();
|
||||
|
||||
SchemeRegistry registry = new SchemeRegistry();
|
||||
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
|
||||
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
|
||||
registry.register(new Scheme("https", socketFactory, 443));
|
||||
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
|
||||
DefaultHttpClient http = new DefaultHttpClient(mgr, client.getParams());
|
||||
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
|
||||
|
||||
return http;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public class BackKeyListener implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
public BackKeyListener(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
if( DownloadFailed )
|
||||
System.exit(1);
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.cancel_download));
|
||||
builder.setMessage(p.getResources().getString(R.string.cancel_download) + (DownloadCanBeResumed ? " " + p.getResources().getString(R.string.cancel_download_resume) : ""));
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
System.exit(1);
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
public StatusWriter Status;
|
||||
public boolean DownloadComplete = false;
|
||||
public boolean DownloadFailed = false;
|
||||
public boolean DownloadCanBeResumed = false;
|
||||
private MainActivity Parent;
|
||||
private String outFilesDir = null;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
/*import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import java.util.Vector;*/
|
||||
import android.view.KeyEvent;
|
||||
|
||||
class Globals
|
||||
{
|
||||
// These config options are modified by ChangeAppsettings.sh script - see the detailed descriptions there
|
||||
public static String ApplicationName = "CommanderGenius";
|
||||
public static String AppLibraries[] = { "sdl-1.2", };
|
||||
public static String AppMainLibraries[] = { "application", "sdl_main" };
|
||||
public static final boolean Using_SDL_1_3 = false;
|
||||
public static final boolean Using_SDL_2_0 = false;
|
||||
public static String[] DataDownloadUrl = { "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download", "High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download" };
|
||||
public static int VideoDepthBpp = 16;
|
||||
public static boolean SwVideoMode = false;
|
||||
public static boolean NeedDepthBuffer = false;
|
||||
public static boolean NeedStencilBuffer = false;
|
||||
public static boolean NeedGles2 = false;
|
||||
public static boolean CompatibilityHacksVideo = false;
|
||||
public static boolean CompatibilityHacksStaticInit = false;
|
||||
public static boolean CompatibilityHacksTextInputEmulatesHwKeyboard = false;
|
||||
public static boolean HorizontalOrientation = true;
|
||||
public static boolean KeepAspectRatioDefaultSetting = false;
|
||||
public static boolean InhibitSuspend = false;
|
||||
public static String ReadmeText = "^You may press \"Home\" now - the data will be downloaded in background".replace("^","\n");
|
||||
public static String CommandLine = "";
|
||||
public static boolean AppUsesMouse = false;
|
||||
public static boolean AppNeedsTwoButtonMouse = false;
|
||||
public static boolean ForceRelativeMouseMode = false; // If both on-screen keyboard and mouse are needed, this will only set the default setting, user may override it later
|
||||
public static boolean ShowMouseCursor = false;
|
||||
public static boolean AppNeedsArrowKeys = true;
|
||||
public static boolean AppNeedsTextInput = true;
|
||||
public static boolean AppUsesJoystick = false;
|
||||
public static boolean AppUsesSecondJoystick = false;
|
||||
public static boolean AppUsesAccelerometer = false;
|
||||
public static boolean AppUsesGyroscope = false;
|
||||
public static boolean AppUsesMultitouch = false;
|
||||
public static boolean NonBlockingSwapBuffers = false;
|
||||
public static boolean ResetSdlConfigForThisVersion = false;
|
||||
public static String DeleteFilesOnUpgrade = "";
|
||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
||||
public static String[] AppTouchscreenKeyboardKeysNames = "Fire Shoot Switch_weapon Jump Run Hide/Seek".split(" ");
|
||||
public static int StartupMenuButtonTimeout = 3000;
|
||||
public static int AppMinimumRAM = 0;
|
||||
public static SettingsMenu.Menu HiddenMenuOptions [] = {}; // If you see error here - update HiddenMenuOptions in your AndroidAppSettings.cfg: change OptionalDownloadConfig to SettingsMenuMisc.OptionalDownloadConfig etc.
|
||||
public static SettingsMenu.Menu FirstStartMenuOptions [] = { new SettingsMenuMisc.ShowReadme(), (AppUsesMouse && ! ForceRelativeMouseMode ? new SettingsMenuMouse.DisplaySizeConfig() : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(), new SettingsMenuMisc.GyroscopeCalibration() };
|
||||
public static String AdmobPublisherId = "";
|
||||
public static String AdmobTestDeviceId = "";
|
||||
public static String AdmobBannerSize = "";
|
||||
|
||||
// Phone-specific config, modified by user in "Change phone config" startup dialog, TODO: move this to settings
|
||||
public static boolean DownloadToSdcard = true;
|
||||
public static boolean PhoneHasTrackball = false;
|
||||
public static boolean PhoneHasArrowKeys = false;
|
||||
public static boolean UseAccelerometerAsArrowKeys = false;
|
||||
public static boolean UseTouchscreenKeyboard = true;
|
||||
public static int TouchscreenKeyboardSize = 1;
|
||||
public static final int TOUCHSCREEN_KEYBOARD_CUSTOM = 4;
|
||||
public static int TouchscreenKeyboardDrawSize = 1;
|
||||
public static int TouchscreenKeyboardTheme = 2;
|
||||
public static int TouchscreenKeyboardTransparency = 2;
|
||||
public static int AccelerometerSensitivity = 2;
|
||||
public static int AccelerometerCenterPos = 2;
|
||||
public static int TrackballDampening = 0;
|
||||
public static int AudioBufferConfig = 0;
|
||||
public static boolean OptionalDataDownload[] = null;
|
||||
public static int LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||
public static int LeftClickKey = KeyEvent.KEYCODE_DPAD_CENTER;
|
||||
public static int LeftClickTimeout = 3;
|
||||
public static int RightClickTimeout = 4;
|
||||
public static int RightClickMethod = AppNeedsTwoButtonMouse ? Mouse.RIGHT_CLICK_WITH_MULTITOUCH : Mouse.RIGHT_CLICK_NONE;
|
||||
public static int RightClickKey = KeyEvent.KEYCODE_MENU;
|
||||
public static boolean MoveMouseWithJoystick = false;
|
||||
public static int MoveMouseWithJoystickSpeed = 0;
|
||||
public static int MoveMouseWithJoystickAccel = 0;
|
||||
public static boolean ClickMouseWithDpad = false;
|
||||
public static boolean RelativeMouseMovement = ForceRelativeMouseMode; // Laptop touchpad mode
|
||||
public static int RelativeMouseMovementSpeed = 2;
|
||||
public static int RelativeMouseMovementAccel = 0;
|
||||
public static int ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
public static boolean KeepAspectRatio = KeepAspectRatioDefaultSetting;
|
||||
public static int ClickScreenPressure = 0;
|
||||
public static int ClickScreenTouchspotSize = 0;
|
||||
public static int RemapHwKeycode[] = new int[SDL_Keys.JAVA_KEYCODE_LAST];
|
||||
public static int RemapScreenKbKeycode[] = new int[6];
|
||||
public static int ScreenKbControlsLayout[][] = AppUsesSecondJoystick ? // Values for 800x480 resolution
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 400, 392, 488, 480 }, { 312, 392, 400, 480 }, { 400, 304, 488, 392 }, { 312, 304, 400, 392 }, { 400, 216, 488, 304 }, { 312, 216, 400, 304 }, { 623, 303, 800, 480 } } :
|
||||
new int[][] { { 0, 303, 177, 480 }, { 0, 0, 48, 48 }, { 712, 392, 800, 480 }, { 624, 392, 712, 480 }, { 712, 304, 800, 392 }, { 624, 304, 712, 392 }, { 712, 216, 800, 304 }, { 624, 216, 712, 304 } };
|
||||
public static boolean ScreenKbControlsShown[] = new boolean[ScreenKbControlsLayout.length]; // Also joystick and text input button added
|
||||
public static int RemapMultitouchGestureKeycode[] = new int[4];
|
||||
public static boolean MultitouchGesturesUsed[] = new boolean[4];
|
||||
public static int MultitouchGestureSensitivity = 1;
|
||||
public static int TouchscreenCalibration[] = new int[4];
|
||||
public static String DataDir = new String("");
|
||||
public static boolean VideoLinearFilter = true;
|
||||
public static boolean MultiThreadedVideo = false;
|
||||
public static boolean BrokenLibCMessageShown = false;
|
||||
// Gyroscope calibration
|
||||
public static float gyro_x1, gyro_x2, gyro_xc, gyro_y1, gyro_y2, gyro_yc, gyro_z1, gyro_z2, gyro_zc;
|
||||
public static boolean OuyaEmulation = false; // For debugging
|
||||
}
|
||||
22
project/javaSDL2/HIDDevice.java
Normal file
22
project/javaSDL2/HIDDevice.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.hardware.usb.UsbDevice;
|
||||
|
||||
interface HIDDevice
|
||||
{
|
||||
public int getId();
|
||||
public int getVendorId();
|
||||
public int getProductId();
|
||||
public String getSerialNumber();
|
||||
public int getVersion();
|
||||
public String getManufacturerName();
|
||||
public String getProductName();
|
||||
public UsbDevice getDevice();
|
||||
public boolean open();
|
||||
public int sendFeatureReport(byte[] report);
|
||||
public int sendOutputReport(byte[] report);
|
||||
public boolean getFeatureReport(byte[] report);
|
||||
public void setFrozen(boolean frozen);
|
||||
public void close();
|
||||
public void shutdown();
|
||||
}
|
||||
650
project/javaSDL2/HIDDeviceBLESteamController.java
Normal file
650
project/javaSDL2/HIDDeviceBLESteamController.java
Normal file
@@ -0,0 +1,650 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCallback;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.bluetooth.BluetoothGattDescriptor;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.bluetooth.BluetoothGattService;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.os.*;
|
||||
|
||||
//import com.android.internal.util.HexDump;
|
||||
|
||||
import java.lang.Runnable;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.UUID;
|
||||
|
||||
class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDevice {
|
||||
|
||||
private static final String TAG = "hidapi";
|
||||
private HIDDeviceManager mManager;
|
||||
private BluetoothDevice mDevice;
|
||||
private int mDeviceId;
|
||||
private BluetoothGatt mGatt;
|
||||
private boolean mIsRegistered = false;
|
||||
private boolean mIsConnected = false;
|
||||
private boolean mIsChromebook = false;
|
||||
private boolean mIsReconnecting = false;
|
||||
private boolean mFrozen = false;
|
||||
private LinkedList<GattOperation> mOperations;
|
||||
GattOperation mCurrentOperation = null;
|
||||
private Handler mHandler;
|
||||
|
||||
private static final int TRANSPORT_AUTO = 0;
|
||||
private static final int TRANSPORT_BREDR = 1;
|
||||
private static final int TRANSPORT_LE = 2;
|
||||
|
||||
private static final int CHROMEBOOK_CONNECTION_CHECK_INTERVAL = 10000;
|
||||
|
||||
static public final UUID steamControllerService = UUID.fromString("100F6C32-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID inputCharacteristic = UUID.fromString("100F6C33-1735-4313-B402-38567131E5F3");
|
||||
static public final UUID reportCharacteristic = UUID.fromString("100F6C34-1735-4313-B402-38567131E5F3");
|
||||
static private final byte[] enterValveMode = new byte[] { (byte)0xC0, (byte)0x87, 0x03, 0x08, 0x07, 0x00 };
|
||||
|
||||
static class GattOperation {
|
||||
private enum Operation {
|
||||
CHR_READ,
|
||||
CHR_WRITE,
|
||||
ENABLE_NOTIFICATION
|
||||
}
|
||||
|
||||
Operation mOp;
|
||||
UUID mUuid;
|
||||
byte[] mValue;
|
||||
BluetoothGatt mGatt;
|
||||
boolean mResult = true;
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
}
|
||||
|
||||
private GattOperation(BluetoothGatt gatt, GattOperation.Operation operation, UUID uuid, byte[] value) {
|
||||
mGatt = gatt;
|
||||
mOp = operation;
|
||||
mUuid = uuid;
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// This is executed in main thread
|
||||
BluetoothGattCharacteristic chr;
|
||||
|
||||
switch (mOp) {
|
||||
case CHR_READ:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Reading characteristic " + chr.getUuid());
|
||||
if (!mGatt.readCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to read characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case CHR_WRITE:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing characteristic " + chr.getUuid() + " value=" + HexDump.toHexString(value));
|
||||
chr.setValue(mValue);
|
||||
if (!mGatt.writeCharacteristic(chr)) {
|
||||
Log.e(TAG, "Unable to write characteristic " + mUuid.toString());
|
||||
mResult = false;
|
||||
break;
|
||||
}
|
||||
mResult = true;
|
||||
break;
|
||||
case ENABLE_NOTIFICATION:
|
||||
chr = getCharacteristic(mUuid);
|
||||
//Log.v(TAG, "Writing descriptor of " + chr.getUuid());
|
||||
if (chr != null) {
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
int properties = chr.getProperties();
|
||||
byte[] value;
|
||||
if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) == BluetoothGattCharacteristic.PROPERTY_NOTIFY) {
|
||||
value = BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE;
|
||||
} else if ((properties & BluetoothGattCharacteristic.PROPERTY_INDICATE) == BluetoothGattCharacteristic.PROPERTY_INDICATE) {
|
||||
value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE;
|
||||
} else {
|
||||
Log.e(TAG, "Unable to start notifications on input characteristic");
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mGatt.setCharacteristicNotification(chr, true);
|
||||
cccd.setValue(value);
|
||||
if (!mGatt.writeDescriptor(cccd)) {
|
||||
Log.e(TAG, "Unable to write descriptor " + mUuid.toString());
|
||||
mResult = false;
|
||||
return;
|
||||
}
|
||||
mResult = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean finish() {
|
||||
return mResult;
|
||||
}
|
||||
|
||||
private BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
|
||||
BluetoothGattService valveService = mGatt.getService(steamControllerService);
|
||||
if (valveService == null)
|
||||
return null;
|
||||
return valveService.getCharacteristic(uuid);
|
||||
}
|
||||
|
||||
static public GattOperation readCharacteristic(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.CHR_READ, uuid);
|
||||
}
|
||||
|
||||
static public GattOperation writeCharacteristic(BluetoothGatt gatt, UUID uuid, byte[] value) {
|
||||
return new GattOperation(gatt, Operation.CHR_WRITE, uuid, value);
|
||||
}
|
||||
|
||||
static public GattOperation enableNotification(BluetoothGatt gatt, UUID uuid) {
|
||||
return new GattOperation(gatt, Operation.ENABLE_NOTIFICATION, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public HIDDeviceBLESteamController(HIDDeviceManager manager, BluetoothDevice device) {
|
||||
mManager = manager;
|
||||
mDevice = device;
|
||||
mDeviceId = mManager.getDeviceIDForIdentifier(getIdentifier());
|
||||
mIsRegistered = false;
|
||||
mIsChromebook = mManager.getContext().getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
||||
mOperations = new LinkedList<GattOperation>();
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
mGatt = connectGatt();
|
||||
// final HIDDeviceBLESteamController finalThis = this;
|
||||
// mHandler.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// finalThis.checkConnectionForChromebookIssue();
|
||||
// }
|
||||
// }, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return String.format("SteamController.%s", mDevice.getAddress());
|
||||
}
|
||||
|
||||
public BluetoothGatt getGatt() {
|
||||
return mGatt;
|
||||
}
|
||||
|
||||
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
|
||||
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
|
||||
private BluetoothGatt connectGatt(boolean managed) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
try {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
|
||||
} catch (Exception e) {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
} else {
|
||||
return mDevice.connectGatt(mManager.getContext(), managed, this);
|
||||
}
|
||||
}
|
||||
|
||||
private BluetoothGatt connectGatt() {
|
||||
return connectGatt(false);
|
||||
}
|
||||
|
||||
protected int getConnectionState() {
|
||||
|
||||
Context context = mManager.getContext();
|
||||
if (context == null) {
|
||||
// We are lacking any context to get our Bluetooth information. We'll just assume disconnected.
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
BluetoothManager btManager = (BluetoothManager)context.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
if (btManager == null) {
|
||||
// This device doesn't support Bluetooth. We should never be here, because how did
|
||||
// we instantiate a device to start with?
|
||||
return BluetoothProfile.STATE_DISCONNECTED;
|
||||
}
|
||||
|
||||
return btManager.getConnectionState(mDevice, BluetoothProfile.GATT);
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
|
||||
if (getConnectionState() != BluetoothProfile.STATE_CONNECTED) {
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void checkConnectionForChromebookIssue() {
|
||||
if (!mIsChromebook) {
|
||||
// We only do this on Chromebooks, because otherwise it's really annoying to just attempt
|
||||
// over and over.
|
||||
return;
|
||||
}
|
||||
|
||||
int connectionState = getConnectionState();
|
||||
|
||||
switch (connectionState) {
|
||||
case BluetoothProfile.STATE_CONNECTED:
|
||||
if (!mIsConnected) {
|
||||
// We are in the Bad Chromebook Place. We can force a disconnect
|
||||
// to try to recover.
|
||||
Log.v(TAG, "Chromebook: We are in a very bad state; the controller shows as connected in the underlying Bluetooth layer, but we never received a callback. Forcing a reconnect.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
else if (!isRegistered()) {
|
||||
if (mGatt.getServices().size() > 0) {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never got our registration. Trying to recover.");
|
||||
probeService(this);
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected to a controller, but never discovered services. Trying to recover.");
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Log.v(TAG, "Chromebook: We are connected, and registered. Everything's good!");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_DISCONNECTED:
|
||||
Log.v(TAG, "Chromebook: We have either been disconnected, or the Chromebook BtGatt.ContextMap bug has bitten us. Attempting a disconnect/reconnect, but we may not be able to recover.");
|
||||
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
break;
|
||||
|
||||
case BluetoothProfile.STATE_CONNECTING:
|
||||
Log.v(TAG, "Chromebook: We're still trying to connect. Waiting a bit longer.");
|
||||
break;
|
||||
}
|
||||
|
||||
final HIDDeviceBLESteamController finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.checkConnectionForChromebookIssue();
|
||||
}
|
||||
}, CHROMEBOOK_CONNECTION_CHECK_INTERVAL);
|
||||
}
|
||||
|
||||
private boolean isRegistered() {
|
||||
return mIsRegistered;
|
||||
}
|
||||
|
||||
private void setRegistered() {
|
||||
mIsRegistered = true;
|
||||
}
|
||||
|
||||
private boolean probeService(HIDDeviceBLESteamController controller) {
|
||||
|
||||
if (isRegistered()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!mIsConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.v(TAG, "probeService controller=" + controller);
|
||||
|
||||
for (BluetoothGattService service : mGatt.getServices()) {
|
||||
if (service.getUuid().equals(steamControllerService)) {
|
||||
Log.v(TAG, "Found Valve steam controller service " + service.getUuid());
|
||||
|
||||
for (BluetoothGattCharacteristic chr : service.getCharacteristics()) {
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
Log.v(TAG, "Found input characteristic");
|
||||
// Start notifications
|
||||
BluetoothGattDescriptor cccd = chr.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
|
||||
if (cccd != null) {
|
||||
enableNotification(chr.getUuid());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mGatt.getServices().size() == 0) && mIsChromebook && !mIsReconnecting) {
|
||||
Log.e(TAG, "Chromebook: Discovered services were empty; this almost certainly means the BtGatt.ContextMap bug has bitten us.");
|
||||
mIsConnected = false;
|
||||
mIsReconnecting = true;
|
||||
mGatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private void finishCurrentGattOperation() {
|
||||
GattOperation op = null;
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null) {
|
||||
op = mCurrentOperation;
|
||||
mCurrentOperation = null;
|
||||
}
|
||||
}
|
||||
if (op != null) {
|
||||
boolean result = op.finish(); // TODO: Maybe in main thread as well?
|
||||
|
||||
// Our operation failed, let's add it back to the beginning of our queue.
|
||||
if (!result) {
|
||||
mOperations.addFirst(op);
|
||||
}
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void executeNextGattOperation() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation != null)
|
||||
return;
|
||||
|
||||
if (mOperations.isEmpty())
|
||||
return;
|
||||
|
||||
mCurrentOperation = mOperations.removeFirst();
|
||||
}
|
||||
|
||||
// Run in main thread
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (mOperations) {
|
||||
if (mCurrentOperation == null) {
|
||||
Log.e(TAG, "Current operation null in executor?");
|
||||
return;
|
||||
}
|
||||
|
||||
mCurrentOperation.run();
|
||||
// now wait for the GATT callback and when it comes, finish this operation
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void queueGattOperation(GattOperation op) {
|
||||
synchronized (mOperations) {
|
||||
mOperations.add(op);
|
||||
}
|
||||
executeNextGattOperation();
|
||||
}
|
||||
|
||||
private void enableNotification(UUID chrUuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.enableNotification(mGatt, chrUuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void writeCharacteristic(UUID uuid, byte[] value) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.writeCharacteristic(mGatt, uuid, value);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
public void readCharacteristic(UUID uuid) {
|
||||
GattOperation op = HIDDeviceBLESteamController.GattOperation.readCharacteristic(mGatt, uuid);
|
||||
queueGattOperation(op);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////////// BluetoothGattCallback overridden methods
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onConnectionStateChange(BluetoothGatt g, int status, int newState) {
|
||||
//Log.v(TAG, "onConnectionStateChange status=" + status + " newState=" + newState);
|
||||
mIsReconnecting = false;
|
||||
if (newState == 2) {
|
||||
mIsConnected = true;
|
||||
// Run directly, without GattOperation
|
||||
if (!isRegistered()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mGatt.discoverServices();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (newState == 0) {
|
||||
mIsConnected = false;
|
||||
}
|
||||
|
||||
// Disconnection is handled in SteamLink using the ACTION_ACL_DISCONNECTED Intent.
|
||||
}
|
||||
|
||||
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onServicesDiscovered status=" + status);
|
||||
if (status == 0) {
|
||||
if (gatt.getServices().size() == 0) {
|
||||
Log.v(TAG, "onServicesDiscovered returned zero services; something has gone horribly wrong down in Android's Bluetooth stack.");
|
||||
mIsReconnecting = true;
|
||||
mIsConnected = false;
|
||||
gatt.disconnect();
|
||||
mGatt = connectGatt(false);
|
||||
}
|
||||
else {
|
||||
probeService(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicRead status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceFeatureReport(getId(), characteristic.getValue());
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
||||
//Log.v(TAG, "onCharacteristicWrite status=" + status + " uuid=" + characteristic.getUuid());
|
||||
|
||||
if (characteristic.getUuid().equals(reportCharacteristic)) {
|
||||
// Only register controller with the native side once it has been fully configured
|
||||
if (!isRegistered()) {
|
||||
Log.v(TAG, "Registering Steam Controller with ID: " + getId());
|
||||
mManager.HIDDeviceConnected(getId(), getIdentifier(), getVendorId(), getProductId(), getSerialNumber(), getVersion(), getManufacturerName(), getProductName(), 0, 0, 0, 0);
|
||||
setRegistered();
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
// Enable this for verbose logging of controller input reports
|
||||
//Log.v(TAG, "onCharacteristicChanged uuid=" + characteristic.getUuid() + " data=" + HexDump.dumpHexString(characteristic.getValue()));
|
||||
|
||||
if (characteristic.getUuid().equals(inputCharacteristic) && !mFrozen) {
|
||||
mManager.HIDDeviceInputReport(getId(), characteristic.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
//Log.v(TAG, "onDescriptorRead status=" + status);
|
||||
}
|
||||
|
||||
public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
|
||||
BluetoothGattCharacteristic chr = descriptor.getCharacteristic();
|
||||
//Log.v(TAG, "onDescriptorWrite status=" + status + " uuid=" + chr.getUuid() + " descriptor=" + descriptor.getUuid());
|
||||
|
||||
if (chr.getUuid().equals(inputCharacteristic)) {
|
||||
boolean hasWrittenInputDescriptor = true;
|
||||
BluetoothGattCharacteristic reportChr = chr.getService().getCharacteristic(reportCharacteristic);
|
||||
if (reportChr != null) {
|
||||
Log.v(TAG, "Writing report characteristic to enter valve mode");
|
||||
reportChr.setValue(enterValveMode);
|
||||
gatt.writeCharacteristic(reportChr);
|
||||
}
|
||||
}
|
||||
|
||||
finishCurrentGattOperation();
|
||||
}
|
||||
|
||||
public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
|
||||
//Log.v(TAG, "onReliableWriteCompleted status=" + status);
|
||||
}
|
||||
|
||||
public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
|
||||
//Log.v(TAG, "onReadRemoteRssi status=" + status);
|
||||
}
|
||||
|
||||
public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
|
||||
//Log.v(TAG, "onMtuChanged status=" + status);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////// Public API
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId() {
|
||||
// Valve Corporation
|
||||
final int VALVE_USB_VID = 0x28DE;
|
||||
return VALVE_USB_VID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProductId() {
|
||||
// We don't have an easy way to query from the Bluetooth device, but we know what it is
|
||||
final int D0G_BLE2_PID = 0x1106;
|
||||
return D0G_BLE2_PID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerialNumber() {
|
||||
// This will be read later via feature report by Steam
|
||||
return "12345";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturerName() {
|
||||
return "Valve Corporation";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName() {
|
||||
return "Steam Controller";
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsbDevice getDevice() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// We need to skip the first byte, as that doesn't go over the air
|
||||
byte[] actual_report = Arrays.copyOfRange(report, 1, report.length - 1);
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(actual_report));
|
||||
writeCharacteristic(reportCharacteristic, actual_report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendOutputReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted sendOutputReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "sendFeatureReport " + HexDump.dumpHexString(report));
|
||||
writeCharacteristic(reportCharacteristic, report);
|
||||
return report.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeatureReport(byte[] report) {
|
||||
if (!isRegistered()) {
|
||||
Log.e(TAG, "Attempted getFeatureReport before Steam Controller is registered!");
|
||||
if (mIsConnected) {
|
||||
probeService(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//Log.v(TAG, "getFeatureReport");
|
||||
readCharacteristic(reportCharacteristic);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrozen(boolean frozen) {
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
close();
|
||||
|
||||
BluetoothGatt g = mGatt;
|
||||
if (g != null) {
|
||||
g.disconnect();
|
||||
g.close();
|
||||
mGatt = null;
|
||||
}
|
||||
mManager = null;
|
||||
mIsRegistered = false;
|
||||
mIsConnected = false;
|
||||
mOperations.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
685
project/javaSDL2/HIDDeviceManager.java
Normal file
685
project/javaSDL2/HIDDeviceManager.java
Normal file
@@ -0,0 +1,685 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.bluetooth.BluetoothManager;
|
||||
import android.bluetooth.BluetoothProfile;
|
||||
import android.util.Log;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.hardware.usb.*;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class HIDDeviceManager {
|
||||
private static final String TAG = "hidapi";
|
||||
private static final String ACTION_USB_PERMISSION = "org.libsdl.app.USB_PERMISSION";
|
||||
|
||||
private static HIDDeviceManager sManager;
|
||||
private static int sManagerRefCount = 0;
|
||||
|
||||
public static HIDDeviceManager acquire(Context context) {
|
||||
if (sManagerRefCount == 0) {
|
||||
sManager = new HIDDeviceManager(context);
|
||||
}
|
||||
++sManagerRefCount;
|
||||
return sManager;
|
||||
}
|
||||
|
||||
public static void release(HIDDeviceManager manager) {
|
||||
if (manager == sManager) {
|
||||
--sManagerRefCount;
|
||||
if (sManagerRefCount == 0) {
|
||||
sManager.close();
|
||||
sManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
private HashMap<Integer, HIDDevice> mDevicesById = new HashMap<Integer, HIDDevice>();
|
||||
private HashMap<BluetoothDevice, HIDDeviceBLESteamController> mBluetoothDevices = new HashMap<BluetoothDevice, HIDDeviceBLESteamController>();
|
||||
private int mNextDeviceId = 0;
|
||||
private SharedPreferences mSharedPreferences = null;
|
||||
private boolean mIsChromebook = false;
|
||||
private UsbManager mUsbManager;
|
||||
private Handler mHandler;
|
||||
private BluetoothManager mBluetoothManager;
|
||||
private List<BluetoothDevice> mLastBluetoothDevices;
|
||||
|
||||
private final BroadcastReceiver mUsbBroadcast = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(UsbManager.ACTION_USB_DEVICE_ATTACHED)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDeviceAttached(usbDevice);
|
||||
} else if (action.equals(UsbManager.ACTION_USB_DEVICE_DETACHED)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDeviceDetached(usbDevice);
|
||||
} else if (action.equals(HIDDeviceManager.ACTION_USB_PERMISSION)) {
|
||||
UsbDevice usbDevice = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
|
||||
handleUsbDevicePermission(usbDevice, intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver mBluetoothBroadcast = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
// Bluetooth device was connected. If it was a Steam Controller, handle it
|
||||
if (action.equals(BluetoothDevice.ACTION_ACL_CONNECTED)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Log.d(TAG, "Bluetooth device connected: " + device);
|
||||
|
||||
if (isSteamController(device)) {
|
||||
connectBluetoothDevice(device);
|
||||
}
|
||||
}
|
||||
|
||||
// Bluetooth device was disconnected, remove from controller manager (if any)
|
||||
if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
|
||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||
Log.d(TAG, "Bluetooth device disconnected: " + device);
|
||||
|
||||
disconnectBluetoothDevice(device);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private HIDDeviceManager(final Context context) {
|
||||
mContext = context;
|
||||
|
||||
// Make sure we have the HIDAPI library loaded with the native functions
|
||||
try {
|
||||
SDL.loadLibrary("hidapi");
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, "Couldn't load hidapi: " + e.toString());
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setCancelable(false);
|
||||
builder.setTitle("SDL HIDAPI Error");
|
||||
builder.setMessage("Please report the following error to the SDL maintainers: " + e.getMessage());
|
||||
builder.setNegativeButton("Quit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
try {
|
||||
// If our context is an activity, exit rather than crashing when we can't
|
||||
// call our native functions.
|
||||
Activity activity = (Activity)context;
|
||||
|
||||
activity.finish();
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
// Context wasn't an activity, there's nothing we can do. Give up and return.
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
HIDDeviceRegisterCallback();
|
||||
|
||||
mSharedPreferences = mContext.getSharedPreferences("hidapi", Context.MODE_PRIVATE);
|
||||
mIsChromebook = mContext.getPackageManager().hasSystemFeature("org.chromium.arc.device_management");
|
||||
|
||||
// if (shouldClear) {
|
||||
// SharedPreferences.Editor spedit = mSharedPreferences.edit();
|
||||
// spedit.clear();
|
||||
// spedit.commit();
|
||||
// }
|
||||
// else
|
||||
{
|
||||
mNextDeviceId = mSharedPreferences.getInt("next_device_id", 0);
|
||||
}
|
||||
|
||||
initializeUSB();
|
||||
initializeBluetooth();
|
||||
}
|
||||
|
||||
public Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public int getDeviceIDForIdentifier(String identifier) {
|
||||
SharedPreferences.Editor spedit = mSharedPreferences.edit();
|
||||
|
||||
int result = mSharedPreferences.getInt(identifier, 0);
|
||||
if (result == 0) {
|
||||
result = mNextDeviceId++;
|
||||
spedit.putInt("next_device_id", mNextDeviceId);
|
||||
}
|
||||
|
||||
spedit.putInt(identifier, result);
|
||||
spedit.commit();
|
||||
return result;
|
||||
}
|
||||
|
||||
private void initializeUSB() {
|
||||
mUsbManager = (UsbManager)mContext.getSystemService(Context.USB_SERVICE);
|
||||
|
||||
/*
|
||||
// Logging
|
||||
for (UsbDevice device : mUsbManager.getDeviceList().values()) {
|
||||
Log.i(TAG,"Path: " + device.getDeviceName());
|
||||
Log.i(TAG,"Manufacturer: " + device.getManufacturerName());
|
||||
Log.i(TAG,"Product: " + device.getProductName());
|
||||
Log.i(TAG,"ID: " + device.getDeviceId());
|
||||
Log.i(TAG,"Class: " + device.getDeviceClass());
|
||||
Log.i(TAG,"Protocol: " + device.getDeviceProtocol());
|
||||
Log.i(TAG,"Vendor ID " + device.getVendorId());
|
||||
Log.i(TAG,"Product ID: " + device.getProductId());
|
||||
Log.i(TAG,"Interface count: " + device.getInterfaceCount());
|
||||
Log.i(TAG,"---------------------------------------");
|
||||
|
||||
// Get interface details
|
||||
for (int index = 0; index < device.getInterfaceCount(); index++) {
|
||||
UsbInterface mUsbInterface = device.getInterface(index);
|
||||
Log.i(TAG," ***** *****");
|
||||
Log.i(TAG," Interface index: " + index);
|
||||
Log.i(TAG," Interface ID: " + mUsbInterface.getId());
|
||||
Log.i(TAG," Interface class: " + mUsbInterface.getInterfaceClass());
|
||||
Log.i(TAG," Interface subclass: " + mUsbInterface.getInterfaceSubclass());
|
||||
Log.i(TAG," Interface protocol: " + mUsbInterface.getInterfaceProtocol());
|
||||
Log.i(TAG," Endpoint count: " + mUsbInterface.getEndpointCount());
|
||||
|
||||
// Get endpoint details
|
||||
for (int epi = 0; epi < mUsbInterface.getEndpointCount(); epi++)
|
||||
{
|
||||
UsbEndpoint mEndpoint = mUsbInterface.getEndpoint(epi);
|
||||
Log.i(TAG," ++++ ++++ ++++");
|
||||
Log.i(TAG," Endpoint index: " + epi);
|
||||
Log.i(TAG," Attributes: " + mEndpoint.getAttributes());
|
||||
Log.i(TAG," Direction: " + mEndpoint.getDirection());
|
||||
Log.i(TAG," Number: " + mEndpoint.getEndpointNumber());
|
||||
Log.i(TAG," Interval: " + mEndpoint.getInterval());
|
||||
Log.i(TAG," Packet size: " + mEndpoint.getMaxPacketSize());
|
||||
Log.i(TAG," Type: " + mEndpoint.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.i(TAG," No more devices connected.");
|
||||
*/
|
||||
|
||||
// Register for USB broadcasts and permission completions
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED);
|
||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
|
||||
filter.addAction(HIDDeviceManager.ACTION_USB_PERMISSION);
|
||||
mContext.registerReceiver(mUsbBroadcast, filter);
|
||||
|
||||
for (UsbDevice usbDevice : mUsbManager.getDeviceList().values()) {
|
||||
handleUsbDeviceAttached(usbDevice);
|
||||
}
|
||||
}
|
||||
|
||||
UsbManager getUSBManager() {
|
||||
return mUsbManager;
|
||||
}
|
||||
|
||||
private void shutdownUSB() {
|
||||
try {
|
||||
mContext.unregisterReceiver(mUsbBroadcast);
|
||||
} catch (Exception e) {
|
||||
// We may not have registered, that's okay
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isHIDDeviceInterface(UsbDevice usbDevice, UsbInterface usbInterface) {
|
||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_HID) {
|
||||
return true;
|
||||
}
|
||||
if (isXbox360Controller(usbDevice, usbInterface) || isXboxOneController(usbDevice, usbInterface)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isXbox360Controller(UsbDevice usbDevice, UsbInterface usbInterface) {
|
||||
final int XB360_IFACE_SUBCLASS = 93;
|
||||
final int XB360_IFACE_PROTOCOL = 1; // Wired
|
||||
final int XB360W_IFACE_PROTOCOL = 129; // Wireless
|
||||
final int[] SUPPORTED_VENDORS = {
|
||||
0x0079, // GPD Win 2
|
||||
0x044f, // Thrustmaster
|
||||
0x045e, // Microsoft
|
||||
0x046d, // Logitech
|
||||
0x056e, // Elecom
|
||||
0x06a3, // Saitek
|
||||
0x0738, // Mad Catz
|
||||
0x07ff, // Mad Catz
|
||||
0x0e6f, // PDP
|
||||
0x0f0d, // Hori
|
||||
0x1038, // SteelSeries
|
||||
0x11c9, // Nacon
|
||||
0x12ab, // Unknown
|
||||
0x1430, // RedOctane
|
||||
0x146b, // BigBen
|
||||
0x1532, // Razer Sabertooth
|
||||
0x15e4, // Numark
|
||||
0x162e, // Joytech
|
||||
0x1689, // Razer Onza
|
||||
0x1bad, // Harmonix
|
||||
0x24c6, // PowerA
|
||||
};
|
||||
|
||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
||||
usbInterface.getInterfaceSubclass() == XB360_IFACE_SUBCLASS &&
|
||||
(usbInterface.getInterfaceProtocol() == XB360_IFACE_PROTOCOL ||
|
||||
usbInterface.getInterfaceProtocol() == XB360W_IFACE_PROTOCOL)) {
|
||||
int vendor_id = usbDevice.getVendorId();
|
||||
for (int supportedVid : SUPPORTED_VENDORS) {
|
||||
if (vendor_id == supportedVid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterface) {
|
||||
final int XB1_IFACE_SUBCLASS = 71;
|
||||
final int XB1_IFACE_PROTOCOL = 208;
|
||||
final int[] SUPPORTED_VENDORS = {
|
||||
0x045e, // Microsoft
|
||||
0x0738, // Mad Catz
|
||||
0x0e6f, // PDP
|
||||
0x0f0d, // Hori
|
||||
0x1532, // Razer Wildcat
|
||||
0x24c6, // PowerA
|
||||
0x2e24, // Hyperkin
|
||||
};
|
||||
|
||||
if (usbInterface.getId() == 0 &&
|
||||
usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
||||
usbInterface.getInterfaceSubclass() == XB1_IFACE_SUBCLASS &&
|
||||
usbInterface.getInterfaceProtocol() == XB1_IFACE_PROTOCOL) {
|
||||
int vendor_id = usbDevice.getVendorId();
|
||||
for (int supportedVid : SUPPORTED_VENDORS) {
|
||||
if (vendor_id == supportedVid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleUsbDeviceAttached(UsbDevice usbDevice) {
|
||||
connectHIDDeviceUSB(usbDevice);
|
||||
}
|
||||
|
||||
private void handleUsbDeviceDetached(UsbDevice usbDevice) {
|
||||
List<Integer> devices = new ArrayList<Integer>();
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
if (usbDevice.equals(device.getDevice())) {
|
||||
devices.add(device.getId());
|
||||
}
|
||||
}
|
||||
for (int id : devices) {
|
||||
HIDDevice device = mDevicesById.get(id);
|
||||
mDevicesById.remove(id);
|
||||
device.shutdown();
|
||||
HIDDeviceDisconnected(id);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUsbDevicePermission(UsbDevice usbDevice, boolean permission_granted) {
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
if (usbDevice.equals(device.getDevice())) {
|
||||
boolean opened = false;
|
||||
if (permission_granted) {
|
||||
opened = device.open();
|
||||
}
|
||||
HIDDeviceOpenResult(device.getId(), opened);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void connectHIDDeviceUSB(UsbDevice usbDevice) {
|
||||
synchronized (this) {
|
||||
for (int interface_index = 0; interface_index < usbDevice.getInterfaceCount(); interface_index++) {
|
||||
UsbInterface usbInterface = usbDevice.getInterface(interface_index);
|
||||
if (isHIDDeviceInterface(usbDevice, usbInterface)) {
|
||||
HIDDeviceUSB device = new HIDDeviceUSB(this, usbDevice, interface_index);
|
||||
int id = device.getId();
|
||||
mDevicesById.put(id, device);
|
||||
|
||||
if (usbDevice != null && !mUsbManager.hasPermission(usbDevice))
|
||||
{
|
||||
HIDDeviceOpenPending(id);
|
||||
try
|
||||
{
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
||||
HIDDeviceOpenResult(id, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HIDDeviceConnected(id, device.getIdentifier(), device.getVendorId(), device.getProductId(), device.getSerialNumber(), device.getVersion(), device.getManufacturerName(), device.getProductName(), usbInterface.getId(), usbInterface.getInterfaceClass(), usbInterface.getInterfaceSubclass(), usbInterface.getInterfaceProtocol());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeBluetooth() {
|
||||
Log.d(TAG, "Initializing Bluetooth");
|
||||
|
||||
if (mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
|
||||
return;
|
||||
}
|
||||
|
||||
// Find bonded bluetooth controllers and create SteamControllers for them
|
||||
mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE);
|
||||
if (mBluetoothManager == null) {
|
||||
// This device doesn't support Bluetooth.
|
||||
return;
|
||||
}
|
||||
|
||||
BluetoothAdapter btAdapter = mBluetoothManager.getAdapter();
|
||||
if (btAdapter == null) {
|
||||
// This device has Bluetooth support in the codebase, but has no available adapters.
|
||||
return;
|
||||
}
|
||||
|
||||
// Get our bonded devices.
|
||||
for (BluetoothDevice device : btAdapter.getBondedDevices()) {
|
||||
|
||||
Log.d(TAG, "Bluetooth device available: " + device);
|
||||
if (isSteamController(device)) {
|
||||
connectBluetoothDevice(device);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// NOTE: These don't work on Chromebooks, to my undying dismay.
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||
filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||
mContext.registerReceiver(mBluetoothBroadcast, filter);
|
||||
|
||||
if (mIsChromebook) {
|
||||
mHandler = new Handler(Looper.getMainLooper());
|
||||
mLastBluetoothDevices = new ArrayList<BluetoothDevice>();
|
||||
|
||||
// final HIDDeviceManager finalThis = this;
|
||||
// mHandler.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// finalThis.chromebookConnectionHandler();
|
||||
// }
|
||||
// }, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private void shutdownBluetooth() {
|
||||
try {
|
||||
mContext.unregisterReceiver(mBluetoothBroadcast);
|
||||
} catch (Exception e) {
|
||||
// We may not have registered, that's okay
|
||||
}
|
||||
}
|
||||
|
||||
// Chromebooks do not pass along ACTION_ACL_CONNECTED / ACTION_ACL_DISCONNECTED properly.
|
||||
// This function provides a sort of dummy version of that, watching for changes in the
|
||||
// connected devices and attempting to add controllers as things change.
|
||||
public void chromebookConnectionHandler() {
|
||||
if (!mIsChromebook) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<BluetoothDevice> disconnected = new ArrayList<BluetoothDevice>();
|
||||
ArrayList<BluetoothDevice> connected = new ArrayList<BluetoothDevice>();
|
||||
|
||||
List<BluetoothDevice> currentConnected = mBluetoothManager.getConnectedDevices(BluetoothProfile.GATT);
|
||||
|
||||
for (BluetoothDevice bluetoothDevice : currentConnected) {
|
||||
if (!mLastBluetoothDevices.contains(bluetoothDevice)) {
|
||||
connected.add(bluetoothDevice);
|
||||
}
|
||||
}
|
||||
for (BluetoothDevice bluetoothDevice : mLastBluetoothDevices) {
|
||||
if (!currentConnected.contains(bluetoothDevice)) {
|
||||
disconnected.add(bluetoothDevice);
|
||||
}
|
||||
}
|
||||
|
||||
mLastBluetoothDevices = currentConnected;
|
||||
|
||||
for (BluetoothDevice bluetoothDevice : disconnected) {
|
||||
disconnectBluetoothDevice(bluetoothDevice);
|
||||
}
|
||||
for (BluetoothDevice bluetoothDevice : connected) {
|
||||
connectBluetoothDevice(bluetoothDevice);
|
||||
}
|
||||
|
||||
final HIDDeviceManager finalThis = this;
|
||||
mHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalThis.chromebookConnectionHandler();
|
||||
}
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
public boolean connectBluetoothDevice(BluetoothDevice bluetoothDevice) {
|
||||
Log.v(TAG, "connectBluetoothDevice device=" + bluetoothDevice);
|
||||
synchronized (this) {
|
||||
if (mBluetoothDevices.containsKey(bluetoothDevice)) {
|
||||
Log.v(TAG, "Steam controller with address " + bluetoothDevice + " already exists, attempting reconnect");
|
||||
|
||||
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
|
||||
device.reconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
HIDDeviceBLESteamController device = new HIDDeviceBLESteamController(this, bluetoothDevice);
|
||||
int id = device.getId();
|
||||
mBluetoothDevices.put(bluetoothDevice, device);
|
||||
mDevicesById.put(id, device);
|
||||
|
||||
// The Steam Controller will mark itself connected once initialization is complete
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void disconnectBluetoothDevice(BluetoothDevice bluetoothDevice) {
|
||||
synchronized (this) {
|
||||
HIDDeviceBLESteamController device = mBluetoothDevices.get(bluetoothDevice);
|
||||
if (device == null)
|
||||
return;
|
||||
|
||||
int id = device.getId();
|
||||
mBluetoothDevices.remove(bluetoothDevice);
|
||||
mDevicesById.remove(id);
|
||||
device.shutdown();
|
||||
HIDDeviceDisconnected(id);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSteamController(BluetoothDevice bluetoothDevice) {
|
||||
// Sanity check. If you pass in a null device, by definition it is never a Steam Controller.
|
||||
if (bluetoothDevice == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the device has no local name, we really don't want to try an equality check against it.
|
||||
if (bluetoothDevice.getName() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return bluetoothDevice.getName().equals("SteamController") && ((bluetoothDevice.getType() & BluetoothDevice.DEVICE_TYPE_LE) != 0);
|
||||
}
|
||||
|
||||
private void close() {
|
||||
shutdownUSB();
|
||||
shutdownBluetooth();
|
||||
synchronized (this) {
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
device.shutdown();
|
||||
}
|
||||
mDevicesById.clear();
|
||||
mBluetoothDevices.clear();
|
||||
HIDDeviceReleaseCallback();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFrozen(boolean frozen) {
|
||||
synchronized (this) {
|
||||
for (HIDDevice device : mDevicesById.values()) {
|
||||
device.setFrozen(frozen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private HIDDevice getDevice(int id) {
|
||||
synchronized (this) {
|
||||
HIDDevice result = mDevicesById.get(id);
|
||||
if (result == null) {
|
||||
Log.v(TAG, "No device for id: " + id);
|
||||
Log.v(TAG, "Available devices: " + mDevicesById.keySet());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
////////// JNI interface functions
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public boolean openDevice(int deviceID) {
|
||||
Log.v(TAG, "openDevice deviceID=" + deviceID);
|
||||
HIDDevice device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look to see if this is a USB device and we have permission to access it
|
||||
UsbDevice usbDevice = device.getDevice();
|
||||
if (usbDevice != null && !mUsbManager.hasPermission(usbDevice)) {
|
||||
HIDDeviceOpenPending(deviceID);
|
||||
try {
|
||||
mUsbManager.requestPermission(usbDevice, PendingIntent.getBroadcast(mContext, 0, new Intent(HIDDeviceManager.ACTION_USB_PERMISSION), 0));
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "Couldn't request permission for USB device " + usbDevice);
|
||||
HIDDeviceOpenResult(deviceID, false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return device.open();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int sendOutputReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
//Log.v(TAG, "sendOutputReport deviceID=" + deviceID + " length=" + report.length);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return device.sendOutputReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int sendFeatureReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
//Log.v(TAG, "sendFeatureReport deviceID=" + deviceID + " length=" + report.length);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return device.sendFeatureReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean getFeatureReport(int deviceID, byte[] report) {
|
||||
try {
|
||||
//Log.v(TAG, "getFeatureReport deviceID=" + deviceID);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return false;
|
||||
}
|
||||
|
||||
return device.getFeatureReport(report);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void closeDevice(int deviceID) {
|
||||
try {
|
||||
Log.v(TAG, "closeDevice deviceID=" + deviceID);
|
||||
HIDDevice device;
|
||||
device = getDevice(deviceID);
|
||||
if (device == null) {
|
||||
HIDDeviceDisconnected(deviceID);
|
||||
return;
|
||||
}
|
||||
|
||||
device.close();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Got exception: " + Log.getStackTraceString(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////// Native methods
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private native void HIDDeviceRegisterCallback();
|
||||
private native void HIDDeviceReleaseCallback();
|
||||
|
||||
native void HIDDeviceConnected(int deviceID, String identifier, int vendorId, int productId, String serial_number, int release_number, String manufacturer_string, String product_string, int interface_number, int interface_class, int interface_subclass, int interface_protocol);
|
||||
native void HIDDeviceOpenPending(int deviceID);
|
||||
native void HIDDeviceOpenResult(int deviceID, boolean opened);
|
||||
native void HIDDeviceDisconnected(int deviceID);
|
||||
|
||||
native void HIDDeviceInputReport(int deviceID, byte[] report);
|
||||
native void HIDDeviceFeatureReport(int deviceID, byte[] report);
|
||||
}
|
||||
304
project/javaSDL2/HIDDeviceUSB.java
Normal file
304
project/javaSDL2/HIDDeviceUSB.java
Normal file
@@ -0,0 +1,304 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.hardware.usb.*;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import java.util.Arrays;
|
||||
|
||||
class HIDDeviceUSB implements HIDDevice {
|
||||
|
||||
private static final String TAG = "hidapi";
|
||||
|
||||
protected HIDDeviceManager mManager;
|
||||
protected UsbDevice mDevice;
|
||||
protected int mInterfaceIndex;
|
||||
protected int mInterface;
|
||||
protected int mDeviceId;
|
||||
protected UsbDeviceConnection mConnection;
|
||||
protected UsbEndpoint mInputEndpoint;
|
||||
protected UsbEndpoint mOutputEndpoint;
|
||||
protected InputThread mInputThread;
|
||||
protected boolean mRunning;
|
||||
protected boolean mFrozen;
|
||||
|
||||
public HIDDeviceUSB(HIDDeviceManager manager, UsbDevice usbDevice, int interface_index) {
|
||||
mManager = manager;
|
||||
mDevice = usbDevice;
|
||||
mInterfaceIndex = interface_index;
|
||||
mInterface = mDevice.getInterface(mInterfaceIndex).getId();
|
||||
mDeviceId = manager.getDeviceIDForIdentifier(getIdentifier());
|
||||
mRunning = false;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return String.format("%s/%x/%x/%d", mDevice.getDeviceName(), mDevice.getVendorId(), mDevice.getProductId(), mInterfaceIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return mDeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId() {
|
||||
return mDevice.getVendorId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProductId() {
|
||||
return mDevice.getProductId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSerialNumber() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getSerialNumber();
|
||||
}
|
||||
if (result == null) {
|
||||
result = "";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturerName() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getManufacturerName();
|
||||
}
|
||||
if (result == null) {
|
||||
result = String.format("%x", getVendorId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProductName() {
|
||||
String result = null;
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
result = mDevice.getProductName();
|
||||
}
|
||||
if (result == null) {
|
||||
result = String.format("%x", getProductId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UsbDevice getDevice() {
|
||||
return mDevice;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return getManufacturerName() + " " + getProductName() + "(0x" + String.format("%x", getVendorId()) + "/0x" + String.format("%x", getProductId()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean open() {
|
||||
mConnection = mManager.getUSBManager().openDevice(mDevice);
|
||||
if (mConnection == null) {
|
||||
Log.w(TAG, "Unable to open USB device " + getDeviceName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force claim our interface
|
||||
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
|
||||
if (!mConnection.claimInterface(iface, true)) {
|
||||
Log.w(TAG, "Failed to claim interfaces on USB device " + getDeviceName());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the endpoints
|
||||
for (int j = 0; j < iface.getEndpointCount(); j++) {
|
||||
UsbEndpoint endpt = iface.getEndpoint(j);
|
||||
switch (endpt.getDirection()) {
|
||||
case UsbConstants.USB_DIR_IN:
|
||||
if (mInputEndpoint == null) {
|
||||
mInputEndpoint = endpt;
|
||||
}
|
||||
break;
|
||||
case UsbConstants.USB_DIR_OUT:
|
||||
if (mOutputEndpoint == null) {
|
||||
mOutputEndpoint = endpt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the required endpoints were present
|
||||
if (mInputEndpoint == null || mOutputEndpoint == null) {
|
||||
Log.w(TAG, "Missing required endpoint on USB device " + getDeviceName());
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Start listening for input
|
||||
mRunning = true;
|
||||
mInputThread = new InputThread();
|
||||
mInputThread.start();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendFeatureReport(byte[] report) {
|
||||
int res = -1;
|
||||
int offset = 0;
|
||||
int length = report.length;
|
||||
boolean skipped_report_id = false;
|
||||
byte report_number = report[0];
|
||||
|
||||
if (report_number == 0x0) {
|
||||
++offset;
|
||||
--length;
|
||||
skipped_report_id = true;
|
||||
}
|
||||
|
||||
res = mConnection.controlTransfer(
|
||||
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_OUT,
|
||||
0x09/*HID set_report*/,
|
||||
(3/*HID feature*/ << 8) | report_number,
|
||||
mInterface,
|
||||
report, offset, length,
|
||||
1000/*timeout millis*/);
|
||||
|
||||
if (res < 0) {
|
||||
Log.w(TAG, "sendFeatureReport() returned " + res + " on device " + getDeviceName());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (skipped_report_id) {
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendOutputReport(byte[] report) {
|
||||
int r = mConnection.bulkTransfer(mOutputEndpoint, report, report.length, 1000);
|
||||
if (r != report.length) {
|
||||
Log.w(TAG, "sendOutputReport() returned " + r + " on device " + getDeviceName());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFeatureReport(byte[] report) {
|
||||
int res = -1;
|
||||
int offset = 0;
|
||||
int length = report.length;
|
||||
boolean skipped_report_id = false;
|
||||
byte report_number = report[0];
|
||||
|
||||
if (report_number == 0x0) {
|
||||
/* Offset the return buffer by 1, so that the report ID
|
||||
will remain in byte 0. */
|
||||
++offset;
|
||||
--length;
|
||||
skipped_report_id = true;
|
||||
}
|
||||
|
||||
res = mConnection.controlTransfer(
|
||||
UsbConstants.USB_TYPE_CLASS | 0x01 /*RECIPIENT_INTERFACE*/ | UsbConstants.USB_DIR_IN,
|
||||
0x01/*HID get_report*/,
|
||||
(3/*HID feature*/ << 8) | report_number,
|
||||
mInterface,
|
||||
report, offset, length,
|
||||
1000/*timeout millis*/);
|
||||
|
||||
if (res < 0) {
|
||||
Log.w(TAG, "getFeatureReport() returned " + res + " on device " + getDeviceName());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (skipped_report_id) {
|
||||
++res;
|
||||
++length;
|
||||
}
|
||||
|
||||
byte[] data;
|
||||
if (res == length) {
|
||||
data = report;
|
||||
} else {
|
||||
data = Arrays.copyOfRange(report, 0, res);
|
||||
}
|
||||
mManager.HIDDeviceFeatureReport(mDeviceId, data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mRunning = false;
|
||||
if (mInputThread != null) {
|
||||
while (mInputThread.isAlive()) {
|
||||
mInputThread.interrupt();
|
||||
try {
|
||||
mInputThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// Keep trying until we're done
|
||||
}
|
||||
}
|
||||
mInputThread = null;
|
||||
}
|
||||
if (mConnection != null) {
|
||||
UsbInterface iface = mDevice.getInterface(mInterfaceIndex);
|
||||
mConnection.releaseInterface(iface);
|
||||
mConnection.close();
|
||||
mConnection = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
close();
|
||||
mManager = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFrozen(boolean frozen) {
|
||||
mFrozen = frozen;
|
||||
}
|
||||
|
||||
protected class InputThread extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
int packetSize = mInputEndpoint.getMaxPacketSize();
|
||||
byte[] packet = new byte[packetSize];
|
||||
while (mRunning) {
|
||||
int r;
|
||||
try
|
||||
{
|
||||
r = mConnection.bulkTransfer(mInputEndpoint, packet, packetSize, 1000);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.v(TAG, "Exception in UsbDeviceConnection bulktransfer: " + e);
|
||||
break;
|
||||
}
|
||||
if (r < 0) {
|
||||
// Could be a timeout or an I/O error
|
||||
}
|
||||
if (r > 0) {
|
||||
byte[] data;
|
||||
if (r == packetSize) {
|
||||
data = packet;
|
||||
} else {
|
||||
data = Arrays.copyOfRange(packet, 0, r);
|
||||
}
|
||||
|
||||
if (!mFrozen) {
|
||||
mManager.HIDDeviceInputReport(mDeviceId, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,592 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import java.lang.String;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
// grep 'SDLK_' SDL_keysym.h | sed 's/SDLK_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||
class SDL_1_2_Keycodes
|
||||
{
|
||||
public static final int SDLK_UNKNOWN = 0;
|
||||
public static final int SDLK_BACKSPACE = 8;
|
||||
public static final int SDLK_TAB = 9;
|
||||
public static final int SDLK_CLEAR = 12;
|
||||
public static final int SDLK_RETURN = 13;
|
||||
public static final int SDLK_PAUSE = 19;
|
||||
public static final int SDLK_ESCAPE = 27;
|
||||
public static final int SDLK_SPACE = 32;
|
||||
public static final int SDLK_EXCLAIM = 33;
|
||||
public static final int SDLK_QUOTEDBL = 34;
|
||||
public static final int SDLK_HASH = 35;
|
||||
public static final int SDLK_DOLLAR = 36;
|
||||
public static final int SDLK_AMPERSAND = 38;
|
||||
public static final int SDLK_QUOTE = 39;
|
||||
public static final int SDLK_LEFTPAREN = 40;
|
||||
public static final int SDLK_RIGHTPAREN = 41;
|
||||
public static final int SDLK_ASTERISK = 42;
|
||||
public static final int SDLK_PLUS = 43;
|
||||
public static final int SDLK_COMMA = 44;
|
||||
public static final int SDLK_MINUS = 45;
|
||||
public static final int SDLK_PERIOD = 46;
|
||||
public static final int SDLK_SLASH = 47;
|
||||
public static final int SDLK_0 = 48;
|
||||
public static final int SDLK_1 = 49;
|
||||
public static final int SDLK_2 = 50;
|
||||
public static final int SDLK_3 = 51;
|
||||
public static final int SDLK_4 = 52;
|
||||
public static final int SDLK_5 = 53;
|
||||
public static final int SDLK_6 = 54;
|
||||
public static final int SDLK_7 = 55;
|
||||
public static final int SDLK_8 = 56;
|
||||
public static final int SDLK_9 = 57;
|
||||
public static final int SDLK_COLON = 58;
|
||||
public static final int SDLK_SEMICOLON = 59;
|
||||
public static final int SDLK_LESS = 60;
|
||||
public static final int SDLK_EQUALS = 61;
|
||||
public static final int SDLK_GREATER = 62;
|
||||
public static final int SDLK_QUESTION = 63;
|
||||
public static final int SDLK_AT = 64;
|
||||
public static final int SDLK_LEFTBRACKET = 91;
|
||||
public static final int SDLK_BACKSLASH = 92;
|
||||
public static final int SDLK_RIGHTBRACKET = 93;
|
||||
public static final int SDLK_CARET = 94;
|
||||
public static final int SDLK_UNDERSCORE = 95;
|
||||
public static final int SDLK_BACKQUOTE = 96;
|
||||
public static final int SDLK_a = 97;
|
||||
public static final int SDLK_b = 98;
|
||||
public static final int SDLK_c = 99;
|
||||
public static final int SDLK_d = 100;
|
||||
public static final int SDLK_e = 101;
|
||||
public static final int SDLK_f = 102;
|
||||
public static final int SDLK_g = 103;
|
||||
public static final int SDLK_h = 104;
|
||||
public static final int SDLK_i = 105;
|
||||
public static final int SDLK_j = 106;
|
||||
public static final int SDLK_k = 107;
|
||||
public static final int SDLK_l = 108;
|
||||
public static final int SDLK_m = 109;
|
||||
public static final int SDLK_n = 110;
|
||||
public static final int SDLK_o = 111;
|
||||
public static final int SDLK_p = 112;
|
||||
public static final int SDLK_q = 113;
|
||||
public static final int SDLK_r = 114;
|
||||
public static final int SDLK_s = 115;
|
||||
public static final int SDLK_t = 116;
|
||||
public static final int SDLK_u = 117;
|
||||
public static final int SDLK_v = 118;
|
||||
public static final int SDLK_w = 119;
|
||||
public static final int SDLK_x = 120;
|
||||
public static final int SDLK_y = 121;
|
||||
public static final int SDLK_z = 122;
|
||||
public static final int SDLK_DELETE = 127;
|
||||
public static final int SDLK_WORLD_0 = 160;
|
||||
public static final int SDLK_WORLD_1 = 161;
|
||||
public static final int SDLK_WORLD_2 = 162;
|
||||
public static final int SDLK_WORLD_3 = 163;
|
||||
public static final int SDLK_WORLD_4 = 164;
|
||||
public static final int SDLK_WORLD_5 = 165;
|
||||
public static final int SDLK_WORLD_6 = 166;
|
||||
public static final int SDLK_WORLD_7 = 167;
|
||||
public static final int SDLK_WORLD_8 = 168;
|
||||
public static final int SDLK_WORLD_9 = 169;
|
||||
public static final int SDLK_WORLD_10 = 170;
|
||||
public static final int SDLK_WORLD_11 = 171;
|
||||
public static final int SDLK_WORLD_12 = 172;
|
||||
public static final int SDLK_WORLD_13 = 173;
|
||||
public static final int SDLK_WORLD_14 = 174;
|
||||
public static final int SDLK_WORLD_15 = 175;
|
||||
public static final int SDLK_WORLD_16 = 176;
|
||||
public static final int SDLK_WORLD_17 = 177;
|
||||
public static final int SDLK_WORLD_18 = 178;
|
||||
public static final int SDLK_WORLD_19 = 179;
|
||||
public static final int SDLK_WORLD_20 = 180;
|
||||
public static final int SDLK_WORLD_21 = 181;
|
||||
public static final int SDLK_WORLD_22 = 182;
|
||||
public static final int SDLK_WORLD_23 = 183;
|
||||
public static final int SDLK_WORLD_24 = 184;
|
||||
public static final int SDLK_WORLD_25 = 185;
|
||||
public static final int SDLK_WORLD_26 = 186;
|
||||
public static final int SDLK_WORLD_27 = 187;
|
||||
public static final int SDLK_WORLD_28 = 188;
|
||||
public static final int SDLK_WORLD_29 = 189;
|
||||
public static final int SDLK_WORLD_30 = 190;
|
||||
public static final int SDLK_WORLD_31 = 191;
|
||||
public static final int SDLK_WORLD_32 = 192;
|
||||
public static final int SDLK_WORLD_33 = 193;
|
||||
public static final int SDLK_WORLD_34 = 194;
|
||||
public static final int SDLK_WORLD_35 = 195;
|
||||
public static final int SDLK_WORLD_36 = 196;
|
||||
public static final int SDLK_WORLD_37 = 197;
|
||||
public static final int SDLK_WORLD_38 = 198;
|
||||
public static final int SDLK_WORLD_39 = 199;
|
||||
public static final int SDLK_WORLD_40 = 200;
|
||||
public static final int SDLK_WORLD_41 = 201;
|
||||
public static final int SDLK_WORLD_42 = 202;
|
||||
public static final int SDLK_WORLD_43 = 203;
|
||||
public static final int SDLK_WORLD_44 = 204;
|
||||
public static final int SDLK_WORLD_45 = 205;
|
||||
public static final int SDLK_WORLD_46 = 206;
|
||||
public static final int SDLK_WORLD_47 = 207;
|
||||
public static final int SDLK_WORLD_48 = 208;
|
||||
public static final int SDLK_WORLD_49 = 209;
|
||||
public static final int SDLK_WORLD_50 = 210;
|
||||
public static final int SDLK_WORLD_51 = 211;
|
||||
public static final int SDLK_WORLD_52 = 212;
|
||||
public static final int SDLK_WORLD_53 = 213;
|
||||
public static final int SDLK_WORLD_54 = 214;
|
||||
public static final int SDLK_WORLD_55 = 215;
|
||||
public static final int SDLK_WORLD_56 = 216;
|
||||
public static final int SDLK_WORLD_57 = 217;
|
||||
public static final int SDLK_WORLD_58 = 218;
|
||||
public static final int SDLK_WORLD_59 = 219;
|
||||
public static final int SDLK_WORLD_60 = 220;
|
||||
public static final int SDLK_WORLD_61 = 221;
|
||||
public static final int SDLK_WORLD_62 = 222;
|
||||
public static final int SDLK_WORLD_63 = 223;
|
||||
public static final int SDLK_WORLD_64 = 224;
|
||||
public static final int SDLK_WORLD_65 = 225;
|
||||
public static final int SDLK_WORLD_66 = 226;
|
||||
public static final int SDLK_WORLD_67 = 227;
|
||||
public static final int SDLK_WORLD_68 = 228;
|
||||
public static final int SDLK_WORLD_69 = 229;
|
||||
public static final int SDLK_WORLD_70 = 230;
|
||||
public static final int SDLK_WORLD_71 = 231;
|
||||
public static final int SDLK_WORLD_72 = 232;
|
||||
public static final int SDLK_WORLD_73 = 233;
|
||||
public static final int SDLK_WORLD_74 = 234;
|
||||
public static final int SDLK_WORLD_75 = 235;
|
||||
public static final int SDLK_WORLD_76 = 236;
|
||||
public static final int SDLK_WORLD_77 = 237;
|
||||
public static final int SDLK_WORLD_78 = 238;
|
||||
public static final int SDLK_WORLD_79 = 239;
|
||||
public static final int SDLK_WORLD_80 = 240;
|
||||
public static final int SDLK_WORLD_81 = 241;
|
||||
public static final int SDLK_WORLD_82 = 242;
|
||||
public static final int SDLK_WORLD_83 = 243;
|
||||
public static final int SDLK_WORLD_84 = 244;
|
||||
public static final int SDLK_WORLD_85 = 245;
|
||||
public static final int SDLK_WORLD_86 = 246;
|
||||
public static final int SDLK_WORLD_87 = 247;
|
||||
public static final int SDLK_WORLD_88 = 248;
|
||||
public static final int SDLK_WORLD_89 = 249;
|
||||
public static final int SDLK_WORLD_90 = 250;
|
||||
public static final int SDLK_WORLD_91 = 251;
|
||||
public static final int SDLK_WORLD_92 = 252;
|
||||
public static final int SDLK_WORLD_93 = 253;
|
||||
public static final int SDLK_WORLD_94 = 254;
|
||||
public static final int SDLK_WORLD_95 = 255;
|
||||
public static final int SDLK_KP0 = 256;
|
||||
public static final int SDLK_KP1 = 257;
|
||||
public static final int SDLK_KP2 = 258;
|
||||
public static final int SDLK_KP3 = 259;
|
||||
public static final int SDLK_KP4 = 260;
|
||||
public static final int SDLK_KP5 = 261;
|
||||
public static final int SDLK_KP6 = 262;
|
||||
public static final int SDLK_KP7 = 263;
|
||||
public static final int SDLK_KP8 = 264;
|
||||
public static final int SDLK_KP9 = 265;
|
||||
public static final int SDLK_KP_PERIOD = 266;
|
||||
public static final int SDLK_KP_DIVIDE = 267;
|
||||
public static final int SDLK_KP_MULTIPLY = 268;
|
||||
public static final int SDLK_KP_MINUS = 269;
|
||||
public static final int SDLK_KP_PLUS = 270;
|
||||
public static final int SDLK_KP_ENTER = 271;
|
||||
public static final int SDLK_KP_EQUALS = 272;
|
||||
public static final int SDLK_UP = 273;
|
||||
public static final int SDLK_DOWN = 274;
|
||||
public static final int SDLK_RIGHT = 275;
|
||||
public static final int SDLK_LEFT = 276;
|
||||
public static final int SDLK_INSERT = 277;
|
||||
public static final int SDLK_HOME = 278;
|
||||
public static final int SDLK_END = 279;
|
||||
public static final int SDLK_PAGEUP = 280;
|
||||
public static final int SDLK_PAGEDOWN = 281;
|
||||
public static final int SDLK_F1 = 282;
|
||||
public static final int SDLK_F2 = 283;
|
||||
public static final int SDLK_F3 = 284;
|
||||
public static final int SDLK_F4 = 285;
|
||||
public static final int SDLK_F5 = 286;
|
||||
public static final int SDLK_F6 = 287;
|
||||
public static final int SDLK_F7 = 288;
|
||||
public static final int SDLK_F8 = 289;
|
||||
public static final int SDLK_F9 = 290;
|
||||
public static final int SDLK_F10 = 291;
|
||||
public static final int SDLK_F11 = 292;
|
||||
public static final int SDLK_F12 = 293;
|
||||
public static final int SDLK_F13 = 294;
|
||||
public static final int SDLK_F14 = 295;
|
||||
public static final int SDLK_F15 = 296;
|
||||
public static final int SDLK_NUMLOCK = 300;
|
||||
public static final int SDLK_CAPSLOCK = 301;
|
||||
public static final int SDLK_SCROLLOCK = 302;
|
||||
public static final int SDLK_RSHIFT = 303;
|
||||
public static final int SDLK_LSHIFT = 304;
|
||||
public static final int SDLK_RCTRL = 305;
|
||||
public static final int SDLK_LCTRL = 306;
|
||||
public static final int SDLK_RALT = 307;
|
||||
public static final int SDLK_LALT = 308;
|
||||
public static final int SDLK_RMETA = 309;
|
||||
public static final int SDLK_LMETA = 310;
|
||||
public static final int SDLK_LSUPER = 311;
|
||||
public static final int SDLK_RSUPER = 312;
|
||||
public static final int SDLK_MODE = 313;
|
||||
public static final int SDLK_COMPOSE = 314;
|
||||
public static final int SDLK_HELP = 315;
|
||||
public static final int SDLK_PRINT = 316;
|
||||
public static final int SDLK_SYSREQ = 317;
|
||||
public static final int SDLK_BREAK = 318;
|
||||
public static final int SDLK_MENU = 319;
|
||||
public static final int SDLK_POWER = 320;
|
||||
public static final int SDLK_EURO = 321;
|
||||
public static final int SDLK_UNDO = 322;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
// Autogenerated by hand with a command:
|
||||
// grep 'SDL_SCANCODE_' SDL_scancode.h | sed 's/SDL_SCANCODE_\([a-zA-Z0-9_]\+\).*[=] \([0-9]\+\).*/public static final int SDLK_\1 = \2;/' >> Keycodes.java
|
||||
class SDL_1_3_Keycodes
|
||||
{
|
||||
public static final int SDLK_UNKNOWN = 0;
|
||||
public static final int SDLK_A = 4;
|
||||
public static final int SDLK_B = 5;
|
||||
public static final int SDLK_C = 6;
|
||||
public static final int SDLK_D = 7;
|
||||
public static final int SDLK_E = 8;
|
||||
public static final int SDLK_F = 9;
|
||||
public static final int SDLK_G = 10;
|
||||
public static final int SDLK_H = 11;
|
||||
public static final int SDLK_I = 12;
|
||||
public static final int SDLK_J = 13;
|
||||
public static final int SDLK_K = 14;
|
||||
public static final int SDLK_L = 15;
|
||||
public static final int SDLK_M = 16;
|
||||
public static final int SDLK_N = 17;
|
||||
public static final int SDLK_O = 18;
|
||||
public static final int SDLK_P = 19;
|
||||
public static final int SDLK_Q = 20;
|
||||
public static final int SDLK_R = 21;
|
||||
public static final int SDLK_S = 22;
|
||||
public static final int SDLK_T = 23;
|
||||
public static final int SDLK_U = 24;
|
||||
public static final int SDLK_V = 25;
|
||||
public static final int SDLK_W = 26;
|
||||
public static final int SDLK_X = 27;
|
||||
public static final int SDLK_Y = 28;
|
||||
public static final int SDLK_Z = 29;
|
||||
public static final int SDLK_1 = 30;
|
||||
public static final int SDLK_2 = 31;
|
||||
public static final int SDLK_3 = 32;
|
||||
public static final int SDLK_4 = 33;
|
||||
public static final int SDLK_5 = 34;
|
||||
public static final int SDLK_6 = 35;
|
||||
public static final int SDLK_7 = 36;
|
||||
public static final int SDLK_8 = 37;
|
||||
public static final int SDLK_9 = 38;
|
||||
public static final int SDLK_0 = 39;
|
||||
public static final int SDLK_RETURN = 40;
|
||||
public static final int SDLK_ESCAPE = 41;
|
||||
public static final int SDLK_BACKSPACE = 42;
|
||||
public static final int SDLK_TAB = 43;
|
||||
public static final int SDLK_SPACE = 44;
|
||||
public static final int SDLK_MINUS = 45;
|
||||
public static final int SDLK_EQUALS = 46;
|
||||
public static final int SDLK_LEFTBRACKET = 47;
|
||||
public static final int SDLK_RIGHTBRACKET = 48;
|
||||
public static final int SDLK_BACKSLASH = 49;
|
||||
public static final int SDLK_NONUSHASH = 50;
|
||||
public static final int SDLK_SEMICOLON = 51;
|
||||
public static final int SDLK_APOSTROPHE = 52;
|
||||
public static final int SDLK_GRAVE = 53;
|
||||
public static final int SDLK_COMMA = 54;
|
||||
public static final int SDLK_PERIOD = 55;
|
||||
public static final int SDLK_SLASH = 56;
|
||||
public static final int SDLK_CAPSLOCK = 57;
|
||||
public static final int SDLK_F1 = 58;
|
||||
public static final int SDLK_F2 = 59;
|
||||
public static final int SDLK_F3 = 60;
|
||||
public static final int SDLK_F4 = 61;
|
||||
public static final int SDLK_F5 = 62;
|
||||
public static final int SDLK_F6 = 63;
|
||||
public static final int SDLK_F7 = 64;
|
||||
public static final int SDLK_F8 = 65;
|
||||
public static final int SDLK_F9 = 66;
|
||||
public static final int SDLK_F10 = 67;
|
||||
public static final int SDLK_F11 = 68;
|
||||
public static final int SDLK_F12 = 69;
|
||||
public static final int SDLK_PRINTSCREEN = 70;
|
||||
public static final int SDLK_SCROLLLOCK = 71;
|
||||
public static final int SDLK_PAUSE = 72;
|
||||
public static final int SDLK_INSERT = 73;
|
||||
public static final int SDLK_HOME = 74;
|
||||
public static final int SDLK_PAGEUP = 75;
|
||||
public static final int SDLK_DELETE = 76;
|
||||
public static final int SDLK_END = 77;
|
||||
public static final int SDLK_PAGEDOWN = 78;
|
||||
public static final int SDLK_RIGHT = 79;
|
||||
public static final int SDLK_LEFT = 80;
|
||||
public static final int SDLK_DOWN = 81;
|
||||
public static final int SDLK_UP = 82;
|
||||
public static final int SDLK_NUMLOCKCLEAR = 83;
|
||||
public static final int SDLK_KP_DIVIDE = 84;
|
||||
public static final int SDLK_KP_MULTIPLY = 85;
|
||||
public static final int SDLK_KP_MINUS = 86;
|
||||
public static final int SDLK_KP_PLUS = 87;
|
||||
public static final int SDLK_KP_ENTER = 88;
|
||||
public static final int SDLK_KP_1 = 89;
|
||||
public static final int SDLK_KP_2 = 90;
|
||||
public static final int SDLK_KP_3 = 91;
|
||||
public static final int SDLK_KP_4 = 92;
|
||||
public static final int SDLK_KP_5 = 93;
|
||||
public static final int SDLK_KP_6 = 94;
|
||||
public static final int SDLK_KP_7 = 95;
|
||||
public static final int SDLK_KP_8 = 96;
|
||||
public static final int SDLK_KP_9 = 97;
|
||||
public static final int SDLK_KP_0 = 98;
|
||||
public static final int SDLK_KP_PERIOD = 99;
|
||||
public static final int SDLK_NONUSBACKSLASH = 100;
|
||||
public static final int SDLK_APPLICATION = 101;
|
||||
public static final int SDLK_POWER = 102;
|
||||
public static final int SDLK_KP_EQUALS = 103;
|
||||
public static final int SDLK_F13 = 104;
|
||||
public static final int SDLK_F14 = 105;
|
||||
public static final int SDLK_F15 = 106;
|
||||
public static final int SDLK_F16 = 107;
|
||||
public static final int SDLK_F17 = 108;
|
||||
public static final int SDLK_F18 = 109;
|
||||
public static final int SDLK_F19 = 110;
|
||||
public static final int SDLK_F20 = 111;
|
||||
public static final int SDLK_F21 = 112;
|
||||
public static final int SDLK_F22 = 113;
|
||||
public static final int SDLK_F23 = 114;
|
||||
public static final int SDLK_F24 = 115;
|
||||
public static final int SDLK_EXECUTE = 116;
|
||||
public static final int SDLK_HELP = 117;
|
||||
public static final int SDLK_MENU = 118;
|
||||
public static final int SDLK_SELECT = 119;
|
||||
public static final int SDLK_STOP = 120;
|
||||
public static final int SDLK_AGAIN = 121;
|
||||
public static final int SDLK_UNDO = 122;
|
||||
public static final int SDLK_CUT = 123;
|
||||
public static final int SDLK_COPY = 124;
|
||||
public static final int SDLK_PASTE = 125;
|
||||
public static final int SDLK_FIND = 126;
|
||||
public static final int SDLK_MUTE = 127;
|
||||
public static final int SDLK_VOLUMEUP = 128;
|
||||
public static final int SDLK_VOLUMEDOWN = 129;
|
||||
public static final int SDLK_KP_COMMA = 133;
|
||||
public static final int SDLK_KP_EQUALSAS400 = 134;
|
||||
public static final int SDLK_INTERNATIONAL1 = 135;
|
||||
public static final int SDLK_INTERNATIONAL2 = 136;
|
||||
public static final int SDLK_INTERNATIONAL3 = 137;
|
||||
public static final int SDLK_INTERNATIONAL4 = 138;
|
||||
public static final int SDLK_INTERNATIONAL5 = 139;
|
||||
public static final int SDLK_INTERNATIONAL6 = 140;
|
||||
public static final int SDLK_INTERNATIONAL7 = 141;
|
||||
public static final int SDLK_INTERNATIONAL8 = 142;
|
||||
public static final int SDLK_INTERNATIONAL9 = 143;
|
||||
public static final int SDLK_LANG1 = 144;
|
||||
public static final int SDLK_LANG2 = 145;
|
||||
public static final int SDLK_LANG3 = 146;
|
||||
public static final int SDLK_LANG4 = 147;
|
||||
public static final int SDLK_LANG5 = 148;
|
||||
public static final int SDLK_LANG6 = 149;
|
||||
public static final int SDLK_LANG7 = 150;
|
||||
public static final int SDLK_LANG8 = 151;
|
||||
public static final int SDLK_LANG9 = 152;
|
||||
public static final int SDLK_ALTERASE = 153;
|
||||
public static final int SDLK_SYSREQ = 154;
|
||||
public static final int SDLK_CANCEL = 155;
|
||||
public static final int SDLK_CLEAR = 156;
|
||||
public static final int SDLK_PRIOR = 157;
|
||||
public static final int SDLK_RETURN2 = 158;
|
||||
public static final int SDLK_SEPARATOR = 159;
|
||||
public static final int SDLK_OUT = 160;
|
||||
public static final int SDLK_OPER = 161;
|
||||
public static final int SDLK_CLEARAGAIN = 162;
|
||||
public static final int SDLK_CRSEL = 163;
|
||||
public static final int SDLK_EXSEL = 164;
|
||||
public static final int SDLK_KP_00 = 176;
|
||||
public static final int SDLK_KP_000 = 177;
|
||||
public static final int SDLK_THOUSANDSSEPARATOR = 178;
|
||||
public static final int SDLK_DECIMALSEPARATOR = 179;
|
||||
public static final int SDLK_CURRENCYUNIT = 180;
|
||||
public static final int SDLK_CURRENCYSUBUNIT = 181;
|
||||
public static final int SDLK_KP_LEFTPAREN = 182;
|
||||
public static final int SDLK_KP_RIGHTPAREN = 183;
|
||||
public static final int SDLK_KP_LEFTBRACE = 184;
|
||||
public static final int SDLK_KP_RIGHTBRACE = 185;
|
||||
public static final int SDLK_KP_TAB = 186;
|
||||
public static final int SDLK_KP_BACKSPACE = 187;
|
||||
public static final int SDLK_KP_A = 188;
|
||||
public static final int SDLK_KP_B = 189;
|
||||
public static final int SDLK_KP_C = 190;
|
||||
public static final int SDLK_KP_D = 191;
|
||||
public static final int SDLK_KP_E = 192;
|
||||
public static final int SDLK_KP_F = 193;
|
||||
public static final int SDLK_KP_XOR = 194;
|
||||
public static final int SDLK_KP_POWER = 195;
|
||||
public static final int SDLK_KP_PERCENT = 196;
|
||||
public static final int SDLK_KP_LESS = 197;
|
||||
public static final int SDLK_KP_GREATER = 198;
|
||||
public static final int SDLK_KP_AMPERSAND = 199;
|
||||
public static final int SDLK_KP_DBLAMPERSAND = 200;
|
||||
public static final int SDLK_KP_VERTICALBAR = 201;
|
||||
public static final int SDLK_KP_DBLVERTICALBAR = 202;
|
||||
public static final int SDLK_KP_COLON = 203;
|
||||
public static final int SDLK_KP_HASH = 204;
|
||||
public static final int SDLK_KP_SPACE = 205;
|
||||
public static final int SDLK_KP_AT = 206;
|
||||
public static final int SDLK_KP_EXCLAM = 207;
|
||||
public static final int SDLK_KP_MEMSTORE = 208;
|
||||
public static final int SDLK_KP_MEMRECALL = 209;
|
||||
public static final int SDLK_KP_MEMCLEAR = 210;
|
||||
public static final int SDLK_KP_MEMADD = 211;
|
||||
public static final int SDLK_KP_MEMSUBTRACT = 212;
|
||||
public static final int SDLK_KP_MEMMULTIPLY = 213;
|
||||
public static final int SDLK_KP_MEMDIVIDE = 214;
|
||||
public static final int SDLK_KP_PLUSMINUS = 215;
|
||||
public static final int SDLK_KP_CLEAR = 216;
|
||||
public static final int SDLK_KP_CLEARENTRY = 217;
|
||||
public static final int SDLK_KP_BINARY = 218;
|
||||
public static final int SDLK_KP_OCTAL = 219;
|
||||
public static final int SDLK_KP_DECIMAL = 220;
|
||||
public static final int SDLK_KP_HEXADECIMAL = 221;
|
||||
public static final int SDLK_LCTRL = 224;
|
||||
public static final int SDLK_LSHIFT = 225;
|
||||
public static final int SDLK_LALT = 226;
|
||||
public static final int SDLK_LGUI = 227;
|
||||
public static final int SDLK_RCTRL = 228;
|
||||
public static final int SDLK_RSHIFT = 229;
|
||||
public static final int SDLK_RALT = 230;
|
||||
public static final int SDLK_RGUI = 231;
|
||||
public static final int SDLK_MODE = 257;
|
||||
public static final int SDLK_AUDIONEXT = 258;
|
||||
public static final int SDLK_AUDIOPREV = 259;
|
||||
public static final int SDLK_AUDIOSTOP = 260;
|
||||
public static final int SDLK_AUDIOPLAY = 261;
|
||||
public static final int SDLK_AUDIOMUTE = 262;
|
||||
public static final int SDLK_MEDIASELECT = 263;
|
||||
public static final int SDLK_WWW = 264;
|
||||
public static final int SDLK_MAIL = 265;
|
||||
public static final int SDLK_CALCULATOR = 266;
|
||||
public static final int SDLK_COMPUTER = 267;
|
||||
public static final int SDLK_AC_SEARCH = 268;
|
||||
public static final int SDLK_AC_HOME = 269;
|
||||
public static final int SDLK_AC_BACK = 270;
|
||||
public static final int SDLK_AC_FORWARD = 271;
|
||||
public static final int SDLK_AC_STOP = 272;
|
||||
public static final int SDLK_AC_REFRESH = 273;
|
||||
public static final int SDLK_AC_BOOKMARKS = 274;
|
||||
public static final int SDLK_BRIGHTNESSDOWN = 275;
|
||||
public static final int SDLK_BRIGHTNESSUP = 276;
|
||||
public static final int SDLK_DISPLAYSWITCH = 277;
|
||||
public static final int SDLK_KBDILLUMTOGGLE = 278;
|
||||
public static final int SDLK_KBDILLUMDOWN = 279;
|
||||
public static final int SDLK_KBDILLUMUP = 280;
|
||||
public static final int SDLK_EJECT = 281;
|
||||
public static final int SDLK_SLEEP = 282;
|
||||
|
||||
public static final int SDLK_NO_REMAP = 512;
|
||||
}
|
||||
|
||||
class SDL_Keys
|
||||
{
|
||||
public static String [] names = null;
|
||||
public static Integer [] values = null;
|
||||
|
||||
public static String [] namesSorted = null;
|
||||
public static Integer [] namesSortedIdx = null;
|
||||
public static Integer [] namesSortedBackIdx = null;
|
||||
|
||||
static final int JAVA_KEYCODE_LAST = 255; // Android 2.3 added several new gaming keys, Android 3.1 added even more - keep in sync with javakeycodes.h
|
||||
|
||||
static String getName(int v)
|
||||
{
|
||||
for( int f = 0; f < values.length; f++ )
|
||||
{
|
||||
if( values[f] == v )
|
||||
return names[f];
|
||||
}
|
||||
return names[0];
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
ArrayList<String> Names = new ArrayList<String> ();
|
||||
ArrayList<Integer> Values = new ArrayList<Integer> ();
|
||||
Field [] fields = SDL_1_2_Keycodes.class.getDeclaredFields();
|
||||
if( Globals.Using_SDL_1_3 )
|
||||
{
|
||||
fields = SDL_1_3_Keycodes.class.getDeclaredFields();
|
||||
}
|
||||
|
||||
try {
|
||||
for(Field f: fields)
|
||||
{
|
||||
Values.add(f.getInt(null));
|
||||
Names.add(f.getName().substring(5).toUpperCase());
|
||||
}
|
||||
} catch(IllegalAccessException e) {};
|
||||
|
||||
// Sort by value
|
||||
for( int i = 0; i < Values.size(); i++ )
|
||||
{
|
||||
for( int j = i; j < Values.size(); j++ )
|
||||
{
|
||||
if( Values.get(i) > Values.get(j) )
|
||||
{
|
||||
int x = Values.get(i);
|
||||
Values.set(i, Values.get(j));
|
||||
Values.set(j, x);
|
||||
String s = Names.get(i);
|
||||
Names.set(i, Names.get(j));
|
||||
Names.set(j, s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
names = Names.toArray(new String[0]);
|
||||
values = Values.toArray(new Integer[0]);
|
||||
namesSorted = Names.toArray(new String[0]);
|
||||
namesSortedIdx = new Integer[values.length];
|
||||
namesSortedBackIdx = new Integer[values.length];
|
||||
Arrays.sort(namesSorted);
|
||||
for( int i = 0; i < namesSorted.length; i++ )
|
||||
{
|
||||
for( int j = 0; j < namesSorted.length; j++ )
|
||||
{
|
||||
if( namesSorted[i].equals( names[j] ) )
|
||||
{
|
||||
namesSortedIdx[i] = j;
|
||||
namesSortedBackIdx[j] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
84
project/javaSDL2/SDL.java
Normal file
84
project/javaSDL2/SDL.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
/**
|
||||
SDL library initialization
|
||||
*/
|
||||
public class SDL {
|
||||
|
||||
// This function should be called first and sets up the native code
|
||||
// so it can call into the Java classes
|
||||
public static void setupJNI() {
|
||||
SDLActivity.nativeSetupJNI();
|
||||
SDLAudioManager.nativeSetupJNI();
|
||||
SDLControllerManager.nativeSetupJNI();
|
||||
}
|
||||
|
||||
// This function should be called each time the activity is started
|
||||
public static void initialize() {
|
||||
setContext(null);
|
||||
|
||||
SDLActivity.initialize();
|
||||
SDLAudioManager.initialize();
|
||||
SDLControllerManager.initialize();
|
||||
}
|
||||
|
||||
// This function stores the current activity (SDL or not)
|
||||
public static void setContext(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
public static Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
|
||||
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
|
||||
|
||||
if (libraryName == null) {
|
||||
throw new NullPointerException("No library name provided.");
|
||||
}
|
||||
|
||||
try {
|
||||
// Let's see if we have ReLinker available in the project. This is necessary for
|
||||
// some projects that have huge numbers of local libraries bundled, and thus may
|
||||
// trip a bug in Android's native library loader which ReLinker works around. (If
|
||||
// loadLibrary works properly, ReLinker will simply use the normal Android method
|
||||
// internally.)
|
||||
//
|
||||
// To use ReLinker, just add it as a dependency. For more information, see
|
||||
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
|
||||
//
|
||||
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
|
||||
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
|
||||
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
|
||||
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
|
||||
|
||||
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
|
||||
// they've changed during updates.
|
||||
Method forceMethod = relinkClass.getDeclaredMethod("force");
|
||||
Object relinkInstance = forceMethod.invoke(null);
|
||||
Class relinkInstanceClass = relinkInstance.getClass();
|
||||
|
||||
// Actually load the library!
|
||||
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
|
||||
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
|
||||
}
|
||||
catch (final Throwable e) {
|
||||
// Fall back
|
||||
try {
|
||||
System.loadLibrary(libraryName);
|
||||
}
|
||||
catch (final UnsatisfiedLinkError ule) {
|
||||
throw ule;
|
||||
}
|
||||
catch (final SecurityException se) {
|
||||
throw se;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static Context mContext;
|
||||
}
|
||||
2327
project/javaSDL2/SDLActivity.java
Normal file
2327
project/javaSDL2/SDLActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
387
project/javaSDL2/SDLAudioManager.java
Normal file
387
project/javaSDL2/SDLAudioManager.java
Normal file
@@ -0,0 +1,387 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import android.media.*;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
public class SDLAudioManager
|
||||
{
|
||||
protected static final String TAG = "SDLAudio";
|
||||
|
||||
protected static AudioTrack mAudioTrack;
|
||||
protected static AudioRecord mAudioRecord;
|
||||
|
||||
public static void initialize() {
|
||||
mAudioTrack = null;
|
||||
mAudioRecord = null;
|
||||
}
|
||||
|
||||
// Audio
|
||||
|
||||
protected static String getAudioFormatString(int audioFormat) {
|
||||
switch (audioFormat) {
|
||||
case AudioFormat.ENCODING_PCM_8BIT:
|
||||
return "8-bit";
|
||||
case AudioFormat.ENCODING_PCM_16BIT:
|
||||
return "16-bit";
|
||||
case AudioFormat.ENCODING_PCM_FLOAT:
|
||||
return "float";
|
||||
default:
|
||||
return Integer.toString(audioFormat);
|
||||
}
|
||||
}
|
||||
|
||||
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
int channelConfig;
|
||||
int sampleSize;
|
||||
int frameSize;
|
||||
|
||||
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
|
||||
|
||||
/* On older devices let's use known good settings */
|
||||
if (Build.VERSION.SDK_INT < 21) {
|
||||
if (desiredChannels > 2) {
|
||||
desiredChannels = 2;
|
||||
}
|
||||
if (sampleRate < 8000) {
|
||||
sampleRate = 8000;
|
||||
} else if (sampleRate > 48000) {
|
||||
sampleRate = 48000;
|
||||
}
|
||||
}
|
||||
|
||||
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
|
||||
int minSDKVersion = (isCapture ? 23 : 21);
|
||||
if (Build.VERSION.SDK_INT < minSDKVersion) {
|
||||
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
}
|
||||
}
|
||||
switch (audioFormat)
|
||||
{
|
||||
case AudioFormat.ENCODING_PCM_8BIT:
|
||||
sampleSize = 1;
|
||||
break;
|
||||
case AudioFormat.ENCODING_PCM_16BIT:
|
||||
sampleSize = 2;
|
||||
break;
|
||||
case AudioFormat.ENCODING_PCM_FLOAT:
|
||||
sampleSize = 4;
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested format " + audioFormat + ", getting ENCODING_PCM_16BIT");
|
||||
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
sampleSize = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (isCapture) {
|
||||
switch (desiredChannels) {
|
||||
case 1:
|
||||
channelConfig = AudioFormat.CHANNEL_IN_MONO;
|
||||
break;
|
||||
case 2:
|
||||
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
|
||||
desiredChannels = 2;
|
||||
channelConfig = AudioFormat.CHANNEL_IN_STEREO;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (desiredChannels) {
|
||||
case 1:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_MONO;
|
||||
break;
|
||||
case 2:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
|
||||
break;
|
||||
case 3:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
|
||||
break;
|
||||
case 4:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_QUAD;
|
||||
break;
|
||||
case 5:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_QUAD | AudioFormat.CHANNEL_OUT_FRONT_CENTER;
|
||||
break;
|
||||
case 6:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
|
||||
break;
|
||||
case 7:
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
|
||||
break;
|
||||
case 8:
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
||||
} else {
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
|
||||
desiredChannels = 6;
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting stereo");
|
||||
desiredChannels = 2;
|
||||
channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Log.v(TAG, "Speaker configuration (and order of channels):");
|
||||
|
||||
if ((channelConfig & 0x00000004) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00000008) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT");
|
||||
}
|
||||
if ((channelConfig & 0x00000010) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000020) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_LOW_FREQUENCY");
|
||||
}
|
||||
if ((channelConfig & 0x00000040) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00000080) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_RIGHT");
|
||||
}
|
||||
if ((channelConfig & 0x00000100) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_LEFT_OF_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000200) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_FRONT_RIGHT_OF_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000400) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_BACK_CENTER");
|
||||
}
|
||||
if ((channelConfig & 0x00000800) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_SIDE_LEFT");
|
||||
}
|
||||
if ((channelConfig & 0x00001000) != 0) {
|
||||
Log.v(TAG, " CHANNEL_OUT_SIDE_RIGHT");
|
||||
}
|
||||
*/
|
||||
}
|
||||
frameSize = (sampleSize * desiredChannels);
|
||||
|
||||
// Let the user pick a larger buffer if they really want -- but ye
|
||||
// gods they probably shouldn't, the minimums are horrifyingly high
|
||||
// latency already
|
||||
int minBufferSize;
|
||||
if (isCapture) {
|
||||
minBufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
|
||||
} else {
|
||||
minBufferSize = AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat);
|
||||
}
|
||||
desiredFrames = Math.max(desiredFrames, (minBufferSize + frameSize - 1) / frameSize);
|
||||
|
||||
int[] results = new int[4];
|
||||
|
||||
if (isCapture) {
|
||||
if (mAudioRecord == null) {
|
||||
mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, sampleRate,
|
||||
channelConfig, audioFormat, desiredFrames * frameSize);
|
||||
|
||||
// see notes about AudioTrack state in audioOpen(), above. Probably also applies here.
|
||||
if (mAudioRecord.getState() != AudioRecord.STATE_INITIALIZED) {
|
||||
Log.e(TAG, "Failed during initialization of AudioRecord");
|
||||
mAudioRecord.release();
|
||||
mAudioRecord = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
mAudioRecord.startRecording();
|
||||
}
|
||||
|
||||
results[0] = mAudioRecord.getSampleRate();
|
||||
results[1] = mAudioRecord.getAudioFormat();
|
||||
results[2] = mAudioRecord.getChannelCount();
|
||||
results[3] = desiredFrames;
|
||||
|
||||
} else {
|
||||
if (mAudioTrack == null) {
|
||||
mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate, channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);
|
||||
|
||||
// Instantiating AudioTrack can "succeed" without an exception and the track may still be invalid
|
||||
// Ref: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/media/java/android/media/AudioTrack.java
|
||||
// Ref: http://developer.android.com/reference/android/media/AudioTrack.html#getState()
|
||||
if (mAudioTrack.getState() != AudioTrack.STATE_INITIALIZED) {
|
||||
/* Try again, with safer values */
|
||||
|
||||
Log.e(TAG, "Failed during initialization of Audio Track");
|
||||
mAudioTrack.release();
|
||||
mAudioTrack = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
mAudioTrack.play();
|
||||
}
|
||||
|
||||
results[0] = mAudioTrack.getSampleRate();
|
||||
results[1] = mAudioTrack.getAudioFormat();
|
||||
results[2] = mAudioTrack.getChannelCount();
|
||||
results[3] = desiredFrames;
|
||||
}
|
||||
|
||||
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", got " + results[3] + " frames of " + results[2] + " channel " + getAudioFormatString(results[1]) + " audio at " + results[0] + " Hz");
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteFloatBuffer(float[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length;) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(float)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteShortBuffer(short[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length;) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(short)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void audioWriteByteBuffer(byte[] buffer) {
|
||||
if (mAudioTrack == null) {
|
||||
Log.e(TAG, "Attempted to make audio call with uninitialized audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < buffer.length; ) {
|
||||
int result = mAudioTrack.write(buffer, i, buffer.length - i);
|
||||
if (result > 0) {
|
||||
i += result;
|
||||
} else if (result == 0) {
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch(InterruptedException e) {
|
||||
// Nom nom
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "SDL audio: error return from write(byte)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
} else {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||
} else {
|
||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void audioClose() {
|
||||
if (mAudioTrack != null) {
|
||||
mAudioTrack.stop();
|
||||
mAudioTrack.release();
|
||||
mAudioTrack = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void captureClose() {
|
||||
if (mAudioRecord != null) {
|
||||
mAudioRecord.stop();
|
||||
mAudioRecord.release();
|
||||
mAudioRecord = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** This method is called by SDL using JNI. */
|
||||
public static void audioSetThreadPriority(boolean iscapture, int device_id) {
|
||||
try {
|
||||
|
||||
/* Set thread name */
|
||||
if (iscapture) {
|
||||
Thread.currentThread().setName("SDLAudioC" + device_id);
|
||||
} else {
|
||||
Thread.currentThread().setName("SDLAudioP" + device_id);
|
||||
}
|
||||
|
||||
/* Set thread priority */
|
||||
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.v(TAG, "modify thread properties failed " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static native int nativeSetupJNI();
|
||||
}
|
||||
788
project/javaSDL2/SDLControllerManager.java
Normal file
788
project/javaSDL2/SDLControllerManager.java
Normal file
@@ -0,0 +1,788 @@
|
||||
package org.libsdl.app;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.*;
|
||||
import android.view.*;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class SDLControllerManager
|
||||
{
|
||||
|
||||
public static native int nativeSetupJNI();
|
||||
|
||||
public static native int nativeAddJoystick(int device_id, String name, String desc,
|
||||
int vendor_id, int product_id,
|
||||
boolean is_accelerometer, int button_mask,
|
||||
int naxes, int nhats, int nballs);
|
||||
public static native int nativeRemoveJoystick(int device_id);
|
||||
public static native int nativeAddHaptic(int device_id, String name);
|
||||
public static native int nativeRemoveHaptic(int device_id);
|
||||
public static native int onNativePadDown(int device_id, int keycode);
|
||||
public static native int onNativePadUp(int device_id, int keycode);
|
||||
public static native void onNativeJoy(int device_id, int axis,
|
||||
float value);
|
||||
public static native void onNativeHat(int device_id, int hat_id,
|
||||
int x, int y);
|
||||
|
||||
protected static SDLJoystickHandler mJoystickHandler;
|
||||
protected static SDLHapticHandler mHapticHandler;
|
||||
|
||||
private static final String TAG = "SDLControllerManager";
|
||||
|
||||
public static void initialize() {
|
||||
if (mJoystickHandler == null) {
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
mJoystickHandler = new SDLJoystickHandler_API19();
|
||||
} else {
|
||||
mJoystickHandler = new SDLJoystickHandler_API16();
|
||||
}
|
||||
}
|
||||
|
||||
if (mHapticHandler == null) {
|
||||
if (Build.VERSION.SDK_INT >= 26) {
|
||||
mHapticHandler = new SDLHapticHandler_API26();
|
||||
} else {
|
||||
mHapticHandler = new SDLHapticHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
|
||||
public static boolean handleJoystickMotionEvent(MotionEvent event) {
|
||||
return mJoystickHandler.handleMotionEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void pollInputDevices() {
|
||||
mJoystickHandler.pollInputDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void pollHapticDevices() {
|
||||
mHapticHandler.pollHapticDevices();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void hapticRun(int device_id, float intensity, int length) {
|
||||
mHapticHandler.run(device_id, intensity, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void hapticStop(int device_id)
|
||||
{
|
||||
mHapticHandler.stop(device_id);
|
||||
}
|
||||
|
||||
// Check if a given device is considered a possible SDL joystick
|
||||
public static boolean isDeviceSDLJoystick(int deviceId) {
|
||||
InputDevice device = InputDevice.getDevice(deviceId);
|
||||
// We cannot use InputDevice.isVirtual before API 16, so let's accept
|
||||
// only nonnegative device ids (VIRTUAL_KEYBOARD equals -1)
|
||||
if ((device == null) || (deviceId < 0)) {
|
||||
return false;
|
||||
}
|
||||
int sources = device.getSources();
|
||||
|
||||
/* This is called for every button press, so let's not spam the logs */
|
||||
/**
|
||||
if ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " has class joystick.");
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a dpad.");
|
||||
}
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) {
|
||||
Log.v(TAG, "Input device " + device.getName() + " is a gamepad.");
|
||||
}
|
||||
**/
|
||||
|
||||
return ((sources & InputDevice.SOURCE_CLASS_JOYSTICK) != 0 ||
|
||||
((sources & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) ||
|
||||
((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SDLJoystickHandler {
|
||||
|
||||
/**
|
||||
* Handles given MotionEvent.
|
||||
* @param event the event to be handled.
|
||||
* @return if given event was processed.
|
||||
*/
|
||||
public boolean handleMotionEvent(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles adding and removing of input devices.
|
||||
*/
|
||||
public void pollInputDevices() {
|
||||
}
|
||||
}
|
||||
|
||||
/* Actual joystick functionality available for API >= 12 devices */
|
||||
class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
||||
|
||||
static class SDLJoystick {
|
||||
public int device_id;
|
||||
public String name;
|
||||
public String desc;
|
||||
public ArrayList<InputDevice.MotionRange> axes;
|
||||
public ArrayList<InputDevice.MotionRange> hats;
|
||||
}
|
||||
static class RangeComparator implements Comparator<InputDevice.MotionRange> {
|
||||
@Override
|
||||
public int compare(InputDevice.MotionRange arg0, InputDevice.MotionRange arg1) {
|
||||
// Some controllers, like the Moga Pro 2, return AXIS_GAS (22) for right trigger and AXIS_BRAKE (23) for left trigger - swap them so they're sorted in the right order for SDL
|
||||
int arg0Axis = arg0.getAxis();
|
||||
int arg1Axis = arg1.getAxis();
|
||||
if (arg0Axis == MotionEvent.AXIS_GAS) {
|
||||
arg0Axis = MotionEvent.AXIS_BRAKE;
|
||||
} else if (arg0Axis == MotionEvent.AXIS_BRAKE) {
|
||||
arg0Axis = MotionEvent.AXIS_GAS;
|
||||
}
|
||||
if (arg1Axis == MotionEvent.AXIS_GAS) {
|
||||
arg1Axis = MotionEvent.AXIS_BRAKE;
|
||||
} else if (arg1Axis == MotionEvent.AXIS_BRAKE) {
|
||||
arg1Axis = MotionEvent.AXIS_GAS;
|
||||
}
|
||||
|
||||
return arg0Axis - arg1Axis;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<SDLJoystick> mJoysticks;
|
||||
|
||||
public SDLJoystickHandler_API16() {
|
||||
|
||||
mJoysticks = new ArrayList<SDLJoystick>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pollInputDevices() {
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
for(int i=0; i < deviceIds.length; ++i) {
|
||||
SDLJoystick joystick = getJoystick(deviceIds[i]);
|
||||
if (joystick == null) {
|
||||
joystick = new SDLJoystick();
|
||||
InputDevice joystickDevice = InputDevice.getDevice(deviceIds[i]);
|
||||
if (SDLControllerManager.isDeviceSDLJoystick(deviceIds[i])) {
|
||||
joystick.device_id = deviceIds[i];
|
||||
joystick.name = joystickDevice.getName();
|
||||
joystick.desc = getJoystickDescriptor(joystickDevice);
|
||||
joystick.axes = new ArrayList<InputDevice.MotionRange>();
|
||||
joystick.hats = new ArrayList<InputDevice.MotionRange>();
|
||||
|
||||
List<InputDevice.MotionRange> ranges = joystickDevice.getMotionRanges();
|
||||
Collections.sort(ranges, new RangeComparator());
|
||||
for (InputDevice.MotionRange range : ranges ) {
|
||||
if ((range.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) != 0) {
|
||||
if (range.getAxis() == MotionEvent.AXIS_HAT_X ||
|
||||
range.getAxis() == MotionEvent.AXIS_HAT_Y) {
|
||||
joystick.hats.add(range);
|
||||
}
|
||||
else {
|
||||
joystick.axes.add(range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mJoysticks.add(joystick);
|
||||
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc, getVendorId(joystickDevice), getProductId(joystickDevice), false, getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check removed devices */
|
||||
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
|
||||
for(int i=0; i < mJoysticks.size(); i++) {
|
||||
int device_id = mJoysticks.get(i).device_id;
|
||||
int j;
|
||||
for (j=0; j < deviceIds.length; j++) {
|
||||
if (device_id == deviceIds[j]) break;
|
||||
}
|
||||
if (j == deviceIds.length) {
|
||||
removedDevices.add(Integer.valueOf(device_id));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i < removedDevices.size(); i++) {
|
||||
int device_id = removedDevices.get(i).intValue();
|
||||
SDLControllerManager.nativeRemoveJoystick(device_id);
|
||||
for (int j=0; j < mJoysticks.size(); j++) {
|
||||
if (mJoysticks.get(j).device_id == device_id) {
|
||||
mJoysticks.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SDLJoystick getJoystick(int device_id) {
|
||||
for(int i=0; i < mJoysticks.size(); i++) {
|
||||
if (mJoysticks.get(i).device_id == device_id) {
|
||||
return mJoysticks.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMotionEvent(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) != 0) {
|
||||
int actionPointerIndex = event.getActionIndex();
|
||||
int action = event.getActionMasked();
|
||||
switch(action) {
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
SDLJoystick joystick = getJoystick(event.getDeviceId());
|
||||
if ( joystick != null ) {
|
||||
for (int i = 0; i < joystick.axes.size(); i++) {
|
||||
InputDevice.MotionRange range = joystick.axes.get(i);
|
||||
/* Normalize the value to -1...1 */
|
||||
float value = ( event.getAxisValue( range.getAxis(), actionPointerIndex) - range.getMin() ) / range.getRange() * 2.0f - 1.0f;
|
||||
SDLControllerManager.onNativeJoy(joystick.device_id, i, value );
|
||||
}
|
||||
for (int i = 0; i < joystick.hats.size(); i+=2) {
|
||||
int hatX = Math.round(event.getAxisValue( joystick.hats.get(i).getAxis(), actionPointerIndex ) );
|
||||
int hatY = Math.round(event.getAxisValue( joystick.hats.get(i+1).getAxis(), actionPointerIndex ) );
|
||||
SDLControllerManager.onNativeHat(joystick.device_id, i/2, hatX, hatY );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getJoystickDescriptor(InputDevice joystickDevice) {
|
||||
String desc = joystickDevice.getDescriptor();
|
||||
|
||||
if (desc != null && !desc.isEmpty()) {
|
||||
return desc;
|
||||
}
|
||||
|
||||
return joystickDevice.getName();
|
||||
}
|
||||
public int getProductId(InputDevice joystickDevice) {
|
||||
return 0;
|
||||
}
|
||||
public int getVendorId(InputDevice joystickDevice) {
|
||||
return 0;
|
||||
}
|
||||
public int getButtonMask(InputDevice joystickDevice) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
|
||||
|
||||
@Override
|
||||
public int getProductId(InputDevice joystickDevice) {
|
||||
return joystickDevice.getProductId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVendorId(InputDevice joystickDevice) {
|
||||
return joystickDevice.getVendorId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonMask(InputDevice joystickDevice) {
|
||||
int button_mask = 0;
|
||||
int[] keys = new int[] {
|
||||
KeyEvent.KEYCODE_BUTTON_A,
|
||||
KeyEvent.KEYCODE_BUTTON_B,
|
||||
KeyEvent.KEYCODE_BUTTON_X,
|
||||
KeyEvent.KEYCODE_BUTTON_Y,
|
||||
KeyEvent.KEYCODE_BACK,
|
||||
KeyEvent.KEYCODE_BUTTON_MODE,
|
||||
KeyEvent.KEYCODE_BUTTON_START,
|
||||
KeyEvent.KEYCODE_BUTTON_THUMBL,
|
||||
KeyEvent.KEYCODE_BUTTON_THUMBR,
|
||||
KeyEvent.KEYCODE_BUTTON_L1,
|
||||
KeyEvent.KEYCODE_BUTTON_R1,
|
||||
KeyEvent.KEYCODE_DPAD_UP,
|
||||
KeyEvent.KEYCODE_DPAD_DOWN,
|
||||
KeyEvent.KEYCODE_DPAD_LEFT,
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT,
|
||||
KeyEvent.KEYCODE_BUTTON_SELECT,
|
||||
KeyEvent.KEYCODE_DPAD_CENTER,
|
||||
|
||||
// These don't map into any SDL controller buttons directly
|
||||
KeyEvent.KEYCODE_BUTTON_L2,
|
||||
KeyEvent.KEYCODE_BUTTON_R2,
|
||||
KeyEvent.KEYCODE_BUTTON_C,
|
||||
KeyEvent.KEYCODE_BUTTON_Z,
|
||||
KeyEvent.KEYCODE_BUTTON_1,
|
||||
KeyEvent.KEYCODE_BUTTON_2,
|
||||
KeyEvent.KEYCODE_BUTTON_3,
|
||||
KeyEvent.KEYCODE_BUTTON_4,
|
||||
KeyEvent.KEYCODE_BUTTON_5,
|
||||
KeyEvent.KEYCODE_BUTTON_6,
|
||||
KeyEvent.KEYCODE_BUTTON_7,
|
||||
KeyEvent.KEYCODE_BUTTON_8,
|
||||
KeyEvent.KEYCODE_BUTTON_9,
|
||||
KeyEvent.KEYCODE_BUTTON_10,
|
||||
KeyEvent.KEYCODE_BUTTON_11,
|
||||
KeyEvent.KEYCODE_BUTTON_12,
|
||||
KeyEvent.KEYCODE_BUTTON_13,
|
||||
KeyEvent.KEYCODE_BUTTON_14,
|
||||
KeyEvent.KEYCODE_BUTTON_15,
|
||||
KeyEvent.KEYCODE_BUTTON_16,
|
||||
};
|
||||
int[] masks = new int[] {
|
||||
(1 << 0), // A -> A
|
||||
(1 << 1), // B -> B
|
||||
(1 << 2), // X -> X
|
||||
(1 << 3), // Y -> Y
|
||||
(1 << 4), // BACK -> BACK
|
||||
(1 << 5), // MODE -> GUIDE
|
||||
(1 << 6), // START -> START
|
||||
(1 << 7), // THUMBL -> LEFTSTICK
|
||||
(1 << 8), // THUMBR -> RIGHTSTICK
|
||||
(1 << 9), // L1 -> LEFTSHOULDER
|
||||
(1 << 10), // R1 -> RIGHTSHOULDER
|
||||
(1 << 11), // DPAD_UP -> DPAD_UP
|
||||
(1 << 12), // DPAD_DOWN -> DPAD_DOWN
|
||||
(1 << 13), // DPAD_LEFT -> DPAD_LEFT
|
||||
(1 << 14), // DPAD_RIGHT -> DPAD_RIGHT
|
||||
(1 << 4), // SELECT -> BACK
|
||||
(1 << 0), // DPAD_CENTER -> A
|
||||
(1 << 15), // L2 -> ??
|
||||
(1 << 16), // R2 -> ??
|
||||
(1 << 17), // C -> ??
|
||||
(1 << 18), // Z -> ??
|
||||
(1 << 20), // 1 -> ??
|
||||
(1 << 21), // 2 -> ??
|
||||
(1 << 22), // 3 -> ??
|
||||
(1 << 23), // 4 -> ??
|
||||
(1 << 24), // 5 -> ??
|
||||
(1 << 25), // 6 -> ??
|
||||
(1 << 26), // 7 -> ??
|
||||
(1 << 27), // 8 -> ??
|
||||
(1 << 28), // 9 -> ??
|
||||
(1 << 29), // 10 -> ??
|
||||
(1 << 30), // 11 -> ??
|
||||
(1 << 31), // 12 -> ??
|
||||
// We're out of room...
|
||||
0xFFFFFFFF, // 13 -> ??
|
||||
0xFFFFFFFF, // 14 -> ??
|
||||
0xFFFFFFFF, // 15 -> ??
|
||||
0xFFFFFFFF, // 16 -> ??
|
||||
};
|
||||
boolean[] has_keys = joystickDevice.hasKeys(keys);
|
||||
for (int i = 0; i < keys.length; ++i) {
|
||||
if (has_keys[i]) {
|
||||
button_mask |= masks[i];
|
||||
}
|
||||
}
|
||||
return button_mask;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLHapticHandler_API26 extends SDLHapticHandler {
|
||||
@Override
|
||||
public void run(int device_id, float intensity, int length) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
Log.d("SDL", "Rtest: Vibe with intensity " + intensity + " for " + length);
|
||||
if (intensity == 0.0f) {
|
||||
stop(device_id);
|
||||
return;
|
||||
}
|
||||
|
||||
int vibeValue = Math.round(intensity * 255);
|
||||
|
||||
if (vibeValue > 255) {
|
||||
vibeValue = 255;
|
||||
}
|
||||
if (vibeValue < 1) {
|
||||
stop(device_id);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
haptic.vib.vibrate(VibrationEffect.createOneShot(length, vibeValue));
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Fall back to the generic method, which uses DEFAULT_AMPLITUDE, but works even if
|
||||
// something went horribly wrong with the Android 8.0 APIs.
|
||||
haptic.vib.vibrate(length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SDLHapticHandler {
|
||||
|
||||
class SDLHaptic {
|
||||
public int device_id;
|
||||
public String name;
|
||||
public Vibrator vib;
|
||||
}
|
||||
|
||||
private ArrayList<SDLHaptic> mHaptics;
|
||||
|
||||
public SDLHapticHandler() {
|
||||
mHaptics = new ArrayList<SDLHaptic>();
|
||||
}
|
||||
|
||||
public void run(int device_id, float intensity, int length) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
haptic.vib.vibrate(length);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(int device_id) {
|
||||
SDLHaptic haptic = getHaptic(device_id);
|
||||
if (haptic != null) {
|
||||
haptic.vib.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
public void pollHapticDevices() {
|
||||
|
||||
final int deviceId_VIBRATOR_SERVICE = 999999;
|
||||
boolean hasVibratorService = false;
|
||||
|
||||
int[] deviceIds = InputDevice.getDeviceIds();
|
||||
// It helps processing the device ids in reverse order
|
||||
// For example, in the case of the XBox 360 wireless dongle,
|
||||
// so the first controller seen by SDL matches what the receiver
|
||||
// considers to be the first controller
|
||||
|
||||
for (int i = deviceIds.length - 1; i > -1; i--) {
|
||||
SDLHaptic haptic = getHaptic(deviceIds[i]);
|
||||
if (haptic == null) {
|
||||
InputDevice device = InputDevice.getDevice(deviceIds[i]);
|
||||
Vibrator vib = device.getVibrator();
|
||||
if (vib.hasVibrator()) {
|
||||
haptic = new SDLHaptic();
|
||||
haptic.device_id = deviceIds[i];
|
||||
haptic.name = device.getName();
|
||||
haptic.vib = vib;
|
||||
mHaptics.add(haptic);
|
||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check VIBRATOR_SERVICE */
|
||||
Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
||||
if (vib != null) {
|
||||
hasVibratorService = vib.hasVibrator();
|
||||
|
||||
if (hasVibratorService) {
|
||||
SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE);
|
||||
if (haptic == null) {
|
||||
haptic = new SDLHaptic();
|
||||
haptic.device_id = deviceId_VIBRATOR_SERVICE;
|
||||
haptic.name = "VIBRATOR_SERVICE";
|
||||
haptic.vib = vib;
|
||||
mHaptics.add(haptic);
|
||||
SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check removed devices */
|
||||
ArrayList<Integer> removedDevices = new ArrayList<Integer>();
|
||||
for(int i=0; i < mHaptics.size(); i++) {
|
||||
int device_id = mHaptics.get(i).device_id;
|
||||
int j;
|
||||
for (j=0; j < deviceIds.length; j++) {
|
||||
if (device_id == deviceIds[j]) break;
|
||||
}
|
||||
|
||||
if (device_id == deviceId_VIBRATOR_SERVICE && hasVibratorService) {
|
||||
// don't remove the vibrator if it is still present
|
||||
} else if (j == deviceIds.length) {
|
||||
removedDevices.add(device_id);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i < removedDevices.size(); i++) {
|
||||
int device_id = removedDevices.get(i);
|
||||
SDLControllerManager.nativeRemoveHaptic(device_id);
|
||||
for (int j=0; j < mHaptics.size(); j++) {
|
||||
if (mHaptics.get(j).device_id == device_id) {
|
||||
mHaptics.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SDLHaptic getHaptic(int device_id) {
|
||||
for(int i=0; i < mHaptics.size(); i++) {
|
||||
if (mHaptics.get(i).device_id == device_id) {
|
||||
return mHaptics.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class SDLGenericMotionListener_API12 implements View.OnGenericMotionListener {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
float x, y;
|
||||
int action;
|
||||
|
||||
switch ( event.getSource() ) {
|
||||
case InputDevice.SOURCE_JOYSTICK:
|
||||
case InputDevice.SOURCE_GAMEPAD:
|
||||
case InputDevice.SOURCE_DPAD:
|
||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Event was not managed
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean supportsRelativeMouse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean inRelativeMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void reclaimRelativeMouseModeIfNeeded()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public float getEventX(MotionEvent event) {
|
||||
return event.getX(0);
|
||||
}
|
||||
|
||||
public float getEventY(MotionEvent event) {
|
||||
return event.getY(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SDLGenericMotionListener_API24 extends SDLGenericMotionListener_API12 {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
|
||||
private boolean mRelativeModeEnabled;
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
|
||||
// Handle relative mouse mode
|
||||
if (mRelativeModeEnabled) {
|
||||
if (event.getSource() == InputDevice.SOURCE_MOUSE) {
|
||||
int action = event.getActionMasked();
|
||||
if (action == MotionEvent.ACTION_HOVER_MOVE) {
|
||||
float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
|
||||
float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Event was not managed, call SDLGenericMotionListener_API12 method
|
||||
return super.onGenericMotion(v, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRelativeMouse() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRelativeMode() {
|
||||
return mRelativeModeEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
mRelativeModeEnabled = enabled;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventX(MotionEvent event) {
|
||||
if (mRelativeModeEnabled) {
|
||||
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
|
||||
}
|
||||
else {
|
||||
return event.getX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventY(MotionEvent event) {
|
||||
if (mRelativeModeEnabled) {
|
||||
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
|
||||
}
|
||||
else {
|
||||
return event.getY(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
|
||||
// Generic Motion (mouse hover, joystick...) events go here
|
||||
private boolean mRelativeModeEnabled;
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotion(View v, MotionEvent event) {
|
||||
float x, y;
|
||||
int action;
|
||||
|
||||
switch ( event.getSource() ) {
|
||||
case InputDevice.SOURCE_JOYSTICK:
|
||||
case InputDevice.SOURCE_GAMEPAD:
|
||||
case InputDevice.SOURCE_DPAD:
|
||||
return SDLControllerManager.handleJoystickMotionEvent(event);
|
||||
|
||||
case InputDevice.SOURCE_MOUSE:
|
||||
// DeX desktop mouse cursor is a separate non-standard input type.
|
||||
case InputDevice.SOURCE_MOUSE | InputDevice.SOURCE_TOUCHSCREEN:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case InputDevice.SOURCE_MOUSE_RELATIVE:
|
||||
action = event.getActionMasked();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_SCROLL:
|
||||
x = event.getAxisValue(MotionEvent.AXIS_HSCROLL, 0);
|
||||
y = event.getAxisValue(MotionEvent.AXIS_VSCROLL, 0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, false);
|
||||
return true;
|
||||
|
||||
case MotionEvent.ACTION_HOVER_MOVE:
|
||||
x = event.getX(0);
|
||||
y = event.getY(0);
|
||||
SDLActivity.onNativeMouse(0, action, x, y, true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Event was not managed
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRelativeMouse() {
|
||||
return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inRelativeMode() {
|
||||
return mRelativeModeEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
|
||||
if (enabled) {
|
||||
SDLActivity.getContentView().requestPointerCapture();
|
||||
}
|
||||
else {
|
||||
SDLActivity.getContentView().releasePointerCapture();
|
||||
}
|
||||
mRelativeModeEnabled = enabled;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reclaimRelativeMouseModeIfNeeded()
|
||||
{
|
||||
if (mRelativeModeEnabled && !SDLActivity.isDeXMode()) {
|
||||
SDLActivity.getContentView().requestPointerCapture();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventX(MotionEvent event) {
|
||||
// Relative mouse in capture mode will only have relative for X/Y
|
||||
return event.getX(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getEventY(MotionEvent event) {
|
||||
// Relative mouse in capture mode will only have relative for X/Y
|
||||
return event.getY(0);
|
||||
}
|
||||
}
|
||||
@@ -1,782 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
// TODO: too much code here, split into multiple files, possibly auto-generated menus?
|
||||
class Settings
|
||||
{
|
||||
static String SettingsFileName = "libsdl-settings.cfg";
|
||||
|
||||
static boolean settingsLoaded = false;
|
||||
static boolean settingsChanged = false;
|
||||
static final int SETTINGS_FILE_VERSION = 5;
|
||||
|
||||
static void Save(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
|
||||
out.writeInt(SETTINGS_FILE_VERSION);
|
||||
out.writeBoolean(Globals.DownloadToSdcard);
|
||||
out.writeBoolean(Globals.PhoneHasArrowKeys);
|
||||
out.writeBoolean(Globals.PhoneHasTrackball);
|
||||
out.writeBoolean(Globals.UseAccelerometerAsArrowKeys);
|
||||
out.writeBoolean(Globals.UseTouchscreenKeyboard);
|
||||
out.writeInt(Globals.TouchscreenKeyboardSize);
|
||||
out.writeInt(Globals.AccelerometerSensitivity);
|
||||
out.writeInt(Globals.AccelerometerCenterPos);
|
||||
out.writeInt(Globals.TrackballDampening);
|
||||
out.writeInt(Globals.AudioBufferConfig);
|
||||
out.writeInt(Globals.TouchscreenKeyboardTheme);
|
||||
out.writeInt(Globals.RightClickMethod);
|
||||
out.writeInt(Globals.ShowScreenUnderFinger);
|
||||
out.writeInt(Globals.LeftClickMethod);
|
||||
out.writeBoolean(Globals.MoveMouseWithJoystick);
|
||||
out.writeBoolean(Globals.ClickMouseWithDpad);
|
||||
out.writeInt(Globals.ClickScreenPressure);
|
||||
out.writeInt(Globals.ClickScreenTouchspotSize);
|
||||
out.writeBoolean(Globals.KeepAspectRatio);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickSpeed);
|
||||
out.writeInt(Globals.MoveMouseWithJoystickAccel);
|
||||
out.writeInt(SDL_Keys.JAVA_KEYCODE_LAST);
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapHwKeycode[i]);
|
||||
}
|
||||
out.writeInt(Globals.RemapScreenKbKeycode.length);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapScreenKbKeycode[i]);
|
||||
}
|
||||
out.writeInt(Globals.ScreenKbControlsShown.length);
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
{
|
||||
out.writeBoolean(Globals.ScreenKbControlsShown[i]);
|
||||
}
|
||||
out.writeInt(Globals.TouchscreenKeyboardTransparency);
|
||||
out.writeInt(Globals.RemapMultitouchGestureKeycode.length);
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
out.writeInt(Globals.RemapMultitouchGestureKeycode[i]);
|
||||
out.writeBoolean(Globals.MultitouchGesturesUsed[i]);
|
||||
}
|
||||
out.writeInt(Globals.MultitouchGestureSensitivity);
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
out.writeInt(Globals.TouchscreenCalibration[i]);
|
||||
out.writeInt(Globals.DataDir.length());
|
||||
for( int i = 0; i < Globals.DataDir.length(); i++ )
|
||||
out.writeChar(Globals.DataDir.charAt(i));
|
||||
out.writeInt(Globals.CommandLine.length());
|
||||
for( int i = 0; i < Globals.CommandLine.length(); i++ )
|
||||
out.writeChar(Globals.CommandLine.charAt(i));
|
||||
out.writeInt(Globals.ScreenKbControlsLayout.length);
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
out.writeInt(Globals.ScreenKbControlsLayout[i][ii]);
|
||||
out.writeInt(Globals.LeftClickKey);
|
||||
out.writeInt(Globals.RightClickKey);
|
||||
out.writeBoolean(Globals.VideoLinearFilter);
|
||||
out.writeInt(Globals.LeftClickTimeout);
|
||||
out.writeInt(Globals.RightClickTimeout);
|
||||
out.writeBoolean(Globals.RelativeMouseMovement);
|
||||
out.writeInt(Globals.RelativeMouseMovementSpeed);
|
||||
out.writeInt(Globals.RelativeMouseMovementAccel);
|
||||
out.writeBoolean(Globals.MultiThreadedVideo);
|
||||
|
||||
out.writeInt(Globals.OptionalDataDownload.length);
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
out.writeBoolean(Globals.OptionalDataDownload[i]);
|
||||
out.writeBoolean(Globals.BrokenLibCMessageShown);
|
||||
out.writeInt(Globals.TouchscreenKeyboardDrawSize);
|
||||
out.writeInt(p.getApplicationVersion());
|
||||
out.writeFloat(Globals.gyro_x1);
|
||||
out.writeFloat(Globals.gyro_x2);
|
||||
out.writeFloat(Globals.gyro_xc);
|
||||
out.writeFloat(Globals.gyro_y1);
|
||||
out.writeFloat(Globals.gyro_y2);
|
||||
out.writeFloat(Globals.gyro_yc);
|
||||
out.writeFloat(Globals.gyro_z1);
|
||||
out.writeFloat(Globals.gyro_z2);
|
||||
out.writeFloat(Globals.gyro_zc);
|
||||
|
||||
out.writeBoolean(Globals.OuyaEmulation);
|
||||
|
||||
out.close();
|
||||
settingsLoaded = true;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {};
|
||||
}
|
||||
|
||||
static void Load( final MainActivity p )
|
||||
{
|
||||
if(settingsLoaded) // Prevent starting twice
|
||||
{
|
||||
return;
|
||||
}
|
||||
Log.i("SDL", "libSDL: Settings.Load(): enter");
|
||||
/*nativeInitKeymap(); // TODO: Disabled in SDL2
|
||||
if( p.isRunningOnOUYA() )
|
||||
nativeSetKeymapKey(KeyEvent.KEYCODE_MENU, nativeGetKeymapKey(KeyEvent.KEYCODE_BACK)); // Ouya does not have Back key, only Menu, so remap Back keycode to Menu
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKey(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapHwKeycode[i] = idx;
|
||||
}
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKeyScreenKb(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapScreenKbKeycode[i] = idx;
|
||||
}*/
|
||||
Globals.ScreenKbControlsShown[0] = (Globals.AppNeedsArrowKeys || Globals.AppUsesJoystick);
|
||||
Globals.ScreenKbControlsShown[1] = Globals.AppNeedsTextInput;
|
||||
for( int i = 2; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
Globals.ScreenKbControlsShown[i] = ( i - 2 < Globals.AppTouchscreenKeyboardKeysAmount );
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
Globals.ScreenKbControlsShown[8] = true;
|
||||
/*for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
int sdlKey = nativeGetKeymapKeyMultitouchGesture(i);
|
||||
int idx = 0;
|
||||
for(int ii = 0; ii < SDL_Keys.values.length; ii++)
|
||||
if(SDL_Keys.values[ii] == sdlKey)
|
||||
idx = ii;
|
||||
Globals.RemapMultitouchGestureKeycode[i] = idx;
|
||||
}*/
|
||||
for( int i = 0; i < Globals.MultitouchGesturesUsed.length; i++ )
|
||||
Globals.MultitouchGesturesUsed[i] = true;
|
||||
// Adjust coordinates of on-screen buttons from 800x480
|
||||
int displayX = 800;
|
||||
int displayY = 480;
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
displayX = dm.widthPixels;
|
||||
displayY = dm.heightPixels;
|
||||
} catch (Exception eeeee) {}
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] *= (float)displayX / 800.0f;
|
||||
Globals.ScreenKbControlsLayout[i][2] *= (float)displayX / 800.0f;
|
||||
Globals.ScreenKbControlsLayout[i][1] *= (float)displayY / 480.0f;
|
||||
Globals.ScreenKbControlsLayout[i][3] *= (float)displayY / 480.0f;
|
||||
// Make them square
|
||||
int wh = Math.min( Globals.ScreenKbControlsLayout[i][2] - Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][3] - Globals.ScreenKbControlsLayout[i][1] );
|
||||
Globals.ScreenKbControlsLayout[i][2] = Globals.ScreenKbControlsLayout[i][0] + wh;
|
||||
Globals.ScreenKbControlsLayout[i][3] = Globals.ScreenKbControlsLayout[i][1] + wh;
|
||||
}
|
||||
|
||||
Log.i("SDL", "android.os.Build.MODEL: " + android.os.Build.MODEL);
|
||||
if( (android.os.Build.MODEL.equals("GT-N7000") || android.os.Build.MODEL.equals("SGH-I717"))
|
||||
&& android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1 )
|
||||
{
|
||||
// Samsung Galaxy Note generates a keypress when you hover a stylus over the screen, and that messes up OpenTTD dialogs
|
||||
// ICS update sends events in a proper way
|
||||
Globals.RemapHwKeycode[112] = SDL_1_2_Keycodes.SDLK_UNKNOWN;
|
||||
}
|
||||
|
||||
try {
|
||||
ObjectInputStream settingsFile = new ObjectInputStream(new FileInputStream( p.getFilesDir().getAbsolutePath() + "/" + SettingsFileName ));
|
||||
if( settingsFile.readInt() != SETTINGS_FILE_VERSION )
|
||||
throw new IOException();
|
||||
Globals.DownloadToSdcard = settingsFile.readBoolean();
|
||||
Globals.PhoneHasArrowKeys = settingsFile.readBoolean();
|
||||
Globals.PhoneHasTrackball = settingsFile.readBoolean();
|
||||
Globals.UseAccelerometerAsArrowKeys = settingsFile.readBoolean();
|
||||
Globals.UseTouchscreenKeyboard = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardSize = settingsFile.readInt();
|
||||
Globals.AccelerometerSensitivity = settingsFile.readInt();
|
||||
Globals.AccelerometerCenterPos = settingsFile.readInt();
|
||||
Globals.TrackballDampening = settingsFile.readInt();
|
||||
Globals.AudioBufferConfig = settingsFile.readInt();
|
||||
Globals.TouchscreenKeyboardTheme = settingsFile.readInt();
|
||||
Globals.RightClickMethod = settingsFile.readInt();
|
||||
Globals.ShowScreenUnderFinger = settingsFile.readInt();
|
||||
Globals.LeftClickMethod = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystick = settingsFile.readBoolean();
|
||||
Globals.ClickMouseWithDpad = settingsFile.readBoolean();
|
||||
Globals.ClickScreenPressure = settingsFile.readInt();
|
||||
Globals.ClickScreenTouchspotSize = settingsFile.readInt();
|
||||
Globals.KeepAspectRatio = settingsFile.readBoolean();
|
||||
Globals.MoveMouseWithJoystickSpeed = settingsFile.readInt();
|
||||
Globals.MoveMouseWithJoystickAccel = settingsFile.readInt();
|
||||
int readKeys = settingsFile.readInt();
|
||||
for( int i = 0; i < readKeys; i++ )
|
||||
{
|
||||
Globals.RemapHwKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.RemapScreenKbKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[i] = settingsFile.readInt();
|
||||
}
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsShown.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
{
|
||||
Globals.ScreenKbControlsShown[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.TouchscreenKeyboardTransparency = settingsFile.readInt();
|
||||
if( settingsFile.readInt() != Globals.RemapMultitouchGestureKeycode.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[i] = settingsFile.readInt();
|
||||
Globals.MultitouchGesturesUsed[i] = settingsFile.readBoolean();
|
||||
}
|
||||
Globals.MultitouchGestureSensitivity = settingsFile.readInt();
|
||||
for( int i = 0; i < Globals.TouchscreenCalibration.length; i++ )
|
||||
Globals.TouchscreenCalibration[i] = settingsFile.readInt();
|
||||
StringBuilder b = new StringBuilder();
|
||||
int len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.DataDir = b.toString();
|
||||
|
||||
b = new StringBuilder();
|
||||
len = settingsFile.readInt();
|
||||
for( int i = 0; i < len; i++ )
|
||||
b.append( settingsFile.readChar() );
|
||||
Globals.CommandLine = b.toString();
|
||||
|
||||
if( settingsFile.readInt() != Globals.ScreenKbControlsLayout.length )
|
||||
throw new IOException();
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
for( int ii = 0; ii < 4; ii++ )
|
||||
Globals.ScreenKbControlsLayout[i][ii] = settingsFile.readInt();
|
||||
Globals.LeftClickKey = settingsFile.readInt();
|
||||
Globals.RightClickKey = settingsFile.readInt();
|
||||
Globals.VideoLinearFilter = settingsFile.readBoolean();
|
||||
Globals.LeftClickTimeout = settingsFile.readInt();
|
||||
Globals.RightClickTimeout = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovement = settingsFile.readBoolean();
|
||||
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
|
||||
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
|
||||
Globals.MultiThreadedVideo = settingsFile.readBoolean();
|
||||
|
||||
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
|
||||
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
|
||||
Globals.OptionalDataDownload[i] = settingsFile.readBoolean();
|
||||
Globals.BrokenLibCMessageShown = settingsFile.readBoolean();
|
||||
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
|
||||
int cfgVersion = settingsFile.readInt();
|
||||
Globals.gyro_x1 = settingsFile.readFloat();
|
||||
Globals.gyro_x2 = settingsFile.readFloat();
|
||||
Globals.gyro_xc = settingsFile.readFloat();
|
||||
Globals.gyro_y1 = settingsFile.readFloat();
|
||||
Globals.gyro_y2 = settingsFile.readFloat();
|
||||
Globals.gyro_yc = settingsFile.readFloat();
|
||||
Globals.gyro_z1 = settingsFile.readFloat();
|
||||
Globals.gyro_z2 = settingsFile.readFloat();
|
||||
Globals.gyro_zc = settingsFile.readFloat();
|
||||
|
||||
Globals.OuyaEmulation = settingsFile.readBoolean();
|
||||
|
||||
settingsLoaded = true;
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.Load(): loaded settings successfully");
|
||||
settingsFile.close();
|
||||
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion());
|
||||
if( cfgVersion != p.getApplicationVersion() )
|
||||
{
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
// Delete settings file, and restart the application
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
Save(p);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch( SecurityException e ) {
|
||||
} catch ( IOException e ) {
|
||||
DeleteFilesOnUpgrade(p);
|
||||
if( Globals.ResetSdlConfigForThisVersion )
|
||||
{
|
||||
Log.i("SDL", "libSDL: old cfg version unknown or too old, our version " + p.getApplicationVersion() + " and we need to clean up config file");
|
||||
DeleteSdlConfigOnUpgradeAndRestart(p);
|
||||
}
|
||||
};
|
||||
|
||||
if( Globals.DataDir.length() == 0 )
|
||||
{
|
||||
if( !Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) )
|
||||
{
|
||||
Log.i("SDL", "libSDL: SD card or external storage is not mounted (state " + Environment.getExternalStorageState() + "), switching to the internal storage.");
|
||||
Globals.DownloadToSdcard = false;
|
||||
}
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
SdcardAppPath.getPath(p) :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
if( Globals.DownloadToSdcard )
|
||||
{
|
||||
// Check if data already installed into deprecated location at /sdcard/app-data/<package-name>
|
||||
String[] fileList = new File(SdcardAppPath.deprecatedPath(p)).list();
|
||||
if( fileList != null )
|
||||
for( String s: fileList )
|
||||
if( s.toUpperCase().startsWith(DataDownloader.DOWNLOAD_FLAG_FILENAME.toUpperCase()) )
|
||||
Globals.DataDir = SdcardAppPath.deprecatedPath(p);
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("SDL", "libSDL: Settings.Load(): loading settings failed, running config dialog");
|
||||
p.setUpStatusLabel();
|
||||
if( checkRamSize(p) )
|
||||
SettingsMenu.showConfig(p, true);
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
||||
public static boolean deleteRecursively(File dir)
|
||||
{
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i<children.length; i++)
|
||||
{
|
||||
boolean success = deleteRecursively(new File(dir, children[i]));
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
}
|
||||
public static boolean deleteRecursivelyAndLog(File dir)
|
||||
{
|
||||
Log.v("SDL", "Deleting old file: " + dir.getAbsolutePath() + " exists " + dir.exists());
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
for (int i=0; i<children.length; i++)
|
||||
{
|
||||
boolean success = deleteRecursively(new File(dir, children[i]));
|
||||
if (!success)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return dir.delete();
|
||||
}
|
||||
public static void DeleteFilesOnUpgrade(final MainActivity p)
|
||||
{
|
||||
String [] files = Globals.DeleteFilesOnUpgrade.split(" ");
|
||||
for(String path: files)
|
||||
{
|
||||
if( path.equals("") )
|
||||
continue;
|
||||
|
||||
deleteRecursivelyAndLog(new File( SdcardAppPath.getPath(p) + "/" + path ));
|
||||
deleteRecursivelyAndLog(new File( p.getFilesDir().getAbsolutePath() + "/" + path ));
|
||||
deleteRecursivelyAndLog(new File( SdcardAppPath.deprecatedPath(p) + "/" + path ));
|
||||
}
|
||||
}
|
||||
public static void DeleteSdlConfigOnUpgradeAndRestart(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
|
||||
out.writeInt(-1);
|
||||
out.close();
|
||||
} catch( FileNotFoundException e ) {
|
||||
} catch ( IOException e ) { }
|
||||
new File( p.getFilesDir() + "/" + SettingsFileName ).delete();
|
||||
PendingIntent intent = PendingIntent.getActivity(p, 0, new Intent(p.getIntent()), p.getIntent().getFlags());
|
||||
AlarmManager mgr = (AlarmManager) p.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
// ===============================================================================================
|
||||
|
||||
static void Apply(MainActivity p)
|
||||
{
|
||||
/*nativeSetVideoDepth(Globals.VideoDepthBpp, Globals.NeedGles2 ? 1 : 0);
|
||||
if(Globals.VideoLinearFilter)
|
||||
nativeSetVideoLinearFilter();
|
||||
if( Globals.CompatibilityHacksVideo )
|
||||
{
|
||||
Globals.MultiThreadedVideo = true;
|
||||
Globals.SwVideoMode = true;
|
||||
nativeSetCompatibilityHacks();
|
||||
}
|
||||
if( Globals.SwVideoMode )
|
||||
nativeSetVideoForceSoftwareMode();
|
||||
if( Globals.SwVideoMode && Globals.MultiThreadedVideo )
|
||||
nativeSetVideoMultithreaded();
|
||||
if( Globals.PhoneHasTrackball )
|
||||
nativeSetTrackballUsed();
|
||||
if( Globals.AppUsesMouse )
|
||||
nativeSetMouseUsed( Globals.RightClickMethod,
|
||||
Globals.ShowScreenUnderFinger,
|
||||
Globals.LeftClickMethod,
|
||||
Globals.MoveMouseWithJoystick ? 1 : 0,
|
||||
Globals.ClickMouseWithDpad ? 1 : 0,
|
||||
Globals.ClickScreenPressure,
|
||||
Globals.ClickScreenTouchspotSize,
|
||||
Globals.MoveMouseWithJoystickSpeed,
|
||||
Globals.MoveMouseWithJoystickAccel,
|
||||
Globals.LeftClickKey,
|
||||
Globals.RightClickKey,
|
||||
Globals.LeftClickTimeout,
|
||||
Globals.RightClickTimeout,
|
||||
Globals.RelativeMouseMovement ? 1 : 0,
|
||||
Globals.RelativeMouseMovementSpeed,
|
||||
Globals.RelativeMouseMovementAccel,
|
||||
Globals.ShowMouseCursor ? 1 : 0 );
|
||||
nativeSetJoystickUsed(Globals.AppUsesJoystick ? 1 : 0, Globals.AppUsesSecondJoystick ? 1 : 0);
|
||||
if( Globals.AppUsesAccelerometer )
|
||||
nativeSetAccelerometerUsed();
|
||||
if( Globals.AppUsesMultitouch )
|
||||
nativeSetMultitouchUsed();
|
||||
nativeSetAccelerometerSettings(Globals.AccelerometerSensitivity, Globals.AccelerometerCenterPos);
|
||||
nativeSetTrackballDampening(Globals.TrackballDampening);
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
boolean screenKbReallyUsed = false;
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
if( Globals.ScreenKbControlsShown[i] )
|
||||
screenKbReallyUsed = true;
|
||||
if( p.isRunningOnOUYA() )
|
||||
screenKbReallyUsed = false;
|
||||
if( screenKbReallyUsed )
|
||||
{
|
||||
nativeSetTouchscreenKeyboardUsed();
|
||||
nativeSetupScreenKeyboard( Globals.TouchscreenKeyboardSize,
|
||||
Globals.TouchscreenKeyboardDrawSize,
|
||||
Globals.TouchscreenKeyboardTheme,
|
||||
Globals.AppTouchscreenKeyboardKeysAmountAutoFire,
|
||||
Globals.TouchscreenKeyboardTransparency );
|
||||
SetupTouchscreenKeyboardGraphics(p);
|
||||
for( int i = 0; i < Globals.RemapScreenKbKeycode.length; i++ )
|
||||
nativeSetKeymapKeyScreenKb(i, SDL_Keys.values[Globals.RemapScreenKbKeycode[i]]);
|
||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
{
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] )
|
||||
nativeSetScreenKbKeyLayout( i, Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
}
|
||||
for( int i = 0; i < Globals.ScreenKbControlsShown.length; i++ )
|
||||
nativeSetScreenKbKeyUsed(i, Globals.ScreenKbControlsShown[i] ? 1 : 0);
|
||||
}
|
||||
else
|
||||
Globals.UseTouchscreenKeyboard = false;
|
||||
}
|
||||
|
||||
for( int i = 0; i < SDL_Keys.JAVA_KEYCODE_LAST; i++ )
|
||||
nativeSetKeymapKey(i, SDL_Keys.values[Globals.RemapHwKeycode[i]]);
|
||||
for( int i = 0; i < Globals.RemapMultitouchGestureKeycode.length; i++ )
|
||||
nativeSetKeymapKeyMultitouchGesture(i, Globals.MultitouchGesturesUsed[i] ? SDL_Keys.values[Globals.RemapMultitouchGestureKeycode[i]] : 0);
|
||||
nativeSetMultitouchGestureSensitivity(Globals.MultitouchGestureSensitivity);
|
||||
if( Globals.TouchscreenCalibration[2] > Globals.TouchscreenCalibration[0] )
|
||||
nativeSetTouchscreenCalibration(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);*/
|
||||
|
||||
String lang = new String(Locale.getDefault().getLanguage());
|
||||
if( Locale.getDefault().getCountry().length() > 0 )
|
||||
lang = lang + "_" + Locale.getDefault().getCountry();
|
||||
Log.i("SDL", "libSDL: setting envvar LANGUAGE to '" + lang + "'");
|
||||
nativeSetEnv( "LANG", lang );
|
||||
nativeSetEnv( "LANGUAGE", lang );
|
||||
// TODO: get current user name and set envvar USER, the API is not availalbe on Android 1.6 so I don't bother with this
|
||||
nativeSetEnv( "APPDIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "SECURE_STORAGE_DIR", p.getFilesDir().getAbsolutePath() );
|
||||
nativeSetEnv( "DATADIR", Globals.DataDir );
|
||||
nativeSetEnv( "UNSECURE_STORAGE_DIR", Globals.DataDir );
|
||||
nativeSetEnv( "HOME", Globals.DataDir );
|
||||
nativeSetEnv( "ANDROID_VERSION", String.valueOf(android.os.Build.VERSION.SDK_INT) );
|
||||
Log.d("SDL", "libSDL: Is running on OUYA: " + p.isRunningOnOUYA());
|
||||
if( p.isRunningOnOUYA() )
|
||||
nativeSetEnv( "OUYA", "1" );
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
float xx = dm.widthPixels/dm.xdpi;
|
||||
float yy = dm.heightPixels/dm.ydpi;
|
||||
float x = Math.max(xx, yy);
|
||||
float y = Math.min(xx, yy);
|
||||
float displayInches = (float)Math.sqrt( x*x + y*y );
|
||||
nativeSetEnv( "DISPLAY_SIZE", String.valueOf(displayInches) );
|
||||
nativeSetEnv( "DISPLAY_SIZE_MM", String.valueOf((int)(displayInches*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_WIDTH", String.valueOf(x) );
|
||||
nativeSetEnv( "DISPLAY_HEIGHT", String.valueOf(y) );
|
||||
nativeSetEnv( "DISPLAY_WIDTH_MM", String.valueOf((int)(x*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_HEIGHT_MM", String.valueOf((int)(y*25.4f)) );
|
||||
nativeSetEnv( "DISPLAY_RESOLUTION_WIDTH", String.valueOf(Math.max(dm.widthPixels, dm.heightPixels)) );
|
||||
nativeSetEnv( "DISPLAY_RESOLUTION_HEIGHT", String.valueOf(Math.min(dm.widthPixels, dm.heightPixels)) );
|
||||
} catch (Exception eeeee) {}
|
||||
}
|
||||
|
||||
static byte [] loadRaw(Activity p, int res)
|
||||
{
|
||||
byte [] buf = new byte[65536 * 2];
|
||||
byte [] a = new byte[65536 * 4 * 10]; // We need 2363516 bytes for the Sun theme
|
||||
int written = 0;
|
||||
try{
|
||||
InputStream is = new GZIPInputStream(p.getResources().openRawResource(res));
|
||||
int readed = 0;
|
||||
while( (readed = is.read(buf)) >= 0 )
|
||||
{
|
||||
if( written + readed > a.length )
|
||||
{
|
||||
byte [] b = new byte [written + readed];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
a = b;
|
||||
}
|
||||
System.arraycopy(buf, 0, a, written, readed);
|
||||
written += readed;
|
||||
}
|
||||
} catch(Exception e) {};
|
||||
byte [] b = new byte [written];
|
||||
System.arraycopy(a, 0, b, 0, written);
|
||||
return b;
|
||||
}
|
||||
|
||||
static void SetupTouchscreenKeyboardGraphics(Activity p)
|
||||
{
|
||||
if( Globals.UseTouchscreenKeyboard )
|
||||
{
|
||||
if(Globals.TouchscreenKeyboardTheme < 0)
|
||||
Globals.TouchscreenKeyboardTheme = 0;
|
||||
if(Globals.TouchscreenKeyboardTheme > 3)
|
||||
Globals.TouchscreenKeyboardTheme = 3;
|
||||
|
||||
if( Globals.TouchscreenKeyboardTheme == 0 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.ultimatedroid));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 1 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.simpletheme));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.sun));
|
||||
}
|
||||
if( Globals.TouchscreenKeyboardTheme == 3 )
|
||||
{
|
||||
nativeSetupScreenKeyboardButtons(loadRaw(p, R.raw.keen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class SdcardAppPath
|
||||
{
|
||||
private static SdcardAppPath get()
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO)
|
||||
return Froyo.Holder.sInstance;
|
||||
else
|
||||
return Dummy.Holder.sInstance;
|
||||
}
|
||||
public abstract String path(final Context p);
|
||||
public static String deprecatedPath(final Context p)
|
||||
{
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + p.getPackageName();
|
||||
}
|
||||
public static String getPath(final Context p)
|
||||
{
|
||||
try {
|
||||
return get().path(p);
|
||||
} catch(Exception e) { }
|
||||
return Dummy.Holder.sInstance.path(p);
|
||||
}
|
||||
|
||||
private static class Froyo extends SdcardAppPath
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final Froyo sInstance = new Froyo();
|
||||
}
|
||||
public String path(final Context p)
|
||||
{
|
||||
return p.getExternalFilesDir(null).getAbsolutePath();
|
||||
}
|
||||
}
|
||||
private static class Dummy extends SdcardAppPath
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final Dummy sInstance = new Dummy();
|
||||
}
|
||||
public String path(final Context p)
|
||||
{
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/" + p.getPackageName() + "/files";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static boolean checkRamSize(final MainActivity p)
|
||||
{
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader("/proc/meminfo"));
|
||||
String line = null;
|
||||
while( ( line = reader.readLine() ) != null )
|
||||
{
|
||||
if( line.indexOf("MemTotal:") == 0 )
|
||||
{
|
||||
String[] fields = line.split("[ \t]+");
|
||||
Long size = Long.parseLong(fields[1]);
|
||||
Log.i("SDL", "Device RAM size: " + size / 1024 + " Mb, required minimum RAM: " + Globals.AppMinimumRAM + " Mb" );
|
||||
if( size / 1024 < Globals.AppMinimumRAM )
|
||||
{
|
||||
settingsChanged = true;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.not_enough_ram);
|
||||
builder.setMessage(p.getResources().getString( R.string.not_enough_ram_size, Globals.AppMinimumRAM, (int)(size / 1024)) );
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
p.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + p.getPackageName())));
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.ignore), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
SettingsMenu.showConfig(p, true);
|
||||
return;
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
p.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + p.getPackageName())));
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
final AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
Log.i("SDL", "Error: cannot parse /proc/meminfo: " + e.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static native void nativeSetTrackballUsed();
|
||||
private static native void nativeSetTrackballDampening(int value);
|
||||
private static native void nativeSetAccelerometerSettings(int sensitivity, int centerPos);
|
||||
private static native void nativeSetMouseUsed(int RightClickMethod, int ShowScreenUnderFinger, int LeftClickMethod,
|
||||
int MoveMouseWithJoystick, int ClickMouseWithDpad, int MaxForce, int MaxRadius,
|
||||
int MoveMouseWithJoystickSpeed, int MoveMouseWithJoystickAccel,
|
||||
int leftClickKeycode, int rightClickKeycode,
|
||||
int leftClickTimeout, int rightClickTimeout,
|
||||
int relativeMovement, int relativeMovementSpeed,
|
||||
int relativeMovementAccel, int showMouseCursor);
|
||||
private static native void nativeSetJoystickUsed(int firstJoystickUsed, int secondJoystickUsed);
|
||||
private static native void nativeSetAccelerometerUsed();
|
||||
private static native void nativeSetMultitouchUsed();
|
||||
private static native void nativeSetTouchscreenKeyboardUsed();
|
||||
private static native void nativeSetVideoLinearFilter();
|
||||
private static native void nativeSetVideoDepth(int bpp, int gles2);
|
||||
private static native void nativeSetCompatibilityHacks();
|
||||
private static native void nativeSetVideoMultithreaded();
|
||||
private static native void nativeSetVideoForceSoftwareMode();
|
||||
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
|
||||
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
|
||||
private static native void nativeInitKeymap();
|
||||
private static native int nativeGetKeymapKey(int key);
|
||||
private static native void nativeSetKeymapKey(int javakey, int key);
|
||||
private static native int nativeGetKeymapKeyScreenKb(int keynum);
|
||||
private static native void nativeSetKeymapKeyScreenKb(int keynum, int key);
|
||||
private static native void nativeSetScreenKbKeyUsed(int keynum, int used);
|
||||
private static native void nativeSetScreenKbKeyLayout(int keynum, int x1, int y1, int x2, int y2);
|
||||
private static native int nativeGetKeymapKeyMultitouchGesture(int keynum);
|
||||
private static native void nativeSetKeymapKeyMultitouchGesture(int keynum, int key);
|
||||
private static native void nativeSetMultitouchGestureSensitivity(int sensitivity);
|
||||
private static native void nativeSetTouchscreenCalibration(int x1, int y1, int x2, int y2);
|
||||
public static native void nativeSetEnv(final String name, final String value);
|
||||
public static native int nativeChmod(final String name, int mode);
|
||||
public static native void nativeChdir(final String dir);
|
||||
}
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenu
|
||||
{
|
||||
public static abstract class Menu
|
||||
{
|
||||
// Should be overridden by children
|
||||
abstract void run(final MainActivity p);
|
||||
abstract String title(final MainActivity p);
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// Should not be overridden
|
||||
boolean enabledOrHidden()
|
||||
{
|
||||
for( Menu m: Globals.HiddenMenuOptions )
|
||||
{
|
||||
if( m.getClass().getName().equals( this.getClass().getName() ) )
|
||||
return false;
|
||||
}
|
||||
return enabled();
|
||||
}
|
||||
void showMenuOptionsList(final MainActivity p, final Menu[] list)
|
||||
{
|
||||
menuStack.add(this);
|
||||
ArrayList<CharSequence> items = new ArrayList<CharSequence> ();
|
||||
for( Menu m: list )
|
||||
{
|
||||
if(m.enabledOrHidden())
|
||||
items.add(m.title(p));
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(title(p));
|
||||
builder.setItems(items.toArray(new CharSequence[0]), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
int selected = 0;
|
||||
|
||||
for( Menu m: list )
|
||||
{
|
||||
if(m.enabledOrHidden())
|
||||
{
|
||||
if( selected == item )
|
||||
{
|
||||
m.run(p);
|
||||
return;
|
||||
}
|
||||
selected ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBackOuterMenu(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static ArrayList<Menu> menuStack = new ArrayList<Menu> ();
|
||||
|
||||
public static void showConfig(final MainActivity p, final boolean firstStart)
|
||||
{
|
||||
Settings.settingsChanged = true;
|
||||
if( Globals.OptionalDataDownload == null )
|
||||
{
|
||||
String downloads[] = Globals.DataDownloadUrl;
|
||||
Globals.OptionalDataDownload = new boolean[downloads.length];
|
||||
boolean oldFormat = true;
|
||||
for( int i = 0; i < downloads.length; i++ )
|
||||
{
|
||||
if( downloads[i].indexOf("!") == 0 )
|
||||
{
|
||||
Globals.OptionalDataDownload[i] = true;
|
||||
oldFormat = false;
|
||||
}
|
||||
}
|
||||
if( oldFormat )
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
}
|
||||
|
||||
if(!firstStart)
|
||||
new MainMenu().run(p);
|
||||
else
|
||||
{
|
||||
if( Globals.StartupMenuButtonTimeout > 0 ) // If we did not disable startup menu altogether
|
||||
{
|
||||
for( Menu m: Globals.FirstStartMenuOptions )
|
||||
{
|
||||
boolean hidden = false;
|
||||
for( Menu m1: Globals.HiddenMenuOptions )
|
||||
{
|
||||
if( m1.getClass().getName().equals( m.getClass().getName() ) )
|
||||
hidden = true;
|
||||
}
|
||||
if( ! hidden )
|
||||
menuStack.add(0, m);
|
||||
}
|
||||
}
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void goBack(final MainActivity p)
|
||||
{
|
||||
if(menuStack.isEmpty())
|
||||
{
|
||||
Settings.Save(p);
|
||||
p.startDownloader();
|
||||
}
|
||||
else
|
||||
{
|
||||
Menu c = menuStack.remove(menuStack.size() - 1);
|
||||
c.run(p);
|
||||
}
|
||||
}
|
||||
|
||||
static void goBackOuterMenu(final MainActivity p)
|
||||
{
|
||||
if(!menuStack.isEmpty())
|
||||
menuStack.remove(menuStack.size() - 1);
|
||||
goBack(p);
|
||||
}
|
||||
|
||||
static class OkButton extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.ok);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
goBackOuterMenu(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class DummyMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.ok);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class MainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.device_config);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new SettingsMenuMisc.DownloadConfig(),
|
||||
new SettingsMenuMisc.OptionalDownloadConfig(false),
|
||||
new SettingsMenuKeyboard.KeyboardConfigMainMenu(),
|
||||
new SettingsMenuMouse.MouseConfigMainMenu(),
|
||||
new SettingsMenuMisc.GyroscopeCalibration(),
|
||||
new SettingsMenuMisc.AudioConfig(),
|
||||
new SettingsMenuKeyboard.RemapHwKeysConfig(),
|
||||
new SettingsMenuKeyboard.ScreenGesturesConfig(),
|
||||
new SettingsMenuMisc.VideoSettingsConfig(),
|
||||
new SettingsMenuMisc.ResetToDefaultsConfig(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,843 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuKeyboard extends SettingsMenu
|
||||
{
|
||||
static class KeyboardConfigMainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.UseTouchscreenKeyboard;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new ScreenKeyboardThemeConfig(),
|
||||
new ScreenKeyboardSizeConfig(),
|
||||
new ScreenKeyboardDrawSizeConfig(),
|
||||
new ScreenKeyboardTransparencyConfig(),
|
||||
new RemapScreenKbConfig(),
|
||||
new CustomizeScreenKbLayout(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardSizeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_size);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny),
|
||||
p.getResources().getString(R.string.controls_screenkb_custom) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_size));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardSize, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardSize = item;
|
||||
dialog.dismiss();
|
||||
if( Globals.TouchscreenKeyboardSize == Globals.TOUCHSCREEN_KEYBOARD_CUSTOM )
|
||||
new CustomizeScreenKbLayout().run(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardDrawSizeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_drawsize);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_large),
|
||||
p.getResources().getString(R.string.controls_screenkb_medium),
|
||||
p.getResources().getString(R.string.controls_screenkb_small),
|
||||
p.getResources().getString(R.string.controls_screenkb_tiny) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_drawsize));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardDrawSize, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardDrawSize = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardThemeConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_theme);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Ultimate Droid", "Sean Stieber"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Simple Theme", "Beholder"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Sun", "Sirea"),
|
||||
p.getResources().getString(R.string.controls_screenkb_by, "Keen", "Gerstrong")
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_theme));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTheme, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTheme = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenKeyboardTransparencyConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.controls_screenkb_transparency);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.controls_screenkb_trans_0),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_1),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_2),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_3),
|
||||
p.getResources().getString(R.string.controls_screenkb_trans_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.controls_screenkb_transparency));
|
||||
builder.setSingleChoiceItems(items, Globals.TouchscreenKeyboardTransparency, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.TouchscreenKeyboardTransparency = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class RemapHwKeysConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_hwkeys);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||
p.keyListener = new KeyRemapTool(p);
|
||||
}
|
||||
|
||||
public static class KeyRemapTool implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
public KeyRemapTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
||||
keyIndex = 0;
|
||||
|
||||
final int KeyIndexFinal = keyIndex;
|
||||
CharSequence[] items = {
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[0]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[1]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[2]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[3]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[4]],
|
||||
SDL_Keys.names[Globals.RemapScreenKbKeycode[5]],
|
||||
p.getResources().getString(R.string.remap_hwkeys_select_more_keys),
|
||||
};
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i] = Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_hwkeys_select_simple);
|
||||
builder.setItems(items, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( item >= 6 )
|
||||
ShowAllKeys(KeyIndexFinal);
|
||||
else
|
||||
{
|
||||
Globals.RemapHwKeycode[KeyIndexFinal] = Globals.RemapScreenKbKeycode[item];
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
public void ShowAllKeys(final int KeyIndex)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_hwkeys_select);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapHwKeycode[KeyIndex]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapHwKeycode[KeyIndex] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class RemapScreenKbConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_screenkb);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_joystick),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_text),
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 3",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
};
|
||||
|
||||
boolean defaults[] = Arrays.copyOf(Globals.ScreenKbControlsShown, Globals.ScreenKbControlsShown.length);
|
||||
if( Globals.AppUsesSecondJoystick )
|
||||
{
|
||||
items = Arrays.copyOf(items, items.length + 1);
|
||||
items[items.length - 1] = p.getResources().getString(R.string.remap_screenkb_joystick) + " 2";
|
||||
defaults = Arrays.copyOf(defaults, defaults.length + 1);
|
||||
defaults[defaults.length - 1] = true;
|
||||
}
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i+2] = items[i+2] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.ScreenKbControlsShown[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showRemapScreenKbConfig2(p, 0);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRemapScreenKbConfig2(final MainActivity p, final int currentButton)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 1",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 2",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 3",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 4",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 5",
|
||||
p.getResources().getString(R.string.remap_screenkb_button) + " 6",
|
||||
};
|
||||
|
||||
for( int i = 0; i < Math.min(6, Globals.AppTouchscreenKeyboardKeysNames.length); i++ )
|
||||
items[i] = items[i] + " - " + Globals.AppTouchscreenKeyboardKeysNames[i].replace("_", " ");
|
||||
|
||||
if( currentButton >= Globals.RemapScreenKbKeycode.length )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
if( ! Globals.ScreenKbControlsShown[currentButton + 2] )
|
||||
{
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(items[currentButton]);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapScreenKbKeycode[currentButton]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapScreenKbKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
showRemapScreenKbConfig2(p, currentButton + 1);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ScreenGesturesConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.remap_screenkb_button_gestures);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateleft),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.MultitouchGesturesUsed[0],
|
||||
Globals.MultitouchGesturesUsed[1],
|
||||
Globals.MultitouchGesturesUsed[2],
|
||||
Globals.MultitouchGesturesUsed[3],
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.remap_screenkb_button_gestures));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.MultitouchGesturesUsed[item] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig2(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenGesturesConfig2(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = {
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_veryfast)
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.remap_screenkb_button_gestures_sensitivity);
|
||||
builder.setSingleChoiceItems(items, Globals.MultitouchGestureSensitivity, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MultitouchGestureSensitivity = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig3(p, 0);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showScreenGesturesConfig3(final MainActivity p, final int currentButton)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomin),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_zoomout),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateleft),
|
||||
p.getResources().getString(R.string.remap_screenkb_button_rotateright),
|
||||
};
|
||||
|
||||
if( currentButton >= Globals.RemapMultitouchGestureKeycode.length )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
if( ! Globals.MultitouchGesturesUsed[currentButton] )
|
||||
{
|
||||
showScreenGesturesConfig3(p, currentButton + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(items[currentButton]);
|
||||
builder.setSingleChoiceItems(SDL_Keys.namesSorted, SDL_Keys.namesSortedBackIdx[Globals.RemapMultitouchGestureKeycode[currentButton]], new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RemapMultitouchGestureKeycode[currentButton] = SDL_Keys.namesSortedIdx[item];
|
||||
|
||||
dialog.dismiss();
|
||||
showScreenGesturesConfig3(p, currentButton + 1);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class CustomizeScreenKbLayout extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.screenkb_custom_layout);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help));
|
||||
CustomizeScreenKbLayoutTool tool = new CustomizeScreenKbLayoutTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
Globals.TouchscreenKeyboardSize = Globals.TOUCHSCREEN_KEYBOARD_CUSTOM;
|
||||
}
|
||||
|
||||
static class CustomizeScreenKbLayoutTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
FrameLayout layout = null;
|
||||
ImageView imgs[] = new ImageView[Globals.ScreenKbControlsLayout.length];
|
||||
Bitmap bmps[] = new Bitmap[Globals.ScreenKbControlsLayout.length];
|
||||
ImageView boundary = null;
|
||||
Bitmap boundaryBmp = null;
|
||||
int currentButton = 0;
|
||||
int buttons[] = {
|
||||
R.drawable.dpad,
|
||||
R.drawable.keyboard,
|
||||
R.drawable.b1,
|
||||
R.drawable.b2,
|
||||
R.drawable.b3,
|
||||
R.drawable.b4,
|
||||
R.drawable.b5,
|
||||
R.drawable.b6,
|
||||
R.drawable.dpad
|
||||
};
|
||||
int oldX = 0, oldY = 0;
|
||||
boolean resizing = false;
|
||||
|
||||
public CustomizeScreenKbLayoutTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
layout = new FrameLayout(p);
|
||||
p.getVideoLayout().addView(layout);
|
||||
boundary = new ImageView(p);
|
||||
boundary.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
boundary.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
boundaryBmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.rectangle );
|
||||
boundary.setImageBitmap(boundaryBmp);
|
||||
layout.addView(boundary);
|
||||
currentButton = -1;
|
||||
if( Globals.TouchscreenKeyboardTheme == 2 )
|
||||
{
|
||||
buttons = new int[] {
|
||||
R.drawable.sun_dpad,
|
||||
R.drawable.sun_keyboard,
|
||||
R.drawable.sun_b1,
|
||||
R.drawable.sun_b2,
|
||||
R.drawable.sun_b3,
|
||||
R.drawable.sun_b4,
|
||||
R.drawable.sun_b5,
|
||||
R.drawable.sun_b6,
|
||||
R.drawable.sun_dpad
|
||||
};
|
||||
}
|
||||
|
||||
int displayX = 800;
|
||||
int displayY = 480;
|
||||
try {
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
p.getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
displayX = dm.widthPixels;
|
||||
displayY = dm.heightPixels;
|
||||
} catch (Exception eeeee) {}
|
||||
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
if( ! Globals.ScreenKbControlsShown[i] )
|
||||
continue;
|
||||
if( currentButton == -1 )
|
||||
currentButton = i;
|
||||
//Log.i("SDL", "Screen kb button " + i + " coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
// Check if the button is off screen edge or shrunk to zero
|
||||
if( Globals.ScreenKbControlsLayout[i][0] > Globals.ScreenKbControlsLayout[i][2] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] > Globals.ScreenKbControlsLayout[i][3] - displayY/12 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY/12;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < Globals.ScreenKbControlsLayout[i][2] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][0] = Globals.ScreenKbControlsLayout[i][2] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < Globals.ScreenKbControlsLayout[i][3] - displayY*2/3 )
|
||||
Globals.ScreenKbControlsLayout[i][1] = Globals.ScreenKbControlsLayout[i][3] - displayY*2/3;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][2] += -Globals.ScreenKbControlsLayout[i][0];
|
||||
Globals.ScreenKbControlsLayout[i][0] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][2] > displayX )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][0] -= Globals.ScreenKbControlsLayout[i][2] - displayX;
|
||||
Globals.ScreenKbControlsLayout[i][2] = displayX;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][1] < 0 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][3] += -Globals.ScreenKbControlsLayout[i][1];
|
||||
Globals.ScreenKbControlsLayout[i][1] = 0;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[i][3] > displayY )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[i][1] -= Globals.ScreenKbControlsLayout[i][3] - displayY;
|
||||
Globals.ScreenKbControlsLayout[i][3] = displayY;
|
||||
}
|
||||
//Log.i("SDL", "After bounds check coords " + Globals.ScreenKbControlsLayout[i][0] + ":" + Globals.ScreenKbControlsLayout[i][1] + ":" + Globals.ScreenKbControlsLayout[i][2] + ":" + Globals.ScreenKbControlsLayout[i][3] );
|
||||
|
||||
imgs[i] = new ImageView(p);
|
||||
imgs[i].setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
imgs[i].setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmps[i] = BitmapFactory.decodeResource( p.getResources(), buttons[i] );
|
||||
imgs[i].setImageBitmap(bmps[i]);
|
||||
imgs[i].setAlpha(128);
|
||||
layout.addView(imgs[i]);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[i].setImageMatrix(m);
|
||||
}
|
||||
boundary.bringToFront();
|
||||
if( currentButton == -1 )
|
||||
onKeyEvent( KeyEvent.KEYCODE_BACK ); // All buttons disabled - do not show anything
|
||||
else
|
||||
setupButton(currentButton);
|
||||
}
|
||||
|
||||
void setupButton(int i)
|
||||
{
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[i].getWidth(), bmps[i].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[i][0], Globals.ScreenKbControlsLayout[i][1],
|
||||
Globals.ScreenKbControlsLayout[i][2], Globals.ScreenKbControlsLayout[i][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[i].setImageMatrix(m);
|
||||
m = new Matrix();
|
||||
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
boundary.setImageMatrix(m);
|
||||
String buttonText = "";
|
||||
if( i >= 2 && i <= 7 )
|
||||
buttonText = p.getResources().getString(R.string.remap_screenkb_button) + (i - 2);
|
||||
if( i >= 2 && i - 2 < Globals.AppTouchscreenKeyboardKeysNames.length )
|
||||
buttonText = Globals.AppTouchscreenKeyboardKeysNames[i - 2].replace("_", " ");
|
||||
if( i == 0 )
|
||||
buttonText = "Joystick";
|
||||
if( i == 1 )
|
||||
buttonText = "Text input";
|
||||
if( i == 8 )
|
||||
buttonText = "Joystick 2";
|
||||
p.setText(p.getResources().getString(R.string.screenkb_custom_layout_help) + "\n" + buttonText);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
if( ev.getAction() == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
oldX = (int)ev.getX();
|
||||
oldY = (int)ev.getY();
|
||||
resizing = true;
|
||||
for( int i = 0; i < Globals.ScreenKbControlsLayout.length; i++ )
|
||||
{
|
||||
if( ! Globals.ScreenKbControlsShown[i] )
|
||||
continue;
|
||||
if( Globals.ScreenKbControlsLayout[i][0] <= oldX &&
|
||||
Globals.ScreenKbControlsLayout[i][2] >= oldX &&
|
||||
Globals.ScreenKbControlsLayout[i][1] <= oldY &&
|
||||
Globals.ScreenKbControlsLayout[i][3] >= oldY )
|
||||
{
|
||||
currentButton = i;
|
||||
setupButton(currentButton);
|
||||
resizing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ev.getAction() == MotionEvent.ACTION_MOVE )
|
||||
{
|
||||
int dx = (int)ev.getX() - oldX;
|
||||
int dy = (int)ev.getY() - oldY;
|
||||
if( resizing )
|
||||
{
|
||||
// Resize slowly, with 1/3 of movement speed
|
||||
dx /= 6;
|
||||
dy /= 6;
|
||||
if( Globals.ScreenKbControlsLayout[currentButton][0] <= Globals.ScreenKbControlsLayout[currentButton][2] + dx*2 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][0] -= dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||
}
|
||||
if( Globals.ScreenKbControlsLayout[currentButton][1] <= Globals.ScreenKbControlsLayout[currentButton][3] + dy*2 )
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||
Globals.ScreenKbControlsLayout[currentButton][3] -= dy;
|
||||
}
|
||||
dx *= 6;
|
||||
dy *= 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.ScreenKbControlsLayout[currentButton][0] += dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][2] += dx;
|
||||
Globals.ScreenKbControlsLayout[currentButton][1] += dy;
|
||||
Globals.ScreenKbControlsLayout[currentButton][3] += dy;
|
||||
}
|
||||
oldX += dx;
|
||||
oldY += dy;
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmps[currentButton].getWidth(), bmps[currentButton].getHeight());
|
||||
RectF dst = new RectF(Globals.ScreenKbControlsLayout[currentButton][0], Globals.ScreenKbControlsLayout[currentButton][1],
|
||||
Globals.ScreenKbControlsLayout[currentButton][2], Globals.ScreenKbControlsLayout[currentButton][3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
imgs[currentButton].setImageMatrix(m);
|
||||
m = new Matrix();
|
||||
src = new RectF(0, 0, boundaryBmp.getWidth(), boundaryBmp.getHeight());
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
boundary.setImageMatrix(m);
|
||||
}
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
if( keyCode == KeyEvent.KEYCODE_BACK )
|
||||
{
|
||||
p.getVideoLayout().removeView(layout);
|
||||
layout = null;
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,755 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Scroller;
|
||||
import android.view.View;
|
||||
import android.view.Gravity;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuMisc extends SettingsMenu
|
||||
{
|
||||
static class DownloadConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.storage_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
long freeSdcard = 0;
|
||||
long freePhone = 0;
|
||||
try
|
||||
{
|
||||
StatFs sdcard = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
||||
StatFs phone = new StatFs(Environment.getDataDirectory().getPath());
|
||||
freeSdcard = (long)sdcard.getAvailableBlocks() * sdcard.getBlockSize() / 1024 / 1024;
|
||||
freePhone = (long)phone.getAvailableBlocks() * phone.getBlockSize() / 1024 / 1024;
|
||||
}
|
||||
catch(Exception e) {}
|
||||
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.storage_phone, freePhone),
|
||||
p.getResources().getString(R.string.storage_sd, freeSdcard),
|
||||
p.getResources().getString(R.string.storage_custom) };
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_question));
|
||||
builder.setSingleChoiceItems(items, Globals.DownloadToSdcard ? 1 : 0, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
|
||||
if( item == 2 )
|
||||
showCustomDownloadDirConfig(p);
|
||||
else
|
||||
{
|
||||
Globals.DownloadToSdcard = (item != 0);
|
||||
Globals.DataDir = Globals.DownloadToSdcard ?
|
||||
Settings.SdcardAppPath.getPath(p) :
|
||||
p.getFilesDir().getAbsolutePath();
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showCustomDownloadDirConfig(final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_custom));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.DataDir);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.DataDir = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
showCommandLineConfig(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showCommandLineConfig(final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.storage_commandline));
|
||||
|
||||
final EditText edit = new EditText(p);
|
||||
edit.setFocusableInTouchMode(true);
|
||||
edit.setFocusable(true);
|
||||
edit.setText(Globals.CommandLine);
|
||||
builder.setView(edit);
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.CommandLine = edit.getText().toString();
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class OptionalDownloadConfig extends Menu
|
||||
{
|
||||
boolean firstStart = false;
|
||||
OptionalDownloadConfig()
|
||||
{
|
||||
firstStart = true;
|
||||
}
|
||||
OptionalDownloadConfig(boolean firstStart)
|
||||
{
|
||||
this.firstStart = firstStart;
|
||||
}
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.downloads);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
String [] downloadFiles = Globals.DataDownloadUrl;
|
||||
final boolean [] mandatory = new boolean[downloadFiles.length];
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.downloads));
|
||||
|
||||
CharSequence[] items = new CharSequence[downloadFiles.length];
|
||||
for(int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
items[i] = new String(downloadFiles[i].split("[|]")[0]);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
items[i] = items[i].toString().substring(1);
|
||||
if( items[i].toString().indexOf("!") == 0 )
|
||||
{
|
||||
items[i] = items[i].toString().substring(1);
|
||||
mandatory[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( Globals.OptionalDataDownload == null || Globals.OptionalDataDownload.length != items.length )
|
||||
{
|
||||
Globals.OptionalDataDownload = new boolean[downloadFiles.length];
|
||||
boolean oldFormat = true;
|
||||
for( int i = 0; i < downloadFiles.length; i++ )
|
||||
{
|
||||
if( downloadFiles[i].indexOf("!") == 0 )
|
||||
{
|
||||
Globals.OptionalDataDownload[i] = true;
|
||||
oldFormat = false;
|
||||
}
|
||||
}
|
||||
if( oldFormat )
|
||||
{
|
||||
Globals.OptionalDataDownload[0] = true;
|
||||
mandatory[0] = true;
|
||||
}
|
||||
}
|
||||
|
||||
builder.setMultiChoiceItems(items, Globals.OptionalDataDownload, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
Globals.OptionalDataDownload[item] = isChecked;
|
||||
if( mandatory[item] && !isChecked )
|
||||
{
|
||||
Globals.OptionalDataDownload[item] = true;
|
||||
((AlertDialog)dialog).getListView().setItemChecked(item, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
if( firstStart )
|
||||
{
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.show_more_options), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
menuStack.clear();
|
||||
new MainMenu().run(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class AudioConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.audiobuf_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.audiobuf_verysmall),
|
||||
p.getResources().getString(R.string.audiobuf_small),
|
||||
p.getResources().getString(R.string.audiobuf_medium),
|
||||
p.getResources().getString(R.string.audiobuf_large) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.audiobuf_question);
|
||||
builder.setSingleChoiceItems(items, Globals.AudioBufferConfig, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.AudioBufferConfig = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class VideoSettingsConfig extends Menu
|
||||
{
|
||||
static int debugMenuShowCount = 0;
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.video);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
debugMenuShowCount++;
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth)
|
||||
};
|
||||
boolean defaults[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter
|
||||
};
|
||||
|
||||
if(Globals.SwVideoMode && !Globals.CompatibilityHacksVideo)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
p.getResources().getString(R.string.video_smooth),
|
||||
p.getResources().getString(R.string.video_separatethread),
|
||||
};
|
||||
boolean defaults2[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
Globals.VideoLinearFilter,
|
||||
Globals.MultiThreadedVideo
|
||||
};
|
||||
items = items2;
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
if(Globals.Using_SDL_1_3)
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.pointandclick_keepaspectratio),
|
||||
};
|
||||
boolean defaults2[] = {
|
||||
Globals.KeepAspectRatio,
|
||||
};
|
||||
items = items2;
|
||||
defaults = defaults2;
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.video));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.KeepAspectRatio = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.VideoLinearFilter = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.MultiThreadedVideo = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( debugMenuShowCount > 5 || Globals.OuyaEmulation )
|
||||
showDebugMenu(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
void showDebugMenu (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
"OUYA emulation"
|
||||
};
|
||||
boolean defaults[] = {
|
||||
Globals.OuyaEmulation,
|
||||
};
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle("Debug settings");
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.OuyaEmulation = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class ShowReadme extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return "Readme";
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
String readmes[] = Globals.ReadmeText.split("\\^");
|
||||
String lang = new String(Locale.getDefault().getLanguage()) + ":";
|
||||
if( p.isRunningOnOUYA() )
|
||||
lang = "ouya:";
|
||||
String readme = readmes[0];
|
||||
String buttonName = "", buttonUrl = "";
|
||||
for( String r: readmes )
|
||||
{
|
||||
if( r.startsWith(lang) )
|
||||
readme = r.substring(lang.length());
|
||||
if( r.startsWith("button:") )
|
||||
{
|
||||
buttonName = r.substring("button:".length());
|
||||
if( buttonName.indexOf(":") != -1 )
|
||||
{
|
||||
buttonUrl = buttonName.substring(buttonName.indexOf(":") + 1);
|
||||
buttonName = buttonName.substring(0, buttonName.indexOf(":"));
|
||||
}
|
||||
}
|
||||
}
|
||||
readme = readme.trim();
|
||||
if( readme.length() <= 2 )
|
||||
{
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
TextView text = new TextView(p);
|
||||
text.setMaxLines(100);
|
||||
//text.setScroller(new Scroller(p));
|
||||
//text.setVerticalScrollBarEnabled(true);
|
||||
text.setText(readme);
|
||||
text.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
text.setPadding(0, 5, 0, 20);
|
||||
text.setTextSize(20.0f);
|
||||
text.setGravity(Gravity.CENTER);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
ScrollView scroll = new ScrollView(p);
|
||||
scroll.addView(text, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
Button ok = new Button(p);
|
||||
final AlertDialog alertDismiss[] = new AlertDialog[1];
|
||||
ok.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
alertDismiss[0].cancel();
|
||||
}
|
||||
});
|
||||
ok.setText(R.string.ok);
|
||||
LinearLayout layout = new LinearLayout(p);
|
||||
layout.setOrientation(LinearLayout.VERTICAL);
|
||||
layout.addView(scroll);
|
||||
//layout.addView(text);
|
||||
layout.addView(ok);
|
||||
if( buttonName.length() > 0 )
|
||||
{
|
||||
Button cancel = new Button(p);
|
||||
cancel.setText(buttonName);
|
||||
final String url = buttonUrl;
|
||||
cancel.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
public void onClick(View v)
|
||||
{
|
||||
if( url.length() > 0 )
|
||||
{
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
i.setData(Uri.parse(url));
|
||||
p.startActivity(i);
|
||||
}
|
||||
alertDismiss[0].cancel();
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
layout.addView(cancel);
|
||||
}
|
||||
builder.setView(layout);
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alertDismiss[0] = alert;
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class GyroscopeCalibration extends Menu implements SensorEventListener
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.calibrate_gyroscope);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppUsesGyroscope;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
if( !Globals.AppUsesGyroscope || !AccelerometerReader.gyro.available(p) )
|
||||
{
|
||||
if( Globals.AppUsesGyroscope )
|
||||
{
|
||||
Toast toast = Toast.makeText(p, p.getResources().getString(R.string.calibrate_gyroscope_not_supported), Toast.LENGTH_LONG);
|
||||
toast.show();
|
||||
}
|
||||
goBack(p);
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.calibrate_gyroscope));
|
||||
builder.setMessage(p.getResources().getString(R.string.calibrate_gyroscope_text));
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
startCalibration(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
ImageView img;
|
||||
Bitmap bmp;
|
||||
int numEvents;
|
||||
MainActivity p;
|
||||
|
||||
void startCalibration(final MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
img = new ImageView(p);
|
||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
||||
img.setImageBitmap(bmp);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF( p.getVideoLayout().getWidth()/2 - 50, p.getVideoLayout().getHeight()/2 - 50,
|
||||
p.getVideoLayout().getWidth()/2 + 50, p.getVideoLayout().getHeight()/2 + 50);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
p.getVideoLayout().addView(img);
|
||||
numEvents = 0;
|
||||
AccelerometerReader.gyro.x1 = 100;
|
||||
AccelerometerReader.gyro.x2 = -100;
|
||||
AccelerometerReader.gyro.xc = 0;
|
||||
AccelerometerReader.gyro.y1 = 100;
|
||||
AccelerometerReader.gyro.y2 = -100;
|
||||
AccelerometerReader.gyro.yc = 0;
|
||||
AccelerometerReader.gyro.z1 = 100;
|
||||
AccelerometerReader.gyro.z2 = -100;
|
||||
AccelerometerReader.gyro.zc = 0;
|
||||
AccelerometerReader.gyro.registerListener(p, this);
|
||||
(new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for(int count = 1; count < 10; count++)
|
||||
{
|
||||
p.setText("" + count + "0% ...");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch( Exception e ) {}
|
||||
}
|
||||
finishCalibration(p);
|
||||
}
|
||||
}
|
||||
)).start();
|
||||
}
|
||||
|
||||
public void onSensorChanged(SensorEvent event)
|
||||
{
|
||||
gyroscopeEvent(event.values[0], event.values[1], event.values[2]);
|
||||
}
|
||||
public void onAccuracyChanged(Sensor s, int a)
|
||||
{
|
||||
}
|
||||
void gyroscopeEvent(float x, float y, float z)
|
||||
{
|
||||
numEvents++;
|
||||
AccelerometerReader.gyro.xc += x;
|
||||
AccelerometerReader.gyro.yc += y;
|
||||
AccelerometerReader.gyro.zc += z;
|
||||
AccelerometerReader.gyro.x1 = Math.min(AccelerometerReader.gyro.x1, x * 1.1f); // Small safety bound coefficient
|
||||
AccelerometerReader.gyro.x2 = Math.max(AccelerometerReader.gyro.x2, x * 1.1f);
|
||||
AccelerometerReader.gyro.y1 = Math.min(AccelerometerReader.gyro.y1, y * 1.1f);
|
||||
AccelerometerReader.gyro.y2 = Math.max(AccelerometerReader.gyro.y2, y * 1.1f);
|
||||
AccelerometerReader.gyro.z1 = Math.min(AccelerometerReader.gyro.z1, z * 1.1f);
|
||||
AccelerometerReader.gyro.z2 = Math.max(AccelerometerReader.gyro.z2, z * 1.1f);
|
||||
final Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF( x * 5000 + p.getVideoLayout().getWidth()/2 - 50, y * 5000 + p.getVideoLayout().getHeight()/2 - 50,
|
||||
x * 5000 + p.getVideoLayout().getWidth()/2 + 50, y * 5000 + p.getVideoLayout().getHeight()/2 + 50);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
p.runOnUiThread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
img.setImageMatrix(m);
|
||||
}
|
||||
});
|
||||
}
|
||||
void finishCalibration(final MainActivity p)
|
||||
{
|
||||
AccelerometerReader.gyro.unregisterListener(p, this);
|
||||
try {
|
||||
Thread.sleep(200); // Just in case we have pending events
|
||||
} catch( Exception e ) {}
|
||||
if( numEvents > 5 )
|
||||
{
|
||||
AccelerometerReader.gyro.xc /= (float)numEvents;
|
||||
AccelerometerReader.gyro.yc /= (float)numEvents;
|
||||
AccelerometerReader.gyro.zc /= (float)numEvents;
|
||||
}
|
||||
p.runOnUiThread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
p.getVideoLayout().removeView(img);
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static class ResetToDefaultsConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.reset_config);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.reset_config_ask));
|
||||
builder.setMessage(p.getResources().getString(R.string.reset_config_ask));
|
||||
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Settings.DeleteSdlConfigOnUpgradeAndRestart(p); // Never returns
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(p.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,771 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.util.Log;
|
||||
import java.io.*;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
import java.util.Locale;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.Collections;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import java.lang.String;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.RectF;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Bitmap;
|
||||
import android.widget.TextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.Button;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.text.Editable;
|
||||
import android.text.SpannedString;
|
||||
import android.content.Intent;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.AlarmManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.net.Uri;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.Arrays;
|
||||
import android.graphics.Color;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.Sensor;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
class SettingsMenuMouse extends SettingsMenu
|
||||
{
|
||||
static class MouseConfigMainMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.mouse_emulation);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppUsesMouse;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
Menu options[] =
|
||||
{
|
||||
new DisplaySizeConfig(false),
|
||||
new LeftClickConfig(),
|
||||
new RightClickConfig(),
|
||||
new AdditionalMouseConfig(),
|
||||
new JoystickMouseConfig(),
|
||||
new TouchPressureMeasurementTool(),
|
||||
new CalibrateTouchscreenMenu(),
|
||||
new OkButton(),
|
||||
};
|
||||
showMenuOptionsList(p, options);
|
||||
}
|
||||
}
|
||||
|
||||
static class DisplaySizeConfig extends Menu
|
||||
{
|
||||
boolean firstStart = false;
|
||||
DisplaySizeConfig()
|
||||
{
|
||||
this.firstStart = true;
|
||||
}
|
||||
DisplaySizeConfig(boolean firstStart)
|
||||
{
|
||||
this.firstStart = firstStart;
|
||||
}
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.display_size_mouse);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.display_size_tiny_touchpad),
|
||||
p.getResources().getString(R.string.display_size_tiny),
|
||||
p.getResources().getString(R.string.display_size_small),
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
};
|
||||
int _size_tiny_touchpad = 0;
|
||||
int _size_tiny = 1;
|
||||
int _size_small = 2;
|
||||
int _size_small_touchpad = 3;
|
||||
int _size_large = 4;
|
||||
int _more_options = 5;
|
||||
|
||||
if( ! Globals.SwVideoMode )
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
};
|
||||
items = items2;
|
||||
_size_small_touchpad = 0;
|
||||
_size_large = 1;
|
||||
_size_tiny_touchpad = _size_tiny = _size_small = 1000;
|
||||
|
||||
}
|
||||
if( firstStart )
|
||||
{
|
||||
CharSequence[] items2 = {
|
||||
p.getResources().getString(R.string.display_size_tiny_touchpad),
|
||||
p.getResources().getString(R.string.display_size_tiny),
|
||||
p.getResources().getString(R.string.display_size_small),
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
p.getResources().getString(R.string.show_more_options),
|
||||
};
|
||||
items = items2;
|
||||
if( ! Globals.SwVideoMode )
|
||||
{
|
||||
CharSequence[] items3 = {
|
||||
p.getResources().getString(R.string.display_size_small_touchpad),
|
||||
p.getResources().getString(R.string.display_size_large),
|
||||
p.getResources().getString(R.string.show_more_options),
|
||||
};
|
||||
items = items3;
|
||||
_more_options = 3;
|
||||
}
|
||||
}
|
||||
// Java is so damn worse than C++11
|
||||
final int size_tiny_touchpad = _size_tiny_touchpad;
|
||||
final int size_tiny = _size_tiny;
|
||||
final int size_small = _size_small;
|
||||
final int size_small_touchpad = _size_small_touchpad;
|
||||
final int size_large = _size_large;
|
||||
final int more_options = _more_options;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.display_size);
|
||||
class ClickListener implements DialogInterface.OnClickListener
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( item == size_large )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NORMAL;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
}
|
||||
if( item == size_small )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_MAGNIFIER;
|
||||
}
|
||||
if( item == size_small_touchpad )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
||||
Globals.RelativeMouseMovement = true;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_NONE;
|
||||
}
|
||||
if( item == size_tiny )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_NEAR_CURSOR;
|
||||
Globals.RelativeMouseMovement = false;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_SCREEN_TRANSFORM;
|
||||
}
|
||||
if( item == size_tiny_touchpad )
|
||||
{
|
||||
Globals.LeftClickMethod = Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT;
|
||||
Globals.RelativeMouseMovement = true;
|
||||
Globals.ShowScreenUnderFinger = Mouse.ZOOM_FULLSCREEN_MAGNIFIER;
|
||||
}
|
||||
if( item == more_options )
|
||||
{
|
||||
menuStack.clear();
|
||||
new MainMenu().run(p);
|
||||
return;
|
||||
}
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
builder.setItems(items, new ClickListener());
|
||||
/*
|
||||
else
|
||||
builder.setSingleChoiceItems(items,
|
||||
Globals.ShowScreenUnderFinger == Mouse.ZOOM_NONE ?
|
||||
( Globals.RelativeMouseMovement ? Globals.SwVideoMode ? 2 : 1 : 0 ) :
|
||||
( Globals.ShowScreenUnderFinger == Mouse.ZOOM_MAGNIFIER && Globals.SwVideoMode ) ? 1 :
|
||||
Globals.ShowScreenUnderFinger + 1,
|
||||
new ClickListener());
|
||||
*/
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class LeftClickConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.leftclick_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_normal),
|
||||
p.getResources().getString(R.string.leftclick_near_cursor),
|
||||
p.getResources().getString(R.string.leftclick_multitouch),
|
||||
p.getResources().getString(R.string.leftclick_pressure),
|
||||
p.getResources().getString(R.string.rightclick_key),
|
||||
p.getResources().getString(R.string.leftclick_timeout),
|
||||
p.getResources().getString(R.string.leftclick_tap),
|
||||
p.getResources().getString(R.string.leftclick_tap_or_timeout) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_question);
|
||||
builder.setSingleChoiceItems(items, Globals.LeftClickMethod, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
Globals.LeftClickMethod = item;
|
||||
if( item == Mouse.LEFT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, true);
|
||||
else if( item == Mouse.LEFT_CLICK_WITH_TIMEOUT || item == Mouse.LEFT_CLICK_WITH_TAP_OR_TIMEOUT )
|
||||
showLeftClickTimeoutConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
static void showLeftClickTimeoutConfig(final MainActivity p) {
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_3),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_timeout_time);
|
||||
builder.setSingleChoiceItems(items, Globals.LeftClickTimeout, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.LeftClickTimeout = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class RightClickConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.rightclick_question);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.AppNeedsTwoButtonMouse;
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.rightclick_none),
|
||||
p.getResources().getString(R.string.rightclick_multitouch),
|
||||
p.getResources().getString(R.string.rightclick_pressure),
|
||||
p.getResources().getString(R.string.rightclick_key),
|
||||
p.getResources().getString(R.string.leftclick_timeout) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.rightclick_question);
|
||||
builder.setSingleChoiceItems(items, Globals.RightClickMethod, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RightClickMethod = item;
|
||||
dialog.dismiss();
|
||||
if( item == Mouse.RIGHT_CLICK_WITH_KEY )
|
||||
p.keyListener = new KeyRemapToolMouseClick(p, false);
|
||||
else if( item == Mouse.RIGHT_CLICK_WITH_TIMEOUT )
|
||||
showRightClickTimeoutConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRightClickTimeoutConfig(final MainActivity p) {
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.leftclick_timeout_time_0),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_1),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_2),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_3),
|
||||
p.getResources().getString(R.string.leftclick_timeout_time_4) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.leftclick_timeout_time);
|
||||
builder.setSingleChoiceItems(items, Globals.RightClickTimeout, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RightClickTimeout = item;
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyRemapToolMouseClick implements MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
boolean leftClick;
|
||||
public KeyRemapToolMouseClick(MainActivity _p, boolean leftClick)
|
||||
{
|
||||
p = _p;
|
||||
p.setText(p.getResources().getString(R.string.remap_hwkeys_press));
|
||||
this.leftClick = leftClick;
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.keyListener = null;
|
||||
int keyIndex = keyCode;
|
||||
if( keyIndex < 0 )
|
||||
keyIndex = 0;
|
||||
if( keyIndex > SDL_Keys.JAVA_KEYCODE_LAST )
|
||||
keyIndex = 0;
|
||||
|
||||
if( leftClick )
|
||||
Globals.LeftClickKey = keyIndex;
|
||||
else
|
||||
Globals.RightClickKey = keyIndex;
|
||||
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
static class AdditionalMouseConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.pointandclick_question);
|
||||
}
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
CharSequence[] items = {
|
||||
p.getResources().getString(R.string.pointandclick_joystickmouse),
|
||||
p.getResources().getString(R.string.click_with_dpadcenter),
|
||||
p.getResources().getString(R.string.pointandclick_relative)
|
||||
};
|
||||
|
||||
boolean defaults[] = {
|
||||
Globals.MoveMouseWithJoystick,
|
||||
Globals.ClickMouseWithDpad,
|
||||
Globals.RelativeMouseMovement
|
||||
};
|
||||
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(p.getResources().getString(R.string.pointandclick_question));
|
||||
builder.setMultiChoiceItems(items, defaults, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item, boolean isChecked)
|
||||
{
|
||||
if( item == 0 )
|
||||
Globals.MoveMouseWithJoystick = isChecked;
|
||||
if( item == 1 )
|
||||
Globals.ClickMouseWithDpad = isChecked;
|
||||
if( item == 2 )
|
||||
Globals.RelativeMouseMovement = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
dialog.dismiss();
|
||||
if( Globals.RelativeMouseMovement )
|
||||
showRelativeMouseMovementConfig(p);
|
||||
else
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRelativeMouseMovementConfig(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_veryslow),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast),
|
||||
p.getResources().getString(R.string.accel_veryfast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_relative_speed);
|
||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementSpeed, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RelativeMouseMovementSpeed = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showRelativeMouseMovementConfig1(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showRelativeMouseMovementConfig1(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_relative_accel);
|
||||
builder.setSingleChoiceItems(items, Globals.RelativeMouseMovementAccel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.RelativeMouseMovementAccel = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class JoystickMouseConfig extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.pointandclick_joystickmousespeed);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.MoveMouseWithJoystick;
|
||||
};
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmousespeed);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickSpeed, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickSpeed = item;
|
||||
|
||||
dialog.dismiss();
|
||||
showJoystickMouseAccelConfig(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
|
||||
static void showJoystickMouseAccelConfig(final MainActivity p)
|
||||
{
|
||||
final CharSequence[] items = { p.getResources().getString(R.string.none),
|
||||
p.getResources().getString(R.string.accel_slow),
|
||||
p.getResources().getString(R.string.accel_medium),
|
||||
p.getResources().getString(R.string.accel_fast) };
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(p);
|
||||
builder.setTitle(R.string.pointandclick_joystickmouseaccel);
|
||||
builder.setSingleChoiceItems(items, Globals.MoveMouseWithJoystickAccel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick(DialogInterface dialog, int item)
|
||||
{
|
||||
Globals.MoveMouseWithJoystickAccel = item;
|
||||
|
||||
dialog.dismiss();
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(new DialogInterface.OnCancelListener()
|
||||
{
|
||||
public void onCancel(DialogInterface dialog)
|
||||
{
|
||||
goBack(p);
|
||||
}
|
||||
});
|
||||
AlertDialog alert = builder.create();
|
||||
alert.setOwnerActivity(p);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
static class TouchPressureMeasurementTool extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.measurepressure);
|
||||
}
|
||||
boolean enabled()
|
||||
{
|
||||
return Globals.RightClickMethod == Mouse.RIGHT_CLICK_WITH_PRESSURE ||
|
||||
Globals.LeftClickMethod == Mouse.LEFT_CLICK_WITH_PRESSURE;
|
||||
};
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.measurepressure_touchplease));
|
||||
p.touchListener = new TouchMeasurementTool(p);
|
||||
}
|
||||
|
||||
public static class TouchMeasurementTool implements MainActivity.TouchEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
ArrayList<Integer> force = new ArrayList<Integer>();
|
||||
ArrayList<Integer> radius = new ArrayList<Integer>();
|
||||
static final int maxEventAmount = 100;
|
||||
|
||||
public TouchMeasurementTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
force.add(new Integer((int)(ev.getPressure() * 1000.0)));
|
||||
radius.add(new Integer((int)(ev.getSize() * 1000.0)));
|
||||
p.setText(p.getResources().getString(R.string.measurepressure_response, force.get(force.size()-1), radius.get(radius.size()-1)));
|
||||
try {
|
||||
Thread.sleep(10L);
|
||||
} catch (InterruptedException e) { }
|
||||
|
||||
if( force.size() >= maxEventAmount )
|
||||
{
|
||||
p.touchListener = null;
|
||||
Globals.ClickScreenPressure = getAverageForce();
|
||||
Globals.ClickScreenTouchspotSize = getAverageRadius();
|
||||
Log.i("SDL", "SDL: measured average force " + Globals.ClickScreenPressure + " radius " + Globals.ClickScreenTouchspotSize);
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
|
||||
int getAverageForce()
|
||||
{
|
||||
int avg = 0;
|
||||
for(Integer f: force)
|
||||
{
|
||||
avg += f;
|
||||
}
|
||||
return avg / force.size();
|
||||
}
|
||||
int getAverageRadius()
|
||||
{
|
||||
int avg = 0;
|
||||
for(Integer r: radius)
|
||||
{
|
||||
avg += r;
|
||||
}
|
||||
return avg / radius.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class CalibrateTouchscreenMenu extends Menu
|
||||
{
|
||||
String title(final MainActivity p)
|
||||
{
|
||||
return p.getResources().getString(R.string.calibrate_touchscreen);
|
||||
}
|
||||
//boolean enabled() { return true; };
|
||||
void run (final MainActivity p)
|
||||
{
|
||||
p.setText(p.getResources().getString(R.string.calibrate_touchscreen_touch));
|
||||
Globals.TouchscreenCalibration[0] = 0;
|
||||
Globals.TouchscreenCalibration[1] = 0;
|
||||
Globals.TouchscreenCalibration[2] = 0;
|
||||
Globals.TouchscreenCalibration[3] = 0;
|
||||
ScreenEdgesCalibrationTool tool = new ScreenEdgesCalibrationTool(p);
|
||||
p.touchListener = tool;
|
||||
p.keyListener = tool;
|
||||
}
|
||||
|
||||
static class ScreenEdgesCalibrationTool implements MainActivity.TouchEventsListener, MainActivity.KeyEventsListener
|
||||
{
|
||||
MainActivity p;
|
||||
ImageView img;
|
||||
Bitmap bmp;
|
||||
|
||||
public ScreenEdgesCalibrationTool(MainActivity _p)
|
||||
{
|
||||
p = _p;
|
||||
img = new ImageView(p);
|
||||
img.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
img.setScaleType(ImageView.ScaleType.MATRIX);
|
||||
bmp = BitmapFactory.decodeResource( p.getResources(), R.drawable.calibrate );
|
||||
img.setImageBitmap(bmp);
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
p.getVideoLayout().addView(img);
|
||||
}
|
||||
|
||||
public void onTouchEvent(final MotionEvent ev)
|
||||
{
|
||||
if( Globals.TouchscreenCalibration[0] == Globals.TouchscreenCalibration[1] &&
|
||||
Globals.TouchscreenCalibration[1] == Globals.TouchscreenCalibration[2] &&
|
||||
Globals.TouchscreenCalibration[2] == Globals.TouchscreenCalibration[3] )
|
||||
{
|
||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
||||
}
|
||||
if( ev.getX() < Globals.TouchscreenCalibration[0] )
|
||||
Globals.TouchscreenCalibration[0] = (int)ev.getX();
|
||||
if( ev.getY() < Globals.TouchscreenCalibration[1] )
|
||||
Globals.TouchscreenCalibration[1] = (int)ev.getY();
|
||||
if( ev.getX() > Globals.TouchscreenCalibration[2] )
|
||||
Globals.TouchscreenCalibration[2] = (int)ev.getX();
|
||||
if( ev.getY() > Globals.TouchscreenCalibration[3] )
|
||||
Globals.TouchscreenCalibration[3] = (int)ev.getY();
|
||||
Matrix m = new Matrix();
|
||||
RectF src = new RectF(0, 0, bmp.getWidth(), bmp.getHeight());
|
||||
RectF dst = new RectF(Globals.TouchscreenCalibration[0], Globals.TouchscreenCalibration[1],
|
||||
Globals.TouchscreenCalibration[2], Globals.TouchscreenCalibration[3]);
|
||||
m.setRectToRect(src, dst, Matrix.ScaleToFit.FILL);
|
||||
img.setImageMatrix(m);
|
||||
}
|
||||
|
||||
public void onKeyEvent(final int keyCode)
|
||||
{
|
||||
p.touchListener = null;
|
||||
p.keyListener = null;
|
||||
p.getVideoLayout().removeView(img);
|
||||
goBack(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,846 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import javax.microedition.khronos.opengles.GL11;
|
||||
import javax.microedition.khronos.opengles.GL11Ext;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGL11;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLContext;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
import javax.microedition.khronos.egl.EGLSurface;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.InputDevice;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.AssetManager;
|
||||
import android.widget.Toast;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.TextView;
|
||||
import java.lang.Thread;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import android.os.Build;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
|
||||
class Mouse
|
||||
{
|
||||
public static final int LEFT_CLICK_NORMAL = 0;
|
||||
public static final int LEFT_CLICK_NEAR_CURSOR = 1;
|
||||
public static final int LEFT_CLICK_WITH_MULTITOUCH = 2;
|
||||
public static final int LEFT_CLICK_WITH_PRESSURE = 3;
|
||||
public static final int LEFT_CLICK_WITH_KEY = 4;
|
||||
public static final int LEFT_CLICK_WITH_TIMEOUT = 5;
|
||||
public static final int LEFT_CLICK_WITH_TAP = 6;
|
||||
public static final int LEFT_CLICK_WITH_TAP_OR_TIMEOUT = 7;
|
||||
|
||||
public static final int RIGHT_CLICK_NONE = 0;
|
||||
public static final int RIGHT_CLICK_WITH_MULTITOUCH = 1;
|
||||
public static final int RIGHT_CLICK_WITH_PRESSURE = 2;
|
||||
public static final int RIGHT_CLICK_WITH_KEY = 3;
|
||||
public static final int RIGHT_CLICK_WITH_TIMEOUT = 4;
|
||||
|
||||
public static final int SDL_FINGER_DOWN = 0;
|
||||
public static final int SDL_FINGER_UP = 1;
|
||||
public static final int SDL_FINGER_MOVE = 2;
|
||||
public static final int SDL_FINGER_HOVER = 3;
|
||||
|
||||
public static final int ZOOM_NONE = 0;
|
||||
public static final int ZOOM_MAGNIFIER = 1;
|
||||
public static final int ZOOM_SCREEN_TRANSFORM = 2;
|
||||
public static final int ZOOM_FULLSCREEN_MAGNIFIER = 3;
|
||||
}
|
||||
|
||||
abstract class DifferentTouchInput
|
||||
{
|
||||
public abstract void process(final MotionEvent event);
|
||||
public abstract void processGenericEvent(final MotionEvent event);
|
||||
|
||||
public static boolean ExternalMouseDetected = false;
|
||||
|
||||
public static DifferentTouchInput getInstance()
|
||||
{
|
||||
boolean multiTouchAvailable1 = false;
|
||||
boolean multiTouchAvailable2 = false;
|
||||
// Not checking for getX(int), getY(int) etc 'cause I'm lazy
|
||||
Method methods [] = MotionEvent.class.getDeclaredMethods();
|
||||
for(Method m: methods)
|
||||
{
|
||||
if( m.getName().equals("getPointerCount") )
|
||||
multiTouchAvailable1 = true;
|
||||
if( m.getName().equals("getPointerId") )
|
||||
multiTouchAvailable2 = true;
|
||||
}
|
||||
try {
|
||||
Log.i("SDL", "Device model: " + android.os.Build.MODEL);
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH )
|
||||
{
|
||||
if( DetectCrappyDragonRiseDatexGamepad() )
|
||||
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance;
|
||||
return IcsTouchInput.Holder.sInstance;
|
||||
}
|
||||
if( android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD )
|
||||
return GingerbreadTouchInput.Holder.sInstance;
|
||||
if (multiTouchAvailable1 && multiTouchAvailable2)
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
else
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
} catch( Exception e ) {
|
||||
try {
|
||||
if (multiTouchAvailable1 && multiTouchAvailable2)
|
||||
return MultiTouchInput.Holder.sInstance;
|
||||
else
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
} catch( Exception ee ) {
|
||||
return SingleTouchInput.Holder.sInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static boolean DetectCrappyDragonRiseDatexGamepad()
|
||||
{
|
||||
if( CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance == null )
|
||||
return false;
|
||||
return CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad.Holder.sInstance.detect();
|
||||
}
|
||||
|
||||
private static class SingleTouchInput extends DifferentTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final SingleTouchInput sInstance = new SingleTouchInput();
|
||||
}
|
||||
@Override
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
if( event.getAction() == MotionEvent.ACTION_DOWN )
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
if( event.getAction() == MotionEvent.ACTION_UP )
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
if( event.getAction() == MotionEvent.ACTION_MOVE )
|
||||
action = Mouse.SDL_FINGER_MOVE;
|
||||
if ( action >= 0 )
|
||||
DemoGLSurfaceView.nativeMotionEvent( (int)event.getX(), (int)event.getY(), action, 0,
|
||||
(int)(event.getPressure() * 1000.0),
|
||||
(int)(event.getSize() * 1000.0) );
|
||||
}
|
||||
}
|
||||
private static class MultiTouchInput extends DifferentTouchInput
|
||||
{
|
||||
public static final int TOUCH_EVENTS_MAX = 16; // Max multitouch pointers
|
||||
|
||||
private class touchEvent
|
||||
{
|
||||
public boolean down = false;
|
||||
public int x = 0;
|
||||
public int y = 0;
|
||||
public int pressure = 0;
|
||||
public int size = 0;
|
||||
}
|
||||
|
||||
protected touchEvent touchEvents[];
|
||||
|
||||
MultiTouchInput()
|
||||
{
|
||||
touchEvents = new touchEvent[TOUCH_EVENTS_MAX];
|
||||
for( int i = 0; i < TOUCH_EVENTS_MAX; i++ )
|
||||
touchEvents[i] = new touchEvent();
|
||||
}
|
||||
|
||||
private static class Holder
|
||||
{
|
||||
private static final MultiTouchInput sInstance = new MultiTouchInput();
|
||||
}
|
||||
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
int action = -1;
|
||||
|
||||
//Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY());
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_CANCEL )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
for( int i = 0; i < TOUCH_EVENTS_MAX; i++ )
|
||||
{
|
||||
if( touchEvents[i].down )
|
||||
{
|
||||
touchEvents[i].down = false;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[i].x, touchEvents[i].y, action, i, touchEvents[i].pressure, touchEvents[i].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
for( int i = 0; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
int id = event.getPointerId(i);
|
||||
if( id >= TOUCH_EVENTS_MAX )
|
||||
id = TOUCH_EVENTS_MAX - 1;
|
||||
touchEvents[id].down = true;
|
||||
touchEvents[id].x = (int)event.getX(i);
|
||||
touchEvents[id].y = (int)event.getY(i);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(i) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(i) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN ||
|
||||
(event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP )
|
||||
{
|
||||
/*
|
||||
String s = "MOVE: ptrs " + event.getPointerCount();
|
||||
for( int i = 0 ; i < event.getPointerCount(); i++ )
|
||||
{
|
||||
s += " p" + event.getPointerId(i) + "=" + (int)event.getX(i) + ":" + (int)event.getY(i);
|
||||
}
|
||||
Log.i("SDL", s);
|
||||
*/
|
||||
int pointerReleased = -1;
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_UP )
|
||||
pointerReleased = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
|
||||
|
||||
for( int id = 0; id < TOUCH_EVENTS_MAX; id++ )
|
||||
{
|
||||
int ii;
|
||||
for( ii = 0; ii < event.getPointerCount(); ii++ )
|
||||
{
|
||||
if( id == event.getPointerId(ii) )
|
||||
break;
|
||||
}
|
||||
if( ii >= event.getPointerCount() )
|
||||
{
|
||||
// Up event
|
||||
if( touchEvents[id].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
touchEvents[id].down = false;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pointerReleased == id && touchEvents[pointerReleased].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
touchEvents[id].down = false;
|
||||
}
|
||||
else if( touchEvents[id].down )
|
||||
{
|
||||
action = Mouse.SDL_FINGER_MOVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
action = Mouse.SDL_FINGER_DOWN;
|
||||
touchEvents[id].down = true;
|
||||
}
|
||||
touchEvents[id].x = (int)event.getX(ii);
|
||||
touchEvents[id].y = (int)event.getY(ii);
|
||||
touchEvents[id].pressure = (int)(event.getPressure(ii) * 1000.0);
|
||||
touchEvents[id].size = (int)(event.getSize(ii) * 1000.0);
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[id].x, touchEvents[id].y, action, id, touchEvents[id].pressure, touchEvents[id].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( (event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_HOVER_MOVE ) // Support bluetooth/USB mouse - available since Android 3.1
|
||||
{
|
||||
// TODO: it is possible that multiple pointers return that event, but we're handling only pointer #0
|
||||
if( touchEvents[0].down )
|
||||
action = Mouse.SDL_FINGER_UP;
|
||||
else
|
||||
action = Mouse.SDL_FINGER_HOVER;
|
||||
touchEvents[0].down = false;
|
||||
touchEvents[0].x = (int)event.getX();
|
||||
touchEvents[0].y = (int)event.getY();
|
||||
touchEvents[0].pressure = 0;
|
||||
touchEvents[0].size = 0;
|
||||
DemoGLSurfaceView.nativeMotionEvent( touchEvents[0].x, touchEvents[0].y, action, 0, touchEvents[0].pressure, touchEvents[0].size );
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class GingerbreadTouchInput extends MultiTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final GingerbreadTouchInput sInstance = new GingerbreadTouchInput();
|
||||
}
|
||||
|
||||
GingerbreadTouchInput()
|
||||
{
|
||||
super();
|
||||
}
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
boolean hwMouseEvent = ( (event.getSource() & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE ||
|
||||
(event.getSource() & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS ||
|
||||
(event.getMetaState() & KeyEvent.FLAG_TRACKING) != 0 ); // Hack to recognize Galaxy Note Gingerbread stylus
|
||||
if( ExternalMouseDetected != hwMouseEvent )
|
||||
{
|
||||
ExternalMouseDetected = hwMouseEvent;
|
||||
DemoGLSurfaceView.nativeHardwareMouseDetected(hwMouseEvent ? 1 : 0);
|
||||
}
|
||||
super.process(event);
|
||||
}
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
process(event);
|
||||
}
|
||||
}
|
||||
private static class IcsTouchInput extends GingerbreadTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final IcsTouchInput sInstance = new IcsTouchInput();
|
||||
}
|
||||
private int buttonState = 0;
|
||||
public void process(final MotionEvent event)
|
||||
{
|
||||
//Log.i("SDL", "Got motion event, type " + (int)(event.getAction()) + " X " + (int)event.getX() + " Y " + (int)event.getY() + " buttons " + buttonState + " source " + event.getSource());
|
||||
int buttonStateNew = event.getButtonState();
|
||||
if( buttonStateNew != buttonState )
|
||||
{
|
||||
for( int i = 1; i <= MotionEvent.BUTTON_FORWARD; i *= 2 )
|
||||
{
|
||||
if( (buttonStateNew & i) != (buttonState & i) )
|
||||
DemoGLSurfaceView.nativeMouseButtonsPressed(i, ((buttonStateNew & i) == 0) ? 0 : 1);
|
||||
}
|
||||
buttonState = buttonStateNew;
|
||||
}
|
||||
super.process(event); // Push mouse coordinate first
|
||||
}
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||
{
|
||||
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||
event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||
event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) );
|
||||
return;
|
||||
}
|
||||
// Process mousewheel
|
||||
if( event.getAction() == MotionEvent.ACTION_SCROLL )
|
||||
{
|
||||
int scrollX = Math.round(event.getAxisValue(MotionEvent.AXIS_HSCROLL));
|
||||
int scrollY = Math.round(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
|
||||
DemoGLSurfaceView.nativeMouseWheel(scrollX, scrollY);
|
||||
return;
|
||||
}
|
||||
super.processGenericEvent(event);
|
||||
}
|
||||
}
|
||||
private static class CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad extends IcsTouchInput
|
||||
{
|
||||
private static class Holder
|
||||
{
|
||||
private static final CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad sInstance = new CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad();
|
||||
}
|
||||
float hatX = 0.0f, hatY = 0.0f;
|
||||
public void processGenericEvent(final MotionEvent event)
|
||||
{
|
||||
// Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it
|
||||
if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK )
|
||||
{
|
||||
// event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events
|
||||
DemoGLSurfaceView.nativeGamepadAnalogJoystickInput(
|
||||
event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y),
|
||||
event.getAxisValue(MotionEvent.AXIS_RX), event.getAxisValue(MotionEvent.AXIS_RZ),
|
||||
0, 0);
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX )
|
||||
{
|
||||
hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
|
||||
if( hatX == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1);
|
||||
}
|
||||
if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY )
|
||||
{
|
||||
hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
|
||||
if( hatY == 0.0f )
|
||||
{
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0);
|
||||
DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0);
|
||||
}
|
||||
else
|
||||
DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
super.processGenericEvent(event);
|
||||
}
|
||||
public boolean detect()
|
||||
{
|
||||
int[] devIds = InputDevice.getDeviceIds();
|
||||
for( int id : devIds )
|
||||
{
|
||||
InputDevice device = InputDevice.getDevice(id);
|
||||
if( device == null )
|
||||
continue;
|
||||
System.out.println("libSDL: input device ID " + id + " type " + device.getSources() + " name " + device.getName() );
|
||||
if( (device.getSources() & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD &&
|
||||
(device.getSources() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK &&
|
||||
device.getName().indexOf("DragonRise Inc") == 0 )
|
||||
{
|
||||
System.out.println("libSDL: Detected crappy DragonRise gamepad, enabling special hack for it. Please press button labeled 'Analog', otherwise it won't work, because it's cheap and crappy");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DemoRenderer extends GLSurfaceView_SDL.Renderer
|
||||
{
|
||||
public DemoRenderer(MainActivity _context)
|
||||
{
|
||||
context = _context;
|
||||
}
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceCreated(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
|
||||
mGlSurfaceCreated = true;
|
||||
mGl = gl;
|
||||
/*if( ! mPaused && ! mFirstTimeStart )
|
||||
nativeGlContextRecreated();*/
|
||||
mFirstTimeStart = false;
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceChanged(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart + " w " + w + " h " + h);
|
||||
if( w < h && Globals.HorizontalOrientation )
|
||||
{
|
||||
// Sometimes when Android awakes from lockscreen, portrait orientation is kept
|
||||
int x = w;
|
||||
w = h;
|
||||
h = x;
|
||||
}
|
||||
mWidth = w;
|
||||
mHeight = h;
|
||||
mGl = gl;
|
||||
//nativeResize(w, h, Globals.KeepAspectRatio ? 1 : 0);
|
||||
}
|
||||
|
||||
public void onSurfaceDestroyed() {
|
||||
Log.i("SDL", "libSDL: DemoRenderer.onSurfaceDestroyed(): paused " + mPaused + " mFirstTimeStart " + mFirstTimeStart );
|
||||
mGlSurfaceCreated = false;
|
||||
mGlContextLost = true;
|
||||
//nativeGlContextLost();
|
||||
};
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
|
||||
mGl = gl;
|
||||
DrawLogo(mGl);
|
||||
SwapBuffers();
|
||||
|
||||
//nativeInitJavaCallbacks();
|
||||
|
||||
// Make main thread priority lower so audio thread won't get underrun
|
||||
// Thread.currentThread().setPriority((Thread.currentThread().getPriority() + Thread.MIN_PRIORITY)/2);
|
||||
|
||||
mGlContextLost = false;
|
||||
|
||||
if(Globals.CompatibilityHacksStaticInit)
|
||||
MainActivity.LoadApplicationLibrary(context);
|
||||
|
||||
Settings.Apply(context);
|
||||
accelerometer = new AccelerometerReader(context);
|
||||
// Tweak video thread priority, if user selected big audio buffer
|
||||
if(Globals.AudioBufferConfig >= 2)
|
||||
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
|
||||
// Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
|
||||
/*nativeInit( Globals.DataDir,
|
||||
Globals.CommandLine,
|
||||
( (Globals.SwVideoMode && Globals.MultiThreadedVideo) || Globals.CompatibilityHacksVideo ) ? 1 : 0,
|
||||
android.os.Debug.isDebuggerConnected() ? 1 : 0 );*/
|
||||
//System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
|
||||
}
|
||||
|
||||
public int swapBuffers() // Called from native code
|
||||
{
|
||||
if( ! super.SwapBuffers() && Globals.NonBlockingSwapBuffers )
|
||||
{
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(mGlContextLost) {
|
||||
mGlContextLost = false;
|
||||
Settings.SetupTouchscreenKeyboardGraphics(context); // Reload on-screen buttons graphics
|
||||
DrawLogo(mGl);
|
||||
super.SwapBuffers();
|
||||
}
|
||||
|
||||
// Unblock event processing thread only after we've finished rendering
|
||||
if(mRatelimitTouchEvents)
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
this.notify();
|
||||
}
|
||||
}
|
||||
/*if( context.isScreenKeyboardShown() )
|
||||
{
|
||||
try {
|
||||
Thread.sleep(50); // Give some time to the keyboard input thread
|
||||
} catch(Exception e) { };
|
||||
}*/
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void showScreenKeyboardWithoutTextInputField() // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public void run()
|
||||
{
|
||||
parent.showScreenKeyboardWithoutTextInputField();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void showScreenKeyboard(final String oldText, int sendBackspace) // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public String oldText;
|
||||
public boolean sendBackspace;
|
||||
public void run()
|
||||
{
|
||||
parent.showScreenKeyboard(oldText, sendBackspace);
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
cb.oldText = oldText;
|
||||
cb.sendBackspace = (sendBackspace != 0);
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public void hideScreenKeyboard() // Called from native code
|
||||
{
|
||||
class Callback implements Runnable
|
||||
{
|
||||
public MainActivity parent;
|
||||
public void run()
|
||||
{
|
||||
//parent.hideScreenKeyboard();
|
||||
}
|
||||
}
|
||||
Callback cb = new Callback();
|
||||
cb.parent = context;
|
||||
context.runOnUiThread(cb);
|
||||
}
|
||||
|
||||
public int isScreenKeyboardShown() // Called from native code
|
||||
{
|
||||
//return context.isScreenKeyboardShown() ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setScreenKeyboardHintMessage(String s)
|
||||
{
|
||||
//context.setScreenKeyboardHintMessage(s);
|
||||
}
|
||||
|
||||
public void startAccelerometerGyroscope(int started)
|
||||
{
|
||||
accelerometer.openedBySDL = (started != 0);
|
||||
if( accelerometer.openedBySDL && !mPaused )
|
||||
accelerometer.start();
|
||||
else
|
||||
accelerometer.stop();
|
||||
}
|
||||
|
||||
public void exitApp()
|
||||
{
|
||||
//nativeDone();
|
||||
}
|
||||
|
||||
public void getAdvertisementParams(int params[])
|
||||
{
|
||||
//context.getAdvertisementParams(params);
|
||||
}
|
||||
public void setAdvertisementVisible(int visible)
|
||||
{
|
||||
//context.setAdvertisementVisible(visible);
|
||||
}
|
||||
public void setAdvertisementPosition(int left, int top)
|
||||
{
|
||||
//context.setAdvertisementPosition(left, top);
|
||||
}
|
||||
public void requestNewAdvertisement()
|
||||
{
|
||||
//context.requestNewAdvertisement();
|
||||
}
|
||||
|
||||
private int PowerOf2(int i)
|
||||
{
|
||||
int value = 1;
|
||||
while (value < i)
|
||||
value <<= 1;
|
||||
return value;
|
||||
}
|
||||
public void DrawLogo(GL10 gl)
|
||||
{
|
||||
/*
|
||||
// TODO: this not quite works, as it seems
|
||||
BitmapDrawable bmp = null;
|
||||
try
|
||||
{
|
||||
bmp = new BitmapDrawable(context.getAssets().open("logo.png"));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
bmp = new BitmapDrawable(context.getResources().openRawResource(R.drawable.publisherlogo));
|
||||
}
|
||||
int width = bmp.getBitmap().getWidth();
|
||||
int height = bmp.getBitmap().getHeight();
|
||||
ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * width * height);
|
||||
//byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
bmp.getBitmap().copyPixelsToBuffer(byteBuffer);
|
||||
byteBuffer.position(0);
|
||||
|
||||
gl.glViewport(0, 0, mWidth, mHeight);
|
||||
gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
|
||||
gl.glColor4x(0x10000, 0x10000, 0x10000, 0x10000);
|
||||
gl.glPixelStorei(gl.GL_UNPACK_ALIGNMENT, 1);
|
||||
gl.glEnable(GL10.GL_TEXTURE_2D);
|
||||
int textureName = -1;
|
||||
int mTextureNameWorkspace[] = new int[1];
|
||||
int mCropWorkspace[] = new int[4];
|
||||
gl.glGenTextures(1, mTextureNameWorkspace, 0);
|
||||
textureName = mTextureNameWorkspace[0];
|
||||
gl.glBindTexture(GL10.GL_TEXTURE_2D, textureName);
|
||||
gl.glActiveTexture(textureName);
|
||||
gl.glClientActiveTexture(textureName);
|
||||
gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, GL10.GL_RGBA,
|
||||
PowerOf2(width), PowerOf2(height), 0,
|
||||
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, null);
|
||||
gl.glTexSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0,
|
||||
width, height,
|
||||
GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, byteBuffer);
|
||||
mCropWorkspace[0] = 0; // u
|
||||
mCropWorkspace[1] = height; // v
|
||||
mCropWorkspace[2] = width;
|
||||
mCropWorkspace[3] = -height;
|
||||
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D,
|
||||
GL11Ext.GL_TEXTURE_CROP_RECT_OES, mCropWorkspace, 0);
|
||||
((GL11Ext) gl).glDrawTexiOES(0, -mHeight, 0, mWidth, mHeight);
|
||||
gl.glActiveTexture(0);
|
||||
gl.glClientActiveTexture(0);
|
||||
gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
|
||||
gl.glDeleteTextures(1, mTextureNameWorkspace, 0);
|
||||
|
||||
gl.glFlush();
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//private native void nativeInitJavaCallbacks();
|
||||
//private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo, int isDebuggerConnected);
|
||||
//private native void nativeResize(int w, int h, int keepAspectRatio);
|
||||
//private native void nativeDone();
|
||||
//private native void nativeGlContextLost();
|
||||
//public native void nativeGlContextRecreated();
|
||||
//public native void nativeGlContextLostAsyncEvent();
|
||||
//public static native void nativeTextInput( int ascii, int unicode );
|
||||
//public static native void nativeTextInputFinished();
|
||||
|
||||
private MainActivity context = null;
|
||||
public AccelerometerReader accelerometer = null;
|
||||
|
||||
private GL10 mGl = null;
|
||||
private EGL10 mEgl = null;
|
||||
private EGLDisplay mEglDisplay = null;
|
||||
private EGLSurface mEglSurface = null;
|
||||
//private EGLContext mEglContext = null;
|
||||
private boolean mGlContextLost = false;
|
||||
public boolean mGlSurfaceCreated = false;
|
||||
public boolean mPaused = false;
|
||||
private boolean mFirstTimeStart = true;
|
||||
public int mWidth = 0;
|
||||
public int mHeight = 0;
|
||||
|
||||
public static final boolean mRatelimitTouchEvents = true; //(Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO);
|
||||
}
|
||||
|
||||
class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
public DemoGLSurfaceView(MainActivity context) {
|
||||
super(context);
|
||||
mParent = context;
|
||||
touchInput = DifferentTouchInput.getInstance();
|
||||
setEGLConfigChooser(Globals.VideoDepthBpp, Globals.NeedDepthBuffer, Globals.NeedStencilBuffer, Globals.NeedGles2);
|
||||
mRenderer = new DemoRenderer(context);
|
||||
setRenderer(mRenderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(final MotionEvent event)
|
||||
{
|
||||
touchInput.process(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onGenericMotionEvent (final MotionEvent event)
|
||||
{
|
||||
touchInput.processGenericEvent(event);
|
||||
if( DemoRenderer.mRatelimitTouchEvents )
|
||||
{
|
||||
limitEventRate(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void limitEventRate(final MotionEvent event)
|
||||
{
|
||||
// Wait a bit, and try to synchronize to app framerate, or event thread will eat all CPU and we'll lose FPS
|
||||
// With Froyo the rate of touch events seems to be limited by OS, but they are arriving faster then we're redrawing anyway
|
||||
if((event.getAction() == MotionEvent.ACTION_MOVE ||
|
||||
event.getAction() == MotionEvent.ACTION_HOVER_MOVE))
|
||||
{
|
||||
synchronized(mRenderer)
|
||||
{
|
||||
try
|
||||
{
|
||||
mRenderer.wait(300L); // And sometimes the app decides not to render at all, so this timeout should not be big.
|
||||
} catch (InterruptedException e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void exitApp() {
|
||||
mRenderer.exitApp();
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if(mRenderer.mPaused)
|
||||
return;
|
||||
mRenderer.mPaused = true;
|
||||
//mRenderer.nativeGlContextLostAsyncEvent();
|
||||
if( mRenderer.accelerometer != null ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||
mRenderer.accelerometer.stop();
|
||||
super.onPause();
|
||||
};
|
||||
|
||||
public boolean isPaused() {
|
||||
return mRenderer.mPaused;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if(!mRenderer.mPaused)
|
||||
return;
|
||||
mRenderer.mPaused = false;
|
||||
super.onResume();
|
||||
Log.i("SDL", "libSDL: DemoGLSurfaceView.onResume(): mRenderer.mGlSurfaceCreated " + mRenderer.mGlSurfaceCreated + " mRenderer.mPaused " + mRenderer.mPaused);
|
||||
/*if( mRenderer.mGlSurfaceCreated && ! mRenderer.mPaused || Globals.NonBlockingSwapBuffers )
|
||||
mRenderer.nativeGlContextRecreated();*/
|
||||
if( mRenderer.accelerometer != null && mRenderer.accelerometer.openedBySDL ) // For some reason it crashes here often - are we getting this event before initialization?
|
||||
mRenderer.accelerometer.start();
|
||||
};
|
||||
|
||||
// This seems like redundant code - it handled in MainActivity.java
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, final KeyEvent event) {
|
||||
//Log.i("SDL", "Got key down event, id " + keyCode + " meta " + event.getMetaState() + " event " + event.toString());
|
||||
if( nativeKey( keyCode, 1 ) == 0 )
|
||||
return super.onKeyDown(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyUp(int keyCode, final KeyEvent event) {
|
||||
//Log.i("SDL", "Got key up event, id " + keyCode + " meta " + event.getMetaState());
|
||||
if( nativeKey( keyCode, 0 ) == 0 )
|
||||
return super.onKeyUp(keyCode, event);
|
||||
return true;
|
||||
}
|
||||
|
||||
DemoRenderer mRenderer;
|
||||
MainActivity mParent;
|
||||
DifferentTouchInput touchInput = null;
|
||||
|
||||
public static native void nativeMotionEvent( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native int nativeKey( int keyCode, int down );
|
||||
public static native void nativeTouchpad( int x, int y, int down, int multitouch );
|
||||
public static native void initJavaCallbacks();
|
||||
public static native void nativeHardwareMouseDetected( int detected );
|
||||
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
||||
public static native void nativeMouseWheel( int scrollX, int scrollY );
|
||||
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Java source code (C) 2009-2012 Sergii Pylypenko
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
package net.sourceforge.clonekeenplus;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.ads.*; // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
|
||||
class Advertisement
|
||||
{
|
||||
private AdView ad;
|
||||
MainActivity parent;
|
||||
|
||||
public Advertisement(MainActivity p)
|
||||
{
|
||||
parent = p;
|
||||
AdSize adSize = AdSize.BANNER;
|
||||
if( Globals.AdmobBannerSize.equals("BANNER") )
|
||||
adSize = AdSize.BANNER;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_BANNER") )
|
||||
adSize = AdSize.IAB_BANNER;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_LEADERBOARD") )
|
||||
adSize = AdSize.IAB_LEADERBOARD;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_MRECT") )
|
||||
adSize = AdSize.IAB_MRECT;
|
||||
else if( Globals.AdmobBannerSize.equals("IAB_WIDE_SKYSCRAPER") )
|
||||
adSize = AdSize.IAB_WIDE_SKYSCRAPER;
|
||||
else if( Globals.AdmobBannerSize.equals("SMART_BANNER") )
|
||||
adSize = AdSize.SMART_BANNER;
|
||||
ad = new AdView(parent, adSize, Globals.AdmobPublisherId);
|
||||
AdRequest adRequest = new AdRequest();
|
||||
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
adRequest.addTestDevice(Globals.AdmobTestDeviceId);
|
||||
ad.loadAd(adRequest);
|
||||
}
|
||||
|
||||
public View getView()
|
||||
{
|
||||
return ad;
|
||||
}
|
||||
|
||||
public void requestNewAd()
|
||||
{
|
||||
AdRequest adRequest = new AdRequest();
|
||||
adRequest.addTestDevice(AdRequest.TEST_EMULATOR); // Copy GoogleAdMobAdsSdk.jar to the directory project/libs
|
||||
adRequest.addTestDevice(Globals.AdmobTestDeviceId);
|
||||
ad.loadAd(adRequest);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
grep '<string name=' values/strings.xml | while read str; do
|
||||
|
||||
if echo "$str" | grep 'translatable="false"' ; then continue; fi
|
||||
|
||||
var=`echo $str | sed 's/<string name=["]\([^"]*\).*/\1/'`
|
||||
text=`echo $str | sed 's/<string name=["][^"]*["]>\([^<]*\).*/\1/'`
|
||||
if [ "$var" = "app_name" ]; then
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
I''ve tired of using Google Translate to create random gibberish in the languages I don't know,
|
||||
I've tired of using Google Translate to create random gibberish in the languages I don't know,
|
||||
so from now on the only supported languages are English, Russian, Ukrainian, and French with some community support,
|
||||
If you wish to maintain a translation - contact me, but I will want a continuous support, not just one-time translation.
|
||||
@@ -62,9 +62,9 @@
|
||||
<string name="rightclick_menu">Menütaste</string>
|
||||
<string name="rightclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
|
||||
<string name="rightclick_pressure">Touchscreen mit Kraft</string>
|
||||
<string name="pointandclick_question">Erweiterte Funktionen</string>
|
||||
<string name="pointandclick_keepaspectratio">Halten 4:3-Bildschirm Seitenverhältnis</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Show-Bildschirm unter dem Finger in einem separaten Fenster</string>
|
||||
<string name="advanced">Erweiterte Funktionen</string>
|
||||
<string name="mouse_keepaspectratio">Halten 4:3-Bildschirm Seitenverhältnis</string>
|
||||
<string name="mouse_showcreenunderfinger">Show-Bildschirm unter dem Finger in einem separaten Fenster</string>
|
||||
<string name="measurepressure_touchplease">Bitte schieben Sie den Finger über den Bildschirm für zwei Sekunden</string>
|
||||
<string name="rightclick_none">Deaktivieren der rechten Maustaste</string>
|
||||
<string name="leftclick_question">Linke Maustaste</string>
|
||||
@@ -73,11 +73,11 @@
|
||||
<string name="leftclick_multitouch">Touch-Screen mit dem zweiten Finger</string>
|
||||
<string name="leftclick_pressure">Touchscreen mit Kraft</string>
|
||||
<string name="leftclick_dpadcenter">Trackball klicken Select-Taste</string>
|
||||
<string name="pointandclick_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
|
||||
<string name="mouse_joystickmouse">Bewegen Sie die Maus mit Joystick oder Trackball</string>
|
||||
<string name="measurepressure_response">Pressure %1$03d Radius %2$03d</string>
|
||||
<string name="click_with_dpadcenter">Linker Mausklick mit Trackball / Joystick Zentrum</string>
|
||||
<string name="pointandclick_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
|
||||
<string name="mouse_joystickmousespeed">Bewegen Sie die Maus mit Joystick-Geschwindigkeit</string>
|
||||
<string name="mouse_joystickmouseaccel">Bewegen Sie die Maus mit Joystick-Beschleunigung</string>
|
||||
<string name="none">Keine</string>
|
||||
<string name="controls_screenkb_transparency">On-Screen-Tastatur Transparenz</string>
|
||||
<string name="controls_screenkb_trans_0">Nicht sichtbar</string>
|
||||
@@ -108,7 +108,7 @@
|
||||
<string name="screenkb_custom_layout">Passen Sie auf dem Bildschirm Tastatur-Layout</string>
|
||||
<string name="screenkb_custom_layout_help">Slide-Bildschirm hinzufügen Taste, drücken Sie Menü zum letzten Knopf rückgängig machen</string>
|
||||
<string name="rightclick_key">Physikalische Schlüssel</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">On-Screen-Lupe</string>
|
||||
<string name="mouse_showcreenunderfinger2">On-Screen-Lupe</string>
|
||||
<string name="video">Video-Einstellungen</string>
|
||||
<string name="video_smooth">Glatte Video</string>
|
||||
<string name="accel_veryslow">Sehr langsam</string>
|
||||
@@ -121,9 +121,9 @@
|
||||
<string name="leftclick_timeout_time_2">0,7 Sek.</string>
|
||||
<string name="leftclick_timeout_time_3">1 Sek.</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 Sek.</string>
|
||||
<string name="pointandclick_relative">Relative Bewegung der Maus (Laptop-Modus)</string>
|
||||
<string name="pointandclick_relative_speed">Relative Maus Bewegungsgeschwindigkeit</string>
|
||||
<string name="pointandclick_relative_accel">Relative Bewegung der Maus Beschleunigung</string>
|
||||
<string name="mouse_relative">Relative Bewegung der Maus (Laptop-Modus)</string>
|
||||
<string name="mouse_relative_speed">Relative Maus Bewegungsgeschwindigkeit</string>
|
||||
<string name="mouse_relative_accel">Relative Bewegung der Maus Beschleunigung</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="video_separatethread">Separaten Thread für Video, FPS bei einigen Geräten zu erhöhen</string>
|
||||
<string name="text_edit_click_here">Tippen Sie auf der Eingabe beginnen, drücken Sie Zurück, wenn Sie fertig</string>
|
||||
@@ -134,4 +134,24 @@
|
||||
<string name="display_size_tiny">Uberklein (Xperia Mini)</string>
|
||||
<string name="show_more_options">Weitere Optionen</string>
|
||||
<string name="controls_screenkb_drawsize">Größe der Schaltfläche Bilder</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="controls_screenkb_custom">Custom</string>
|
||||
<string name="mouse_hover_jitter_filter">Filter jitter for stylus/finger hover</string>
|
||||
<string name="remap_hwkeys_select_simple">Select action</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Show all keycodes</string>
|
||||
<string name="display_size_small_touchpad">Small, touchpad mode</string>
|
||||
<string name="display_size_tiny_touchpad">Tiny, touchpad mode</string>
|
||||
<string name="hardware_mouse_detected">Hardware mouse detected, disabling mouse emulation</string>
|
||||
<string name="not_enough_ram">Not enough RAM</string>
|
||||
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
|
||||
<string name="calibrate_gyroscope_text">Put your device on a flat surface</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
|
||||
<string name="reset_config">Reset config to defaults</string>
|
||||
<string name="reset_config_ask">Reset all options to default values?</string>
|
||||
<string name="cancel_download">Cancel data downloading?</string>
|
||||
<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
</resources>
|
||||
|
||||
@@ -62,9 +62,9 @@
|
||||
<string name="rightclick_menu">Valikkonäppäin</string>
|
||||
<string name="rightclick_multitouch">Kosketusnäyttö on toinen sormi</string>
|
||||
<string name="rightclick_pressure">Kosketusnäyttö voimalla</string>
|
||||
<string name="pointandclick_question">Lisäominaisuudet</string>
|
||||
<string name="pointandclick_keepaspectratio">Pidä 04:03 kuvasuhde</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Näytä näytön alle sormi erillisessä ikkunassa</string>
|
||||
<string name="advanced">Lisäominaisuudet</string>
|
||||
<string name="mouse_keepaspectratio">Pidä 04:03 kuvasuhde</string>
|
||||
<string name="mouse_showcreenunderfinger">Näytä näytön alle sormi erillisessä ikkunassa</string>
|
||||
<string name="measurepressure_touchplease">Ole hyvä ja liu\u0026#39;uttamalla sormea näytöllä kaksi sekuntia</string>
|
||||
<string name="rightclick_none">Poista oikealla hiiren klikkauksella</string>
|
||||
<string name="leftclick_question">Vasen hiiren nappi</string>
|
||||
@@ -73,11 +73,11 @@
|
||||
<string name="leftclick_multitouch">Kosketusnäyttö on toinen sormi</string>
|
||||
<string name="leftclick_pressure">Kosketusnäyttö voimalla</string>
|
||||
<string name="leftclick_dpadcenter">Trackball Valitse / Select-näppäintä</string>
|
||||
<string name="pointandclick_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
|
||||
<string name="mouse_joystickmouse">Siirrä hiiren ohjaimella tai trackball</string>
|
||||
<string name="measurepressure_response">Paine %1$03d säde %2$03d</string>
|
||||
<string name="click_with_dpadcenter">Vasen hiiren klikkaus trackball-ohjaimella keskusta</string>
|
||||
<string name="pointandclick_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
|
||||
<string name="mouse_joystickmousespeed">Siirrä hiiri ohjainta nopeasti</string>
|
||||
<string name="mouse_joystickmouseaccel">Siirrä hiiri ohjainta kiihtyvyys</string>
|
||||
<string name="none">Ei</string>
|
||||
<string name="controls_screenkb_transparency">Näyttönäppäimistöllä avoimuutta</string>
|
||||
<string name="controls_screenkb_trans_0">Näkymätön</string>
|
||||
@@ -108,7 +108,7 @@
|
||||
<string name="screenkb_custom_layout">Mukauta-ruudun näppäimistö</string>
|
||||
<string name="screenkb_custom_layout_help">Työnnä näytön lisätä painikkeen, paina Menu kumota viimeksi painike</string>
|
||||
<string name="rightclick_key">Fyysinen avain</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Näytöllä suurennuslasi</string>
|
||||
<string name="mouse_showcreenunderfinger2">Näytöllä suurennuslasi</string>
|
||||
<string name="video">Videon asetukset</string>
|
||||
<string name="video_smooth">Tasainen video</string>
|
||||
<string name="accel_veryslow">Erittäin hidas</string>
|
||||
@@ -121,9 +121,9 @@
|
||||
<string name="leftclick_timeout_time_2">0,7 sekuntia</string>
|
||||
<string name="leftclick_timeout_time_3">1 sek</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 sek</string>
|
||||
<string name="pointandclick_relative">Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa)</string>
|
||||
<string name="pointandclick_relative_speed">Suhteellinen hiiren liikkeen nopeus</string>
|
||||
<string name="pointandclick_relative_accel">Suhteellinen hiiren liikkeen kiihtyvyys</string>
|
||||
<string name="mouse_relative">Suhteellinen hiiren liikkeet (kannettavan tietokoneen tilassa)</string>
|
||||
<string name="mouse_relative_speed">Suhteellinen hiiren liikkeen nopeus</string>
|
||||
<string name="mouse_relative_accel">Suhteellinen hiiren liikkeen kiihtyvyys</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="video_separatethread">Erillisessä säikeessä video, kasvaa FPS joissakin laitteissa</string>
|
||||
<string name="text_edit_click_here">Napauta aloittaa kirjoittamisen, paina Takaisin, kun olet valmis</string>
|
||||
@@ -134,4 +134,24 @@
|
||||
<string name="display_size_tiny">Tiny (Xperia Mini)</string>
|
||||
<string name="show_more_options">Näytä enemmän vaihtoehtoja</string>
|
||||
<string name="controls_screenkb_drawsize">Koko painike kuvia</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="controls_screenkb_custom">Custom</string>
|
||||
<string name="mouse_hover_jitter_filter">Filter jitter for stylus/finger hover</string>
|
||||
<string name="remap_hwkeys_select_simple">Select action</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Show all keycodes</string>
|
||||
<string name="display_size_small_touchpad">Small, touchpad mode</string>
|
||||
<string name="display_size_tiny_touchpad">Tiny, touchpad mode</string>
|
||||
<string name="hardware_mouse_detected">Hardware mouse detected, disabling mouse emulation</string>
|
||||
<string name="not_enough_ram">Not enough RAM</string>
|
||||
<string name="not_enough_ram_size">This app needs %1$d Mb RAM, your device has %2$d Mb</string>
|
||||
<string name="ignore">Ignore</string>
|
||||
<string name="calibrate_gyroscope">Calibrate gyroscope</string>
|
||||
<string name="calibrate_gyroscope_text">Put your device on a flat surface</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Your device does not have gyroscope</string>
|
||||
<string name="reset_config">Reset config to defaults</string>
|
||||
<string name="reset_config_ask">Reset all options to default values?</string>
|
||||
<string name="cancel_download">Cancel data downloading?</string>
|
||||
<string name="cancel_download_resume">You can resume it later, the data will not be downloaded twice.</string>
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
</resources>
|
||||
|
||||
196
project/javaSDL2/translations/values-es/strings.xml
Normal file
196
project/javaSDL2/translations/values-es/strings.xml
Normal file
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- values-es/string.xml string resource in spanish languaje -->
|
||||
|
||||
<resources>
|
||||
<string name="init">Inicializando</string>
|
||||
<string name="please_wait">Por favor espere mientras se descargan los datos</string>
|
||||
|
||||
<string name="device_config">Configuración del dispositivo</string>
|
||||
<string name="device_change_cfg">Cambiar la configuración del dispositivo</string>
|
||||
|
||||
<string name="download_unneeded">No se necesita descarga</string>
|
||||
<string name="connecting_to">Conectándose a %s</string>
|
||||
<string name="failed_connecting_to">Fallo al conectarse a %s</string>
|
||||
<string name="error_connecting_to">Error al conectarse a %s</string>
|
||||
<string name="dl_from">Descargándose datos desde %s</string>
|
||||
<string name="error_dl_from">Error al descargarse los datos desde %s</string>
|
||||
<string name="error_write">Error al escribir en %s</string>
|
||||
<string name="dl_progress">%1$.0f%% hecho: archivo %2$s</string>
|
||||
<string name="dl_finished">Finalizado</string>
|
||||
|
||||
<string name="storage_phone">Almacenamiento interno - %d MB libres</string>
|
||||
<string name="storage_sd">Almacenamiento SD card - %d MB libres</string>
|
||||
<string name="storage_custom">Especifique el directorio</string>
|
||||
<string name="storage_commandline">Especifique los parámetros de la línea de comandos, one argument per line</string>
|
||||
<string name="storage_question">Lugar donde guardar los datos de la instalación</string>
|
||||
<string name="optional_downloads">Descargas</string>
|
||||
<string name="downloads">Descargas</string>
|
||||
<string name="ok">Aceptar</string>
|
||||
<string name="cancel">Cancelar</string>
|
||||
|
||||
<string name="controls_arrows">Flechas / Joystick / Cruceta mando video consola</string>
|
||||
<string name="controls_trackball">Bola de control (Trackball)</string>
|
||||
<string name="controls_accel">Acelerómetro</string>
|
||||
<string name="controls_touch">Sólo Tocando la pantalla</string>
|
||||
<string name="controls_question">¿ Qué clase de teclas de navegación tiene su dispositivo ?</string>
|
||||
|
||||
<string name="controls_additional">Controles adicionales</string>
|
||||
<string name="controls_screenkb">Teclado virtual en pantalla</string>
|
||||
<string name="controls_accelnav">Acelerómetro</string>
|
||||
|
||||
<string name="controls_screenkb_size">Tamaño del teclado virtual en pantalla</string>
|
||||
<string name="controls_screenkb_drawsize">Tamaño de las imágenes de los botones</string>
|
||||
<string name="controls_screenkb_large">Grande</string>
|
||||
<string name="controls_screenkb_medium">Mediano</string>
|
||||
<string name="controls_screenkb_small">Pequeño</string>
|
||||
<string name="controls_screenkb_tiny">Diminuto</string>
|
||||
<string name="controls_screenkb_custom">Personalizado</string>
|
||||
<string name="controls_screenkb_theme">Tema del teclado virtual en pantalla</string>
|
||||
<string name="controls_screenkb_by">%1$s x %2$s</string>
|
||||
<string name="controls_screenkb_transparency">Teclado virtual en pantalla transparente</string>
|
||||
<string name="controls_screenkb_trans_0">Invisible</string>
|
||||
<string name="controls_screenkb_trans_1">Semi invisible</string>
|
||||
<string name="controls_screenkb_trans_2">Transparente</string>
|
||||
<string name="controls_screenkb_trans_3">Semi transparente</string>
|
||||
<string name="controls_screenkb_trans_4">Opaco</string>
|
||||
|
||||
<string name="trackball_no_dampening">Sin retardo (muy rápido)</string>
|
||||
<string name="trackball_fast">Rápido</string>
|
||||
<string name="trackball_medium">Mediano</string>
|
||||
<string name="trackball_slow">Lento</string>
|
||||
<string name="trackball_question">Retardo de la Bola control(Trackball)</string>
|
||||
|
||||
<string name="accel_veryfast">Muy rápido</string>
|
||||
<string name="accel_fast">Rápido</string>
|
||||
<string name="accel_medium">Mediano</string>
|
||||
<string name="accel_slow">Lento</string>
|
||||
<string name="accel_veryslow">Muy lento</string>
|
||||
<string name="accel_question">Determinar velocidad accelerómetro</string>
|
||||
|
||||
<string name="accel_floating">Flotante</string>
|
||||
<string name="accel_fixed_start">Fijo cuando la aplicación comienza</string>
|
||||
<string name="accel_fixed_horiz">Fijar la orientación de la tablet</string>
|
||||
<string name="accel_question_center">Centrar la posición del acelerómetro</string>
|
||||
|
||||
<string name="mouse_emulation">Emulación del ratón</string>
|
||||
<string name="rightclick_question">Botón derecho del ratón</string>
|
||||
<string name="rightclick_menu">Tecla de menú</string>
|
||||
<string name="rightclick_key">Tecla física</string>
|
||||
<string name="rightclick_multitouch">Tocar la pantalla con un segundo dedo</string>
|
||||
<string name="rightclick_pressure">Tocar la pantalla durante un tiempo prolongado</string>
|
||||
<string name="rightclick_none">Desabilitar el botón derecho del ratón</string>
|
||||
|
||||
<string name="leftclick_question">Botón izquierdo del ratón</string>
|
||||
<string name="leftclick_normal">Normal</string>
|
||||
<string name="leftclick_near_cursor">Tocar cerca del cursor del ratón</string>
|
||||
<string name="leftclick_multitouch">Tocar la pantalla con un segundo dedo</string>
|
||||
<string name="leftclick_pressure">Tocar la pantalla durante un tiempo prolongado</string>
|
||||
<string name="leftclick_dpadcenter">Botón del Trackball / centrar joystick</string>
|
||||
<string name="leftclick_timeout">Dejar de tocar y tocar la pantalla durante ...</string>
|
||||
<string name="leftclick_tap">Un toque rápido (no tocar, tocar, y no tocar)</string>
|
||||
<string name="leftclick_tap_or_timeout">Tocar o dejar de tocar</string>
|
||||
<string name="leftclick_timeout_time">Mantener toque durante ...</string>
|
||||
<string name="leftclick_timeout_time_0">0.3 sec</string>
|
||||
<string name="leftclick_timeout_time_1">0.5 sec</string>
|
||||
<string name="leftclick_timeout_time_2">0.7 sec</string>
|
||||
<string name="leftclick_timeout_time_3">1 sec</string>
|
||||
<string name="leftclick_timeout_time_4">1.5 sec</string>
|
||||
<string name="click_with_dpadcenter">Botón izquierdo del ratón mediante: Bola(trackball)/centrar joystick</string>
|
||||
|
||||
<string name="advanced">Características avanzadas</string>
|
||||
<string name="mouse_keepaspectratio">Mantenr proporción de la pantalla 4:3</string>
|
||||
<string name="mouse_showcreenunderfinger">Mostrar la pantalla debajo del dedo en una ventana por separado</string>
|
||||
<string name="mouse_showcreenunderfinger2">Mostrar lente de aumento sobre la pantalla</string>
|
||||
<string name="mouse_joystickmouse">Mover el ratón mediante joystick o bola(trackball)</string>
|
||||
<string name="mouse_joystickmousespeed">Mover el ratón mediante un joystick de velocidad</string>
|
||||
<string name="mouse_joystickmouseaccel">Mover el ratón mediante un joystick de aceleración</string>
|
||||
<string name="mouse_relative">Movimiento relativo del ratón (laptop mode)</string>
|
||||
<string name="mouse_relative_speed">Velocidad relativa del movimiento del ratón</string>
|
||||
<string name="mouse_relative_accel">Aceleración relativa del movimiento del ratón</string>
|
||||
<string name="mouse_hover_jitter_filter">Filtro elimina nerviosismo al escribir/dedo flotante</string>
|
||||
<string name="mouse_gyroscope_mouse">Controlar el ratón mediante el giroscopio</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">Sensibilidad del giroscopio</string>
|
||||
<string name="mouse_finger_hover">Dedo flotante deslizante</string>
|
||||
<string name="mouse_subframe_touch_events">Múltiples eventos de toque por fotograma</string>
|
||||
|
||||
<string name="none">Nada</string>
|
||||
|
||||
<string name="measurepressure">Calibrar la presión del toque</string>
|
||||
<string name="measurepressure_touchplease">Por favor deslice el dedo por la pantalla durante dos segundos</string>
|
||||
<string name="measurepressure_response">Presión %1$03d radio %2$03d</string>
|
||||
|
||||
<string name="audiobuf_verysmall">Muy pequeña (dispositivos rápidos, menos retraso)</string>
|
||||
<string name="audiobuf_small">Pequeña</string>
|
||||
<string name="audiobuf_medium">Media</string>
|
||||
<string name="audiobuf_large">Grande (dispositivos antiguos, si el sonido se entrecorta)</string>
|
||||
<string name="audiobuf_question">Tamaño de la memoria de almacenamiento de audio</string>
|
||||
|
||||
<string name="remap_hwkeys">Cambiar teclas físicas</string>
|
||||
<string name="remap_hwkeys_press">Presione una tecla excepto Botón central(HOME) y Botón encendido, puede usar las teclas de volumen</string>
|
||||
<string name="remap_hwkeys_select">Seleccionar código de la tecla SDL</string>
|
||||
<string name="remap_hwkeys_select_simple">Seleccionar acción</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Mostrar todos los códigos de teclas</string>
|
||||
|
||||
<string name="remap_screenkb">Cambiar controles de pulsación pantalla</string>
|
||||
<string name="remap_screenkb_joystick">Joystick</string>
|
||||
<string name="remap_screenkb_button">Botón</string>
|
||||
<string name="remap_screenkb_button_text">Bótón para introducir texto</string>
|
||||
<string name="remap_screenkb_button_gestures">Gestos con dos dedos</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Sensibilidad de gestos con dos dedos</string>
|
||||
<string name="remap_screenkb_button_zoomin">Gesto para Zoom de aumento con dos dedos</string>
|
||||
<string name="remap_screenkb_button_zoomout">Gesto prara Zoom de disminución con dos dedos</string>
|
||||
<string name="remap_screenkb_button_rotateleft">Gesto para rotar a la izquierda con dos dedos</string>
|
||||
<string name="remap_screenkb_button_rotateright">Gesto para rotar a la derecha con dos dedos</string>
|
||||
|
||||
<string name="screenkb_custom_layout">Pesonalizar la presentación del teclado virtual en pantalla</string>
|
||||
<string name="screenkb_custom_layout_help">Presione botón Atras para finalizar. Cambiar tamaño botones deslizando sobre el espacio vacío.</string>
|
||||
<string name="screenkb_floating_joystick">Joystick flotante</string>
|
||||
|
||||
<string name="calibrate_touchscreen">Calibrar el toque sobre la pantalla</string>
|
||||
<string name="calibrate_touchscreen_touch">Toque todas las esquinas de la pantalla, puse botón Atras para finalizar</string>
|
||||
|
||||
<string name="video">Configuración de Video</string>
|
||||
<string name="video_smooth">Filtro de lineas</string>
|
||||
<string name="video_separatethread">Hebra/proceso separado para video, puede incrementar FPS, puede colgar la APP</string>
|
||||
<string name="video_orientation_vertical">Orientación Horizontal/Vertical de la pantalla</string>
|
||||
<string name="video_bpp_24">24 bits profundidad del color</string>
|
||||
<string name="video_immersive">Ocultar botones de navegación(botones pantalla) / modo inmersión</string>
|
||||
|
||||
<string name="text_edit_click_here">Toque y suelte para empezar a teclear, presione botón Atras para finalizar</string>
|
||||
|
||||
<string name="display_size_mouse">Modo de emulación del ratón</string>
|
||||
<string name="display_size">Tamaño de la pantalla para la emulación del ratón</string>
|
||||
<string name="display_size_large">Grande (tablets)</string>
|
||||
<string name="display_size_small">Pequeña, lupa de aumento</string>
|
||||
<string name="display_size_small_touchpad">Pequeña, modo touchpad</string>
|
||||
<string name="display_size_tiny">Diminuta</string>
|
||||
<string name="display_size_tiny_touchpad">Diminuta, modo touchpad</string>
|
||||
|
||||
<string name="show_more_options">Mostrar más opciones</string>
|
||||
|
||||
<string name="hardware_mouse_detected">Detección del ratón real, desabilita emulación del ratón</string>
|
||||
|
||||
<string name="not_enough_ram">No hay suficiente memoria RAM</string>
|
||||
<string name="not_enough_ram_size">Esta APP necesita %1$d Mb RAM, su dispositivo tiene %2$d Mb</string>
|
||||
<string name="ignore">Ignorar</string>
|
||||
|
||||
<string name="calibrate_gyroscope">Calibrar giroscopio</string>
|
||||
<string name="calibrate_gyroscope_text">Mantenga quieta la pantalla en una superficie plana, que no vibre</string>
|
||||
<string name="calibrate_gyroscope_not_supported">Su dispositivo no tiene giroscopio</string>
|
||||
|
||||
<string name="reset_config">Resetear configuración a valores por defecto</string>
|
||||
<string name="reset_config_ask">¿ Resetear todas las opciones a valores por defecto ?</string>
|
||||
|
||||
<string name="cancel_download">¿ Cancelar descarga de datos ?</string>
|
||||
<string name="cancel_download_resume">Usted puede continuar después, los datos ya guardados no se descargarán otra vez.</string>
|
||||
<string name="yes">Si</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
<!-- Play Game Services strings -->
|
||||
<string name="gamehelper_sign_in_failed">Fallo al conectarse a la cuenta. Por favor chequee la conexión de la red e inténtelo de nuevo.</string>
|
||||
<string name="gamehelper_app_misconfigured">La aplicacion esta incorrectamente configurada. Chequee que el nombre del paquete y certificado coincide con el ID de cliente creado en la Consola de Desarrollo. También, si la aplicación no esta todavía publicada, chequee que la cuenta que usted esta intentando acceder esta listada como cuenta de testeador. Vea registro de errores(logs) para más información.</string>
|
||||
<string name="gamehelper_license_failed">Chequeo de licencia fallido.</string>
|
||||
<string name="gamehelper_unknown_error">Error desconocido.</string>
|
||||
<string name="accessing_network">Accediendo a la red, por favor espere</string>
|
||||
</resources>
|
||||
@@ -19,7 +19,7 @@
|
||||
<string name="storage_phone">Stockage interne - %d Mo de libre</string>
|
||||
<string name="storage_sd">Carte SD - %d Mo de libre</string>
|
||||
<string name="storage_custom">Choisir le répertoire</string>
|
||||
<string name="storage_commandline">Choisir les paramètres de la ligne de commande</string>
|
||||
<string name="storage_commandline">Choisir les paramètres de la ligne de commande, one argument per line</string>
|
||||
<string name="storage_question">Où télécharger les données</string>
|
||||
<string name="optional_downloads">Téléchargements</string>
|
||||
<string name="downloads">Téléchargements</string>
|
||||
@@ -98,16 +98,16 @@
|
||||
<string name="leftclick_timeout_time_4">1,5 sec</string>
|
||||
<string name="click_with_dpadcenter">Cliquez gauche de la souris avec le Trackball / centre du joystick </string>
|
||||
|
||||
<string name="pointandclick_question">Fonctionnalités avancées</string>
|
||||
<string name="pointandclick_keepaspectratio">Gardez le format 4:3 écran</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Afficher l\'écran sous le doigt dans une fenêtre séparée</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Loupe à l\'écran</string>
|
||||
<string name="pointandclick_joystickmouse">Déplacez la souris avec un trackball ou le joystick</string>
|
||||
<string name="pointandclick_joystickmousespeed">Déplacez la souris avec la vitesse du joystick</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Déplacez la souris avec l\'accélération du joystick</string>
|
||||
<string name="pointandclick_relative">Mouvement relatif de la souris (mode portable)</string>
|
||||
<string name="pointandclick_relative_speed">Vitesse relative de la souris</string>
|
||||
<string name="pointandclick_relative_accel">Accélération relative de la souris</string>
|
||||
<string name="advanced">Fonctionnalités avancées</string>
|
||||
<string name="mouse_keepaspectratio">Gardez le format 4:3 écran</string>
|
||||
<string name="mouse_showcreenunderfinger">Afficher l\'écran sous le doigt dans une fenêtre séparée</string>
|
||||
<string name="mouse_showcreenunderfinger2">Loupe à l\'écran</string>
|
||||
<string name="mouse_joystickmouse">Déplacez la souris avec un trackball ou le joystick</string>
|
||||
<string name="mouse_joystickmousespeed">Déplacez la souris avec la vitesse du joystick</string>
|
||||
<string name="mouse_joystickmouseaccel">Déplacez la souris avec l\'accélération du joystick</string>
|
||||
<string name="mouse_relative">Mouvement relatif de la souris (mode portable)</string>
|
||||
<string name="mouse_relative_speed">Vitesse relative de la souris</string>
|
||||
<string name="mouse_relative_accel">Accélération relative de la souris</string>
|
||||
|
||||
<string name="none">Aucun</string>
|
||||
|
||||
@@ -173,4 +173,20 @@
|
||||
<string name="no">No</string>
|
||||
<string name="screenkb_custom_layout_help">Press BACK when done. Resize buttons by sliding on empty space.</string>
|
||||
<string name="controls_screenkb_custom">Custom</string>
|
||||
<string name="mouse_hover_jitter_filter">Filter jitter for stylus/finger hover</string>
|
||||
<string name="remap_hwkeys_select_simple">Select action</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Show all keycodes</string>
|
||||
<string name="mouse_gyroscope_mouse">Control mouse with gyroscope</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">Gyroscope sensitivity</string>
|
||||
<string name="mouse_finger_hover">Finger hover</string>
|
||||
<string name="mouse_subframe_touch_events">Multiple touch events per video frame</string>
|
||||
<string name="screenkb_floating_joystick">Floating joystick</string>
|
||||
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||
<string name="video_immersive">Hide system navigation buttons / immersive mode</string>
|
||||
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
||||
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string>
|
||||
<string name="gamehelper_license_failed">License check failed.</string>
|
||||
<string name="gamehelper_unknown_error">Unknown error.</string>
|
||||
<string name="accessing_network">Accessing network, please wait</string>
|
||||
</resources>
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
<string name="storage_phone">Внутреннее хранение - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куда сохранять данные приложения</string>
|
||||
<string name="storage_access">Разрешение на запись на SD карту</string>
|
||||
<string name="optional_downloads">Дополнительные загрузки</string>
|
||||
<string name="ok">Продолжить</string>
|
||||
<string name="controls_arrows">Стрелки / джойстик / Dpad</string>
|
||||
<string name="controls_trackball">Трекбол</string>
|
||||
<string name="controls_accel">Акселерометр</string>
|
||||
<string name="controls_touch">Только сенсорный экран</string>
|
||||
<string name="controls_question">Какие на телефоне клавиши навигации?</string>
|
||||
<string name="controls_question">Какие на телефоне кнопки навигации?</string>
|
||||
<string name="controls_additional">Дополнительные элементы управления</string>
|
||||
<string name="controls_screenkb">Экранная клавиатура</string>
|
||||
<string name="controls_accelnav">Акселерометр</string>
|
||||
@@ -43,12 +44,12 @@
|
||||
<string name="accel_slow">Медленно</string>
|
||||
<string name="accel_question">Чувствительность акселерометра</string>
|
||||
<string name="rightclick_question">Правая кнопка мыши</string>
|
||||
<string name="rightclick_menu">Клавиша меню</string>
|
||||
<string name="rightclick_menu">Кнопка меню</string>
|
||||
<string name="rightclick_multitouch">Касание экрана вторым пальцем</string>
|
||||
<string name="rightclick_pressure">Нажатие на экран с силой</string>
|
||||
<string name="pointandclick_question">Расширенные функции</string>
|
||||
<string name="pointandclick_keepaspectratio">Сохранять соотношение сторон 4:3 на экране</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Экранная лупа</string>
|
||||
<string name="advanced">Расширенные функции</string>
|
||||
<string name="mouse_keepaspectratio">Сохранять соотношение сторон 4:3 на экране</string>
|
||||
<string name="mouse_showcreenunderfinger">Экранная лупа</string>
|
||||
<string name="measurepressure_touchplease">Пожалуйста, проведите пальцем по экрану в течение двух секунд</string>
|
||||
<string name="measurepressure_response">Давление %1$03d радиус %2$03d </string>
|
||||
<string name="audiobuf_verysmall">Очень мало (быстрые устройства)</string>
|
||||
@@ -67,10 +68,10 @@
|
||||
<string name="leftclick_multitouch">Касание двумя пальцами</string>
|
||||
<string name="leftclick_pressure">Нажатие с силой</string>
|
||||
<string name="leftclick_dpadcenter">Нажатие на трекбол / центр джойстика</string>
|
||||
<string name="pointandclick_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
|
||||
<string name="mouse_joystickmouse">Перемещение мыши при помощи джойстика или трекбола</string>
|
||||
<string name="click_with_dpadcenter">Левый клик мыши при помощи трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
|
||||
<string name="mouse_joystickmousespeed">Перемещение мыши джойстиком - скорость</string>
|
||||
<string name="mouse_joystickmouseaccel">Перемещение мыши джойстиком - ускорение</string>
|
||||
<string name="none">Нет</string>
|
||||
<string name="controls_screenkb_transparency">Прозрачность клавиатуры</string>
|
||||
<string name="controls_screenkb_trans_0">Невидимый</string>
|
||||
@@ -80,8 +81,8 @@
|
||||
<string name="controls_screenkb_trans_4">Непрозрачные</string>
|
||||
<string name="mouse_emulation">Эмуляции мыши</string>
|
||||
<string name="measurepressure">Калибровка сенсорного давления</string>
|
||||
<string name="remap_hwkeys">Переназначение физических клавиш</string>
|
||||
<string name="remap_hwkeys_press">Нажмите любую клавишу, кроме HOME и POWER, вы можете использовать клавиши регулировки громкости</string>
|
||||
<string name="remap_hwkeys">Переназначение физических кнопок</string>
|
||||
<string name="remap_hwkeys_press">Нажмите любую клавишу, кроме HOME и POWER, вы можете использовать кнопки регулировки громкости</string>
|
||||
<string name="remap_hwkeys_select">Выберите код кнопки SDL</string>
|
||||
<string name="remap_screenkb">Переназначение экранных кнопок</string>
|
||||
<string name="remap_screenkb_joystick">Экранный джойстик</string>
|
||||
@@ -95,13 +96,13 @@
|
||||
<string name="accel_veryfast">Очень быстро</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Чувствительность жеста двумя пальцами по экрану</string>
|
||||
<string name="storage_custom">Укажите каталог</string>
|
||||
<string name="storage_commandline">Укажите параметры командной строки</string>
|
||||
<string name="storage_commandline">Параметры командной строки, каждый аргумент на отдельной строке</string>
|
||||
<string name="calibrate_touchscreen">Калибровка сенсорного экрана</string>
|
||||
<string name="calibrate_touchscreen_touch">Дотроньтесь до всех краев экрана, потом нажмите Назад/BACK</string>
|
||||
<string name="screenkb_custom_layout">Настройка расположения кнопок</string>
|
||||
<string name="screenkb_custom_layout_help">Нажмите клавишу Назад/BACK для завершения. Проведите по пустому месту, чтобы изменить размер кнопки</string>
|
||||
<string name="screenkb_custom_layout_help">Нажмите кнопку Назад/BACK для завершения. Проведите по пустому месту, чтобы изменить размер кнопки</string>
|
||||
<string name="rightclick_key">Физическая кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наэкранная лупа</string>
|
||||
<string name="mouse_showcreenunderfinger2">Наэкранная лупа</string>
|
||||
<string name="video">Настройки видео</string>
|
||||
<string name="video_smooth">Линейное сглаживание видео</string>
|
||||
<string name="accel_veryslow">Очень медленно</string>
|
||||
@@ -114,9 +115,9 @@
|
||||
<string name="leftclick_timeout_time_2">0,7 сек</string>
|
||||
<string name="leftclick_timeout_time_3">1 сек</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 сек</string>
|
||||
<string name="pointandclick_relative">Относительное движение мыши (режим ноутбука)</string>
|
||||
<string name="pointandclick_relative_speed">Скорость движения мыши</string>
|
||||
<string name="pointandclick_relative_accel">Ускорение движения мыши</string>
|
||||
<string name="mouse_relative">Относительное движение мыши (режим ноутбука)</string>
|
||||
<string name="mouse_relative_speed">Скорость движения мыши</string>
|
||||
<string name="mouse_relative_accel">Ускорение движения мыши</string>
|
||||
<string name="downloads">Загрузки</string>
|
||||
<string name="video_separatethread">Отдельный поток для видео, увеличит FPS на некоторых устройствах</string>
|
||||
<string name="text_edit_click_here">Нажмите, чтобы ввести текст, нажмите Назад, когда закончите</string>
|
||||
@@ -146,4 +147,20 @@
|
||||
<string name="yes">Да</string>
|
||||
<string name="no">Нет</string>
|
||||
<string name="controls_screenkb_custom">Пользовательские настройки</string>
|
||||
<string name="mouse_hover_jitter_filter">Фильтровать дрожание при поднесении стилуса/пальца к экрану</string>
|
||||
<string name="remap_hwkeys_select_simple">Выберите действие</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Показать все коды кнопок</string>
|
||||
<string name="mouse_gyroscope_mouse">Control mouse with gyroscope</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">Gyroscope sensitivity</string>
|
||||
<string name="mouse_finger_hover">Finger hover</string>
|
||||
<string name="mouse_subframe_touch_events">Multiple touch events per video frame</string>
|
||||
<string name="screenkb_floating_joystick">Floating joystick</string>
|
||||
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||
<string name="video_immersive">Hide system navigation buttons / immersive mode</string>
|
||||
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
||||
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string>
|
||||
<string name="gamehelper_license_failed">License check failed.</string>
|
||||
<string name="gamehelper_unknown_error">Unknown error.</string>
|
||||
<string name="accessing_network">Accessing network, please wait</string>
|
||||
</resources>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<string name="storage_phone">Внутрішнє зберігання - %d Мб</string>
|
||||
<string name="storage_sd">SD карта - %d Мб</string>
|
||||
<string name="storage_question">Куди зберігати дані програми</string>
|
||||
<string name="storage_access">Дозвіл на запис на SD карту</string>
|
||||
<string name="optional_downloads">Додаткові завантаження</string>
|
||||
<string name="ok">ОК</string>
|
||||
<string name="controls_arrows">Стрілки / джойстік / Dpad</string>
|
||||
@@ -46,9 +47,9 @@
|
||||
<string name="rightclick_menu">Кнопка меню</string>
|
||||
<string name="rightclick_multitouch">Торкання екрана другим пальцем</string>
|
||||
<string name="rightclick_pressure">Натиск на екран силою</string>
|
||||
<string name="pointandclick_question">Розширені функції</string>
|
||||
<string name="pointandclick_keepaspectratio">Зберігати співвідношення сторін 4:3 на екрані</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Наекранна лупа</string>
|
||||
<string name="advanced">Розширені функції</string>
|
||||
<string name="mouse_keepaspectratio">Зберігати співвідношення сторін 4:3 на екрані</string>
|
||||
<string name="mouse_showcreenunderfinger">Наекранна лупа</string>
|
||||
<string name="measurepressure_touchplease">Будь-ласка, проведіть пальцем по екрану на протязі двох секунд</string>
|
||||
<string name="measurepressure_response">Тиск %1$03d радіус %2$03d </string>
|
||||
<string name="audiobuf_verysmall">Дуже мало (швидкі пристрої)</string>
|
||||
@@ -67,10 +68,10 @@
|
||||
<string name="leftclick_multitouch">Натиск на екран другим пальцем</string>
|
||||
<string name="leftclick_pressure">>Натиск на екран з силою</string>
|
||||
<string name="leftclick_dpadcenter">Натиск на трекбол / центр джойстику</string>
|
||||
<string name="pointandclick_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
|
||||
<string name="mouse_joystickmouse">Переміщення миші за допомогою джойстика або трекбола</string>
|
||||
<string name="click_with_dpadcenter">Лівий клік миші за допомогою трекбола / центра джойстика</string>
|
||||
<string name="pointandclick_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
|
||||
<string name="mouse_joystickmousespeed">Переміщення миші джойстиком - швидкiсть</string>
|
||||
<string name="mouse_joystickmouseaccel">Переміщення миші джойстиком - прискорення</string>
|
||||
<string name="none">Немає</string>
|
||||
<string name="controls_screenkb_transparency">Прозорість клавіатури</string>
|
||||
<string name="controls_screenkb_trans_0">Невидимий</string>
|
||||
@@ -95,13 +96,13 @@
|
||||
<string name="accel_veryfast">Дуже швидко</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">Чутливість жесту двома пальцями по екрану</string>
|
||||
<string name="storage_custom">Вкажіть каталог</string>
|
||||
<string name="storage_commandline">Вкажіть параметри командного рядка</string>
|
||||
<string name="storage_commandline">Вкажіть параметри командного рядка, кожен аргумент на окремому рядку</string>
|
||||
<string name="calibrate_touchscreen">Калібрування сенсорного екрану</string>
|
||||
<string name="calibrate_touchscreen_touch">Доторкнiться до всіх країв екрану, потiм натисніть Назад/BACK</string>
|
||||
<string name="screenkb_custom_layout">Налаштування положення кнопок</string>
|
||||
<string name="screenkb_custom_layout_help">Натисніть Назад/BACK для завершення. Проведiть по екрану, щоб змінити розмір кнопки</string>
|
||||
<string name="rightclick_key">Фізична кнопка</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">Наекранна лупа</string>
|
||||
<string name="mouse_showcreenunderfinger2">Наекранна лупа</string>
|
||||
<string name="video">Налаштування відео</string>
|
||||
<string name="video_smooth">Лінійне сглажування відео</string>
|
||||
<string name="accel_veryslow">Дуже повільно</string>
|
||||
@@ -114,9 +115,9 @@
|
||||
<string name="leftclick_timeout_time_2">0,7 секунд</string>
|
||||
<string name="leftclick_timeout_time_3">1 сек</string>
|
||||
<string name="leftclick_timeout_time_4">1,5 сек</string>
|
||||
<string name="pointandclick_relative">Відносний рух миші (режим ноутбука)</string>
|
||||
<string name="pointandclick_relative_speed">Швидкість руху миші</string>
|
||||
<string name="pointandclick_relative_accel">Прискорення руху миші</string>
|
||||
<string name="mouse_relative">Відносний рух миші (режим ноутбука)</string>
|
||||
<string name="mouse_relative_speed">Швидкість руху миші</string>
|
||||
<string name="mouse_relative_accel">Прискорення руху миші</string>
|
||||
<string name="downloads">Завантаження</string>
|
||||
<string name="video_separatethread">Окремий потік для відео, збільшить FPS на деяких пристроях</string>
|
||||
<string name="text_edit_click_here">Натисніть, щоб ввести текст, натисніть Назад, коли закiнчете</string>
|
||||
@@ -145,4 +146,20 @@
|
||||
<string name="yes">Так</string>
|
||||
<string name="no">Ні</string>
|
||||
<string name="controls_screenkb_custom">Налаштування користувача</string>
|
||||
<string name="mouse_hover_jitter_filter">Фільтрувати тремтіння при піднесенні стилуса/пальця до екрану</string>
|
||||
<string name="remap_hwkeys_select_simple">Виберіть дію</string>
|
||||
<string name="remap_hwkeys_select_more_keys">Показати всі коди кнопок</string>
|
||||
<string name="mouse_gyroscope_mouse">Control mouse with gyroscope</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">Gyroscope sensitivity</string>
|
||||
<string name="mouse_finger_hover">Finger hover</string>
|
||||
<string name="mouse_subframe_touch_events">Multiple touch events per video frame</string>
|
||||
<string name="screenkb_floating_joystick">Floating joystick</string>
|
||||
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||
<string name="video_immersive">Hide system navigation buttons / immersive mode</string>
|
||||
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
||||
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string>
|
||||
<string name="gamehelper_license_failed">License check failed.</string>
|
||||
<string name="gamehelper_unknown_error">Unknown error.</string>
|
||||
<string name="accessing_network">Accessing network, please wait</string>
|
||||
</resources>
|
||||
|
||||
205
project/javaSDL2/translations/values-zh/strings.xml
Normal file
205
project/javaSDL2/translations/values-zh/strings.xml
Normal file
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Commander Genius</string>
|
||||
|
||||
|
||||
<string name="init">初始化中</string>
|
||||
<string name="please_wait">正在下载数据,请稍候</string>
|
||||
|
||||
<string name="device_config">设备配置</string>
|
||||
<string name="device_change_cfg">更改设备配置</string>
|
||||
|
||||
<string name="download_unneeded">没有需要下载的内容</string>
|
||||
<string name="connecting_to">正在连接到 %s</string>
|
||||
<string name="failed_connecting_to">连接到 %s 失败</string>
|
||||
<string name="error_connecting_to"> %s 连接出错</string>
|
||||
<string name="dl_from">正在从 %s 下载数据</string>
|
||||
<string name="error_dl_from">从 %s 下载数据时出错</string>
|
||||
<string name="error_write">写入到 %s 时出错</string>
|
||||
<string name="dl_progress">%1$.0f%% 已完成: 文件 %2$s</string>
|
||||
<string name="dl_finished">已完成</string>
|
||||
|
||||
<string name="storage_phone">内部储存 - %d MB 空闲</string>
|
||||
<string name="storage_sd">SD卡储存 - %d MB 空闲</string>
|
||||
<string name="storage_custom">自定义目录</string>
|
||||
<string name="storage_commandline">命令行参数,每行一个参数</string>
|
||||
<string name="storage_question">数据文件安装位置</string>
|
||||
<string name="optional_downloads">下载</string>
|
||||
<string name="downloads">下载</string>
|
||||
<string name="ok">完成</string>
|
||||
<string name="cancel">取消</string>
|
||||
|
||||
<string name="controls_arrows">箭头 / 操纵杆 / 方向键</string>
|
||||
<string name="controls_trackball">轨迹球</string>
|
||||
<string name="controls_accel">加速度计</string>
|
||||
<string name="controls_touch">只使用触屏</string>
|
||||
<string name="controls_question">您的设备有哪些导航键?</string>
|
||||
|
||||
<string name="controls_additional">附加控制</string>
|
||||
<string name="controls_screenkb">屏幕键盘</string>
|
||||
<string name="controls_accelnav">加速度计</string>
|
||||
|
||||
<string name="controls_screenkb_size">屏幕键盘大小</string>
|
||||
<string name="controls_screenkb_drawsize">按钮大小</string>
|
||||
<string name="controls_screenkb_large">大</string>
|
||||
<string name="controls_screenkb_medium">中</string>
|
||||
<string name="controls_screenkb_small">小</string>
|
||||
<string name="controls_screenkb_tiny">微小</string>
|
||||
<string name="controls_screenkb_custom">自定义</string>
|
||||
<string name="controls_screenkb_theme">屏幕键盘主题</string>
|
||||
<string name="controls_screenkb_by">%1$s by %2$s</string>
|
||||
<string name="controls_screenkb_transparency">屏幕键盘透明度</string>
|
||||
<string name="controls_screenkb_trans_0">隐形</string>
|
||||
<string name="controls_screenkb_trans_1">半隐形</string>
|
||||
<string name="controls_screenkb_trans_2">透明</string>
|
||||
<string name="controls_screenkb_trans_3">半透明</string>
|
||||
<string name="controls_screenkb_trans_4">不透明</string>
|
||||
|
||||
<string name="trackball_no_dampening">无阻碍</string>
|
||||
<string name="trackball_fast">快</string>
|
||||
<string name="trackball_medium">中</string>
|
||||
<string name="trackball_slow">慢</string>
|
||||
<string name="trackball_question">轨迹球阻碍</string>
|
||||
|
||||
<string name="accel_veryfast">非常快</string>
|
||||
<string name="accel_fast">快</string>
|
||||
<string name="accel_medium">中</string>
|
||||
<string name="accel_slow">慢</string>
|
||||
<string name="accel_veryslow">非常慢</string>
|
||||
<string name="accel_question">加速度计灵敏度</string>
|
||||
|
||||
<string name="accel_floating">Floating</string>
|
||||
<string name="accel_fixed_start">在应用程序启动时修复</string>
|
||||
<string name="accel_fixed_horiz">Fixed to table desk orientation</string>
|
||||
<string name="accel_question_center">加速度计中心位置</string>
|
||||
|
||||
<string name="mouse_emulation">鼠标模拟</string>
|
||||
<string name="rightclick_question">单击鼠标右键</string>
|
||||
<string name="rightclick_menu">菜单键</string>
|
||||
<string name="rightclick_key">物理按键</string>
|
||||
<string name="rightclick_multitouch">双指触摸</string>
|
||||
<string name="rightclick_pressure">使用按压力度</string>
|
||||
<string name="rightclick_none">禁用鼠标右键</string>
|
||||
|
||||
<string name="leftclick_question">鼠标左键单击</string>
|
||||
<string name="leftclick_normal">正常</string>
|
||||
<string name="leftclick_near_cursor">触摸靠近鼠标光标</string>
|
||||
<string name="leftclick_multitouch">双指触摸</string>
|
||||
<string name="leftclick_pressure">使用按压力度</string>
|
||||
<string name="leftclick_dpadcenter">轨迹球点击 / 操纵杆中心</string>
|
||||
<string name="leftclick_timeout">长按一个点</string>
|
||||
<string name="leftclick_tap">点击</string>
|
||||
<string name="leftclick_tap_or_timeout">点击或长按</string>
|
||||
<string name="leftclick_timeout_time">长按超时</string>
|
||||
<string name="leftclick_timeout_time_0">0.3 秒</string>
|
||||
<string name="leftclick_timeout_time_1">0.5 秒</string>
|
||||
<string name="leftclick_timeout_time_2">0.7 秒</string>
|
||||
<string name="leftclick_timeout_time_3">1 秒</string>
|
||||
<string name="leftclick_timeout_time_4">1.5 秒</string>
|
||||
<string name="click_with_dpadcenter">左键点击和轨迹球点击 / 操纵杆中心</string>
|
||||
|
||||
<string name="advanced">高级功能</string>
|
||||
<string name="mouse_keepaspectratio">保持4:3的屏幕宽高比</string>
|
||||
<string name="mouse_showcreenunderfinger">在单独的窗口中显示屏幕</string>
|
||||
<string name="mouse_showcreenunderfinger2">屏幕放大镜</string>
|
||||
<string name="mouse_joystickmouse">使用操纵杆或轨迹球移动鼠标</string>
|
||||
<string name="mouse_joystickmousespeed">使用操纵杆移动鼠标时的速度</string>
|
||||
<string name="mouse_joystickmouseaccel">使用操纵杆加速移动鼠标</string>
|
||||
<string name="mouse_relative">鼠标相对移动(笔记本模式)</string>
|
||||
<string name="mouse_relative_speed">鼠标相对移动速度</string>
|
||||
<string name="mouse_relative_accel">鼠标相对移动加速</string>
|
||||
<string name="mouse_hover_jitter_filter">过滤指针/手指的抖动</string>
|
||||
<string name="mouse_gyroscope_mouse">用陀螺仪控制鼠标移动</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">陀螺仪灵敏度</string>
|
||||
<string name="mouse_finger_hover">手指抖动</string>
|
||||
<string name="mouse_subframe_touch_events">每一帧的多点触摸事件</string>
|
||||
|
||||
<string name="none">无</string>
|
||||
|
||||
<string name="measurepressure">校准触摸屏压力</string>
|
||||
<string name="measurepressure_touchplease">请将手指滑过屏幕两秒钟</string>
|
||||
<string name="measurepressure_response">压力 %1$03d 半径 %2$03d</string>
|
||||
|
||||
<string name="audiobuf_verysmall">非常小(较新的设备,延迟低)</string>
|
||||
<string name="audiobuf_small">小</string>
|
||||
<string name="audiobuf_medium">中等</string>
|
||||
<string name="audiobuf_large">大(较老的设备,如果声音不稳定请选此项)</string>
|
||||
<string name="audiobuf_question">音频缓冲大小</string>
|
||||
|
||||
<string name="remap_hwkeys">映射物理按键</string>
|
||||
<string name="remap_hwkeys_press">按下任意按键 除了HOME键和POWER键,如音量键</string>
|
||||
<string name="remap_hwkeys_select">选择SDL按键</string>
|
||||
<string name="remap_hwkeys_select_simple">选择动作</string>
|
||||
<string name="remap_hwkeys_select_more_keys">显示所有按键</string>
|
||||
|
||||
<string name="remap_screenkb">映射屏幕控件</string>
|
||||
<string name="remap_screenkb_joystick">手柄</string>
|
||||
<string name="remap_screenkb_button">按钮</string>
|
||||
<string name="remap_screenkb_button_text">文本输入按钮</string>
|
||||
<string name="remap_screenkb_button_gestures">双指手势</string>
|
||||
<string name="remap_screenkb_button_gestures_sensitivity">双指手势灵敏度</string>
|
||||
<string name="remap_screenkb_button_zoomin">双指放大</string>
|
||||
<string name="remap_screenkb_button_zoomout">双指缩小</string>
|
||||
<string name="remap_screenkb_button_rotateleft">双指向左旋转</string>
|
||||
<string name="remap_screenkb_button_rotateright">双指向右旋转</string>
|
||||
|
||||
<string name="screenkb_custom_layout">自定义屏幕键盘布局</string>
|
||||
<string name="screenkb_custom_layout_help">按返回键结束,在空白区域滑动调整按钮大小</string>
|
||||
<string name="screenkb_floating_joystick">浮动操纵杆</string>
|
||||
|
||||
<string name="calibrate_touchscreen">校准触摸屏</string>
|
||||
<string name="calibrate_touchscreen_touch">触摸屏幕的所有边缘,按返回键结束</string>
|
||||
|
||||
<string name="video">视频选项</string>
|
||||
<string name="video_smooth">线性过滤</string>
|
||||
<string name="video_separatethread">用单线程处理视频,可能会提高FPS,也可能使程序崩溃</string>
|
||||
<string name="video_orientation_vertical">切换横屏/竖屏</string>
|
||||
<string name="video_orientation_autodetect">自动检测屏幕方向</string>
|
||||
<string name="video_bpp_24">24 bpp颜色深度</string>
|
||||
<string name="video_immersive">隐藏系统导航按钮/沉浸模式</string>
|
||||
<string name="tv_borders">电视边框</string>
|
||||
|
||||
<string name="text_edit_click_here">点击开始输入,按返回键结束</string>
|
||||
|
||||
<string name="display_size_mouse">鼠标仿真模式</string>
|
||||
<string name="display_size">显示仿真鼠标的大小</string>
|
||||
<string name="display_size_desktop">桌面版,无仿真</string>
|
||||
<string name="display_size_large">大(适用于平板电脑)</string>
|
||||
<string name="display_size_small">小,放大镜</string>
|
||||
<string name="display_size_small_touchpad">小,触摸模式</string>
|
||||
<string name="display_size_tiny">很小</string>
|
||||
<string name="display_size_tiny_touchpad">很小,触摸模式</string>
|
||||
|
||||
<string name="show_more_options">显示更多选项</string>
|
||||
|
||||
<string name="hardware_mouse_detected">检测到鼠标硬件,禁用鼠标仿真</string>
|
||||
|
||||
<string name="not_enough_ram">没有足够的 RAM</string>
|
||||
<string name="not_enough_ram_size">本程序需要 %1$d Mb 的RAM,您的设备有 %2$d Mb</string>
|
||||
<string name="ignore">忽略</string>
|
||||
|
||||
<string name="calibrate_gyroscope">校准陀螺仪</string>
|
||||
<string name="calibrate_gyroscope_text">将您的设备放在水平表面上</string>
|
||||
<string name="calibrate_gyroscope_not_supported">您的设备没有陀螺仪</string>
|
||||
|
||||
<string name="reset_config">将所有配置重置为默认值</string>
|
||||
<string name="reset_config_ask">是否将所有选项重置为默认值?</string>
|
||||
|
||||
<string name="cancel_download">是否取消数据下载?</string>
|
||||
<string name="cancel_download_resume">您可以稍后恢复它,数据不会被下载两次。</string>
|
||||
<string name="yes">是</string>
|
||||
<string name="no">否</string>
|
||||
|
||||
<!-- Play Game Services strings -->
|
||||
<string name="gamehelper_sign_in_failed">无法登录,请检查您的网络连接,然后重试。</string>
|
||||
<string name="gamehelper_app_misconfigured">应用程序配置不正确。请检查包名和签名证书是否与开发者控制台中创建的客户端ID一致。此外,如果应用程序尚未发布,请检查您的帐户是否为测试人员帐户。详细信息,请参阅日志。</string>
|
||||
<string name="gamehelper_license_failed">许可证检查失败。</string>
|
||||
<string name="gamehelper_unknown_error">未知错误。</string>
|
||||
<string name="accessing_network">正在访问网络,请稍候</string>
|
||||
|
||||
<string name="restarting_please_wait">重新启动中,请稍候。</string>
|
||||
|
||||
<string name="notification_app_is_running">%s 正在运行中</string>
|
||||
<string name="notification_stop">停止</string>
|
||||
|
||||
</resources>
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<resources
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="MissingTranslation">
|
||||
<string name="app_name">Commander Genius</string>
|
||||
|
||||
|
||||
@@ -22,8 +24,9 @@
|
||||
<string name="storage_phone">Internal storage - %d MB free</string>
|
||||
<string name="storage_sd">SD card storage - %d MB free</string>
|
||||
<string name="storage_custom">Specify directory</string>
|
||||
<string name="storage_commandline">Specify command line parameters</string>
|
||||
<string name="storage_commandline">Command line parameters, one argument per line</string>
|
||||
<string name="storage_question">Data installation location</string>
|
||||
<string name="storage_access">Permission to write to SD card</string>
|
||||
<string name="optional_downloads">Downloads</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
<string name="ok">OK</string>
|
||||
@@ -98,16 +101,21 @@
|
||||
<string name="leftclick_timeout_time_4">1.5 sec</string>
|
||||
<string name="click_with_dpadcenter">Left mouse click with trackball / joystick center</string>
|
||||
|
||||
<string name="pointandclick_question">Advanced features</string>
|
||||
<string name="pointandclick_keepaspectratio">Keep 4:3 screen aspect ratio</string>
|
||||
<string name="pointandclick_showcreenunderfinger">Show screen under finger in separate window</string>
|
||||
<string name="pointandclick_showcreenunderfinger2">On-screen magnifying glass</string>
|
||||
<string name="pointandclick_joystickmouse">Move mouse with joystick or trackball</string>
|
||||
<string name="pointandclick_joystickmousespeed">Move mouse with joystick speed</string>
|
||||
<string name="pointandclick_joystickmouseaccel">Move mouse with joystick acceleration</string>
|
||||
<string name="pointandclick_relative">Relative mouse movement (laptop mode)</string>
|
||||
<string name="pointandclick_relative_speed">Relative mouse movement speed</string>
|
||||
<string name="pointandclick_relative_accel">Relative mouse movement acceleration</string>
|
||||
<string name="advanced">Advanced features</string>
|
||||
<string name="mouse_keepaspectratio">Keep 4:3 screen aspect ratio</string>
|
||||
<string name="mouse_showcreenunderfinger">Show screen under finger in separate window</string>
|
||||
<string name="mouse_showcreenunderfinger2">On-screen magnifying glass</string>
|
||||
<string name="mouse_joystickmouse">Move mouse with joystick or trackball</string>
|
||||
<string name="mouse_joystickmousespeed">Move mouse with joystick speed</string>
|
||||
<string name="mouse_joystickmouseaccel">Move mouse with joystick acceleration</string>
|
||||
<string name="mouse_relative">Relative mouse movement (laptop mode)</string>
|
||||
<string name="mouse_relative_speed">Relative mouse movement speed</string>
|
||||
<string name="mouse_relative_accel">Relative mouse movement acceleration</string>
|
||||
<string name="mouse_hover_jitter_filter">Filter jitter for stylus/finger hover</string>
|
||||
<string name="mouse_gyroscope_mouse">Control mouse with gyroscope</string>
|
||||
<string name="mouse_gyroscope_mouse_sensitivity">Gyroscope sensitivity</string>
|
||||
<string name="mouse_finger_hover">Finger hover</string>
|
||||
<string name="mouse_subframe_touch_events">Multiple touch events per video frame</string>
|
||||
|
||||
<string name="none">None</string>
|
||||
|
||||
@@ -140,18 +148,25 @@
|
||||
|
||||
<string name="screenkb_custom_layout">Customize on-screen keyboard layout</string>
|
||||
<string name="screenkb_custom_layout_help">Press BACK when done. Resize buttons by sliding on empty space.</string>
|
||||
<string name="screenkb_floating_joystick">Floating joystick</string>
|
||||
|
||||
<string name="calibrate_touchscreen">Calibrate touchscreen</string>
|
||||
<string name="calibrate_touchscreen_touch">Touch all edges of the screen, press BACK when done</string>
|
||||
|
||||
<string name="video">Video settings</string>
|
||||
<string name="video_smooth">Linear video filtering</string>
|
||||
<string name="video_separatethread">Separate thread for video, will increase FPS on some devices</string>
|
||||
<string name="video_separatethread">Separate thread for video, it can increase FPS, it also can crash the app</string>
|
||||
<string name="video_orientation_vertical">Portrait/vertical screen orientation</string>
|
||||
<string name="video_orientation_autodetect">Auto-detect screen orientation</string>
|
||||
<string name="video_bpp_24">24 bpp screen color depth</string>
|
||||
<string name="video_immersive">Hide system navigation buttons / immersive mode</string>
|
||||
<string name="tv_borders">TV borders</string>
|
||||
|
||||
<string name="text_edit_click_here">Tap to start typing, press Back when done</string>
|
||||
|
||||
<string name="display_size_mouse">Mouse emulation mode</string>
|
||||
<string name="display_size">Display size for mouse emulation</string>
|
||||
<string name="display_size_desktop">Desktop, no emulation</string>
|
||||
<string name="display_size_large">Large (tablets)</string>
|
||||
<string name="display_size_small">Small, magnifying glass</string>
|
||||
<string name="display_size_small_touchpad">Small, touchpad mode</string>
|
||||
@@ -178,4 +193,18 @@
|
||||
<string name="yes">Yes</string>
|
||||
<string name="no">No</string>
|
||||
|
||||
<!-- Play Game Services strings -->
|
||||
<string name="gamehelper_sign_in_failed">Failed to sign in. Please check your network connection and try again.</string>
|
||||
<string name="gamehelper_app_misconfigured">The application is incorrectly configured. Check that the package name and signing certificate match the client ID created in Developer Console. Also, if the application is not yet published, check that the account you are trying to sign in with is listed as a tester account. See logs for more information.</string>
|
||||
<string name="gamehelper_license_failed">License check failed.</string>
|
||||
<string name="gamehelper_unknown_error">Unknown error.</string>
|
||||
<string name="accessing_network">Accessing network, please wait</string>
|
||||
|
||||
<string name="google_play_game_services_app_id" translatable="false">==GOOGLEPLAYGAMESERVICES_APP_ID==</string>
|
||||
|
||||
<string name="restarting_please_wait">Restarting, please wait.</string>
|
||||
|
||||
<string name="notification_app_is_running">%s is running</string>
|
||||
<string name="notification_stop">Stop</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -7,9 +7,24 @@ endif
|
||||
NDK_VERSION := $(strip $(patsubst android-ndk-%,%,$(filter android-ndk-%, $(subst /, ,$(dir $(TARGET_CC))))))
|
||||
#$(info NDK version $(NDK_VERSION)) # This warning puzzles ndk-gdb
|
||||
ifneq ($(filter r1 r2 r3 r4 r5 r6 r7 r8,$(NDK_VERSION)),)
|
||||
$(error Your NDK $(NDK_VERSION) is too old, please download NDK r4b, r5c or r6 from http://developer.android.com)
|
||||
$(error Your NDK $(NDK_VERSION) is too old, please download NDK from http://developer.android.com)
|
||||
endif
|
||||
|
||||
NDK_PATH := $(shell dirname $(shell which ndk-build))
|
||||
|
||||
include $(call all-subdir-makefiles)
|
||||
NDK_SUBDIR_MAKEFILES_FULL := $(call all-subdir-makefiles)
|
||||
|
||||
# If you want to exclude certain subprojects from the build process.
|
||||
# v.g.: SDL2_image already brings it's own implementation of png, so we exclude the bundled one
|
||||
ifeq ($(SDL_VERSION),2.0)
|
||||
BLACKLISTED_SUBPROJECTS := jpeg png ogg mpg123 timidity fluidsynth faad openal sdl_blitpool sdl_gfx sdl_image sdl_main sdl_mixer sdl_net sdl_sound sdl_ttf zzip freetype
|
||||
else
|
||||
BLACKLISTED_SUBPROJECTS := sdl2_image
|
||||
endif
|
||||
|
||||
BLACKLISTED_MAKEFILES := $(addprefix jni/../jni/,$(BLACKLISTED_SUBPROJECTS))
|
||||
BLACKLISTED_MAKEFILES := $(addsuffix /Android.mk,$(BLACKLISTED_MAKEFILES))
|
||||
|
||||
NDK_SUBDIR_MAKEFILES := $(filter-out $(BLACKLISTED_MAKEFILES), $(NDK_SUBDIR_MAKEFILES_FULL))
|
||||
|
||||
include $(NDK_SUBDIR_MAKEFILES)
|
||||
|
||||
@@ -2,6 +2,16 @@ APP_PROJECT_PATH := $(call my-dir)/..
|
||||
|
||||
include jni/Settings.mk
|
||||
|
||||
APP_STL := $(if $(filter clang%, $(NDK_TOOLCHAIN_VERSION)), c++_static, gnustl_static)
|
||||
APP_CFLAGS := -O3 -DNDEBUG -g # arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources
|
||||
ifneq ($(filter c++_shared, $(APP_MODULES)),)
|
||||
APP_STL := c++_shared
|
||||
else
|
||||
APP_STL := none
|
||||
endif
|
||||
APP_CFLAGS := -g
|
||||
ifneq ($(NDK_DEBUG),1)
|
||||
APP_CFLAGS += -Oz -DNDEBUG # -Oz works best with clang
|
||||
endif
|
||||
APP_PIE := true # This feature makes executables incompatible to Android API 15 or lower, but executables without PIE will not run on Android 5.0 and newer
|
||||
SDL_EXCLUDE_LIBGCC := -Wl,--exclude-libs,libgcc.a
|
||||
SDL_EXCLUDE_LIBUNWIND := -Wl,--exclude-libs,libunwind.a
|
||||
APP_LDFLAGS = $(if $(filter clang%, $(NDK_TOOLCHAIN_VERSION)), $(SDL_EXCLUDE_LIBGCC) $(if $(filter armeabi%, $(APP_ABI)), $(SDL_EXCLUDE_LIBUNWIND)))
|
||||
|
||||
@@ -1,39 +1,100 @@
|
||||
# Makefile to build precompiled libraries, which cannot be built using standard NDK makefiles
|
||||
# TODO: libboost, libffmpeg, libpython (used only in GemRB)
|
||||
|
||||
ARCHES32 := armeabi armeabi-v7a x86 mips
|
||||
ARCHES64 := arm64-v8a
|
||||
ARCHES32 := armeabi-v7a x86
|
||||
ARCHES64 := arm64-v8a x86_64
|
||||
|
||||
ICONV := $(foreach ARCH, $(ARCHES32), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
|
||||
ICONV := $(foreach ARCH, $(ARCHES32) $(ARCHES64), iconv/lib/$(ARCH)/libiconv.so iconv/lib/$(ARCH)/libcharset.so)
|
||||
|
||||
ICU_LIBS := data i18n io le lx test tu uc
|
||||
ICU := $(foreach ARCH, $(ARCHES32), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/libicu$(NAME).a))
|
||||
ICU_LIBS := icudata icui18n icuio icutest icutu icuuc iculx icu-le-hb harfbuzz
|
||||
ICU := $(foreach ARCH, $(ARCHES32) $(ARCHES64), $(foreach NAME, $(ICU_LIBS), icuuc/lib/$(ARCH)/lib$(NAME).a))
|
||||
|
||||
OPENSSL := $(foreach ARCH, $(ARCHES32) $(ARCHES64), openssl/lib-$(ARCH)/libcrypto.so.sdl.1.so openssl/lib-$(ARCH)/libssl.so.sdl.1.so)
|
||||
|
||||
PYTHON3 := $(foreach ARCH, $(ARCHES32) $(ARCHES64), python3/lib-$(ARCH)/libcrypto.so.sdl.1.so python3/lib-$(ARCH)/libssl.so.sdl.1.so)
|
||||
LIBS := $(ICONV) $(ICU) $(OPENSSL)
|
||||
|
||||
LIBS := $(ICONV) $(ICU) $(OPENSSL) $(PYTHON3)
|
||||
.PHONY: all boost openssl icu
|
||||
all: $(LIBS)
|
||||
|
||||
prebuilt-libraries: $(LIBS)
|
||||
openssl: $(OPENSSL)
|
||||
|
||||
.NOTPARALLEL: $(LIBS)
|
||||
icu: $(ICONV) $(ICU)
|
||||
|
||||
$(ICONV) $(ICU):
|
||||
#.NOTPARALLEL: $(LIBS) $(BOOST)
|
||||
|
||||
$(ICONV) $(ICU): iconv/src/build.sh
|
||||
cd iconv/src && \
|
||||
./build.sh && \
|
||||
for ARCH in $(ARCHES32); do \
|
||||
mkdir -p ../lib/$$ARCH ; \
|
||||
for ARCH in $(ARCHES32) $(ARCHES64); do \
|
||||
mkdir -p ../lib/$$ARCH ../include ; \
|
||||
cp -f $$ARCH/libiconv.so $$ARCH/libcharset.so ../lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/*.h ../include/ ; \
|
||||
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/layout ../../icuuc/include/unicode ; \
|
||||
cp -f $$ARCH/libicu*.a ../../icuuc/lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
mkdir -p ../../icuuc/lib/$$ARCH ../../icuuc/include/unicode ../../icuuc/include/layout ; \
|
||||
cp -f $$ARCH/libicu*.a $$ARCH/libharfbuzz.a ../../icuuc/lib/$$ARCH/ ; \
|
||||
cp -f $$ARCH/include/unicode/*.h ../../icuuc/include/unicode/ ; \
|
||||
done
|
||||
cp -f $$ARCH/include/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
cp -f $$ARCH/include/icu-le-hb/layout/*.h ../../icuuc/include/layout/ ; \
|
||||
done && \
|
||||
git clean -f -d -x
|
||||
|
||||
$(OPENSSL):
|
||||
$(OPENSSL): openssl/compile.sh
|
||||
cd openssl && ./compile.sh
|
||||
|
||||
$(PYTHON3):
|
||||
cd python3 && ./compile.sh
|
||||
BOOST_LIBS := \
|
||||
atomic \
|
||||
chrono \
|
||||
container \
|
||||
context \
|
||||
contract \
|
||||
coroutine \
|
||||
date_time \
|
||||
exception \
|
||||
fiber \
|
||||
filesystem \
|
||||
graph \
|
||||
iostreams \
|
||||
locale \
|
||||
log \
|
||||
log_setup \
|
||||
math_c99 \
|
||||
math_c99f \
|
||||
math_c99l \
|
||||
math_tr1 \
|
||||
math_tr1f \
|
||||
math_tr1l \
|
||||
prg_exec_monitor \
|
||||
program_options \
|
||||
random \
|
||||
regex \
|
||||
serialization \
|
||||
stacktrace_basic \
|
||||
stacktrace_noop \
|
||||
system \
|
||||
test_exec_monitor \
|
||||
thread \
|
||||
timer \
|
||||
type_erasure \
|
||||
unit_test_framework \
|
||||
wave \
|
||||
wserialization \
|
||||
|
||||
|
||||
BOOST := $(foreach ARCH, $(ARCHES32) $(ARCHES64), $(foreach NAME, $(BOOST_LIBS), boost/lib/$(ARCH)/libboost_$(NAME).a))
|
||||
|
||||
$(BOOST): boost/src/build-android.sh
|
||||
rm -rf boost/include boost/lib ; \
|
||||
cd boost/src && \
|
||||
./build-android.sh --boost=1.69.0 --with-iconv --arch=$(shell echo $(foreach ARCH, $(ARCHES32) $(ARCHES64),$(ARCH),) | tr -d ' ') && \
|
||||
for ARCH in $(ARCHES32) $(ARCHES64); do \
|
||||
mkdir -p ../lib/$$ARCH ../include ; \
|
||||
$(foreach NAME, $(BOOST_LIBS), cp -f build/out/$$ARCH/lib/libboost_$(NAME)-clang-mt-*.a ../lib/$$ARCH/libboost_$(NAME).a || exit 1 ;) \
|
||||
cp -r -f build/out/$$ARCH/include/boost-*/* ../include/ || exit 1 ; \
|
||||
done || exit 1 ; \
|
||||
git clean -f -d -x ; \
|
||||
$(foreach NAME, $(BOOST_LIBS), ln -sf boost ../../boost_$(NAME) ;)
|
||||
|
||||
boost: $(BOOST)
|
||||
|
||||
iconv/src/build.sh boost/src/build-android.sh:
|
||||
git submodule update --init --recursive
|
||||
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
|
||||
# To filter out static libs from all libs in makefile
|
||||
APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng android_support gl4es nanogl
|
||||
APP_AVAILABLE_STATIC_LIBS := jpeg png freetype fontconfig xerces ogg vorbis flac \
|
||||
boost_atomic boost_chrono boost_container boost_context boost_coroutine boost_date_time boost_exception boost_filesystem \
|
||||
boost_graph boost_iostreams boost_locale boost_log boost_log_setup boost_prg_exec_monitor boost_program_options boost_random \
|
||||
boost_regex boost_serialization boost_signals boost_stacktrace_basic boost_stacktrace_noop \
|
||||
boost_system boost_test_exec_monitor boost_thread boost_timer boost_type_erasure boost_unit_test_framework boost_wave boost_wserialization \
|
||||
glu icudata icutest icui18n icuio icule iculx icutu icuuc icu-le-hb harfbuzz sdl_savepng android_support \
|
||||
gl4es nanogl gd guichan
|
||||
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg
|
||||
|
||||
ifeq ($(APP_ABI),)
|
||||
APP_ABI := armeabi
|
||||
APP_ABI := armeabi-v7a
|
||||
endif
|
||||
|
||||
# The namespace in Java file, with dots replaced with underscores
|
||||
@@ -54,11 +60,6 @@ SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=UNKNOWN -DSDL_ANDROID_KEYCO
|
||||
|
||||
SDL_VERSION := 1.2
|
||||
|
||||
# Link-time optimization enabled for optimization junkies. -O999 etc
|
||||
#APP_CFLAGS := -flto
|
||||
#APP_CXXFLAGS := -flto
|
||||
#APP_LDFLAGS := -flto
|
||||
# Latest GCC got better LTO support
|
||||
NDK_TOOLCHAIN_VERSION := clang
|
||||
|
||||
APP_PLATFORM := android-18
|
||||
APP_PLATFORM := android-16
|
||||
|
||||
@@ -45,13 +45,16 @@ ifneq ($(APPLICATION_CUSTOM_BUILD_SCRIPT),)
|
||||
LOCAL_SRC_FILES := dummy.c
|
||||
endif
|
||||
|
||||
ifeq ($(SDL_VERSION),2.0)
|
||||
LOCAL_SHARED_LIBRARIES := SDL2 $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
else
|
||||
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION) $(filter-out $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
endif
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBRARIES))
|
||||
|
||||
APP_STL := gnustl_static
|
||||
|
||||
LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz # -lgnustl_static
|
||||
LOCAL_LDLIBS := $(APPLICATION_GLES_LIBRARY) -ldl -llog -lz
|
||||
|
||||
LOCAL_LDFLAGS := -Lobj/local/$(TARGET_ARCH_ABI)
|
||||
|
||||
@@ -67,6 +70,7 @@ SDL_APP_LIB_DEPENDS-$(TARGET_ARCH_ABI) += $(foreach LIB, $(LOCAL_STATIC_LIBRARIE
|
||||
obj/local/$(TARGET_ARCH_ABI)/libcrypto.so: obj/local/$(TARGET_ARCH_ABI)/libcrypto.so.sdl.0.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libssl.so: obj/local/$(TARGET_ARCH_ABI)/libssl.so.sdl.0.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libcurl.so: obj/local/$(TARGET_ARCH_ABI)/libcurl-sdl.so
|
||||
obj/local/$(TARGET_ARCH_ABI)/libexpat.so: obj/local/$(TARGET_ARCH_ABI)/libexpat-sdl.so
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -87,31 +91,12 @@ LOCAL_PATH_SDL_APPLICATION := $(LOCAL_PATH)
|
||||
|
||||
$(shell cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_UNLOCK))
|
||||
|
||||
obj/local/armeabi/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi.so: $(SDL_APP_LIB_DEPENDS-armeabi) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh armeabi arm-linux-androideabi && $(PARALLEL_UNLOCK) && \
|
||||
{ [ -e libapplication.so ] && ln -s libapplication.so libapplication-armeabi.so || true ; }
|
||||
|
||||
obj/local/armeabi-v7a/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi-v7a.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi-v7a.so: $(SDL_APP_LIB_DEPENDS-armeabi-v7a) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh armeabi-v7a arm-linux-androideabi && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/armeabi-v7a-hard/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi-v7a-hard.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi-v7a-hard.so: $(SDL_APP_LIB_DEPENDS-armeabi-v7a-hard) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh armeabi-v7a-hard arm-linux-androideabi && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/mips/libapplication.so: $(LOCAL_PATH)/src/libapplication-mips.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-mips.so: $(SDL_APP_LIB_DEPENDS-mips) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && $(PARALLEL_LOCK) && \
|
||||
./AndroidBuild.sh mips mipsel-linux-android && $(PARALLEL_UNLOCK)
|
||||
|
||||
obj/local/x86/libapplication.so: $(LOCAL_PATH)/src/libapplication-x86.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-x86.so: $(SDL_APP_LIB_DEPENDS-x86) OVERRIDE_CUSTOM_LIB
|
||||
|
||||
@@ -13,11 +13,13 @@ AppVersionCode=101
|
||||
AppVersionName="1.01"
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version, first associated with the file
|
||||
# If the URL does not contain 'http://' or 'https://', it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by the build system
|
||||
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for obb file
|
||||
# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries
|
||||
# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip
|
||||
AppDataDownloadUrl="!!Game data is 1 Mb|ballfield3.zip"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
@@ -46,12 +48,16 @@ NeedDepthBuffer=n
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# Use GLES 2.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Use glshim library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
|
||||
UseGlshim=
|
||||
# Use GLES 3.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles3=n
|
||||
|
||||
# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
|
||||
UseGl4es=
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
@@ -64,10 +70,10 @@ SdlVideoResize=y
|
||||
SdlVideoResizeKeepAspect=n
|
||||
|
||||
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=n
|
||||
InhibitSuspend=y
|
||||
|
||||
# Create Android service, so the app is less likely to be killed while in background
|
||||
CreateService=y
|
||||
CreateService=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
@@ -75,7 +81,7 @@ CompatibilityHacksForceScreenUpdate=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() after mouse click (ScummVM and all Amiga emulators do that) -
|
||||
# force screen update by moving mouse cursor a little after each click (y) or (n)
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=y
|
||||
CompatibilityHacksForceScreenUpdateMouseClick=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
@@ -119,13 +125,13 @@ AppNeedsTwoButtonMouse=y
|
||||
|
||||
# Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n)
|
||||
# If you disable it, swiping with two fingers will send mouse wheel events
|
||||
RightMouseButtonLongPress=
|
||||
RightMouseButtonLongPress=n
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Screen follows mouse cursor, when it's covered by soft keyboard, this works only in software video mode (y) or (n)
|
||||
ScreenFollowsMouse=
|
||||
ScreenFollowsMouse=n
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=n
|
||||
@@ -145,7 +151,7 @@ AppNeedsTextInput=y
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
# This will disable AppNeedsArrowKeys option
|
||||
AppUsesJoystick=n
|
||||
AppUsesJoystick=y
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=n
|
||||
@@ -163,7 +169,7 @@ AppUsesGyroscope=y
|
||||
AppUsesOrientationSensor=
|
||||
|
||||
# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting
|
||||
MoveMouseWithGyroscope=
|
||||
MoveMouseWithGyroscope=n
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=y
|
||||
@@ -173,8 +179,11 @@ AppUsesMultitouch=y
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application needs to access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)
|
||||
AccessSdCard=y
|
||||
# Application needs read/write access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)
|
||||
AccessSdCard=n
|
||||
|
||||
# Application needs to read it's own OBB file. Enable this if you are using Play Store expansion files. (y) / (n)
|
||||
ReadObbFile=
|
||||
|
||||
# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)
|
||||
AccessInternet=
|
||||
@@ -182,6 +191,9 @@ AccessInternet=
|
||||
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
|
||||
ImmersiveMode=y
|
||||
|
||||
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
|
||||
HideSystemMousePointer=
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
@@ -215,24 +227,33 @@ RedefinedKeysScreenKbNames="0 1 2 3 4 5 6 7 8 9"
|
||||
# 7 = SuperNintendo from RetroArch
|
||||
# 8 = DualShock from RetroArch
|
||||
# 9 = Nintendo64 from RetroArch
|
||||
TouchscreenKeysTheme=4
|
||||
TouchscreenKeysTheme=1
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
RedefinedKeysGamepad="0 1 2 3 4 5 6 7 8 9"
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight
|
||||
RedefinedKeysGamepad="0 1 2 3 4 5 6 7 8 9 j k UP DOWN LEFT RIGHT PAGEUP PAGEDOWN HOME END PLUS MINUS LEFTBRACKET RIGHTBRACKET"
|
||||
|
||||
# Redefine keys for the second gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysSecondGamepad="q w e r t y u i o p a s d f g h z x c v b n m COMMA"
|
||||
|
||||
# Redefine keys for the third gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysThirdGamepad="F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15 PRINT"
|
||||
|
||||
# Redefine keys for the fourth gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysFourthGamepad="KP0 KP1 KP2 KP3 KP4 KP5 KP6 KP7 KP8 KP9 KP_PERIOD KP_DIVIDE KP_MULTIPLY KP_MINUS KP_PLUS KP_ENTER"
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=3000
|
||||
StartupMenuButtonTimeout=1000
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.StorageAccessConfig SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
HiddenMenuOptions=''
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
FirstStartMenuOptions='SettingsMenu.DummyMenu'
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.StorageAccessConfig SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
FirstStartMenuOptions=''
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
@@ -240,20 +261,26 @@ AppMinimumRAM=0
|
||||
# GCC version, or 'clang' for CLANG
|
||||
NDK_TOOLCHAIN_VERSION=clang
|
||||
|
||||
# Android platform version.
|
||||
# android-16 = Android 4.1, the earliest supported version in NDK r18.
|
||||
# android-18 = Android 4.3, the first version supporting GLES3.
|
||||
# android-21 = Android 5.1, the first version with SO_REUSEPORT defined.
|
||||
APP_PLATFORM=
|
||||
|
||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||
# Available architectures: armeabi armeabi-v7a x86 mips arm64-v8a
|
||||
MultiABI='armeabi-v7a x86 arm64-v8a'
|
||||
# Available architectures: armeabi-v7a arm64-v8a x86 x86_64
|
||||
MultiABI='arm64-v8a'
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# MP3 patents are expired, but libmad license is GPL, not LGPL
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="sdl_image"
|
||||
CompiledLibraries="sdl_image c++_shared"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=n
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags='-O2 -finline-functions'
|
||||
AppCflags=''
|
||||
|
||||
# Aditional C++-specific compiler flags for application, added after AppCflags
|
||||
AppCppflags=''
|
||||
@@ -271,7 +298,7 @@ AppSubdirsBuild=''
|
||||
AppBuildExclude=''
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline=''
|
||||
AppCmdline='ballfield'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
@@ -289,3 +316,6 @@ AdmobBannerSize=
|
||||
# Google Play Game Services application ID, required for cloud saves to work
|
||||
GooglePlayGameServicesId=
|
||||
|
||||
# The app will open files with following extension, file path will be added to commandline params
|
||||
AppOpenFileExtension='png PNG jpg JPG jpeg JPEG gif GIF'
|
||||
|
||||
|
||||
796
project/jni/application/ballfield/ballfield.c
Normal file
796
project/jni/application/ballfield/ballfield.c
Normal file
@@ -0,0 +1,796 @@
|
||||
/*
|
||||
* "Ballfield"
|
||||
*
|
||||
* (C) David Olofson <david@olofson.net>, 2002, 2003
|
||||
*
|
||||
* This software is released under the terms of the GPL.
|
||||
*
|
||||
* Contact author for permission if you want to use this
|
||||
* software, or work derived from it, under other terms.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <android/log.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <SDL/SDL_screenkeyboard.h>
|
||||
#include <SDL/SDL_android.h>
|
||||
|
||||
#define fprintf(X, ...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__)
|
||||
#define printf(...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__)
|
||||
|
||||
extern int create_server_socket(int portno);
|
||||
|
||||
|
||||
/*----------------------------------------------------------
|
||||
Definitions...
|
||||
----------------------------------------------------------*/
|
||||
|
||||
#define SCREEN_W 640
|
||||
#define SCREEN_H 540
|
||||
|
||||
|
||||
#define BALLS 300
|
||||
|
||||
#define COLORS 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Sint32 x, y, z; /* Position */
|
||||
Uint32 c; /* Color */
|
||||
} point_t;
|
||||
|
||||
|
||||
/*
|
||||
* Ballfield
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
point_t points[BALLS];
|
||||
SDL_Rect *frames;
|
||||
SDL_Surface *gfx[COLORS];
|
||||
int use_alpha;
|
||||
} ballfield_t;
|
||||
|
||||
|
||||
/*
|
||||
* Size of the biggest ball image in pixels
|
||||
*
|
||||
* Balls are scaled down and *packed*, one pixel
|
||||
* smaller for each frame down to 1x1. The actual
|
||||
* image width is (obviously...) the same as the
|
||||
* width of the first frame.
|
||||
*/
|
||||
#define BALL_W 32
|
||||
#define BALL_H 32
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------
|
||||
General tool functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Bump areas of low and high alpha to 0% or 100%
|
||||
* respectively, just in case the graphics contains
|
||||
* "alpha noise".
|
||||
*/
|
||||
SDL_Surface *clean_alpha(SDL_Surface *s)
|
||||
{
|
||||
SDL_Surface *work;
|
||||
SDL_Rect r;
|
||||
Uint32 *pixels;
|
||||
int pp;
|
||||
int x, y;
|
||||
|
||||
work = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h,
|
||||
32, 0xff000000, 0x00ff0000, 0x0000ff00,
|
||||
0x000000ff);
|
||||
if(!work)
|
||||
return NULL;
|
||||
|
||||
r.x = r.y = 0;
|
||||
r.w = s->w;
|
||||
r.h = s->h;
|
||||
if(SDL_BlitSurface(s, &r, work, NULL) < 0)
|
||||
{
|
||||
SDL_FreeSurface(work);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_LockSurface(work);
|
||||
pixels = (Uint32 *)work->pixels;
|
||||
pp = work->pitch / sizeof(Uint32);
|
||||
for(y = 0; y < work->h; ++y)
|
||||
for(x = 0; x < work->w; ++x)
|
||||
{
|
||||
Uint32 pix = pixels[y*pp + x];
|
||||
switch((pix & 0xff) >> 4)
|
||||
{
|
||||
case 0:
|
||||
pix = 0x00000000;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 15:
|
||||
pix |= 0xff;
|
||||
break;
|
||||
}
|
||||
pixels[y*pp + x] = pix;
|
||||
}
|
||||
SDL_UnlockSurface(work);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load and convert an antialiazed, zoomed set of sprites.
|
||||
*/
|
||||
SDL_Surface *load_zoomed(const char *name, int alpha)
|
||||
{
|
||||
SDL_Surface *sprites;
|
||||
SDL_Surface *temp = IMG_Load(name);
|
||||
if(!temp)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
sprites = temp;
|
||||
SDL_SetAlpha(sprites, 0, 255);
|
||||
temp = clean_alpha(sprites);
|
||||
SDL_FreeSurface(sprites);
|
||||
*/
|
||||
if(!temp)
|
||||
{
|
||||
fprintf(stderr, "Could not clean alpha!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(alpha)
|
||||
{
|
||||
SDL_SetAlpha(temp, 0, SDL_ALPHA_OPAQUE);
|
||||
sprites = SDL_DisplayFormatAlpha(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp->format, 0, 0, 0));
|
||||
sprites = SDL_DisplayFormat(temp);
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
return sprites;
|
||||
}
|
||||
|
||||
|
||||
void print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, float value)
|
||||
{
|
||||
char buf[16];
|
||||
int val = (int)(value * 10.0);
|
||||
int pos, p = 0;
|
||||
SDL_Rect from;
|
||||
|
||||
/* Sign */
|
||||
if(val < 0)
|
||||
{
|
||||
buf[p++] = 10;
|
||||
val = -val;
|
||||
}
|
||||
|
||||
/* Integer part */
|
||||
pos = 10000000;
|
||||
while(pos > 1)
|
||||
{
|
||||
int num = val / pos;
|
||||
val -= num * pos;
|
||||
pos /= 10;
|
||||
if(p || num)
|
||||
buf[p++] = num;
|
||||
}
|
||||
|
||||
/* Decimals */
|
||||
if(val / pos)
|
||||
{
|
||||
buf[p++] = 11;
|
||||
while(pos > 0)
|
||||
{
|
||||
int num = val / pos;
|
||||
val -= num * pos;
|
||||
pos /= 10;
|
||||
buf[p++] = num;
|
||||
}
|
||||
}
|
||||
|
||||
/* Render! */
|
||||
from.y = 0;
|
||||
from.w = 7;
|
||||
from.h = 10;
|
||||
for(pos = 0; pos < p; ++pos)
|
||||
{
|
||||
SDL_Rect to;
|
||||
to.x = x + pos * 7;
|
||||
to.y = y;
|
||||
from.x = buf[pos] * 7;
|
||||
SDL_BlitSurface(font, &from, dst, &to);
|
||||
}
|
||||
}
|
||||
|
||||
void print_num_hex(SDL_Surface *dst, SDL_Surface *font, int x, int y, unsigned val)
|
||||
{
|
||||
char buf[8];
|
||||
int pos, p = 0;
|
||||
SDL_Rect from;
|
||||
|
||||
//val = htonl(val); // Big-endian
|
||||
|
||||
/* Render! */
|
||||
from.y = 0;
|
||||
from.w = 7;
|
||||
from.h = 10;
|
||||
for(pos = 0; pos < 8; ++pos)
|
||||
{
|
||||
SDL_Rect to;
|
||||
to.x = 8 * 7 - (x + pos * 7); // Little-endian number wrapped backwards
|
||||
to.y = y;
|
||||
from.x = ( ( val >> (pos * 4) ) & 0xf ) * 7;
|
||||
SDL_BlitSurface(font, &from, dst, &to);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
ballfield_t functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
ballfield_t *ballfield_init(void)
|
||||
{
|
||||
int i;
|
||||
ballfield_t *bf = (ballfield_t *)calloc(sizeof(ballfield_t), 1);
|
||||
if(!bf)
|
||||
return NULL;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
bf->points[i].x = rand() % 0x20000;
|
||||
bf->points[i].y = rand() % 0x20000;
|
||||
bf->points[i].z = 0x20000 * i / BALLS;
|
||||
if(rand() % 100 > 80)
|
||||
bf->points[i].c = 1;
|
||||
else
|
||||
bf->points[i].c = 0;
|
||||
}
|
||||
return bf;
|
||||
}
|
||||
|
||||
|
||||
void ballfield_free(ballfield_t *bf)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < COLORS; ++i)
|
||||
SDL_FreeSurface(bf->gfx[i]);
|
||||
}
|
||||
|
||||
|
||||
static int ballfield_init_frames(ballfield_t *bf)
|
||||
{
|
||||
int i, j;
|
||||
/*
|
||||
* Set up source rects for all frames
|
||||
*/
|
||||
bf->frames = (SDL_Rect *)calloc(sizeof(SDL_Rect), bf->gfx[0]->w);
|
||||
if(!bf->frames)
|
||||
{
|
||||
fprintf(stderr, "No memory for frame rects!\n");
|
||||
return -1;
|
||||
}
|
||||
for(j = 0, i = 0; i < bf->gfx[0]->w; ++i)
|
||||
{
|
||||
bf->frames[i].x = 0;
|
||||
bf->frames[i].y = j;
|
||||
bf->frames[i].w = bf->gfx[0]->w - i;
|
||||
bf->frames[i].h = bf->gfx[0]->w - i;
|
||||
j += bf->gfx[0]->w - i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ballfield_load_gfx(ballfield_t *bf, const char *name, unsigned int color)
|
||||
{
|
||||
if(color >= COLORS)
|
||||
return -1;
|
||||
|
||||
bf->gfx[color] = load_zoomed(name, bf->use_alpha);
|
||||
if(!bf->gfx[color])
|
||||
return -2;
|
||||
|
||||
if(!bf->frames)
|
||||
return ballfield_init_frames(bf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ballfield_move(ballfield_t *bf, Sint32 dx, Sint32 dy, Sint32 dz)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
bf->points[i].x += dx;
|
||||
bf->points[i].x &= 0x1ffff;
|
||||
bf->points[i].y += dy;
|
||||
bf->points[i].y &= 0x1ffff;
|
||||
bf->points[i].z += dz;
|
||||
bf->points[i].z &= 0x1ffff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ballfield_render(ballfield_t *bf, SDL_Surface *screen)
|
||||
{
|
||||
int i, j, z;
|
||||
|
||||
/*
|
||||
* Find the ball with the highest Z.
|
||||
*/
|
||||
z = 0;
|
||||
j = 0;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
if(bf->points[i].z > z)
|
||||
{
|
||||
j = i;
|
||||
z = bf->points[i].z;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Render all balls in back->front order.
|
||||
*/
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
SDL_Rect r;
|
||||
int f;
|
||||
z = bf->points[j].z;
|
||||
z += 50;
|
||||
f = ((bf->frames[0].w << 12) + 100000) / z;
|
||||
f = bf->frames[0].w - f;
|
||||
if(f < 0)
|
||||
f = 0;
|
||||
else if(f > bf->frames[0].w - 1)
|
||||
f = bf->frames[0].w - 1;
|
||||
z >>= 7;
|
||||
z += 1;
|
||||
r.x = (bf->points[j].x - 0x10000) / z;
|
||||
r.y = (bf->points[j].y - 0x10000) / z;
|
||||
r.x += (screen->w - bf->frames[f].w) >> 1;
|
||||
r.y += (screen->h - bf->frames[f].h) >> 1;
|
||||
SDL_BlitSurface(bf->gfx[bf->points[j].c],
|
||||
&bf->frames[f], screen, &r);
|
||||
if(--j < 0)
|
||||
j = BALLS - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------
|
||||
Other rendering functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Draw tiled background image with offset.
|
||||
*/
|
||||
void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
|
||||
{
|
||||
/*
|
||||
int x, y;
|
||||
SDL_Rect r;
|
||||
if(xo < 0)
|
||||
xo += back->w*(-xo/back->w + 1);
|
||||
if(yo < 0)
|
||||
yo += back->h*(-yo/back->h + 1);
|
||||
xo %= back->w;
|
||||
yo %= back->h;
|
||||
for(y = -yo; y < screen->h; y += back->h)
|
||||
for(x = -xo; x < screen->w; x += back->w)
|
||||
{
|
||||
r.x = x;
|
||||
r.y = y;
|
||||
SDL_BlitSurface(back, NULL, screen, &r);
|
||||
}
|
||||
*/
|
||||
SDL_Rect r;
|
||||
xo %= back->w/8;
|
||||
yo %= back->h/8;
|
||||
r.x = xo - back->w/2 + screen->w/2;
|
||||
r.y = yo - back->h/2 + screen->h/2;
|
||||
r.w = back->w;
|
||||
r.h = back->h;
|
||||
SDL_BlitSurface(back, NULL, screen, &r);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
main()
|
||||
----------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ballfield_t *balls;
|
||||
SDL_Surface *screen;
|
||||
SDL_Surface *temp_image;
|
||||
SDL_Surface *back, *logo, *font, *font_hex;
|
||||
SDL_Event event;
|
||||
int bpp = 16,
|
||||
flags = SDL_HWSURFACE,
|
||||
alpha = 1;
|
||||
int x_offs = 0, y_offs = 0;
|
||||
long tick,
|
||||
last_tick,
|
||||
last_avg_tick;
|
||||
double t = 0;
|
||||
float dt;
|
||||
int i;
|
||||
float fps = 0.0;
|
||||
int fps_count = 0;
|
||||
int fps_start = 0;
|
||||
float x_speed, y_speed, z_speed;
|
||||
enum { MAX_POINTERS = 16 };
|
||||
// some random colors
|
||||
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
|
||||
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
|
||||
int accel[5], screenjoy[4], gamepads[4][8];
|
||||
SDL_Surface *mouse[4];
|
||||
int screenKeyboardShown = 0;
|
||||
char asyncTextInputBuf[256];
|
||||
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
SDL_Joystick * joysticks[6];
|
||||
for( i = 0; i < 6; i++ )
|
||||
joysticks[i] = SDL_JoystickOpen(i);
|
||||
|
||||
atexit(SDL_Quit);
|
||||
|
||||
screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, bpp, flags);
|
||||
if(!screen)
|
||||
{
|
||||
fprintf(stderr, "Failed to open screen!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("Ballfield", "Ballfield");
|
||||
if(flags & SDL_FULLSCREEN)
|
||||
SDL_ShowCursor(0);
|
||||
|
||||
balls = ballfield_init();
|
||||
if(!balls)
|
||||
{
|
||||
fprintf(stderr, "Failed to create ballfield!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load and prepare balls...
|
||||
*/
|
||||
balls->use_alpha = alpha;
|
||||
if( ballfield_load_gfx(balls, "blueball.png", 0)
|
||||
||
|
||||
ballfield_load_gfx(balls, "redball.png", 1) )
|
||||
{
|
||||
fprintf(stderr, "Could not load balls!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load background image
|
||||
*/
|
||||
temp_image = IMG_Load(argc > 1 ? argv[1] : "sun.gif");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load background!\n");
|
||||
exit(-1);
|
||||
}
|
||||
back = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
/*
|
||||
* Load logo
|
||||
*/
|
||||
temp_image = SDL_LoadBMP("logo.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load logo!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
logo = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
/*
|
||||
* Load font
|
||||
*/
|
||||
temp_image = SDL_LoadBMP("font7x10.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load font!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
font = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
temp_image = SDL_LoadBMP("font7x10-hex.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load hex font!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
font_hex = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
char name[32];
|
||||
sprintf(name, "mouse%d.png", i);
|
||||
temp_image = IMG_Load(name);
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load %s!\n", name);
|
||||
exit(-1);
|
||||
}
|
||||
//mouse[i] = SDL_DisplayFormat(temp_image);
|
||||
//SDL_FreeSurface(temp_image);
|
||||
mouse[i] = temp_image; // Keep alpha
|
||||
}
|
||||
|
||||
last_avg_tick = last_tick = SDL_GetTicks();
|
||||
|
||||
memset(touchPointers, 0, sizeof(touchPointers));
|
||||
memset(accel, 0, sizeof(accel));
|
||||
memset(screenjoy, 0, sizeof(screenjoy));
|
||||
memset(gamepads, 0, sizeof(gamepads));
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "sizeof(int) %d long %d long long %d size_t %d", sizeof(int), sizeof(long), sizeof(long long), sizeof(size_t));
|
||||
/*
|
||||
wchar_t ss[256];
|
||||
const wchar_t *ss2 = L"String 2 ЕНГ ---";
|
||||
swprintf(ss, 256, L"String ЙЦУК --- %ls", ss2);
|
||||
char ss3[512] = "";
|
||||
char ss4[512] = "";
|
||||
for(i = 0; i < wcslen(ss); i++)
|
||||
{
|
||||
char tmp[16];
|
||||
sprintf(tmp, "%04X ", (int)ss[i]);
|
||||
strcat(ss3, tmp);
|
||||
sprintf(ss4, "%ls", ss);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "swprintf: len %d data %s: %s", wcslen(ss), ss3, ss4);
|
||||
*/
|
||||
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "On-screen buttons:");
|
||||
for(i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++)
|
||||
{
|
||||
SDL_Rect r;
|
||||
SDL_ANDROID_GetScreenKeyboardButtonPos(i, &r);
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "{ %d, %d, %d, %d },", r.x, r.y, r.x+r.h, r.y+r.w);
|
||||
}
|
||||
//SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, 1);
|
||||
//SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, 1);
|
||||
|
||||
while(1)
|
||||
{
|
||||
SDL_Rect r;
|
||||
|
||||
/* Timing */
|
||||
tick = SDL_GetTicks();
|
||||
dt = (tick - last_tick) * 0.001f;
|
||||
last_tick = tick;
|
||||
|
||||
if( bpp == 32 )
|
||||
SDL_FillRect(screen, NULL, 0); // Clear alpha channel
|
||||
|
||||
/* Background image */
|
||||
tiled_back(back, screen, x_offs>>11, y_offs>>11);
|
||||
|
||||
/* Ballfield */
|
||||
ballfield_render(balls, screen);
|
||||
|
||||
/* Logo */
|
||||
r.x = 2;
|
||||
r.y = 2;
|
||||
SDL_BlitSurface(logo, NULL, screen, &r);
|
||||
|
||||
/* FPS counter */
|
||||
if(tick > fps_start + 1000)
|
||||
{
|
||||
fps = (float)fps_count * 1000.0 / (tick - fps_start);
|
||||
fps_count = 0;
|
||||
fps_start = tick;
|
||||
}
|
||||
|
||||
print_num(screen, font, screen->w-37, screen->h-12, fps);
|
||||
++fps_count;
|
||||
|
||||
for(i=0; i<MAX_POINTERS; i++)
|
||||
{
|
||||
if( !touchPointers[i].pressed )
|
||||
continue;
|
||||
r.x = touchPointers[i].x;
|
||||
r.y = touchPointers[i].y;
|
||||
r.w = 50;// + touchPointers[i].pressure / 5;
|
||||
r.h = 50;// + touchPointers[i].pressure / 5;
|
||||
r.x -= r.w/2;
|
||||
r.y -= r.h/2;
|
||||
SDL_FillRect(screen, &r, colors[i]);
|
||||
}
|
||||
int joyInput[][3] = {
|
||||
{accel[0], accel[1], 10},
|
||||
{accel[2], accel[3], 10 + abs(accel[4]) * 100 / 32767},
|
||||
{screenjoy[0], screenjoy[1], 10},
|
||||
{screenjoy[2], screenjoy[3], 10},
|
||||
{gamepads[0][0], gamepads[0][1], 10 + gamepads[0][4] * 100 / 32767},
|
||||
{gamepads[0][2], gamepads[0][3], 10 + gamepads[0][5] * 100 / 32767},
|
||||
{gamepads[0][6], gamepads[0][7], 10},
|
||||
{gamepads[1][0], gamepads[1][1], 10 + gamepads[1][4] * 100 / 32767},
|
||||
{gamepads[1][2], gamepads[1][3], 10 + gamepads[1][5] * 100 / 32767},
|
||||
{gamepads[1][6], gamepads[1][7], 10},
|
||||
{gamepads[2][0], gamepads[2][1], 10 + gamepads[2][4] * 100 / 32767},
|
||||
{gamepads[2][2], gamepads[2][3], 10 + gamepads[2][5] * 100 / 32767},
|
||||
{gamepads[2][6], gamepads[2][7], 10},
|
||||
{gamepads[3][0], gamepads[3][1], 10 + gamepads[3][4] * 100 / 32767},
|
||||
{gamepads[3][2], gamepads[3][3], 10 + gamepads[3][5] * 100 / 32767},
|
||||
{gamepads[3][6], gamepads[3][7], 10},
|
||||
};
|
||||
for( i = 0; i < 15; i++ )
|
||||
{
|
||||
r.w = joyInput[i][2];
|
||||
r.h = joyInput[i][2];
|
||||
r.x = SCREEN_W/2 + joyInput[i][0] * SCREEN_H / 65536 - r.w/2;
|
||||
r.y = SCREEN_H/2 + joyInput[i][1] * SCREEN_H / 65536 - r.w/2;
|
||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Joy input %d: %d %d %d", i, joyInput[i][0], joyInput[i][1], joyInput[i][2] );
|
||||
SDL_FillRect(screen, &r, i * 123);
|
||||
}
|
||||
|
||||
int mx, my;
|
||||
int b = SDL_GetMouseState(&mx, &my);
|
||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse: %04d %04d buttons %d", mx, my, b);
|
||||
int cursorIdx = 0;
|
||||
if( b & SDL_BUTTON_LMASK )
|
||||
cursorIdx |= 1;
|
||||
if( b & SDL_BUTTON_RMASK )
|
||||
cursorIdx |= 2;
|
||||
r.x = mx;
|
||||
r.y = my;
|
||||
r.w = mouse[cursorIdx]->w;
|
||||
r.h = mouse[cursorIdx]->h;
|
||||
r.x -= r.w/2;
|
||||
r.y -= r.h/2;
|
||||
SDL_BlitSurface(mouse[cursorIdx], NULL, screen, &r);
|
||||
|
||||
SDL_Flip(SDL_GetVideoSurface());
|
||||
SDL_Event evt;
|
||||
while( SDL_PollEvent(&evt) )
|
||||
{
|
||||
if(evt.type == SDL_KEYUP || evt.type == SDL_KEYDOWN)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, SDL_GetKeyName(evt.key.keysym.sym), (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode);
|
||||
if(evt.key.keysym.sym == SDLK_ESCAPE)
|
||||
return 0;
|
||||
if( evt.key.state == SDL_RELEASED )
|
||||
{
|
||||
if(evt.key.keysym.sym == SDLK_0)
|
||||
{
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 1);
|
||||
//SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_1)
|
||||
{
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 0);
|
||||
//SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
//*((int*) 0x1000) = 1000; // When you need to test your debugger
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_2)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input started");
|
||||
strcpy(asyncTextInputBuf, "async");
|
||||
SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf));
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_3)
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, 0);
|
||||
if(evt.key.keysym.sym == SDLK_4)
|
||||
SDL_ToggleScreenKeyboard(NULL);
|
||||
if(evt.key.keysym.sym == SDLK_5)
|
||||
SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput();
|
||||
}
|
||||
}
|
||||
if(evt.type == SDL_MOUSEBUTTONUP || evt.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL mouse button event: evt %s state %s button %d coords %d:%d", evt.type == SDL_MOUSEBUTTONUP ? "UP " : "DOWN" , evt.button.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.button.button, (int)evt.button.x, (int)evt.button.y);
|
||||
}
|
||||
if(evt.type == SDL_VIDEORESIZE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL resize event: %d x %d", evt.resize.w, evt.resize.h);
|
||||
if(evt.type == SDL_ACTIVEEVENT)
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state);
|
||||
// Android-specific events - accelerometer, multitoush, and on-screen joystick
|
||||
if( evt.type == SDL_JOYAXISMOTION )
|
||||
{
|
||||
if(evt.jaxis.which == 0) // Multitouch and on-screen joysticks
|
||||
{
|
||||
if(evt.jaxis.axis < 4)
|
||||
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
|
||||
else
|
||||
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
|
||||
}
|
||||
if(evt.jaxis.which == 1)
|
||||
{
|
||||
accel[evt.jaxis.axis] = evt.jaxis.value; // accelerometer and gyroscope
|
||||
}
|
||||
if(evt.jaxis.which >= 2)
|
||||
{
|
||||
// Each gamepad has 8 axes - two joystick hats, two triggers, and Ouya touchpad
|
||||
gamepads[evt.jaxis.which - 2][evt.jaxis.axis] = evt.jaxis.value;
|
||||
}
|
||||
}
|
||||
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
|
||||
{
|
||||
if(evt.jbutton.which == 0) // Multitouch and on-screen joystick
|
||||
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
|
||||
}
|
||||
if( evt.type == SDL_JOYBALLMOTION )
|
||||
{
|
||||
if(evt.jball.which == 0) // Multitouch and on-screen joystick
|
||||
{
|
||||
touchPointers[evt.jball.ball].x = evt.jball.xrel;
|
||||
touchPointers[evt.jball.ball].y = evt.jball.yrel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL) )
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen keyboard shown: %d -> %d", screenKeyboardShown, SDL_IsScreenKeyboardShown(NULL));
|
||||
screenKeyboardShown = SDL_IsScreenKeyboardShown(NULL);
|
||||
}
|
||||
if( SDL_IsScreenKeyboardShown(NULL) )
|
||||
{
|
||||
if(SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf)) == SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input: %s", asyncTextInputBuf);
|
||||
}
|
||||
}
|
||||
|
||||
/* Animate */
|
||||
x_speed = 500.0 * sin(t * 0.37);
|
||||
y_speed = 500.0 * sin(t * 0.53);
|
||||
z_speed = 400.0 * sin(t * 0.21);
|
||||
if( SDL_GetKeyState(NULL)[SDLK_LEFT] || SDL_GetKeyState(NULL)[SDLK_a] )
|
||||
x_speed -= 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_RIGHT] || SDL_GetKeyState(NULL)[SDLK_d] )
|
||||
x_speed += 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_UP] || SDL_GetKeyState(NULL)[SDLK_w] )
|
||||
y_speed -= 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_DOWN] || SDL_GetKeyState(NULL)[SDLK_s] )
|
||||
y_speed += 100000 * dt;
|
||||
|
||||
ballfield_move(balls, x_speed, y_speed, z_speed);
|
||||
x_offs -= x_speed;
|
||||
y_offs -= y_speed;
|
||||
|
||||
t += dt;
|
||||
}
|
||||
|
||||
ballfield_free(balls);
|
||||
SDL_FreeSurface(back);
|
||||
SDL_FreeSurface(logo);
|
||||
SDL_FreeSurface(font);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,795 +0,0 @@
|
||||
/*
|
||||
* "Ballfield"
|
||||
*
|
||||
* (C) David Olofson <david@olofson.net>, 2002, 2003
|
||||
*
|
||||
* This software is released under the terms of the GPL.
|
||||
*
|
||||
* Contact author for permission if you want to use this
|
||||
* software, or work derived from it, under other terms.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <android/log.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include <SDL/SDL.h>
|
||||
#include <SDL/SDL_image.h>
|
||||
#include <SDL/SDL_screenkeyboard.h>
|
||||
#include <SDL/SDL_android.h>
|
||||
|
||||
#define fprintf(X, ...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__)
|
||||
#define printf(...) __android_log_print(ANDROID_LOG_INFO, "Ballfield", __VA_ARGS__)
|
||||
|
||||
/*----------------------------------------------------------
|
||||
Definitions...
|
||||
----------------------------------------------------------*/
|
||||
|
||||
#define SCREEN_W 640
|
||||
#define SCREEN_H 256
|
||||
|
||||
|
||||
#define BALLS 300
|
||||
|
||||
#define COLORS 2
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Sint32 x, y, z; /* Position */
|
||||
Uint32 c; /* Color */
|
||||
} point_t;
|
||||
|
||||
|
||||
/*
|
||||
* Ballfield
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
point_t points[BALLS];
|
||||
SDL_Rect *frames;
|
||||
SDL_Surface *gfx[COLORS];
|
||||
int use_alpha;
|
||||
} ballfield_t;
|
||||
|
||||
|
||||
/*
|
||||
* Size of the biggest ball image in pixels
|
||||
*
|
||||
* Balls are scaled down and *packed*, one pixel
|
||||
* smaller for each frame down to 1x1. The actual
|
||||
* image width is (obviously...) the same as the
|
||||
* width of the first frame.
|
||||
*/
|
||||
#define BALL_W 32
|
||||
#define BALL_H 32
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------
|
||||
General tool functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Bump areas of low and high alpha to 0% or 100%
|
||||
* respectively, just in case the graphics contains
|
||||
* "alpha noise".
|
||||
*/
|
||||
SDL_Surface *clean_alpha(SDL_Surface *s)
|
||||
{
|
||||
SDL_Surface *work;
|
||||
SDL_Rect r;
|
||||
Uint32 *pixels;
|
||||
int pp;
|
||||
int x, y;
|
||||
|
||||
work = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h,
|
||||
32, 0xff000000, 0x00ff0000, 0x0000ff00,
|
||||
0x000000ff);
|
||||
if(!work)
|
||||
return NULL;
|
||||
|
||||
r.x = r.y = 0;
|
||||
r.w = s->w;
|
||||
r.h = s->h;
|
||||
if(SDL_BlitSurface(s, &r, work, NULL) < 0)
|
||||
{
|
||||
SDL_FreeSurface(work);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_LockSurface(work);
|
||||
pixels = (Uint32 *)work->pixels;
|
||||
pp = work->pitch / sizeof(Uint32);
|
||||
for(y = 0; y < work->h; ++y)
|
||||
for(x = 0; x < work->w; ++x)
|
||||
{
|
||||
Uint32 pix = pixels[y*pp + x];
|
||||
switch((pix & 0xff) >> 4)
|
||||
{
|
||||
case 0:
|
||||
pix = 0x00000000;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 15:
|
||||
pix |= 0xff;
|
||||
break;
|
||||
}
|
||||
pixels[y*pp + x] = pix;
|
||||
}
|
||||
SDL_UnlockSurface(work);
|
||||
|
||||
return work;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load and convert an antialiazed, zoomed set of sprites.
|
||||
*/
|
||||
SDL_Surface *load_zoomed(char *name, int alpha)
|
||||
{
|
||||
SDL_Surface *sprites;
|
||||
SDL_Surface *temp = IMG_Load(name);
|
||||
if(!temp)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
sprites = temp;
|
||||
SDL_SetAlpha(sprites, 0, 255);
|
||||
temp = clean_alpha(sprites);
|
||||
SDL_FreeSurface(sprites);
|
||||
*/
|
||||
if(!temp)
|
||||
{
|
||||
fprintf(stderr, "Could not clean alpha!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(alpha)
|
||||
{
|
||||
SDL_SetAlpha(temp, 0, SDL_ALPHA_OPAQUE);
|
||||
sprites = SDL_DisplayFormatAlpha(temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp->format, 0, 0, 0));
|
||||
sprites = SDL_DisplayFormat(temp);
|
||||
}
|
||||
SDL_FreeSurface(temp);
|
||||
|
||||
return sprites;
|
||||
}
|
||||
|
||||
|
||||
void print_num(SDL_Surface *dst, SDL_Surface *font, int x, int y, float value)
|
||||
{
|
||||
char buf[16];
|
||||
int val = (int)(value * 10.0);
|
||||
int pos, p = 0;
|
||||
SDL_Rect from;
|
||||
|
||||
/* Sign */
|
||||
if(val < 0)
|
||||
{
|
||||
buf[p++] = 10;
|
||||
val = -val;
|
||||
}
|
||||
|
||||
/* Integer part */
|
||||
pos = 10000000;
|
||||
while(pos > 1)
|
||||
{
|
||||
int num = val / pos;
|
||||
val -= num * pos;
|
||||
pos /= 10;
|
||||
if(p || num)
|
||||
buf[p++] = num;
|
||||
}
|
||||
|
||||
/* Decimals */
|
||||
if(val / pos)
|
||||
{
|
||||
buf[p++] = 11;
|
||||
while(pos > 0)
|
||||
{
|
||||
int num = val / pos;
|
||||
val -= num * pos;
|
||||
pos /= 10;
|
||||
buf[p++] = num;
|
||||
}
|
||||
}
|
||||
|
||||
/* Render! */
|
||||
from.y = 0;
|
||||
from.w = 7;
|
||||
from.h = 10;
|
||||
for(pos = 0; pos < p; ++pos)
|
||||
{
|
||||
SDL_Rect to;
|
||||
to.x = x + pos * 7;
|
||||
to.y = y;
|
||||
from.x = buf[pos] * 7;
|
||||
SDL_BlitSurface(font, &from, dst, &to);
|
||||
}
|
||||
}
|
||||
|
||||
void print_num_hex(SDL_Surface *dst, SDL_Surface *font, int x, int y, unsigned val)
|
||||
{
|
||||
char buf[8];
|
||||
int pos, p = 0;
|
||||
SDL_Rect from;
|
||||
|
||||
//val = htonl(val); // Big-endian
|
||||
|
||||
/* Render! */
|
||||
from.y = 0;
|
||||
from.w = 7;
|
||||
from.h = 10;
|
||||
for(pos = 0; pos < 8; ++pos)
|
||||
{
|
||||
SDL_Rect to;
|
||||
to.x = 8 * 7 - (x + pos * 7); // Little-endian number wrapped backwards
|
||||
to.y = y;
|
||||
from.x = ( ( val >> (pos * 4) ) & 0xf ) * 7;
|
||||
SDL_BlitSurface(font, &from, dst, &to);
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
ballfield_t functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
ballfield_t *ballfield_init(void)
|
||||
{
|
||||
int i;
|
||||
ballfield_t *bf = (ballfield_t *)calloc(sizeof(ballfield_t), 1);
|
||||
if(!bf)
|
||||
return NULL;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
bf->points[i].x = rand() % 0x20000;
|
||||
bf->points[i].y = rand() % 0x20000;
|
||||
bf->points[i].z = 0x20000 * i / BALLS;
|
||||
if(rand() % 100 > 80)
|
||||
bf->points[i].c = 1;
|
||||
else
|
||||
bf->points[i].c = 0;
|
||||
}
|
||||
return bf;
|
||||
}
|
||||
|
||||
|
||||
void ballfield_free(ballfield_t *bf)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < COLORS; ++i)
|
||||
SDL_FreeSurface(bf->gfx[i]);
|
||||
}
|
||||
|
||||
|
||||
static int ballfield_init_frames(ballfield_t *bf)
|
||||
{
|
||||
int i, j;
|
||||
/*
|
||||
* Set up source rects for all frames
|
||||
*/
|
||||
bf->frames = (SDL_Rect *)calloc(sizeof(SDL_Rect), bf->gfx[0]->w);
|
||||
if(!bf->frames)
|
||||
{
|
||||
fprintf(stderr, "No memory for frame rects!\n");
|
||||
return -1;
|
||||
}
|
||||
for(j = 0, i = 0; i < bf->gfx[0]->w; ++i)
|
||||
{
|
||||
bf->frames[i].x = 0;
|
||||
bf->frames[i].y = j;
|
||||
bf->frames[i].w = bf->gfx[0]->w - i;
|
||||
bf->frames[i].h = bf->gfx[0]->w - i;
|
||||
j += bf->gfx[0]->w - i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ballfield_load_gfx(ballfield_t *bf, char *name, unsigned int color)
|
||||
{
|
||||
if(color >= COLORS)
|
||||
return -1;
|
||||
|
||||
bf->gfx[color] = load_zoomed(name, bf->use_alpha);
|
||||
if(!bf->gfx[color])
|
||||
return -2;
|
||||
|
||||
if(!bf->frames)
|
||||
return ballfield_init_frames(bf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ballfield_move(ballfield_t *bf, Sint32 dx, Sint32 dy, Sint32 dz)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
bf->points[i].x += dx;
|
||||
bf->points[i].x &= 0x1ffff;
|
||||
bf->points[i].y += dy;
|
||||
bf->points[i].y &= 0x1ffff;
|
||||
bf->points[i].z += dz;
|
||||
bf->points[i].z &= 0x1ffff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ballfield_render(ballfield_t *bf, SDL_Surface *screen)
|
||||
{
|
||||
int i, j, z;
|
||||
|
||||
/*
|
||||
* Find the ball with the highest Z.
|
||||
*/
|
||||
z = 0;
|
||||
j = 0;
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
if(bf->points[i].z > z)
|
||||
{
|
||||
j = i;
|
||||
z = bf->points[i].z;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Render all balls in back->front order.
|
||||
*/
|
||||
for(i = 0; i < BALLS; ++i)
|
||||
{
|
||||
SDL_Rect r;
|
||||
int f;
|
||||
z = bf->points[j].z;
|
||||
z += 50;
|
||||
f = ((bf->frames[0].w << 12) + 100000) / z;
|
||||
f = bf->frames[0].w - f;
|
||||
if(f < 0)
|
||||
f = 0;
|
||||
else if(f > bf->frames[0].w - 1)
|
||||
f = bf->frames[0].w - 1;
|
||||
z >>= 7;
|
||||
z += 1;
|
||||
r.x = (bf->points[j].x - 0x10000) / z;
|
||||
r.y = (bf->points[j].y - 0x10000) / z;
|
||||
r.x += (screen->w - bf->frames[f].w) >> 1;
|
||||
r.y += (screen->h - bf->frames[f].h) >> 1;
|
||||
SDL_BlitSurface(bf->gfx[bf->points[j].c],
|
||||
&bf->frames[f], screen, &r);
|
||||
if(--j < 0)
|
||||
j = BALLS - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------
|
||||
Other rendering functions
|
||||
----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Draw tiled background image with offset.
|
||||
*/
|
||||
void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
|
||||
{
|
||||
/*
|
||||
int x, y;
|
||||
SDL_Rect r;
|
||||
if(xo < 0)
|
||||
xo += back->w*(-xo/back->w + 1);
|
||||
if(yo < 0)
|
||||
yo += back->h*(-yo/back->h + 1);
|
||||
xo %= back->w;
|
||||
yo %= back->h;
|
||||
for(y = -yo; y < screen->h; y += back->h)
|
||||
for(x = -xo; x < screen->w; x += back->w)
|
||||
{
|
||||
r.x = x;
|
||||
r.y = y;
|
||||
SDL_BlitSurface(back, NULL, screen, &r);
|
||||
}
|
||||
*/
|
||||
SDL_Rect r;
|
||||
xo %= back->w/8;
|
||||
yo %= back->h/8;
|
||||
r.x = xo - back->w/2 + screen->w/2;
|
||||
r.y = yo - back->h/2 + screen->h/2;
|
||||
r.w = back->w;
|
||||
r.h = back->h;
|
||||
SDL_BlitSurface(back, NULL, screen, &r);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------
|
||||
main()
|
||||
----------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
ballfield_t *balls;
|
||||
SDL_Surface *screen;
|
||||
SDL_Surface *temp_image;
|
||||
SDL_Surface *back, *logo, *font, *font_hex;
|
||||
SDL_Event event;
|
||||
int bpp = 16,
|
||||
flags = SDL_HWSURFACE,
|
||||
alpha = 1;
|
||||
int x_offs = 0, y_offs = 0;
|
||||
long tick,
|
||||
last_tick,
|
||||
last_avg_tick;
|
||||
double t = 0;
|
||||
float dt;
|
||||
int i;
|
||||
float fps = 0.0;
|
||||
int fps_count = 0;
|
||||
int fps_start = 0;
|
||||
float x_speed, y_speed, z_speed;
|
||||
enum { MAX_POINTERS = 16 };
|
||||
// some random colors
|
||||
int colors[MAX_POINTERS] = { 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee, 0xaaaaaa, 0xffffff, 0x888888, 0xcccccc, 0x666666, 0x999999, 0xdddddd, 0xeeeeee };
|
||||
struct TouchPointer_t { int x; int y; int pressure; int pressed; } touchPointers[MAX_POINTERS];
|
||||
int accel[5], screenjoy[4], gamepads[4][8];
|
||||
SDL_Surface *mouse[4];
|
||||
int screenKeyboardShown = 0;
|
||||
int asyncTextInput = 0;
|
||||
char asyncTextInputBuf[256];
|
||||
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK);
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
SDL_Joystick * joysticks[6];
|
||||
for( i = 0; i < 6; i++ )
|
||||
joysticks[i] = SDL_JoystickOpen(i);
|
||||
|
||||
atexit(SDL_Quit);
|
||||
|
||||
screen = SDL_SetVideoMode(SCREEN_W, SCREEN_H, bpp, flags);
|
||||
if(!screen)
|
||||
{
|
||||
fprintf(stderr, "Failed to open screen!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("Ballfield", "Ballfield");
|
||||
if(flags & SDL_FULLSCREEN)
|
||||
SDL_ShowCursor(0);
|
||||
|
||||
balls = ballfield_init();
|
||||
if(!balls)
|
||||
{
|
||||
fprintf(stderr, "Failed to create ballfield!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load and prepare balls...
|
||||
*/
|
||||
balls->use_alpha = alpha;
|
||||
if( ballfield_load_gfx(balls, "blueball.png", 0)
|
||||
||
|
||||
ballfield_load_gfx(balls, "redball.png", 1) )
|
||||
{
|
||||
fprintf(stderr, "Could not load balls!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Load background image
|
||||
*/
|
||||
temp_image = IMG_Load("sun.gif");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load background!\n");
|
||||
exit(-1);
|
||||
}
|
||||
back = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
/*
|
||||
* Load logo
|
||||
*/
|
||||
temp_image = SDL_LoadBMP("logo.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load logo!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
logo = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
/*
|
||||
* Load font
|
||||
*/
|
||||
temp_image = SDL_LoadBMP("font7x10.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load font!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
font = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
temp_image = SDL_LoadBMP("font7x10-hex.bmp");
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load hex font!\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_SetColorKey(temp_image, SDL_SRCCOLORKEY,
|
||||
SDL_MapRGB(temp_image->format, 255, 0, 255));
|
||||
font_hex = SDL_DisplayFormat(temp_image);
|
||||
SDL_FreeSurface(temp_image);
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
char name[32];
|
||||
sprintf(name, "mouse%d.png", i);
|
||||
temp_image = IMG_Load(name);
|
||||
if(!temp_image)
|
||||
{
|
||||
fprintf(stderr, "Could not load %s!\n", name);
|
||||
exit(-1);
|
||||
}
|
||||
//mouse[i] = SDL_DisplayFormat(temp_image);
|
||||
//SDL_FreeSurface(temp_image);
|
||||
mouse[i] = temp_image; // Keep alpha
|
||||
}
|
||||
|
||||
last_avg_tick = last_tick = SDL_GetTicks();
|
||||
|
||||
memset(touchPointers, 0, sizeof(touchPointers));
|
||||
memset(accel, 0, sizeof(accel));
|
||||
memset(screenjoy, 0, sizeof(screenjoy));
|
||||
memset(gamepads, 0, sizeof(gamepads));
|
||||
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "sizeof(int) %d long %d long long %d size_t %d", sizeof(int), sizeof(long), sizeof(long long), sizeof(size_t));
|
||||
/*
|
||||
wchar_t ss[256];
|
||||
const wchar_t *ss2 = L"String 2 ЕНГ ---";
|
||||
swprintf(ss, 256, L"String ЙЦУК --- %ls", ss2);
|
||||
char ss3[512] = "";
|
||||
char ss4[512] = "";
|
||||
for(i = 0; i < wcslen(ss); i++)
|
||||
{
|
||||
char tmp[16];
|
||||
sprintf(tmp, "%04X ", (int)ss[i]);
|
||||
strcat(ss3, tmp);
|
||||
sprintf(ss4, "%ls", ss);
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "swprintf: len %d data %s: %s", wcslen(ss), ss3, ss4);
|
||||
*/
|
||||
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "On-screen buttons:");
|
||||
for(i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++)
|
||||
{
|
||||
SDL_Rect r;
|
||||
SDL_ANDROID_GetScreenKeyboardButtonPos(i, &r);
|
||||
__android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "{ %d, %d, %d, %d },", r.x, r.y, r.x+r.h, r.y+r.w);
|
||||
}
|
||||
//SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, 1);
|
||||
//SDL_ANDROID_SetScreenKeyboardButtonGenerateTouchEvents(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, 1);
|
||||
|
||||
while(1)
|
||||
{
|
||||
SDL_Rect r;
|
||||
|
||||
/* Timing */
|
||||
tick = SDL_GetTicks();
|
||||
dt = (tick - last_tick) * 0.001f;
|
||||
last_tick = tick;
|
||||
|
||||
if( bpp == 32 )
|
||||
SDL_FillRect(screen, NULL, 0); // Clear alpha channel
|
||||
|
||||
/* Background image */
|
||||
tiled_back(back, screen, x_offs>>11, y_offs>>11);
|
||||
|
||||
/* Ballfield */
|
||||
ballfield_render(balls, screen);
|
||||
|
||||
/* Logo */
|
||||
r.x = 2;
|
||||
r.y = 2;
|
||||
SDL_BlitSurface(logo, NULL, screen, &r);
|
||||
|
||||
/* FPS counter */
|
||||
if(tick > fps_start + 1000)
|
||||
{
|
||||
fps = (float)fps_count * 1000.0 / (tick - fps_start);
|
||||
fps_count = 0;
|
||||
fps_start = tick;
|
||||
}
|
||||
|
||||
print_num(screen, font, screen->w-37, screen->h-12, fps);
|
||||
++fps_count;
|
||||
|
||||
for(i=0; i<MAX_POINTERS; i++)
|
||||
{
|
||||
if( !touchPointers[i].pressed )
|
||||
continue;
|
||||
r.x = touchPointers[i].x;
|
||||
r.y = touchPointers[i].y;
|
||||
r.w = 50 + touchPointers[i].pressure / 5;
|
||||
r.h = 50 + touchPointers[i].pressure / 5;
|
||||
r.x -= r.w/2;
|
||||
r.y -= r.h/2;
|
||||
SDL_FillRect(screen, &r, colors[i]);
|
||||
}
|
||||
int joyInput[][3] = {
|
||||
{accel[0], accel[1], 10},
|
||||
{accel[2], accel[3], 10 + abs(accel[4]) * 100 / 32767},
|
||||
{screenjoy[0], screenjoy[1], 10},
|
||||
{screenjoy[2], screenjoy[3], 10},
|
||||
{gamepads[0][0], gamepads[0][1], 10 + gamepads[0][4] * 100 / 32767},
|
||||
{gamepads[0][2], gamepads[0][3], 10 + gamepads[0][5] * 100 / 32767},
|
||||
{gamepads[0][6], gamepads[0][7], 10},
|
||||
{gamepads[1][0], gamepads[1][1], 10 + gamepads[1][4] * 100 / 32767},
|
||||
{gamepads[1][2], gamepads[1][3], 10 + gamepads[1][5] * 100 / 32767},
|
||||
{gamepads[1][6], gamepads[1][7], 10},
|
||||
{gamepads[2][0], gamepads[2][1], 10 + gamepads[2][4] * 100 / 32767},
|
||||
{gamepads[2][2], gamepads[2][3], 10 + gamepads[2][5] * 100 / 32767},
|
||||
{gamepads[2][6], gamepads[2][7], 10},
|
||||
{gamepads[3][0], gamepads[3][1], 10 + gamepads[3][4] * 100 / 32767},
|
||||
{gamepads[3][2], gamepads[3][3], 10 + gamepads[3][5] * 100 / 32767},
|
||||
{gamepads[3][6], gamepads[3][7], 10},
|
||||
};
|
||||
for( i = 0; i < 15; i++ )
|
||||
{
|
||||
r.w = joyInput[i][2];
|
||||
r.h = joyInput[i][2];
|
||||
r.x = SCREEN_W/2 + joyInput[i][0] * SCREEN_H / 65536 - r.w/2;
|
||||
r.y = SCREEN_H/2 + joyInput[i][1] * SCREEN_H / 65536 - r.w/2;
|
||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Joy input %d: %d %d %d", i, joyInput[i][0], joyInput[i][1], joyInput[i][2] );
|
||||
SDL_FillRect(screen, &r, i * 123);
|
||||
}
|
||||
|
||||
int mx, my;
|
||||
int b = SDL_GetMouseState(&mx, &my);
|
||||
//__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Mouse: %04d %04d buttons %d", mx, my, b);
|
||||
int cursorIdx = 0;
|
||||
if( b & SDL_BUTTON_LMASK )
|
||||
cursorIdx |= 1;
|
||||
if( b & SDL_BUTTON_RMASK )
|
||||
cursorIdx |= 2;
|
||||
r.x = mx;
|
||||
r.y = my;
|
||||
r.w = mouse[cursorIdx]->w;
|
||||
r.h = mouse[cursorIdx]->h;
|
||||
r.x -= r.w/2;
|
||||
r.y -= r.h/2;
|
||||
SDL_BlitSurface(mouse[cursorIdx], NULL, screen, &r);
|
||||
|
||||
SDL_Flip(SDL_GetVideoSurface());
|
||||
SDL_Event evt;
|
||||
while( SDL_PollEvent(&evt) )
|
||||
{
|
||||
if(evt.type == SDL_KEYUP || evt.type == SDL_KEYDOWN)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL key event: evt %s state %s key %4d %12s scancode %4d mod %2d unicode %d", evt.type == SDL_KEYUP ? "UP " : "DOWN" , evt.key.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.key.keysym.sym, SDL_GetKeyName(evt.key.keysym.sym), (int)evt.key.keysym.scancode, (int)evt.key.keysym.mod, (int)evt.key.keysym.unicode);
|
||||
if(evt.key.keysym.sym == SDLK_ESCAPE)
|
||||
return 0;
|
||||
if( evt.key.state == SDL_RELEASED )
|
||||
{
|
||||
if(evt.key.keysym.sym == SDLK_0)
|
||||
{
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 1);
|
||||
SDL_ANDROID_SetMouseEmulationMode(0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_1)
|
||||
{
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, 0);
|
||||
SDL_ANDROID_SetMouseEmulationMode(1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1);
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_2)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input started");
|
||||
asyncTextInput = 1;
|
||||
asyncTextInputBuf[0] = 0;
|
||||
SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf));
|
||||
}
|
||||
if(evt.key.keysym.sym == SDLK_3)
|
||||
SDL_ANDROID_SetScreenKeyboardButtonShown(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, 0);
|
||||
if(evt.key.keysym.sym == SDLK_4)
|
||||
SDL_ToggleScreenKeyboard(NULL);
|
||||
if(evt.key.keysym.sym == SDLK_5)
|
||||
SDL_ANDROID_ToggleScreenKeyboardWithoutTextInput();
|
||||
}
|
||||
}
|
||||
if(evt.type == SDL_MOUSEBUTTONUP || evt.type == SDL_MOUSEBUTTONDOWN)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL mouse button event: evt %s state %s button %d coords %d:%d", evt.type == SDL_MOUSEBUTTONUP ? "UP " : "DOWN" , evt.button.state == SDL_PRESSED ? "PRESSED " : "RELEASED", (int)evt.button.button, (int)evt.button.x, (int)evt.button.y);
|
||||
}
|
||||
if(evt.type == SDL_VIDEORESIZE)
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "SDL resize event: %d x %d", evt.resize.w, evt.resize.h);
|
||||
if(evt.type == SDL_ACTIVEEVENT)
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "======= SDL active event: gain %d state %d", evt.active.gain, evt.active.state);
|
||||
// Android-specific events - accelerometer, multitoush, and on-screen joystick
|
||||
if( evt.type == SDL_JOYAXISMOTION )
|
||||
{
|
||||
if(evt.jaxis.which == 0) // Multitouch and on-screen joysticks
|
||||
{
|
||||
if(evt.jaxis.axis < 4)
|
||||
screenjoy[evt.jaxis.axis] = evt.jaxis.value;
|
||||
else
|
||||
touchPointers[evt.jaxis.axis - 4].pressure = evt.jaxis.value;
|
||||
}
|
||||
if(evt.jaxis.which == 1)
|
||||
{
|
||||
accel[evt.jaxis.axis] = evt.jaxis.value; // accelerometer and gyroscope
|
||||
}
|
||||
if(evt.jaxis.which >= 2)
|
||||
{
|
||||
// Each gamepad has 8 axes - two joystick hats, two triggers, and Ouya touchpad
|
||||
gamepads[evt.jaxis.which - 2][evt.jaxis.axis] = evt.jaxis.value;
|
||||
}
|
||||
}
|
||||
if( evt.type == SDL_JOYBUTTONDOWN || evt.type == SDL_JOYBUTTONUP )
|
||||
{
|
||||
if(evt.jbutton.which == 0) // Multitouch and on-screen joystick
|
||||
touchPointers[evt.jbutton.button].pressed = (evt.jbutton.state == SDL_PRESSED);
|
||||
}
|
||||
if( evt.type == SDL_JOYBALLMOTION )
|
||||
{
|
||||
if(evt.jball.which == 0) // Multitouch and on-screen joystick
|
||||
{
|
||||
touchPointers[evt.jball.ball].x = evt.jball.xrel;
|
||||
touchPointers[evt.jball.ball].y = evt.jball.yrel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( screenKeyboardShown != SDL_IsScreenKeyboardShown(NULL))
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Screen keyboard shown: %d -> %d", screenKeyboardShown, SDL_IsScreenKeyboardShown(NULL));
|
||||
screenKeyboardShown = SDL_IsScreenKeyboardShown(NULL);
|
||||
}
|
||||
if( asyncTextInput )
|
||||
{
|
||||
if( SDL_ANDROID_GetScreenKeyboardTextInputAsync(asyncTextInputBuf, sizeof(asyncTextInputBuf)) == SDL_ANDROID_TEXTINPUT_ASYNC_FINISHED)
|
||||
{
|
||||
__android_log_print(ANDROID_LOG_INFO, "Ballfield", "Async text input: %s", asyncTextInputBuf);
|
||||
asyncTextInput = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Animate */
|
||||
x_speed = 500.0 * sin(t * 0.37);
|
||||
y_speed = 500.0 * sin(t * 0.53);
|
||||
z_speed = 400.0 * sin(t * 0.21);
|
||||
if( SDL_GetKeyState(NULL)[SDLK_LEFT] )
|
||||
x_speed -= 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_RIGHT] )
|
||||
x_speed += 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_UP] )
|
||||
y_speed -= 100000 * dt;
|
||||
if( SDL_GetKeyState(NULL)[SDLK_DOWN] )
|
||||
y_speed += 100000 * dt;
|
||||
|
||||
ballfield_move(balls, x_speed, y_speed, z_speed);
|
||||
x_offs -= x_speed;
|
||||
y_offs -= y_speed;
|
||||
|
||||
t += dt;
|
||||
}
|
||||
|
||||
ballfield_free(balls);
|
||||
SDL_FreeSurface(back);
|
||||
SDL_FreeSurface(logo);
|
||||
SDL_FreeSurface(font);
|
||||
return 0;
|
||||
}
|
||||
@@ -7,10 +7,10 @@ AppName="BasiliskII"
|
||||
AppFullName=net.cebix.basilisk
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=10001
|
||||
AppVersionCode=10005
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.0.0.01"
|
||||
AppVersionName="1.0.0.05"
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
@@ -236,3 +236,6 @@ AdmobTestDeviceId=
|
||||
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
|
||||
AdmobBannerSize=
|
||||
|
||||
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
|
||||
HideSystemMousePointer=y
|
||||
|
||||
|
||||
@@ -9,16 +9,19 @@ ln -sf libsdl-1.2.so $LOCAL_PATH/../../../obj/local/$1/libpthread.so
|
||||
ln -sf libsdl_image.so $LOCAL_PATH/../../../obj/local/$1/libSDL_image.so
|
||||
ln -sf libsdl_ttf.so $LOCAL_PATH/../../../obj/local/$1/libSDL_ttf.so
|
||||
|
||||
JOBS=4
|
||||
|
||||
if [ \! -f basiliskii/src/Unix/configure ] ; then
|
||||
sh -c "cd basiliskii/src/Unix && ./autogen.sh"
|
||||
rm -f basiliskii/src/Unix/Makefile
|
||||
fi
|
||||
|
||||
if [ \! -f basiliskii/src/Unix/Makefile ] ; then
|
||||
env CFLAGS="-Ofast" \
|
||||
env LIBS="-lgnustl_static" \
|
||||
../setEnvironment-$1.sh sh -c "cd basiliskii/src/Unix && ./configure --build=x86_64-unknown-linux-gnu --host=$2 --enable-sdl-video --enable-sdl-audio --without-gtk --without-esd --without-x"
|
||||
env LIBS="-lgnustl_static -lc -lm" \
|
||||
../setEnvironment-$1.sh sh -c "cd basiliskii/src/Unix && env no_dev_ptmx=1 ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no ac_cv_sys_file_offset_bits=no \
|
||||
./configure --build=x86_64-unknown-linux-gnu --host=$2 --enable-sdl-video --enable-sdl-audio --without-gtk --without-esd --without-x" || exit 1
|
||||
fi
|
||||
|
||||
make -C basiliskii/src/Unix && mv -f basiliskii/src/Unix/BasiliskII libapplication-$1.so
|
||||
make -C basiliskii/src/Unix -j$JOBS && mv -f basiliskii/src/Unix/BasiliskII libapplication-$1.so
|
||||
|
||||
|
||||
BIN
project/jni/application/basiliskii/AndroidData/cfg.zip
Normal file → Executable file
BIN
project/jni/application/basiliskii/AndroidData/cfg.zip
Normal file → Executable file
Binary file not shown.
BIN
project/jni/application/basiliskii/AndroidData/guichan-gui.zip
Normal file → Executable file
BIN
project/jni/application/basiliskii/AndroidData/guichan-gui.zip
Normal file → Executable file
Binary file not shown.
Submodule project/jni/application/basiliskii/basiliskii updated: 3405babdd2...06a7bb327c
Binary file not shown.
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 7.9 KiB |
@@ -13,11 +13,13 @@ AppVersionCode=1406
|
||||
AppVersionName="1.4.06"
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, '!!' will also hide the entry from the menu, so it cannot be disabled
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
# If the URL does not contain 'http://' or 'https://', it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by the build system
|
||||
# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version for obb file
|
||||
# You can use .zip.xz archives for better compression, but you need to add 'lzma' to CompiledLibraries
|
||||
# Generate .zip.xz files like this: zip -0 -r data.zip your-data/* ; xz -8 data.zip
|
||||
AppDataDownloadUrl="!Game data|data3.zip"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
@@ -46,10 +48,17 @@ NeedDepthBuffer=n
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# Use GLES 2.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Use GLES 3.x context
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles3=n
|
||||
|
||||
# Use gl4es library for provide OpenGL 1.x functionality to OpenGL ES accelerated cards (y) or (n)
|
||||
UseGl4es=
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=y
|
||||
@@ -80,6 +89,14 @@ CompatibilityHacksStaticInit=n
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||
|
||||
# Built-in text input keyboards with custom layouts for emulators, requires CompatibilityHacksTextInputEmulatesHwKeyboard=y
|
||||
# 0 or empty - standard Android keyboard
|
||||
# 1 - Simple QWERTY keyboard, no function keys, no arrow keys
|
||||
# 2 - Commodore 64 keyboard
|
||||
# 3 - Amiga keyboard
|
||||
# 4 - Atari800 keyboard
|
||||
TextInputKeyboard=
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=n
|
||||
|
||||
@@ -113,6 +130,9 @@ RightMouseButtonLongPress=
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Screen follows mouse cursor, when it's covered by soft keyboard, this works only in software video mode (y) or (n)
|
||||
ScreenFollowsMouse=
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=
|
||||
|
||||
@@ -145,6 +165,9 @@ AppUsesAccelerometer=n
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=n
|
||||
|
||||
# Application uses orientation sensor (y) or (n), reported as joystick 1 axes 8-10
|
||||
AppUsesOrientationSensor=
|
||||
|
||||
# Use gyroscope to move mouse cursor (y) or (n), it eats battery, and can be disabled in settings, do not use with AppUsesGyroscope setting
|
||||
MoveMouseWithGyroscope=
|
||||
|
||||
@@ -156,15 +179,21 @@ AppUsesMultitouch=n
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application needs to access SD card. If your data files are bigger than 5 Mb, enable it. (y) / (n)
|
||||
# Application needs read/write access SD card. Always disable it, unless you want to access user photos and downloads. (y) / (n)
|
||||
AccessSdCard=
|
||||
|
||||
# Application needs to read it's own OBB file. Enable this if you are using Play Store expansion files. (y) / (n)
|
||||
ReadObbFile=
|
||||
|
||||
# Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n)
|
||||
AccessInternet=
|
||||
|
||||
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
|
||||
ImmersiveMode=
|
||||
|
||||
# Hide Android system mouse cursor image when USB mouse is attached (y) or (n) - the app must draw it's own mouse cursor
|
||||
HideSystemMousePointer=
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
@@ -188,38 +217,62 @@ RedefinedKeysScreenKb="RETURN SPACE"
|
||||
RedefinedKeysScreenKbNames="RETURN SPACE"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with cross joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with cross joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
# 4 = Retro by Santiago Radeff (red/white, with cross joystick)
|
||||
# 5 = GameBoy from RetroArch
|
||||
# 6 = PlayStation from RetroArch
|
||||
# 7 = SuperNintendo from RetroArch
|
||||
# 8 = DualShock from RetroArch
|
||||
# 9 = Nintendo64 from RetroArch
|
||||
TouchscreenKeysTheme=2
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb Start Select Up Down Left Right LThumbUp LThumbDown LThumbLeft LThumbRight RThumbUp RThumbDown RThumbLeft RThumbRight
|
||||
RedefinedKeysGamepad="RETURN ESCAPE SPACE SPACE"
|
||||
|
||||
# Redefine keys for the second gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysSecondGamepad=""
|
||||
|
||||
# Redefine keys for the third gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysThirdGamepad=""
|
||||
|
||||
# Redefine keys for the fourth gamepad, same as the first gamepad if not set:
|
||||
RedefinedKeysFourthGamepad=""
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=0
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.StorageAccessConfig SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
HiddenMenuOptions='SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.MouseConfigMainMenu'
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.StorageAccessConfig SettingsMenuMisc.CommandlineConfig SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout SettingsMenuKeyboard.ScreenKeyboardAdvanced
|
||||
FirstStartMenuOptions=''
|
||||
|
||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||
# Available architectures: armeabi armeabi-v7a armeabi-v7a-hard x86 mips
|
||||
MultiABI='armeabi-v7a x86'
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
|
||||
# GCC version, or 'clang' for CLANG
|
||||
NDK_TOOLCHAIN_VERSION=
|
||||
|
||||
# Android platform version.
|
||||
# android-16 = Android 4.1, the earliest supported version in NDK r18.
|
||||
# android-18 = Android 4.3, the first version supporting GLES3.
|
||||
# android-21 = Android 5.1, the first version with SO_REUSEPORT defined.
|
||||
APP_PLATFORM=
|
||||
|
||||
# Specify architectures to compile, 'all' or 'y' to compile for all architectures.
|
||||
# Available architectures: armeabi-v7a arm64-v8a x86 x86_64
|
||||
MultiABI='arm64-v8a'
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# MP3 patents are expired, but libmad license is GPL, not LGPL
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="sdl_image sdl_mixer"
|
||||
|
||||
@@ -229,6 +282,9 @@ CustomBuildScript=n
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags=''
|
||||
|
||||
# Aditional C++-specific compiler flags for application, added after AppCflags
|
||||
AppCppflags=''
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags=''
|
||||
|
||||
@@ -260,3 +316,6 @@ AdmobBannerSize=
|
||||
# Google Play Game Services application ID, required for cloud saves to work
|
||||
GooglePlayGameServicesId=520035027247
|
||||
|
||||
# The app will open files with following extension, file path will be added to commandline params
|
||||
AppOpenFileExtension=''
|
||||
|
||||
|
||||
1
project/jni/application/bochs/.gitignore
vendored
1
project/jni/application/bochs/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/*.so
|
||||
@@ -1 +0,0 @@
|
||||
bochs/android/bochs/AndroidAppSettings.cfg
|
||||
@@ -1 +0,0 @@
|
||||
bochs/android/bochs/AndroidBuild.sh
|
||||
@@ -1 +0,0 @@
|
||||
bochs/android/bochs/AndroidData
|
||||
Submodule project/jni/application/bochs/bochs deleted from 14678cc8ea
@@ -1 +0,0 @@
|
||||
bochs/android/bochs/icon.png
|
||||
1
project/jni/application/c-dogs/.gitignore
vendored
1
project/jni/application/c-dogs/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/AndroidData
|
||||
@@ -1,237 +0,0 @@
|
||||
# The application settings for Android libSDL port
|
||||
|
||||
# Specify application name (e.x. My Application)
|
||||
AppName="C-Dogs"
|
||||
|
||||
# Specify reversed site name of application (e.x. com.mysite.myapp)
|
||||
AppFullName=cxong.cdogs
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=101
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.01"
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
AppDataDownloadUrl="!!Game data|data.zip"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=n
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade="%"
|
||||
|
||||
# Here you may type readme text, which will be shown during startup. Format is:
|
||||
# Text in English, use \\\\n to separate lines (that's four backslashes)^de:Text in Deutsch^ru:Text in Russian^button:Button that will open some URL:http://url-to-open/
|
||||
ReadmeText='^Readme text'
|
||||
|
||||
# libSDL version to use (1.2/1.3/2.0)
|
||||
LibSdlVersion=1.2
|
||||
|
||||
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
|
||||
ScreenOrientation=h
|
||||
|
||||
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=n
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
VideoDepthBpp=16
|
||||
|
||||
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedDepthBuffer=n
|
||||
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=n
|
||||
|
||||
# Application video output will be resized to fit into native device screen (y)/(n)
|
||||
SdlVideoResize=y
|
||||
|
||||
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
|
||||
SdlVideoResizeKeepAspect=y
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
CompatibilityHacks=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=n
|
||||
|
||||
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
|
||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||
|
||||
# Hack for VCMI: preload additional shared libraries before aplication start
|
||||
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||
|
||||
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
|
||||
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
|
||||
CompatibilityHacksSlowCompatibleEventQueue=n
|
||||
|
||||
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
|
||||
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n
|
||||
|
||||
# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects.
|
||||
# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)
|
||||
CompatibilityHacksProperUsageOfSDL_UpdateRects=
|
||||
|
||||
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
|
||||
AppUsesMouse=n
|
||||
|
||||
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
|
||||
AppNeedsTwoButtonMouse=n
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=
|
||||
|
||||
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
|
||||
ForceRelativeMouseMode=n
|
||||
|
||||
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
|
||||
AppNeedsArrowKeys=y
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=y
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
AppUsesJoystick=n
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=n
|
||||
|
||||
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
|
||||
AppUsesAccelerometer=n
|
||||
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=n
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=n
|
||||
|
||||
# Application records audio (it will use any available source, such a s microphone)
|
||||
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application needs to access SD card. If your data files are bigger than 5 Mb, enable it. (y) / (n)
|
||||
AccessSdCard=
|
||||
|
||||
# Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n)
|
||||
ImmersiveMode=
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
# This option is reported to be buggy, sometimes failing to restore video state
|
||||
NonBlockingSwapBuffers=n
|
||||
|
||||
# Redefine common hardware keys to SDL keysyms
|
||||
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
|
||||
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
|
||||
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
|
||||
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
|
||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP SPACE ESCAPE"
|
||||
|
||||
# Number of virtual keyboard keys (currently 6 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmount=3
|
||||
|
||||
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
|
||||
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
|
||||
RedefinedKeysScreenKb="RETURN RSHIFT TAB"
|
||||
|
||||
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
|
||||
RedefinedKeysScreenKbNames="Fire Weapons Map"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
TouchscreenKeysTheme=1
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
RedefinedKeysGamepad="RETURN RSHIFT TAB TAB RSHIFT RETURN"
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=0
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
HiddenMenuOptions=''
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
FirstStartMenuOptions=''
|
||||
|
||||
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
|
||||
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
|
||||
MultiABI=all
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="sdl_image sdl_mixer"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=n
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags='-O2 -finline-functions -D__MACTYPES__ --include jni/application/android_debug.h'
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags=''
|
||||
|
||||
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
|
||||
AppOverlapsSystemHeaders=
|
||||
|
||||
# Build only following subdirs (empty will build all dirs, ignored with custom script)
|
||||
AppSubdirsBuild='src/src src/src/cdogs src/src/json src/src/missions src/src/tinydir src/src/cdogs/hqx/src'
|
||||
|
||||
# Exclude these files from build
|
||||
AppBuildExclude='src/src/cdogsed.c src/src/cdogs/hqx/src/hqx.c'
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline='cdogs --fullscreen --screen=800x480'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
MinimumScreenSize=s
|
||||
|
||||
# Your AdMob Publisher ID, (n) if you don't want advertisements
|
||||
AdmobPublisherId=n
|
||||
|
||||
# Your AdMob test device ID, to receive a test ad
|
||||
AdmobTestDeviceId=
|
||||
|
||||
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
|
||||
AdmobBannerSize=
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Patching..."
|
||||
[ -e src/patched.flag ] || { patch -p1 -d src < android.diff && touch src/patched.flag || exit 1 ; }
|
||||
|
||||
echo "Archiving data"
|
||||
mkdir -p AndroidData
|
||||
cd src
|
||||
#git submodule update --init --recursive
|
||||
cmake . -DCDOGS_DATA_DIR=\"./\" || { echo "Please install cmake: sudo apt-get install cmake" ; exit 1 ; } || exit 1
|
||||
zip -r ../AndroidData/data.zip doc dogfights graphics missions music sounds >/dev/null
|
||||
|
||||
exit 0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user