project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/frontlib/Flib.java
equal
deleted
inserted
replaced
|
1 package org.hedgewars.hedgeroid.frontlib; |
|
2 |
|
3 import java.util.Collections; |
|
4 |
|
5 import android.util.Log; |
|
6 |
|
7 import com.sun.jna.Library; |
|
8 import com.sun.jna.Native; |
|
9 |
|
10 public class Flib { |
|
11 static { |
|
12 System.loadLibrary("SDL_net"); |
|
13 System.setProperty("jna.encoding", "UTF8"); // Ugly global setting, but it seems JNA doesn't allow setting this per-library... |
|
14 } |
|
15 public static final Frontlib INSTANCE = (Frontlib)Native.loadLibrary("frontlib", Frontlib.class, Collections.singletonMap(Library.OPTION_TYPE_MAPPER, FrontlibTypeMapper.INSTANCE)); |
|
16 |
|
17 // Hook frontlib logging into Android logging |
|
18 private static final Frontlib.LogCallback logCb = new Frontlib.LogCallback() { |
|
19 public void callback(int level, String message) { |
|
20 if(level >= Frontlib.FLIB_LOGLEVEL_ERROR) { |
|
21 Log.e("Frontlib", message); |
|
22 } else if(level == Frontlib.FLIB_LOGLEVEL_WARNING){ |
|
23 Log.w("Frontlib", message); |
|
24 } else if(level == Frontlib.FLIB_LOGLEVEL_INFO){ |
|
25 Log.i("Frontlib", message); |
|
26 } else if(level <= Frontlib.FLIB_LOGLEVEL_DEBUG){ |
|
27 Log.d("Frontlib", message); |
|
28 } |
|
29 } |
|
30 }; |
|
31 static { |
|
32 INSTANCE.flib_log_setLevel(Frontlib.FLIB_LOGLEVEL_ALL); |
|
33 INSTANCE.flib_log_setCallback(logCb); |
|
34 } |
|
35 } |