-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f74ebb
commit 7133284
Showing
21 changed files
with
1,502 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ | |
</activity> | ||
</application> | ||
|
||
</manifest> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SDL2 Example | ||
|
||
This is a copy-paste of [Andrew Kelly's SDL Zig Demo](https://github.com/andrewrk/sdl-zig-demo) but running on Android. The build is setup so you can also target your native operating system as well. | ||
|
||
### Build and install to test one target against a local emulator | ||
|
||
```sh | ||
zig build -Dtarget=x86_64-linux-android | ||
adb install ./zig-out/bin/sdl-zig-demo.apk | ||
``` | ||
|
||
### Build and install for all supported Android targets | ||
|
||
```sh | ||
zig build -Dandroid=true | ||
adb install ./zig-out/bin/sdl-zig-demo.apk | ||
``` | ||
|
||
### Build and run natively on your operating system | ||
|
||
```sh | ||
zig build run | ||
``` | ||
|
||
### Uninstall your application | ||
|
||
If installing your application fails with something like: | ||
``` | ||
adb: failed to install ./zig-out/bin/sdl2.apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Existing package com.zig.sdl2 signatures do not match newer version; ignoring!] | ||
``` | ||
|
||
```sh | ||
adb uninstall "com.zig.sdl2" | ||
``` | ||
|
||
### View logs of application | ||
|
||
Powershell | ||
```sh | ||
adb logcat | Select-String com.zig.sdl2: | ||
``` | ||
|
||
Bash | ||
```sh | ||
adb logcat --pid=`adb shell pidof -s com.zig.sdl2` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:versionCode="1" | ||
android:versionName="1.0" | ||
android:installLocation="auto" | ||
package="com.zig.sdl2"> | ||
<!-- | ||
Based on: | ||
https://github.com/libsdl-org/SDL/blob/release-2.30.7/android-project/app/src/main/AndroidManifest.xml | ||
--> | ||
|
||
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="35" /> | ||
|
||
<!-- 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 downloading to the external storage on Android 5.1 and older --> | ||
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="22" /> --> | ||
|
||
<!-- Allow access to Bluetooth devices --> | ||
<!-- Currently this is just for Steam Controller support and requires setting SDL_HINT_JOYSTICK_HIDAPI_STEAM --> | ||
<!-- <uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" /> --> | ||
<!-- <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" /> --> | ||
|
||
<!-- Allow access to the vibrator --> | ||
<uses-permission android:name="android.permission.VIBRATE" /> | ||
|
||
<!-- 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="@mipmap/ic_launcher" | ||
android:allowBackup="true" | ||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" | ||
android:hardwareAccelerated="true" | ||
android:debuggable="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="ZigSDLActivity" | ||
android:label="@string/app_name" | ||
android:alwaysRetainTaskState="true" | ||
android:launchMode="singleInstance" | ||
android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" | ||
android:preferMinimalPostProcessing="true" | ||
android:exported="true" | ||
> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
<!-- Let Android know that we can handle some USB devices and should receive this event --> | ||
<!-- <intent-filter> | ||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> | ||
</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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<!-- Pretty name of your app --> | ||
<string name="app_name">Zig SDL2</string> | ||
<!-- | ||
This is required for the APK name. This identifies your app, Android will associate | ||
your signing key with this identifier and will prevent updates if the key changes. | ||
--> | ||
<string name="package_name">com.zig.sdl2</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.zig.sdl2; // <- Your game package name | ||
|
||
import org.libsdl.app.SDLActivity; | ||
|
||
/** | ||
* A sample wrapper class that just calls SDLActivity | ||
*/ | ||
public class ZigSDLActivity extends SDLActivity { | ||
// @Override | ||
// protected String[] getLibraries() { | ||
// return new String[] { | ||
// "hidapi", | ||
// "SDL2", | ||
// // "SDL2_image", | ||
// // "SDL2_mixer", | ||
// // "SDL2_net", | ||
// // "SDL2_ttf", | ||
// "main" | ||
// }; | ||
// } | ||
} |
Oops, something went wrong.