mirror of https://github.com/encounter/SDL.git
Implement SDL_HapticStopEffect on Android (thanks Rachel!)
This commit is contained in:
parent
a794126d56
commit
09ab752aa3
|
@ -81,6 +81,14 @@ public class SDLControllerManager
|
||||||
mHapticHandler.run(device_id, length);
|
mHapticHandler.run(device_id, 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
|
// Check if a given device is considered a possible SDL joystick
|
||||||
public static boolean isDeviceSDLJoystick(int deviceId) {
|
public static boolean isDeviceSDLJoystick(int deviceId) {
|
||||||
InputDevice device = InputDevice.getDevice(deviceId);
|
InputDevice device = InputDevice.getDevice(deviceId);
|
||||||
|
@ -422,6 +430,13 @@ class SDLHapticHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void stop(int device_id) {
|
||||||
|
SDLHaptic haptic = getHaptic(device_id);
|
||||||
|
if (haptic != null) {
|
||||||
|
haptic.vib.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void pollHapticDevices() {
|
public void pollHapticDevices() {
|
||||||
|
|
||||||
final int deviceId_VIBRATOR_SERVICE = 999999;
|
final int deviceId_VIBRATOR_SERVICE = 999999;
|
||||||
|
|
|
@ -258,6 +258,7 @@ static jclass mControllerManagerClass;
|
||||||
static jmethodID midPollInputDevices;
|
static jmethodID midPollInputDevices;
|
||||||
static jmethodID midPollHapticDevices;
|
static jmethodID midPollHapticDevices;
|
||||||
static jmethodID midHapticRun;
|
static jmethodID midHapticRun;
|
||||||
|
static jmethodID midHapticStop;
|
||||||
|
|
||||||
/* static fields */
|
/* static fields */
|
||||||
static jfieldID fidSeparateMouseAndTouch;
|
static jfieldID fidSeparateMouseAndTouch;
|
||||||
|
@ -430,8 +431,10 @@ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv* mEn
|
||||||
"pollHapticDevices", "()V");
|
"pollHapticDevices", "()V");
|
||||||
midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
|
midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
|
||||||
"hapticRun", "(II)V");
|
"hapticRun", "(II)V");
|
||||||
|
midHapticStop = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass,
|
||||||
|
"hapticStop", "(I)V");
|
||||||
|
|
||||||
if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun) {
|
if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun || !midHapticStop) {
|
||||||
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLControllerManager.java?");
|
__android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLControllerManager.java?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1892,6 +1895,11 @@ void Android_JNI_HapticRun(int device_id, int length)
|
||||||
(*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticRun, device_id, length);
|
(*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticRun, device_id, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Android_JNI_HapticStop(int device_id)
|
||||||
|
{
|
||||||
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
(*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticStop, device_id);
|
||||||
|
}
|
||||||
|
|
||||||
/* See SDLActivity.java for constants. */
|
/* See SDLActivity.java for constants. */
|
||||||
#define COMMAND_SET_KEEP_SCREEN_ON 5
|
#define COMMAND_SET_KEEP_SCREEN_ON 5
|
||||||
|
|
|
@ -79,6 +79,7 @@ void Android_JNI_PollInputDevices(void);
|
||||||
/* Haptic support */
|
/* Haptic support */
|
||||||
void Android_JNI_PollHapticDevices(void);
|
void Android_JNI_PollHapticDevices(void);
|
||||||
void Android_JNI_HapticRun(int device_id, int length);
|
void Android_JNI_HapticRun(int device_id, int length);
|
||||||
|
void Android_JNI_HapticStop(int device_id);
|
||||||
|
|
||||||
/* Video */
|
/* Video */
|
||||||
void Android_JNI_SuspendScreenSaver(SDL_bool suspend);
|
void Android_JNI_SuspendScreenSaver(SDL_bool suspend);
|
||||||
|
|
|
@ -238,6 +238,7 @@ SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
|
||||||
int
|
int
|
||||||
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect)
|
||||||
{
|
{
|
||||||
|
Android_JNI_HapticStop (((SDL_hapticlist_item *)haptic->hwdata)->device_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue