djiuser_b9fA0wj643ey
lvl.1
Germany
Offline
|
I'm working on a camera app using Android Camera2 SDK which has button for start/stop recording, and a zoom functionality. I've integrated the DJI mobile SDK and I did the registration with the API key generated from the developer account. When I start the app, I receive a `REGISTRATION_SUCCESS` from `DJISDKManager.SDKManagerCallback()#onRegister()` and the Gimbal is connected through Bluetooth to the phone. I test the connectivity with handHeld.isConnected() which returns true.
Now the issue is, how can I intercept the hardware button press events from the Gimbal ?
I tried something like this, but it doesn't work. I couldn't find any documentation about how to receive callbacks when hardware buttons are pressed.
HandHeld handHeld = (HandHeld) DJISDKManager.getInstance().getProduct();
handHeld.getHandHeldController().setHardwareStateCallback(hardwareState -> {
switch (hardwareState.getRecordAndShutterButtons()) {
case IDLE: {
Log.e(TAG, "getRecordAndShutterButtons IDLE");
break;
}
case RECORD_CLICK: {
Log.e(TAG, "getRecordAndShutterButtons RECORD_CLICK");
break;
}
case SHUTTER_CLICK: {
Log.e(TAG, "getRecordAndShutterButtons SHUTTER_CLICK");
break;
}
case SHUTTER_LONG_CLICK: {
Log.e(TAG, "getRecordAndShutterButtons SHUTTER_LONG_CLICK");
break;
}
default: {
Log.e(TAG, "getRecordAndShutterButtons UNKNOWN");
}
}
switch (hardwareState.getZoomState()) {
case IDLE: {
Log.e(TAG, "getZoomState IDLE");
break;
}
case ZOOM_IN: {
Log.e(TAG, "getZoomState ZOOM_IN");
break;
}
case ZOOM_OUT: {
Log.e(TAG, "getZoomState ZOOM_OUT");
break;
}
default: {
Log.e(TAG, "getTriggerButton UNKNOWN");
}
}
});
I tested hardwareState.getStickVerticalDirection() and hardwareState.getStickHorizontalDirection(), by moving the joystick analog and I get approximately the correct values (left/right/up/down)
but all other functions like hardwareState.getZoomState() or hardwareState.getRecordAndShutterButtons() they always return IDLE state. (when I press the record button, for some reason it increases the audio of the phone, and the volume seek bar appears, its like Im pressing the volume button)
These are some logs from handHeld.getHandHeldController().setHardwareStateCallback() that I receive randomly without pressing any button:
/com.dji.sdk.sample E/Camera2: getRecordAndShutterButtons IDLE
/com.dji.sdk.sample E/Camera2: getZoomState IDLE
/com.dji.sdk.sample E/Camera2: getTriggerButton IDLE
/com.dji.sdk.sample E/Camera2: getModeButton IDLE
/com.dji.sdk.sample E/Camera2: getRecordAndShutterButtons IDLE
/com.dji.sdk.sample E/Camera2: getZoomState IDLE
/com.dji.sdk.sample E/Camera2: getTriggerButton IDLE
/com.dji.sdk.sample E/Camera2: getModeButton IDLE
/com.dji.sdk.sample E/Camera2: getRecordAndShutterButtons IDLE
/com.dji.sdk.sample E/Camera2: getZoomState IDLE
/com.dji.sdk.sample E/Camera2: getTriggerButton IDLE
/com.dji.sdk.sample E/Camera2: getModeButton IDLE
The model name is: OM5-602S46
Im using the Sample code app to test these hardware buttons callbacks.
It would be great that someone could help me on this.
|
|