Skip to content

Commit

Permalink
Added javadoc comments to document methods used by JNI.
Browse files Browse the repository at this point in the history
  • Loading branch information
philippwiesemann committed May 29, 2014
1 parent eac27bc commit f29ac39
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions android-project/src/org/libsdl/app/SDLActivity.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -297,24 +297,37 @@ public static native int nativeAddJoystick(int device_id, String name,
int naxes, int nhats, int nballs); int naxes, int nhats, int nballs);
public static native int nativeRemoveJoystick(int device_id); public static native int nativeRemoveJoystick(int device_id);


/**
* This method is called by SDL using JNI.
*/
public static void flipBuffers() { public static void flipBuffers() {
SDLActivity.nativeFlipBuffers(); SDLActivity.nativeFlipBuffers();
} }


/**
* This method is called by SDL using JNI.
*/
public static boolean setActivityTitle(String title) { public static boolean setActivityTitle(String title) {
// Called from SDLMain() thread and can't directly affect the view // Called from SDLMain() thread and can't directly affect the view
return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title); return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
} }


/**
* This method is called by SDL using JNI.
*/
public static boolean sendMessage(int command, int param) { public static boolean sendMessage(int command, int param) {
return mSingleton.sendCommand(command, Integer.valueOf(param)); return mSingleton.sendCommand(command, Integer.valueOf(param));
} }


/**
* This method is called by SDL using JNI.
*/
public static Context getContext() { public static Context getContext() {
return mSingleton; return mSingleton;
} }


/** /**
* This method is called by SDL using JNI.
* @return result of getSystemService(name) but executed on UI thread. * @return result of getSystemService(name) but executed on UI thread.
*/ */
public Object getSystemServiceFromUiThread(final String name) { public Object getSystemServiceFromUiThread(final String name) {
Expand Down Expand Up @@ -380,16 +393,26 @@ public void run() {
} }
} }


/**
* This method is called by SDL using JNI.
*/
public static boolean showTextInput(int x, int y, int w, int h) { public static boolean showTextInput(int x, int y, int w, int h) {
// Transfer the task to the main thread as a Runnable // Transfer the task to the main thread as a Runnable
return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h)); return mSingleton.commandHandler.post(new ShowTextInputTask(x, y, w, h));
} }


/**
* This method is called by SDL using JNI.
*/
public static Surface getNativeSurface() { public static Surface getNativeSurface() {
return SDLActivity.mSurface.getNativeSurface(); return SDLActivity.mSurface.getNativeSurface();
} }


// Audio // Audio

/**
* This method is called by SDL using JNI.
*/
public static int audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) { public static int audioInit(int sampleRate, boolean is16Bit, boolean isStereo, int desiredFrames) {
int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO; int channelConfig = isStereo ? AudioFormat.CHANNEL_CONFIGURATION_STEREO : AudioFormat.CHANNEL_CONFIGURATION_MONO;
int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; int audioFormat = is16Bit ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT;
Expand Down Expand Up @@ -423,7 +446,10 @@ public static int audioInit(int sampleRate, boolean is16Bit, boolean isStereo, i


return 0; return 0;
} }


/**
* This method is called by SDL using JNI.
*/
public static void audioWriteShortBuffer(short[] buffer) { public static void audioWriteShortBuffer(short[] buffer) {
for (int i = 0; i < buffer.length; ) { for (int i = 0; i < buffer.length; ) {
int result = mAudioTrack.write(buffer, i, buffer.length - i); int result = mAudioTrack.write(buffer, i, buffer.length - i);
Expand All @@ -441,7 +467,10 @@ public static void audioWriteShortBuffer(short[] buffer) {
} }
} }
} }


/**
* This method is called by SDL using JNI.
*/
public static void audioWriteByteBuffer(byte[] buffer) { public static void audioWriteByteBuffer(byte[] buffer) {
for (int i = 0; i < buffer.length; ) { for (int i = 0; i < buffer.length; ) {
int result = mAudioTrack.write(buffer, i, buffer.length - i); int result = mAudioTrack.write(buffer, i, buffer.length - i);
Expand All @@ -460,6 +489,9 @@ public static void audioWriteByteBuffer(byte[] buffer) {
} }
} }


/**
* This method is called by SDL using JNI.
*/
public static void audioQuit() { public static void audioQuit() {
if (mAudioTrack != null) { if (mAudioTrack != null) {
mAudioTrack.stop(); mAudioTrack.stop();
Expand All @@ -470,6 +502,7 @@ public static void audioQuit() {
// Input // Input


/** /**
* This method is called by SDL using JNI.
* @return an array which may be empty but is never null. * @return an array which may be empty but is never null.
*/ */
public static int[] inputGetInputDeviceIds(int sources) { public static int[] inputGetInputDeviceIds(int sources) {
Expand All @@ -484,12 +517,15 @@ public static int[] inputGetInputDeviceIds(int sources) {
} }
return Arrays.copyOf(filtered, used); return Arrays.copyOf(filtered, used);
} }

// Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance // Joystick glue code, just a series of stubs that redirect to the SDLJoystickHandler instance
public static boolean handleJoystickMotionEvent(MotionEvent event) { public static boolean handleJoystickMotionEvent(MotionEvent event) {
return mJoystickHandler.handleMotionEvent(event); return mJoystickHandler.handleMotionEvent(event);
} }


/**
* This method is called by SDL using JNI.
*/
public static void pollInputDevices() { public static void pollInputDevices() {
if (SDLActivity.mSDLThread != null) { if (SDLActivity.mSDLThread != null) {
mJoystickHandler.pollInputDevices(); mJoystickHandler.pollInputDevices();
Expand Down

0 comments on commit f29ac39

Please sign in to comment.