#include "service_id_define.h"
#include "dock/input_device.h"
#include "custom_runtime.h"
-#include "input_app.h"
#include "wearable_log.h"
-
- #include "ln_api.h"
+#include "graphic_service.h"
+#include "ln_api.h"
#include "power_display_service.h"
+#ifdef __cplusplus
+ extern "C"
+ {
+#endif
+#include "input_app.h"
+#ifdef __cplusplus
+ }
+#endif
#ifdef CUSTOM_UTILS
#include "custom_utils.h"
#endif
namespace OHOS
{
+ // 静态回调函数声明
+ static void HandleFuncKeyLongPressCallBack(void);
REGIST_SLICE(VIEW_THUNDER_BIRD, ThunderBirdMainView, ThunderBirdPresenter);
// 注册 VENDOR_DOWN 长按5秒事件
// uapi_button_register_event_cb(func_button_callback_vendor_down_long_press_5s, BUTTON3_LONGPRESS_5S);
+
+ // 注册 FUNC 键长按2秒事件
+ int32_t ret = uapi_button_register_event_cb(HandleFuncKeyLongPressCallBack, BUTTON1_LONGPRESS_2S);
+ if (ret != ERRCODE_SUCC)
+ {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event error, ret = %d", ret);
+ }
+ else
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Register FuncKey LongPress Event success");
+ }
}
bool ThunderBirdPresenter::HandleFuncKey(uint16_t keyState, int16_t currentView, int16_t currentSubView, int screenState)
{
// 长按FUNC键:开启对话模式切换
- if (keyState == InputDevice::STATE_LONG_PRESS && screenState == 0) {
- //NativeAbility::GetInstance().SwitchSlice(VIEW_LCD_TEST);
- if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW)
- {
- ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
- isDialogueing = true;
- }
- else
- {
- ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
- isDialogueing = false;
- }
- return true;
- }
+ // if (keyState == InputDevice::STATE_LONG_PRESS && screenState == 0) {
+ // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKey: KEY_TYPE_FUNC long press");
+ // //NativeAbility::GetInstance().SwitchSlice(VIEW_LCD_TEST);
+ // if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW)
+ // {
+ // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+ // isDialogueing = true;
+ // }
+ // else
+ // {
+ // ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
+ // isDialogueing = false;
+ // }
+ // return true;
+ // }
// 短按FUNC键(息屏状态下)
if (keyState == InputDevice::STATE_PRESS && screenState == 0 ) {
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKey: KEY_TYPE_FUNC press");
if(currentView == THUNDERBIRD_LULLABYVIEW && currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3)
{
HandleLullabyFunction(currentView, currentSubView);
*/
void ThunderBirdPresenter::HandleDialogueFunction(int16_t currentView, int16_t currentSubView)
{
- bool flag = ThunderBirdModel::GetInstance()->Get_is_all_services_ready();
- if(flag == false)
- {
- return;
- }
+ //bool flag = ThunderBirdModel::GetInstance()->Get_is_all_services_ready();
+ // if(flag == false)
+ // {
+ // return;
+ // }
if (currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING) {
// 停止录音并发送
- // ThunderBirdModel::GetInstance()->StopRecording();
ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
- // ThunderBirdModel::GetInstance()->SendRecording();
- uapi_stop_AI_asr();
+ ln_ws_end_audio_chat();
} else {
// 开始录音
ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
- // ThunderBirdModel::GetInstance()->StartRecording();
- uapi_start_AI_asr();
+ ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);
}
}
ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3);
break;
case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3:
- do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_RANDOM, NULL, 0);//随机故事
+ //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_RANDOM, NULL, 0);//随机故事
ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
break;
case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4:
break;
case ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_5:
do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_STORY_FINISH, NULL, 0);//确认结束哄睡
- ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
+ ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
break;
}
}
ThunderBirdModel::GetInstance()->SetQrcodeChecked(true);
}
+ // ==================== FUNC键长按功能 ====================
+
+ static void HandleFuncKeyLongPressCallBack(void)
+ {
+ if (ThunderBirdPresenter::GetInstance()) {
+ ThunderBirdPresenter::GetInstance()->HandleFuncKeyLongPress();
+ }
+ }
+ /**
+ * @brief 处理FUNC键长按事件
+ */
+ void ThunderBirdPresenter::HandleFuncKeyLongPress(void)
+ {
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::HandleFuncKeyLongPress - FUNC key long press detected");
+ // 长按FUNC键2秒的处理逻辑
+ // 触发对话模式切换
+ if (ThunderBirdMainView::GetInstance()) {
+ int16_t currentView = ThunderBirdMainView::GetInstance()->GetCurrentView();
+ int16_t currentSubView = ThunderBirdMainView::GetInstance()->GetCurrentSubView();
+
+ if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW)
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+ isDialogueing = true;
+ }
+ else
+ {
+ ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
+ isDialogueing = false;
+ }
+ }
+ }
+
}