MotionDJ.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:66k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*******************************************************************************
  36.  * Filename:
  37.  * ---------
  38.  *  MotionDJ.c
  39.  *
  40.  * Project:
  41.  * --------
  42.  *  MAUI
  43.  *
  44.  * Description:
  45.  * ------------
  46.  *  Motion Game - DJ
  47.  *
  48.  * Author:
  49.  * -------
  50.  * -------
  51.  *
  52.  *============================================================================
  53.  *             HISTORY
  54.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  55.  *------------------------------------------------------------------------------
  56.  * removed!
  57.  * removed!
  58.  * removed!
  59.  *
  60.  * removed!
  61.  * removed!
  62.  * removed!
  63.  *
  64.  * removed!
  65.  * removed!
  66.  * removed!
  67.  *
  68.  * removed!
  69.  * removed!
  70.  * removed!
  71.  *
  72.  *------------------------------------------------------------------------------
  73.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  74.  *============================================================================
  75.  *******************************************************************************/
  76. #ifndef _MMI_MOTION_DJ_C
  77. #define _MMI_MOTION_DJ_C
  78. #define __NEWSIMULATOR 
  79. #include "MMI_features.h" /* features */
  80. #include "stdC.h" /* Datatype */
  81. #include "GameInc.h" /* Game Include */
  82. #ifdef IS_DJ_BASE_MOTIONGAME /* this must after GameInc.h" */
  83. #include "gdi_include.h" /* GDI */
  84. #include "MotionDJDefs.h"
  85. #include "filemgr.h" /* file related */
  86. #include "FileManagerGProt.h" /* file related */
  87. #include "MainMenuDef.h" /* fun&game icon id */
  88. #include "NVRAMType.h" /* NVRAM data type */
  89. #include "NVRAMProt.h" /* NVRAM access fucntions */
  90. #include "NVRAMEnum.h" /* NVRAM ID define */
  91. #include "CommonScreens.h" /* DisplayPopup() */
  92. #include "GlobalConstants.h" /* KEY ID define */
  93. #include "GlobalDefs.h" /* Golbal Image and string ID */
  94. #include "gui.h" /* Gui functions */
  95. #include "wgui_categories.h" /* Categories */
  96. #include "wgui_categories_inputs.h" /* inputs */
  97. #include "HistoryGprot.h" /* Screen history */
  98. #include "Unicodexdcl.h" /* Unicode transform functions */
  99. #include "gpioInc.h" /* LED related */
  100. #include "KeyBrd.h" /* keypad tone related interface */
  101. #include "mmiapi_enum.h" /* Stop LED */
  102. #include "GameFramework.h" /* for game settings */
  103. #include "filemgr.h" /* file manager */
  104. #include "mdi_datatype.h" /* mdi datatype */
  105. #include "mdi_audio.h" /* audio */
  106. #include "mdi_motion.h" /* motion sensor */
  107. /***************************************************************************** 
  108. * Include
  109. *****************************************************************************/
  110. /***************************************************************************** 
  111. * Define
  112. *****************************************************************************/
  113. #define DJ_MENU_ICON_IMG_ID MAIN_MENU_TITLE_FUNANDGAMES_ICON
  114. #define DJ_AUDIO_COUNT (10)
  115. #define DJ_VOLUME_LEVEL (7)
  116. #define DJ_NUM_OF_INSTRUMENT_ENTRY  (3)
  117. #define DJ_NUM_OF_VOCAL_ENTRY  (3)
  118. #define DJ_NUM_OF_ALL_ENTRY (DJ_NUM_OF_INSTRUMENT_ENTRY+DJ_NUM_OF_VOCAL_ENTRY)
  119. #define DJ_ICON_FADE_TIME (300)
  120. #define DJ_FONT_COLOR (pixtel_UI_color(255, 255, 255))
  121. #define DJ_FONT_BORDER_COLOR (pixtel_UI_color(0, 0, 0))
  122. #define DJ_SEL_FONT_COLOR (pixtel_UI_color(255, 255, 255))
  123. #define DJ_SEL_FONT_BORDER_COLOR (pixtel_UI_color(255, 0, 0))
  124. /* turn on this flag will enable indivisual audio's volume config - mdi/med not implement yet */
  125. //#define DJ_ENABLE_INDIVISUAL_VOLUME
  126. /***************************************************************************** 
  127. * Typedef 
  128. *****************************************************************************/
  129. typedef enum {
  130. DJ_TRIGGER_NONE,
  131. DJ_TRIGGER_AUTO,
  132. DJ_TRIGGER_SHAKE,
  133. DJ_TRIGGER_PRESS,
  134. NUM_OF_DJ_TRIGGER_TYPE
  135. } dj_trigger_type_enum;
  136. typedef enum {
  137. DJ_AUD_INSTRUMENT,
  138. DJ_AUD_VOCAL,
  139. NUM_OF_DJ_AUDIO_TYPE
  140. } dj_audio_type_enum;
  141. typedef enum {
  142. DJ_KEY_NONE,
  143. DJ_KEY_0,
  144. DJ_KEY_1,
  145. DJ_KEY_2,
  146. DJ_KEY_3,
  147. DJ_KEY_4,
  148. DJ_KEY_5,
  149. DJ_KEY_6,
  150. DJ_KEY_7,
  151. DJ_KEY_8,
  152. DJ_KEY_9,
  153. DJ_KEY_STAR,
  154. DJ_KEY_POUND,
  155. NUM_OF_DJ_KEY
  156. } dj_key_enum;
  157. /* 16 byte - NVRAM_EF_MOTION_DJ_SIZE */
  158. typedef struct {
  159. U16 audio_type; /* 2 byte */
  160. U16 audio_id; /* 2 byte */
  161. U16 vol; /* 2 byte */
  162. U16 trigger; /* 2 byte */
  163. U16 key; /* 2 byte */
  164. U16 reserve_1; /* 2 byte */
  165. U16 reserve_2; /* 2 byte */
  166. U16 reserve_3; /* 2 byte */
  167. } dj_event_struct;
  168. typedef struct{
  169. UI_string_type audio_str[DJ_AUDIO_COUNT];
  170. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  171. UI_string_type volume_str[DJ_VOLUME_LEVEL];
  172. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  173. UI_string_type trigger_str[NUM_OF_DJ_TRIGGER_TYPE];
  174. UI_string_type key_str[NUM_OF_DJ_KEY];
  175. /* selected */
  176. S32 audio_selected;
  177. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  178. S32 volume_selected;
  179. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  180. S32 trigger_selected;
  181. S32 key_selected;
  182. } setting_data_struct;
  183. typedef struct{
  184. BOOL is_trigger_sel;
  185. BOOL is_key_sel;
  186. BOOL is_text_sel;
  187. } dj_draw_state_struct;
  188. typedef struct{
  189. S32  icon_trigger_x;
  190. S32  icon_trigger_y;
  191. S32  icon_key_x;
  192. S32  icon_key_y;
  193. S32  text_x;
  194. S32  text_y;
  195. } dj_draw_pos_struct;
  196. /* context */
  197. typedef struct{
  198. S32  selected_idx;
  199. U16  selected_audio_type;
  200. U16  prev_trigger;
  201. GDI_HANDLE item_layer;
  202. GDI_HANDLE bg_layer;
  203. GDI_HANDLE bg_anim;
  204. MDI_HANDLE aud_bg_handle;
  205. MDI_HANDLE aud_handle[DJ_NUM_OF_ALL_ENTRY];
  206. BOOL is_key_pressed[NUM_OF_DJ_KEY];
  207. setting_data_struct inline_data;
  208. dj_event_struct event_list[DJ_NUM_OF_ALL_ENTRY];
  209. dj_draw_state_struct draw_state[DJ_NUM_OF_ALL_ENTRY];
  210. } dj_cntx_struct;
  211. const dj_draw_pos_struct g_dj_draw_pos[DJ_NUM_OF_ALL_ENTRY] = 
  212. {
  213. 3,  11,  52,  11,  92,  28,  /* inst 0 */
  214. 3,  42,  52,  42,  92,  59,  /* inst 1 */
  215. 3,  73,  52,  73,  92,  90,  /* inst 2 */
  216. 3, 103,  52, 103,  92, 121,  /* vox 0 */
  217. 3, 135,  52, 135,  92, 152,  /* vox 1 */
  218. 3, 166,  52,  166, 92, 183  /* vox 2 */
  219. };
  220. /***************************************************************************** 
  221. * Global Variable
  222. *****************************************************************************/
  223. /***************************************************************************** 
  224. * Global Function
  225. *****************************************************************************/
  226. extern void inline_select_menu_goto_item(S32 index);
  227. /***************************************************************************** 
  228. * Local Variable
  229. *****************************************************************************/
  230. dj_cntx_struct g_dj_cntx;
  231. /***************************************************************************** 
  232. * Local Function
  233. *****************************************************************************/
  234. /* app */
  235. static void mmi_motion_dj_highlight_start(void);
  236. static void mmi_motion_dj_highlight_setting(void);
  237. /* setting screen */
  238. static void mmi_motion_dj_entry_setting_scr(void);
  239. static void mmi_motion_dj_setting_highlight_hdlr(S32 index);
  240. /* edit screen */
  241. static void mmi_motion_dj_entry_edit_scr(void);
  242. static void mmi_motion_dj_exit_edit_scr(void);
  243. static void mmi_motion_dj_edit_highlight_hdlr(S32 index);
  244. static void mmi_motion_dj_edit_delay_play_audio(void);
  245. static void mmi_motion_dj_edit_trigger_highlight_handler(S32 index);
  246. static void mmi_motion_dj_edit_audio_highlight_handler(S32 index);
  247. static void mmi_motion_dj_edit_key_highlight_handler(S32 index);
  248. static void mmi_motion_dj_edit_done(void);
  249. /* play screen */
  250. static void mmi_motion_dj_entry_play_scr(void);
  251. static void mmi_motion_dj_exit_play_scr(void);
  252. static void mmi_motion_dj_play_shake_trigger(void);
  253. static void mmi_motion_dj_draw_items(void);
  254. static void mmi_motion_dj_auto_play_finish_hdlr(mdi_handle handle, mdi_result result);
  255. static void mmi_motion_dj_auto_icon_timeout(void);
  256. static void mmi_motion_dj_shake_0_icon_timeout(void);
  257. static void mmi_motion_dj_shake_1_icon_timeout(void);
  258. static void mmi_motion_dj_shake_2_icon_timeout(void);
  259. static void mmi_motion_dj_shake_3_icon_timeout(void);
  260. static void mmi_motion_dj_shake_4_icon_timeout(void);
  261. static void mmi_motion_dj_shake_5_icon_timeout(void);
  262. static void mmi_motion_dj_play_key_0_press(void);
  263. static void mmi_motion_dj_play_key_0_release(void);
  264. static void mmi_motion_dj_play_key_1_press(void);
  265. static void mmi_motion_dj_play_key_1_release(void);
  266. static void mmi_motion_dj_play_key_2_press(void);
  267. static void mmi_motion_dj_play_key_2_release(void);
  268. static void mmi_motion_dj_play_key_3_press(void);
  269. static void mmi_motion_dj_play_key_3_release(void);
  270. static void mmi_motion_dj_play_key_4_press(void);
  271. static void mmi_motion_dj_play_key_4_release(void);
  272. static void mmi_motion_dj_play_key_5_press(void);
  273. static void mmi_motion_dj_play_key_5_release(void);
  274. static void mmi_motion_dj_play_key_6_press(void);
  275. static void mmi_motion_dj_play_key_6_release(void);
  276. static void mmi_motion_dj_play_key_7_press(void);
  277. static void mmi_motion_dj_play_key_7_release(void);
  278. static void mmi_motion_dj_play_key_8_press(void);
  279. static void mmi_motion_dj_play_key_8_release(void);
  280. static void mmi_motion_dj_play_key_9_press(void);
  281. static void mmi_motion_dj_play_key_9_release(void);
  282. static void mmi_motion_dj_play_key_star_press(void);
  283. static void mmi_motion_dj_play_key_star_release(void);
  284. static void mmi_motion_dj_play_key_pound_press(void);
  285. static void mmi_motion_dj_play_key_pound_release(void);
  286. /*****************************************************************************
  287. *
  288. * App                                                
  289. *
  290. *****************************************************************************/
  291. /*****************************************************************************
  292. * FUNCTION
  293. *  mmi_motion_dj_init_app()
  294. * DESCRIPTION
  295. *  init dj app
  296. * PARAMETERS
  297. *  void
  298. * RETURNS
  299. *   void
  300. * GLOBALS AFFECTED
  301. *   nil
  302. *****************************************************************************/
  303. void mmi_motion_dj_init_app(void)
  304. {
  305.    /*----------------------------------------------------------------*/
  306.    /* Code Body                                                      */
  307.    /*----------------------------------------------------------------*/
  308. SetHiliteHandler(MENU_ID_MOTION_DJ_START, mmi_motion_dj_highlight_start);
  309. SetHiliteHandler(MENU_ID_MOTION_DJ_SETTING, mmi_motion_dj_highlight_setting);
  310. }
  311. /*****************************************************************************
  312. * FUNCTION
  313. *  mmi_motion_dj_entry_app()
  314. * DESCRIPTION
  315. *   enter point of dj app
  316. * PARAMETERS
  317. *  void
  318. * RETURNS
  319. *   void
  320. * GLOBALS AFFECTED
  321. *   nil
  322. *****************************************************************************/
  323. BOOL dj_first_load;
  324. void mmi_motion_dj_entry_app(void)
  325. {
  326.    /*----------------------------------------------------------------*/
  327.    /* Local Variables                                                */
  328.    /*----------------------------------------------------------------*/
  329. U16 item_list[16];
  330. U16 item_icons[16];
  331. U16 num_item;
  332. U8 *gui_buffer;
  333. U8 *popup_list[32];
  334. S32 i;
  335. S32 idx;
  336. S16 error;
  337.    /*----------------------------------------------------------------*/
  338.    /* Code Body                                                      */
  339.    /*----------------------------------------------------------------*/
  340. EntryNewScreen(SCR_ID_MOTION_DJ_APP, NULL, mmi_motion_dj_entry_app, NULL);
  341. /* load value from NVRAM */
  342.   ReadRecord( NVRAM_EF_MOTION_DJ_LID, 
  343.    NVRAM_EF_MOTION_DJ_TOTAL, 
  344.    (void*)&g_dj_cntx.event_list[0], 
  345.    NVRAM_EF_MOTION_DJ_SIZE, 
  346.    &error);
  347. /* init if needed */
  348. #ifdef MMI_ON_WIN32
  349. if(g_dj_cntx.event_list[0].audio_type == 0 && dj_first_load)
  350. #else
  351. if(g_dj_cntx.event_list[0].audio_type == 0xffff)
  352. #endif
  353. {
  354. dj_first_load = FALSE;
  355. idx = 0;
  356. for(i = 0 ; i < DJ_NUM_OF_INSTRUMENT_ENTRY; i++)
  357. {
  358. g_dj_cntx.event_list[idx].audio_type  = DJ_AUD_INSTRUMENT;
  359. g_dj_cntx.event_list[idx].audio_id  = 0;
  360. g_dj_cntx.event_list[idx].vol  = LEVEL4;
  361. g_dj_cntx.event_list[idx].trigger  = DJ_TRIGGER_NONE;
  362. g_dj_cntx.event_list[idx].key   = DJ_KEY_NONE;
  363. idx++;
  364. }
  365. for(i = 0 ; i < DJ_NUM_OF_VOCAL_ENTRY; i++)
  366. {
  367. g_dj_cntx.event_list[idx].audio_type  = DJ_AUD_VOCAL;
  368. g_dj_cntx.event_list[idx].audio_id  = 0;
  369. g_dj_cntx.event_list[idx].vol  = LEVEL4;
  370. g_dj_cntx.event_list[idx].trigger  = DJ_TRIGGER_NONE;
  371. g_dj_cntx.event_list[idx].key  = DJ_KEY_NONE;
  372. idx++;
  373. }
  374. }
  375. gui_buffer = GetCurrGuiBuffer(SCR_ID_MOTION_DJ_APP);
  376. num_item = GetNumOfChild(MENU_ID_MOTION_DJ_APP);
  377. GetSequenceStringIds(MENU_ID_MOTION_DJ_APP, item_list);
  378. GetSequenceImageIds(MENU_ID_MOTION_DJ_APP, item_icons);
  379. SetParentHandler(MENU_ID_MOTION_DJ_APP);
  380. RegisterHighlightHandler(ExecuteCurrHiliteHandler);
  381. for(i = 0; i < num_item; i++)
  382. item_icons[i] = (U16) (IMG_GLOBAL_L1+i);
  383. for(i = 0 ; i < num_item; i++)
  384. popup_list[i] = NULL;
  385. ConstructHintsList(MENU_ID_MOTION_DJ_APP, popup_list);
  386. ShowCategory52Screen(STR_ID_MOTION_DJ_APP, DJ_MENU_ICON_IMG_ID,
  387. STR_GLOBAL_OK, IMG_GLOBAL_OK,
  388. STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  389. num_item, item_list, item_icons, (U8**)popup_list, 0, 0, gui_buffer);
  390. SetRightSoftkeyFunction(GoBackHistory,KEY_EVENT_UP);
  391. SetKeyHandler(GoBackHistory, KEY_LEFT_ARROW,KEY_EVENT_DOWN);
  392. }
  393. /*****************************************************************************
  394. * FUNCTION
  395. *  mmi_motion_dj_highlight_start()
  396. * DESCRIPTION
  397. *   highlight handler of start
  398. * PARAMETERS
  399. *  void
  400. * RETURNS
  401. *   void
  402. * GLOBALS AFFECTED
  403. *   nil
  404. *****************************************************************************/
  405. static void mmi_motion_dj_highlight_start(void)
  406. {
  407.    /*----------------------------------------------------------------*/
  408.    /* Code Body                                                      */
  409.    /*----------------------------------------------------------------*/
  410. SetLeftSoftkeyFunction(mmi_motion_dj_entry_play_scr, KEY_EVENT_UP);
  411. SetKeyHandler(mmi_motion_dj_entry_play_scr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  412. }
  413. /*****************************************************************************
  414. * FUNCTION
  415. *  mmi_motion_dj_highlight_start()
  416. * DESCRIPTION
  417. *   highlight handler of start
  418. * PARAMETERS
  419. *  void
  420. * RETURNS
  421. *   void
  422. * GLOBALS AFFECTED
  423. *   nil
  424. *****************************************************************************/
  425. static void mmi_motion_dj_highlight_setting(void)
  426. {
  427.    /*----------------------------------------------------------------*/
  428.    /* Code Body                                                      */
  429.    /*----------------------------------------------------------------*/
  430. SetLeftSoftkeyFunction(mmi_motion_dj_entry_setting_scr, KEY_EVENT_UP);
  431. SetKeyHandler(mmi_motion_dj_entry_setting_scr, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
  432. }
  433. /*****************************************************************************
  434. *
  435. * Setting Screen                                                
  436. *
  437. *****************************************************************************/
  438. /*****************************************************************************
  439. * FUNCTION
  440. *  mmi_motion_dj_entry_setting_scr()
  441. * DESCRIPTION
  442. *   enter setting screen
  443. * PARAMETERS
  444. *  void
  445. * RETURNS
  446. *   void
  447. * GLOBALS AFFECTED
  448. *   nil
  449. *****************************************************************************/
  450. static void mmi_motion_dj_entry_setting_scr(void)
  451. {
  452. /*----------------------------------------------------------------*/
  453.    /* Local Variables                                                */
  454.    /*----------------------------------------------------------------*/
  455. U8 *gui_buffer;
  456. U16  icon_list_1[MAX_SUB_MENUS]; 
  457. U16  icon_list_2[MAX_SUB_MENUS]; 
  458. S32 i;
  459.    /*----------------------------------------------------------------*/
  460.    /* Code Body                                                      */
  461.    /*----------------------------------------------------------------*/
  462. EntryNewScreen(SCR_ID_MOTION_DJ_SETTING, NULL, mmi_motion_dj_entry_setting_scr, NULL);
  463. gui_buffer = GetCurrGuiBuffer(SCR_ID_MOTION_DJ_SETTING);
  464. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  465. {
  466. if(i < DJ_NUM_OF_INSTRUMENT_ENTRY)
  467. {
  468. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  469. {
  470. pfnUnicodeStrcpy((PS8)subMenuDataPtrs[i],
  471. (PS8)GetString((U16)(STR_ID_MOTION_DJ_INSTRUMENT_0+g_dj_cntx.event_list[i].audio_id)));
  472. }
  473. else
  474. {
  475. pfnUnicodeStrcpy( (PS8)subMenuDataPtrs[i], 
  476. (PS8)GetString(STR_ID_MOTION_DJ_INSTRUMENT_TITLE_1+i));
  477. }
  478. }
  479. else
  480. {
  481. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  482. {
  483. pfnUnicodeStrcpy((PS8)subMenuDataPtrs[i],
  484. (PS8)GetString((U16)(STR_ID_MOTION_DJ_VOCAL_0+g_dj_cntx.event_list[i].audio_id)));
  485. }
  486. else
  487. {
  488. pfnUnicodeStrcpy( (PS8)subMenuDataPtrs[i], 
  489. (PS8)GetString(STR_ID_MOTION_DJ_VOCAL_TITLE_1+i-DJ_NUM_OF_INSTRUMENT_ENTRY));
  490. }
  491. }
  492. icon_list_1[i] = (U16)(IMG_ID_MOTION_DJ_ICON_TRIGGER_NONE+g_dj_cntx.event_list[i].trigger);
  493. icon_list_2[i] = (U16)(IMG_ID_MOTION_DJ_ICON_KEY_DUMMY+g_dj_cntx.event_list[i].key);
  494. }
  495. /* get item count */
  496. RegisterHighlightHandler(mmi_motion_dj_setting_highlight_hdlr);
  497. ShowCategory73Screen(STR_ID_MOTION_DJ_SETTING, DJ_MENU_ICON_IMG_ID,
  498. STR_GLOBAL_OPTIONS,0,
  499. STR_GLOBAL_BACK, 0,
  500. DJ_NUM_OF_ALL_ENTRY,
  501. (U8**)subMenuDataPtrs, /* list of items */
  502. (U16*)icon_list_1,  /* list of icon1 */
  503. (U16*)icon_list_2, /* list of icon2 */
  504. (U16)0, /* highlighted item */
  505. gui_buffer,
  506. 1); /* display flag */
  507. SetLeftSoftkeyFunction(mmi_motion_dj_entry_edit_scr, KEY_EVENT_UP);
  508. SetRightSoftkeyFunction(GoBackHistory, KEY_EVENT_UP);
  509. }
  510. /*****************************************************************************
  511. * FUNCTION
  512. *  mmi_motion_dj_setting_highlight_hdlr()
  513. * DESCRIPTION
  514. *   highlight handler for settng
  515. * PARAMETERS
  516. *  index  IN highlighted item index
  517. * RETURNS
  518. *   void
  519. * GLOBALS AFFECTED
  520. *   nil
  521. *****************************************************************************/
  522. static void mmi_motion_dj_setting_highlight_hdlr(S32 index)
  523. {
  524.    /*----------------------------------------------------------------*/
  525.    /* Code Body                                                      */
  526.    /*----------------------------------------------------------------*/
  527. g_dj_cntx.selected_idx = index;
  528.    if(index < DJ_NUM_OF_INSTRUMENT_ENTRY)
  529.    {
  530. g_dj_cntx.selected_audio_type = DJ_AUD_INSTRUMENT;
  531.    }
  532.    else
  533.    {
  534. g_dj_cntx.selected_audio_type = DJ_AUD_VOCAL;
  535.    }
  536. }
  537. /*****************************************************************************
  538. *
  539. * Edit Screen                                                
  540. *
  541. *****************************************************************************/
  542. /*****************************************************************************
  543. * FUNCTION
  544. *  mmi_motion_dj_entry_edit_scr()
  545. * DESCRIPTION
  546. *   enter audio edit screen
  547. * PARAMETERS
  548. *  void
  549. * RETURNS
  550. *   void
  551. * GLOBALS AFFECTED
  552. *   nil
  553. *****************************************************************************/
  554. static void mmi_motion_dj_entry_edit_scr(void)
  555. {
  556.    /*----------------------------------------------------------------*/
  557.    /* Local Variables                                                */
  558.    /*----------------------------------------------------------------*/
  559. U8   *gui_buffer;
  560. U8 *input_buffer;
  561. U16  input_buffer_size;
  562. S32  item_idx;
  563. S32  i;
  564.    /*----------------------------------------------------------------*/
  565.    /* Code Body                                                      */
  566.    /*----------------------------------------------------------------*/
  567. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  568. /* TODO: can add dedicate icons */
  569. UI_image_ID_type item_icons[8] =
  570. {
  571. IMG_GLOBAL_L1, /* audio */
  572. 0,
  573. IMG_GLOBAL_L2, /* vol */
  574. 0,
  575. IMG_GLOBAL_L3, /* trigger */
  576. 0,
  577. IMG_GLOBAL_L4, /* key */
  578. 0,
  579. };
  580. #else
  581. /* TODO: can add dedicate icons */
  582. UI_image_ID_type item_icons[8] =
  583. {
  584. IMG_GLOBAL_L1, /* audio */
  585. 0,
  586. IMG_GLOBAL_L2, /* trigger */
  587. 0,
  588. IMG_GLOBAL_L3, /* key */
  589. 0,
  590. };
  591. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  592. EntryNewScreen(SCR_ID_MOTION_DJ_EDIT, mmi_motion_dj_exit_edit_scr, NULL, NULL);
  593. gui_buffer = GetCurrGuiBuffer(SCR_ID_MOTION_DJ_EDIT);
  594.    mdi_audio_suspend_background_play();
  595.    
  596. /* load setting to inline data */
  597. g_dj_cntx.inline_data.audio_selected  = g_dj_cntx.event_list[g_dj_cntx.selected_idx].audio_id;
  598. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  599. g_dj_cntx.inline_data.volume_selected  = g_dj_cntx.event_list[g_dj_cntx.selected_idx].vol;
  600. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  601. g_dj_cntx.inline_data.trigger_selected = g_dj_cntx.event_list[g_dj_cntx.selected_idx].trigger;
  602. g_dj_cntx.inline_data.key_selected  = g_dj_cntx.event_list[g_dj_cntx.selected_idx].key;
  603. g_dj_cntx.prev_trigger = g_dj_cntx.inline_data.trigger_selected;
  604. InitializeCategory57Screen();
  605.   
  606. item_idx = 0;
  607. /************************************/
  608. /* audio - inline selection  */
  609. /************************************/
  610. /* caption */
  611. SetInlineItemCaption(&wgui_inline_items[item_idx], (PU8)GetString((U16)(STR_ID_MOTION_DJ_EDIT_AUDIO)));
  612. item_idx++;
  613.    if(g_dj_cntx.selected_audio_type == DJ_AUD_INSTRUMENT)
  614.    {
  615.    for(i = 0; i < DJ_AUDIO_COUNT; i++)
  616. {
  617. g_dj_cntx.inline_data.audio_str[i] = (UI_string_type)GetString((U16)(STR_ID_MOTION_DJ_INSTRUMENT_0+i));
  618. }
  619.    }
  620.    else
  621.    {
  622.     for(i = 0; i < DJ_AUDIO_COUNT; i++)
  623. {
  624. g_dj_cntx.inline_data.audio_str[i] = (UI_string_type)GetString((U16)(STR_ID_MOTION_DJ_VOCAL_0+i));
  625. }
  626.    }
  627.    
  628. SetInlineItemActivation(&wgui_inline_items[item_idx],
  629. INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  630. 0 );
  631. SetInlineItemSelect( &wgui_inline_items[item_idx], 
  632. DJ_AUDIO_COUNT,
  633. (U8**)g_dj_cntx.inline_data.audio_str,
  634. &g_dj_cntx.inline_data.audio_selected);
  635. RegisterInlineSelectHighlightHandler(&wgui_inline_items[item_idx], 
  636. mmi_motion_dj_edit_audio_highlight_handler);
  637. item_idx++;
  638. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  639. /************************************/
  640. /* volume - inline selection  */
  641. /************************************/
  642. /* caption */
  643. SetInlineItemCaption(&wgui_inline_items[item_idx], (PU8)GetString((U16)(STR_ID_MOTION_DJ_EDIT_VOLUME)));
  644. item_idx++;
  645. /* inline selection */
  646.    for(i = 0; i < DJ_VOLUME_LEVEL; i++)
  647. {
  648. g_dj_cntx.inline_data.volume_str[i] = (UI_string_type)GetString((U16)(STR_GLOBAL_0+i+1));
  649. }
  650. SetInlineItemActivation(&wgui_inline_items[item_idx],
  651. INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  652. 0 );
  653. SetInlineItemSelect( &wgui_inline_items[item_idx], 
  654. DJ_VOLUME_LEVEL,
  655. (U8**)g_dj_cntx.inline_data.volume_str,
  656. &g_dj_cntx.inline_data.volume_selected);
  657. item_idx++;
  658. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  659. /************************************/
  660. /* trigger - inline selection  */
  661. /************************************/
  662. /* caption */
  663. SetInlineItemCaption(&wgui_inline_items[item_idx], (PU8)GetString((U16)(STR_ID_MOTION_DJ_EDIT_TRIGGER)));
  664. item_idx++;
  665. /* inline selection */
  666. g_dj_cntx.inline_data.trigger_str[0] = (UI_string_type)GetString((U16)(STR_GLOBAL_NONE));
  667.    for(i = 0; i < NUM_OF_DJ_TRIGGER_TYPE-1; i++)
  668. {
  669. g_dj_cntx.inline_data.trigger_str[i+1] = (UI_string_type)GetString((U16)(STR_ID_MOTION_DJ_EDIT_TRIGGER_AUTO+i));
  670. }
  671.   
  672. SetInlineItemActivation(&wgui_inline_items[item_idx],
  673. INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  674. 0 );
  675. SetInlineItemSelect( &wgui_inline_items[item_idx], 
  676. NUM_OF_DJ_TRIGGER_TYPE,
  677. (U8**)g_dj_cntx.inline_data.trigger_str,
  678. &g_dj_cntx.inline_data.trigger_selected);
  679. RegisterInlineSelectHighlightHandler(&wgui_inline_items[item_idx], 
  680. mmi_motion_dj_edit_trigger_highlight_handler);
  681. item_idx++;
  682. /************************************/
  683. /* key - inline selection  */
  684. /************************************/
  685. /* caption */
  686. SetInlineItemCaption(&wgui_inline_items[item_idx], (PU8)GetString((U16)(STR_ID_MOTION_DJ_EDIT_KEY)));
  687. item_idx++;
  688. /* inline selection */
  689. g_dj_cntx.inline_data.key_str[0] = (UI_string_type)GetString((U16)(STR_GLOBAL_NONE));
  690.    for(i = 0; i < NUM_OF_DJ_KEY-1; i++)
  691. {
  692. g_dj_cntx.inline_data.key_str[i+1] = (UI_string_type)GetString((U16)(STR_ID_MOTION_DJ_KEY_0+i));
  693. }
  694. SetInlineItemActivation(&wgui_inline_items[item_idx],
  695. INLINE_ITEM_ACTIVATE_WITHOUT_KEY_EVENT,
  696. 0 );
  697. SetInlineItemSelect( &wgui_inline_items[item_idx], 
  698. NUM_OF_DJ_KEY,
  699. (U8**)g_dj_cntx.inline_data.key_str,
  700. &g_dj_cntx.inline_data.key_selected);
  701. RegisterInlineSelectHighlightHandler(&wgui_inline_items[item_idx], 
  702. mmi_motion_dj_edit_key_highlight_handler);
  703. item_idx++;
  704. /* show screen */
  705. input_buffer = GetCurrNInputBuffer(SCR_ID_MOTION_DJ_EDIT, &input_buffer_size);
  706. if(input_buffer != NULL)
  707. SetCategory57Data(wgui_inline_items, item_idx, input_buffer);
  708. RegisterHighlightHandler(mmi_motion_dj_edit_highlight_hdlr);
  709. ShowCategory57Screen(SCR_ID_MOTION_DJ_EDIT, DJ_MENU_ICON_IMG_ID,
  710. 0, 0,
  711. STR_GLOBAL_BACK, IMG_GLOBAL_BACK,
  712. item_idx,
  713. item_icons, 
  714. wgui_inline_items,
  715. 0, gui_buffer);
  716. /* set key hdlr */
  717. SetCategory57RightSoftkeyFunctions( GoBackHistory, 
  718. GoBackHistory);
  719. DisableCategory57ScreenDone();
  720. }
  721. /*****************************************************************************
  722. * FUNCTION
  723. *  mmi_motion_dj_exit_edit_scr()
  724. * DESCRIPTION
  725. *   exit event edit screen
  726. * PARAMETERS
  727. *  void
  728. * RETURNS
  729. *   void
  730. * GLOBALS AFFECTED
  731. *   nil
  732. *****************************************************************************/
  733. static void mmi_motion_dj_exit_edit_scr(void)
  734. {
  735.    /*----------------------------------------------------------------*/
  736.    /* Local Variables                                                */
  737.    /*----------------------------------------------------------------*/
  738. U16  input_buffer_size;                
  739. S16 num_history = 0;
  740. history  h;
  741.    /*----------------------------------------------------------------*/
  742.    /* Code Body                                                      */
  743.    /*----------------------------------------------------------------*/
  744.    mdi_audio_stop_string();
  745.    mdi_audio_resume_background_play();
  746.    
  747. CloseCategory57Screen();       
  748. h.scrnID = SCR_ID_MOTION_DJ_EDIT;
  749. h.entryFuncPtr = mmi_motion_dj_entry_edit_scr;
  750. pfnUnicodeStrcpy((S8*)h.inputBuffer, (S8*)&num_history);
  751. input_buffer_size = (U16)GetCategory57DataSize(); 
  752. GetCategory57History (h.guiBuffer);
  753. GetCategory57Data ((U8*)h.inputBuffer);       
  754. AddNHistory(h, input_buffer_size);          
  755. }
  756. /*****************************************************************************
  757. * FUNCTION
  758. *  mmi_motion_dj_edit_highlight_hdlr()
  759. * DESCRIPTION
  760. *   setting edit done
  761. * PARAMETERS
  762. *  index  IN  selected index
  763. * RETURNS
  764. *   void
  765. * GLOBALS AFFECTED
  766. *   nil
  767. *****************************************************************************/
  768. static void mmi_motion_dj_edit_highlight_hdlr(S32 index)
  769. {
  770.    /*----------------------------------------------------------------*/
  771.    /* Code Body                                                      */
  772.    /*----------------------------------------------------------------*/
  773. mdi_audio_stop_string();
  774.    
  775. ChangeLeftSoftkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
  776. SetCategory57LeftSoftkeyFunction(mmi_motion_dj_edit_done);
  777. }
  778. /*****************************************************************************
  779. * FUNCTION
  780. *  mmi_motion_dj_edit_trigger_highlight_handler()
  781. * DESCRIPTION
  782. *   inline select trigger hilight handler
  783. * PARAMETERS
  784. *  index  IN  selected index
  785. * RETURNS
  786. *   void
  787. * GLOBALS AFFECTED
  788. *   nil
  789. *****************************************************************************/
  790. static void mmi_motion_dj_edit_trigger_highlight_handler(S32 index)
  791. {
  792.    /*----------------------------------------------------------------*/
  793.    /* Code Body                                                      */
  794.    /*----------------------------------------------------------------*/
  795.    /* trigger changed */
  796. if(g_dj_cntx.prev_trigger != g_dj_cntx.inline_data.trigger_selected)
  797. {
  798. g_dj_cntx.prev_trigger = g_dj_cntx.inline_data.trigger_selected;
  799. if(g_dj_cntx.inline_data.key_selected != DJ_KEY_NONE)
  800. {
  801. g_dj_cntx.inline_data.key_selected = DJ_KEY_NONE;
  802. EntryNewScreen(SCR_ID_MOTION_DJ_DUMMY, NULL, NULL, NULL);
  803. GoBackHistory();
  804. }
  805. }
  806. }
  807. /*****************************************************************************
  808. * FUNCTION
  809. *  mmi_motion_dj_edit_audio_highlight_handler()
  810. * DESCRIPTION
  811. *   inline select audio hilight handler
  812. * PARAMETERS
  813. *  index  IN  selected index
  814. * RETURNS
  815. *   void
  816. * GLOBALS AFFECTED
  817. *   nil
  818. *****************************************************************************/
  819. static void mmi_motion_dj_edit_audio_highlight_handler(S32 index)
  820. {
  821.    /*----------------------------------------------------------------*/
  822.    /* Code Body                                                      */
  823.    /*----------------------------------------------------------------*/
  824.    mdi_audio_stop_string();
  825.    pixtel_UI_start_timer(400, mmi_motion_dj_edit_delay_play_audio);
  826. }
  827. /*****************************************************************************
  828. * FUNCTION
  829. *  mmi_motion_dj_edit_delay_play_audio()
  830. * DESCRIPTION
  831. *   delay play audio
  832. * PARAMETERS
  833. *  void
  834. * RETURNS
  835. *   void
  836. * GLOBALS AFFECTED
  837. *   nil
  838. *****************************************************************************/
  839. static void mmi_motion_dj_edit_delay_play_audio(void)
  840. {
  841.    /*----------------------------------------------------------------*/
  842.    /* Local Variables                                                */
  843.    /*----------------------------------------------------------------*/
  844. S32  select_aud_idx;
  845.    PU8 raw_data;
  846.    U32 size;
  847.    
  848.    
  849.    /*----------------------------------------------------------------*/
  850.    /* Code Body                                                      */
  851.    /*----------------------------------------------------------------*/
  852. select_aud_idx = g_dj_cntx.inline_data.audio_selected;
  853.    
  854.    if(g_dj_cntx.selected_audio_type == DJ_AUD_INSTRUMENT)
  855.    {
  856. #define INST_SWITCH_CASE(__id__)
  857. case __id__:
  858. raw_data = (PU8)motion_dj_instrument_midi_##__id__;
  859. size = DJ_AUD_INS_MIDI_##__id__##_LEN; 
  860. break;
  861.   switch(select_aud_idx)
  862.   {
  863. INST_SWITCH_CASE(0)
  864. INST_SWITCH_CASE(1)
  865. INST_SWITCH_CASE(2)
  866. INST_SWITCH_CASE(3)
  867. INST_SWITCH_CASE(4)
  868. INST_SWITCH_CASE(5)
  869. INST_SWITCH_CASE(6)
  870. INST_SWITCH_CASE(7)
  871. INST_SWITCH_CASE(8)
  872. INST_SWITCH_CASE(9)
  873.   }
  874.   
  875. mdi_audio_play_string_with_vol_path_non_block( (void*)raw_data,
  876. (U32)size, 
  877. MDI_FORMAT_SMF,
  878. DEVICE_AUDIO_PLAY_ONCE,
  879. NULL,
  880. NULL,
  881. mmi_gfx_get_audio_vol(),
  882. MDI_DEVICE_SPEAKER2);
  883.    }
  884.    else
  885.    {
  886. #define VOX_SWITCH_CASE(__id__)
  887. case __id__:
  888. raw_data = (PU8)motion_dj_vocal_wav_##__id__;
  889. size = DJ_AUD_VOX_WAVE_##__id__##_LEN; 
  890. break;
  891.    
  892.   switch(select_aud_idx)
  893.   {
  894. VOX_SWITCH_CASE(0)
  895. VOX_SWITCH_CASE(1)
  896. VOX_SWITCH_CASE(2)
  897. VOX_SWITCH_CASE(3)
  898. VOX_SWITCH_CASE(4)
  899. VOX_SWITCH_CASE(5)
  900. VOX_SWITCH_CASE(6)
  901. VOX_SWITCH_CASE(7)
  902. VOX_SWITCH_CASE(8)
  903. VOX_SWITCH_CASE(9)
  904.   }
  905.    
  906. mdi_audio_play_string_with_vol_path_non_block( (void*)raw_data,
  907. (U32)size,
  908. MDI_FORMAT_WAV,
  909. DEVICE_AUDIO_PLAY_ONCE,
  910. NULL,
  911. NULL,
  912. mmi_gfx_get_audio_vol(),
  913. MDI_DEVICE_SPEAKER2);
  914.    }
  915.    
  916.    
  917. }
  918. /*****************************************************************************
  919. * FUNCTION
  920. *  mmi_motion_dj_edit_key_highlight_handler()
  921. * DESCRIPTION
  922. *   setting edit done
  923. * PARAMETERS
  924. *  index  IN  selected index
  925. * RETURNS
  926. *   void
  927. * GLOBALS AFFECTED
  928. *   nil
  929. *****************************************************************************/
  930. static void mmi_motion_dj_edit_key_highlight_handler(S32 index)
  931. {
  932.    /*----------------------------------------------------------------*/
  933.    /* Code Body                                                      */
  934.    /*----------------------------------------------------------------*/
  935. #if 0
  936. /* under construction !*/
  937. /* under construction !*/
  938. /* under construction !*/
  939. /* under construction !*/
  940. /* under construction !*/
  941. /* under construction !*/
  942. /* under construction !*/
  943. /* under construction !*/
  944. /* under construction !*/
  945. /* under construction !*/
  946. /* under construction !*/
  947. /* under construction !*/
  948. /* under construction !*/
  949. /* under construction !*/
  950. #endif
  951. }
  952. /*****************************************************************************
  953. * FUNCTION
  954. *  mmi_motion_dj_edit_done()
  955. * DESCRIPTION
  956. *   setting edit done
  957. * PARAMETERS
  958. *  void
  959. * RETURNS
  960. *   void
  961. * GLOBALS AFFECTED
  962. *   nil
  963. *****************************************************************************/
  964. static void mmi_motion_dj_edit_done(void)
  965. {
  966.    /*----------------------------------------------------------------*/
  967.    /* Local Variables                                                */
  968.    /*----------------------------------------------------------------*/
  969. S16 error;
  970. S32 i;
  971. U16 trigger;
  972. U16 key;
  973.    
  974.    /*----------------------------------------------------------------*/
  975.    /* Code Body                                                      */
  976.    /*----------------------------------------------------------------*/
  977. trigger  = g_dj_cntx.inline_data.trigger_selected;
  978. key  = g_dj_cntx.inline_data.key_selected;
  979. if(trigger != DJ_TRIGGER_NONE)
  980. {
  981. /* trigger is press but key is not set */
  982. if(trigger == DJ_TRIGGER_PRESS)
  983. {
  984. if(key == DJ_KEY_NONE)
  985. {
  986. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_EMPTY_KEY), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  987. return;
  988. }
  989. }
  990. for(i = 0; i < DJ_NUM_OF_ALL_ENTRY; i++)
  991. {
  992. if(g_dj_cntx.selected_idx != i) 
  993. {
  994. if(trigger == DJ_TRIGGER_AUTO)
  995. {
  996. if(g_dj_cntx.event_list[i].trigger == trigger)
  997. {
  998. /* already has auto trigger event */
  999. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_HAS_AUTO), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  1000. return;
  1001. }
  1002. else
  1003. {
  1004. g_dj_cntx.inline_data.key_selected = DJ_KEY_NONE;
  1005. }
  1006. }
  1007. else if((trigger == DJ_TRIGGER_SHAKE) || (trigger == DJ_TRIGGER_PRESS)) 
  1008. {
  1009. /* has same event - shake and press with same key */
  1010. if( (g_dj_cntx.event_list[i].key != DJ_KEY_NONE) &&
  1011.  (g_dj_cntx.event_list[i].key == key))
  1012. {
  1013. if(trigger == DJ_TRIGGER_SHAKE)
  1014. {
  1015. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_HAS_SHAKE_SAME_KEY), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  1016. return;
  1017. }
  1018. else if(trigger == DJ_TRIGGER_PRESS)
  1019. {
  1020. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_HAS_PRESS_SAME_KEY), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  1021. return;
  1022. }
  1023. }
  1024. else if( (trigger == DJ_TRIGGER_SHAKE) && 
  1025. (key == DJ_KEY_NONE) &&
  1026. (g_dj_cntx.event_list[i].trigger == trigger) &&
  1027. (g_dj_cntx.event_list[i].key == key))
  1028. {
  1029. /* has shake only */
  1030. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_HAS_SHAKE), IMG_GLOBAL_WARNING, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  1031. return;
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. /* checking: can only have 1 auto */
  1038. DisplayPopup((PU8)GetString(STR_GLOBAL_DONE), IMG_GLOBAL_ACTIVATED, 1, UI_POPUP_NOTIFYDURATION_TIME, SUCCESS_TONE);
  1039. DeleteNHistory(1);
  1040. /* pass , write to NVRAM */
  1041. g_dj_cntx.event_list[g_dj_cntx.selected_idx].audio_id = g_dj_cntx.inline_data.audio_selected;
  1042. #ifdef DJ_ENABLE_INDIVISUAL_VOLUME
  1043. g_dj_cntx.event_list[g_dj_cntx.selected_idx].vol  = g_dj_cntx.inline_data.volume_selected;
  1044. #endif /* DJ_ENABLE_INDIVISUAL_VOLUME */
  1045. g_dj_cntx.event_list[g_dj_cntx.selected_idx].trigger = g_dj_cntx.inline_data.trigger_selected;
  1046. g_dj_cntx.event_list[g_dj_cntx.selected_idx].key = g_dj_cntx.inline_data.key_selected;
  1047. /* write value from NVRAM */
  1048.   WriteRecord(NVRAM_EF_MOTION_DJ_LID, 
  1049.    NVRAM_EF_MOTION_DJ_TOTAL, 
  1050.    (void*)&g_dj_cntx.event_list[0], 
  1051.    NVRAM_EF_MOTION_DJ_SIZE, 
  1052.    &error);
  1053. }
  1054. /*****************************************************************************
  1055. *
  1056. * Play Screen                                                
  1057. *
  1058. *****************************************************************************/
  1059. /*****************************************************************************
  1060. * FUNCTION
  1061. *  mmi_motion_dj_entry_play_scr()
  1062. * DESCRIPTION
  1063. *   enter play screen
  1064. * PARAMETERS
  1065. *  void
  1066. * RETURNS
  1067. *   void
  1068. * GLOBALS AFFECTED
  1069. *   nil
  1070. *****************************************************************************/
  1071. static void mmi_motion_dj_entry_play_scr(void)
  1072. {
  1073. /*----------------------------------------------------------------*/
  1074.    /* Local Variables                                                */
  1075.    /*----------------------------------------------------------------*/
  1076. U8 *gui_buffer;
  1077. S32 i;
  1078. BOOL has_trigger;
  1079.    /*----------------------------------------------------------------*/
  1080.    /* Code Body                                                      */
  1081.    /*----------------------------------------------------------------*/
  1082. /* check if has any trigger */
  1083.    has_trigger = FALSE;
  1084.    
  1085.    for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1086. {
  1087. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  1088. {
  1089. has_trigger = TRUE;
  1090. }
  1091.    }
  1092. if(!has_trigger)
  1093. {
  1094. DisplayPopup((PU8)GetString(STR_ID_MOTION_DJ_NOTIFY_EMPTY_TRIGGER), IMG_GLOBAL_INFO, 1, UI_POPUP_NOTIFYDURATION_TIME, WARNING_TONE); 
  1095. return;
  1096. }
  1097. /* entry new screen */
  1098. EntryNewScreen(SCR_ID_MOTION_DJ_PLAY, mmi_motion_dj_exit_play_scr, mmi_motion_dj_entry_play_scr, NULL);
  1099. gui_buffer = GetCurrGuiBuffer(SCR_ID_MOTION_DJ_PLAY);
  1100. /* entry full screen app */
  1101. entry_full_screen();
  1102. gdi_layer_reset_clip();
  1103. gdi_layer_reset_text_clip();
  1104. /* stop bg music */
  1105. mdi_audio_suspend_background_play();
  1106. /* stop MMI sleep */
  1107. TurnOnBacklight(0);
  1108. /* force all playing keypad tone off */
  1109. AudioStopReq(GetCurKeypadTone());
  1110. /* disable key pad tone */
  1111. mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_DISABLED);
  1112. /* disalbe align timer  */
  1113. UI_disable_alignment_timers();
  1114. /* enable multi-layer */
  1115. gdi_layer_multi_layer_enable();
  1116. /* enable motion sensor */
  1117. mdi_motion_power_on();
  1118. mdi_motion_start_listen_shake(MDI_MOTION_SENSITIVE_LOW, 
  1119. mmi_motion_dj_play_shake_trigger);
  1120. /* RSK up leave screen */
  1121. SetKeyHandler(GoBackHistory, KEY_RSK, KEY_EVENT_UP);
  1122. SetKeyHandler(mmi_motion_dj_play_key_0_press,  KEY_0, KEY_EVENT_DOWN);
  1123. SetKeyHandler(mmi_motion_dj_play_key_0_release, KEY_0, KEY_EVENT_UP);
  1124. SetKeyHandler(mmi_motion_dj_play_key_1_press,  KEY_1, KEY_EVENT_DOWN);
  1125. SetKeyHandler(mmi_motion_dj_play_key_1_release, KEY_1, KEY_EVENT_UP);
  1126. SetKeyHandler(mmi_motion_dj_play_key_2_press,  KEY_2, KEY_EVENT_DOWN);
  1127. SetKeyHandler(mmi_motion_dj_play_key_2_release, KEY_2, KEY_EVENT_UP);
  1128. SetKeyHandler(mmi_motion_dj_play_key_3_press,  KEY_3, KEY_EVENT_DOWN);
  1129. SetKeyHandler(mmi_motion_dj_play_key_3_release, KEY_3, KEY_EVENT_UP);
  1130. SetKeyHandler(mmi_motion_dj_play_key_4_press,  KEY_4, KEY_EVENT_DOWN);
  1131. SetKeyHandler(mmi_motion_dj_play_key_4_release, KEY_4, KEY_EVENT_UP);
  1132. SetKeyHandler(mmi_motion_dj_play_key_5_press,  KEY_5, KEY_EVENT_DOWN);
  1133. SetKeyHandler(mmi_motion_dj_play_key_5_release, KEY_5, KEY_EVENT_UP);
  1134. SetKeyHandler(mmi_motion_dj_play_key_6_press,  KEY_6, KEY_EVENT_DOWN);
  1135. SetKeyHandler(mmi_motion_dj_play_key_6_release, KEY_6, KEY_EVENT_UP);
  1136. SetKeyHandler(mmi_motion_dj_play_key_7_press,  KEY_7, KEY_EVENT_DOWN);
  1137. SetKeyHandler(mmi_motion_dj_play_key_7_release, KEY_7, KEY_EVENT_UP);
  1138. SetKeyHandler(mmi_motion_dj_play_key_8_press,  KEY_8, KEY_EVENT_DOWN);
  1139. SetKeyHandler(mmi_motion_dj_play_key_8_release, KEY_8, KEY_EVENT_UP);
  1140. SetKeyHandler(mmi_motion_dj_play_key_9_press,  KEY_9, KEY_EVENT_DOWN);
  1141. SetKeyHandler(mmi_motion_dj_play_key_9_release, KEY_9, KEY_EVENT_UP);
  1142. SetKeyHandler(mmi_motion_dj_play_key_star_press,  KEY_STAR, KEY_EVENT_DOWN);
  1143. SetKeyHandler(mmi_motion_dj_play_key_star_release,  KEY_STAR, KEY_EVENT_UP);
  1144. SetKeyHandler(mmi_motion_dj_play_key_pound_press,  KEY_POUND, KEY_EVENT_DOWN);
  1145. SetKeyHandler(mmi_motion_dj_play_key_pound_release,  KEY_POUND, KEY_EVENT_UP);
  1146. #ifndef DJ_ENABLE_INDIVISUAL_VOLUME
  1147. SetKeyHandler(mmi_gfx_volume_up, KEY_VOL_UP, KEY_EVENT_DOWN);
  1148. SetKeyHandler(mmi_gfx_volume_down, KEY_VOL_DOWN, KEY_EVENT_DOWN);
  1149. #endif /* !DJ_ENABLE_INDIVISUAL_VOLUME */
  1150. for(i = 0; i < NUM_OF_DJ_KEY; i++)
  1151. {
  1152. g_dj_cntx.is_key_pressed[i] = FALSE;
  1153. g_dj_cntx.draw_state[i].is_trigger_sel = FALSE;
  1154. g_dj_cntx.draw_state[i].is_key_sel  = FALSE;
  1155. g_dj_cntx.draw_state[i].is_text_sel  = FALSE;
  1156. /* start a bg midi which will always active DPS */
  1157. g_dj_cntx.aud_bg_handle = 
  1158. mdi_audio_mma_open_midi((void*)motion_dj_aud_dummy_bg, DJ_AUD_DUMMY_BG_LEN, 0, NULL);
  1159. mdi_audio_mma_play_midi(g_dj_cntx.aud_bg_handle);
  1160. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1161. {
  1162. g_dj_cntx.aud_handle[i] = 0;
  1163. if(i < DJ_NUM_OF_INSTRUMENT_ENTRY)
  1164. {
  1165. /* clear handle first */
  1166. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  1167. {
  1168. #define DJ_OPEN_MIDI_CASE(__idx__)
  1169. {
  1170. case(__idx__):
  1171. {
  1172. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_AUTO)
  1173. {
  1174. g_dj_cntx.aud_handle[i] =
  1175. mdi_audio_mma_open_midi((void*)motion_dj_instrument_midi_##__idx__,
  1176. (U32)DJ_AUD_INS_MIDI_##__idx__##_LEN,
  1177.                            0,
  1178.                              NULL);
  1179. }
  1180. else
  1181. {
  1182. g_dj_cntx.aud_handle[i] =
  1183. mdi_audio_mma_open_midi((void*)motion_dj_instrument_midi_##__idx__,
  1184. (U32)DJ_AUD_INS_MIDI_##__idx__##_LEN,
  1185.                            1,
  1186.                              NULL);
  1187. }
  1188. }
  1189. break;
  1190. }
  1191. switch(g_dj_cntx.event_list[i].audio_id)
  1192. {
  1193. DJ_OPEN_MIDI_CASE(0);
  1194. DJ_OPEN_MIDI_CASE(1);
  1195. DJ_OPEN_MIDI_CASE(2);
  1196. DJ_OPEN_MIDI_CASE(3);
  1197. DJ_OPEN_MIDI_CASE(4);
  1198. DJ_OPEN_MIDI_CASE(5);
  1199. DJ_OPEN_MIDI_CASE(6);
  1200. DJ_OPEN_MIDI_CASE(7);
  1201. DJ_OPEN_MIDI_CASE(8);
  1202. DJ_OPEN_MIDI_CASE(9);
  1203. }
  1204. }
  1205. /* start auto play */
  1206. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_AUTO)
  1207. {
  1208. mdi_audio_mma_play_midi(g_dj_cntx.aud_handle[i]);
  1209. }
  1210. }
  1211. else 
  1212. {
  1213. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  1214. {
  1215. #define DJ_OPEN_WAVE_CASE(__idx__)
  1216. {
  1217. case(__idx__):
  1218. {
  1219. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_AUTO)
  1220. {
  1221. g_dj_cntx.aud_handle[i] =
  1222. mdi_audio_mma_open_wav((void*)motion_dj_vocal_wav_##__idx__,
  1223. (U32)DJ_AUD_VOX_WAVE_##__idx__##_LEN,
  1224.                            0,
  1225.                              NULL);
  1226. }
  1227. else
  1228. {
  1229. g_dj_cntx.aud_handle[i] =
  1230. mdi_audio_mma_open_wav((void*)motion_dj_vocal_wav_##__idx__,
  1231. (U32)DJ_AUD_VOX_WAVE_##__idx__##_LEN,
  1232.                            1,
  1233.                              NULL);
  1234. }
  1235. }
  1236. break;
  1237. }
  1238. switch(g_dj_cntx.event_list[i].audio_id)
  1239. {
  1240. DJ_OPEN_WAVE_CASE(0);
  1241. DJ_OPEN_WAVE_CASE(1);
  1242. DJ_OPEN_WAVE_CASE(2);
  1243. DJ_OPEN_WAVE_CASE(3);
  1244. DJ_OPEN_WAVE_CASE(4);
  1245. DJ_OPEN_WAVE_CASE(5);
  1246. DJ_OPEN_WAVE_CASE(6);
  1247. DJ_OPEN_WAVE_CASE(7);
  1248. DJ_OPEN_WAVE_CASE(8);
  1249. DJ_OPEN_WAVE_CASE(9);
  1250. }
  1251. /* start auto play */
  1252. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_AUTO)
  1253. {
  1254. mdi_audio_mma_play_wav(g_dj_cntx.aud_handle[i]);
  1255. }
  1256. }
  1257. }
  1258. }
  1259. /* create layer */
  1260. gdi_layer_get_base_handle(&g_dj_cntx.bg_layer);
  1261. gdi_layer_clear(GDI_COLOR_BLACK);
  1262. gdi_layer_create(0,0, UI_device_width, UI_device_height, &g_dj_cntx.item_layer);
  1263. gdi_layer_push_and_set_active(g_dj_cntx.item_layer);
  1264. gdi_layer_set_source_key(TRUE, GDI_COLOR_TRANSPARENT);
  1265. gdi_layer_pop_and_restore_active();
  1266. gdi_layer_set_blt_layer(g_dj_cntx.bg_layer, g_dj_cntx.item_layer, 0, 0);
  1267.    /* draw backgroud */
  1268. gdi_layer_push_and_set_active(g_dj_cntx.bg_layer);
  1269. gdi_image_draw_animation_id(0, 0, IMG_ID_MOTION_DJ_PLAY_BG, &g_dj_cntx.bg_anim);
  1270.    gdi_layer_pop_and_restore_active();
  1271. /* draw items */
  1272. mmi_motion_dj_draw_items();
  1273.   gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1274. }
  1275. /*****************************************************************************
  1276. * FUNCTION
  1277. *  mmi_motion_dj_exit_play_scr()
  1278. * DESCRIPTION
  1279. *   enter play screen
  1280. * PARAMETERS
  1281. *  void
  1282. * RETURNS
  1283. *   void
  1284. * GLOBALS AFFECTED
  1285. *   nil
  1286. *****************************************************************************/
  1287. static void mmi_motion_dj_exit_play_scr(void)
  1288. {
  1289.    /*----------------------------------------------------------------*/
  1290.    /* Local Variables                                                */
  1291.    /*----------------------------------------------------------------*/
  1292. S32 i;
  1293. /*----------------------------------------------------------------*/
  1294.    /* Code Body                                                      */
  1295.    /*----------------------------------------------------------------*/
  1296. pixtel_UI_cancel_timer(mmi_motion_dj_auto_icon_timeout);
  1297. pixtel_UI_cancel_timer(mmi_motion_dj_shake_0_icon_timeout);
  1298. pixtel_UI_cancel_timer(mmi_motion_dj_shake_1_icon_timeout);
  1299. pixtel_UI_cancel_timer(mmi_motion_dj_shake_2_icon_timeout);
  1300. pixtel_UI_cancel_timer(mmi_motion_dj_shake_3_icon_timeout);
  1301. pixtel_UI_cancel_timer(mmi_motion_dj_shake_4_icon_timeout);
  1302. pixtel_UI_cancel_timer(mmi_motion_dj_shake_5_icon_timeout);
  1303. gdi_image_stop_animation(g_dj_cntx.bg_anim);
  1304. /* disable motion sensor */
  1305. mdi_motion_power_off();
  1306.    /* stop dummy background audio */
  1307. mdi_audio_mma_stop_midi(g_dj_cntx.aud_bg_handle);
  1308. mdi_audio_mma_close_midi(g_dj_cntx.aud_bg_handle);
  1309. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1310. {
  1311. if(g_dj_cntx.aud_handle[i] != 0)
  1312. {
  1313. if(i < DJ_NUM_OF_INSTRUMENT_ENTRY)
  1314. {
  1315. mdi_audio_mma_stop_midi(g_dj_cntx.aud_handle[i]);
  1316. mdi_audio_mma_close_midi(g_dj_cntx.aud_handle[i]);
  1317. }
  1318. else
  1319. {
  1320. mdi_audio_mma_stop_wav(g_dj_cntx.aud_handle[i]);
  1321. mdi_audio_mma_close_wav(g_dj_cntx.aud_handle[i]);
  1322. }
  1323. }
  1324. }
  1325.    
  1326. /* free layer */
  1327. gdi_layer_free(g_dj_cntx.item_layer);
  1328. gdi_layer_set_blt_layer(g_dj_cntx.bg_layer, 0, 0, 0);
  1329.    
  1330. /* resume alignment timer */
  1331. UI_enable_alignment_timers();
  1332. /* let MMI can sleep */
  1333. TurnOffBacklight();
  1334. /* enable multi-layer */
  1335. gdi_layer_multi_layer_disable();
  1336. /* resume background audio */
  1337. mdi_audio_resume_background_play();
  1338. /* re-enable keypad tone */
  1339. mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  1340. /* this will force title status to redraw */
  1341. entry_full_screen();
  1342. }
  1343. /*****************************************************************************
  1344. * FUNCTION
  1345. *  mmi_motion_dj_draw_items()
  1346. * DESCRIPTION
  1347. *   draw items
  1348. * PARAMETERS
  1349. *  void
  1350. * RETURNS
  1351. *   void
  1352. * GLOBALS AFFECTED
  1353. *   nil
  1354. *****************************************************************************/
  1355. static void mmi_motion_dj_draw_items(void)
  1356. {
  1357. /*----------------------------------------------------------------*/
  1358.    /* Local Variables                                                */
  1359.    /*----------------------------------------------------------------*/
  1360. U16  text_id;
  1361. S32 i;
  1362.    /*----------------------------------------------------------------*/
  1363.    /* Code Body                                                      */
  1364.    /*----------------------------------------------------------------*/
  1365. gdi_layer_push_and_set_active(g_dj_cntx.item_layer);
  1366. gdi_layer_clear(GDI_COLOR_TRANSPARENT);
  1367. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1368. {
  1369. if(g_dj_cntx.event_list[i].trigger != DJ_TRIGGER_NONE)
  1370. {
  1371. if(i < DJ_NUM_OF_INSTRUMENT_ENTRY)
  1372. {
  1373. text_id = STR_ID_MOTION_DJ_INSTRUMENT_0;
  1374. }
  1375. else
  1376. {
  1377. text_id = STR_ID_MOTION_DJ_VOCAL_0;
  1378. }
  1379. if(g_dj_cntx.draw_state[i].is_trigger_sel)
  1380. {
  1381. gdi_image_draw_id(g_dj_draw_pos[i].icon_trigger_x, 
  1382. g_dj_draw_pos[i].icon_trigger_y,
  1383. (U16)(IMG_ID_MOTION_DJ_PLAY_NONE_SEL+g_dj_cntx.event_list[i].trigger));
  1384. }
  1385. else
  1386. {
  1387. gdi_image_draw_id(g_dj_draw_pos[i].icon_trigger_x, 
  1388. g_dj_draw_pos[i].icon_trigger_y,
  1389. (U16)(IMG_ID_MOTION_DJ_PLAY_NONE+g_dj_cntx.event_list[i].trigger));
  1390. }
  1391. if(g_dj_cntx.event_list[i].key != DJ_KEY_NONE)
  1392. {
  1393. if(g_dj_cntx.draw_state[i].is_key_sel)
  1394. {
  1395. gdi_image_draw_id(g_dj_draw_pos[i].icon_key_x, 
  1396. g_dj_draw_pos[i].icon_key_y,
  1397. (U16)(IMG_ID_MOTION_DJ_PLAY_KEY_0_SEL+g_dj_cntx.event_list[i].key-1));
  1398. }
  1399. else
  1400. {
  1401. gdi_image_draw_id(g_dj_draw_pos[i].icon_key_x, 
  1402. g_dj_draw_pos[i].icon_key_y,
  1403. (U16)(IMG_ID_MOTION_DJ_PLAY_KEY_0+g_dj_cntx.event_list[i].key-1));
  1404. }
  1405. }
  1406. pixtel_UI_set_font(&MMI_medium_font);
  1407. pixtel_UI_move_text_cursor(g_dj_draw_pos[i].text_x, g_dj_draw_pos[i].text_y);
  1408. pixtel_UI_set_text_color(DJ_FONT_COLOR);
  1409. pixtel_UI_set_text_border_color(DJ_FONT_BORDER_COLOR);
  1410.    pixtel_UI_print_bordered_text((UI_string_type)GetString((U16)(text_id+g_dj_cntx.event_list[i].audio_id)));
  1411. }
  1412. }
  1413.    gdi_layer_pop_and_restore_active();
  1414. }
  1415. /*****************************************************************************
  1416. * FUNCTION
  1417. *  mmi_motion_dj_play_shake_trigger()
  1418. * DESCRIPTION
  1419. *   shake trigger
  1420. * PARAMETERS
  1421. *  void
  1422. * RETURNS
  1423. *   void
  1424. * GLOBALS AFFECTED
  1425. *   nil
  1426. *****************************************************************************/
  1427. static void mmi_motion_dj_play_shake_trigger(void)
  1428. {
  1429. /*----------------------------------------------------------------*/
  1430.    /* Local Variables                                                */
  1431.    /*----------------------------------------------------------------*/
  1432. S32  i;
  1433. BOOL  has_shake_key;
  1434. BOOL  has_shake_only;
  1435. S32 shake_key_idx;
  1436. S32  shake_only_idx;
  1437. S32  idx;
  1438.    /*----------------------------------------------------------------*/
  1439.    /* Code Body                                                      */
  1440.    /*----------------------------------------------------------------*/
  1441. /* check if has shake event with key press */
  1442.    
  1443.    has_shake_key  = FALSE;
  1444.    has_shake_only  = FALSE;
  1445.    
  1446.    for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1447. {
  1448. /* has shake with key event */
  1449. if( (g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_SHAKE) &&
  1450.  (g_dj_cntx.event_list[i].key != DJ_KEY_NONE) &&
  1451.  (g_dj_cntx.is_key_pressed[g_dj_cntx.event_list[i].key] == TRUE))
  1452. {
  1453. has_shake_key  = TRUE;
  1454. shake_key_idx = i;
  1455. break;
  1456. }
  1457. else if( (g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_SHAKE) &&
  1458.   (g_dj_cntx.event_list[i].key == DJ_KEY_NONE) )
  1459. {
  1460. has_shake_only = TRUE;
  1461. shake_only_idx = i;
  1462. }
  1463.    }
  1464.    if(has_shake_key || has_shake_only)
  1465.    {
  1466. if(has_shake_key)
  1467. idx = shake_key_idx;
  1468. else if(has_shake_only)
  1469. idx = shake_only_idx;
  1470.    
  1471. g_dj_cntx.draw_state[idx].is_trigger_sel = TRUE;
  1472. switch(idx)
  1473. {
  1474. case 0:
  1475. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_0_icon_timeout);
  1476. break;
  1477. case 1:
  1478. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_1_icon_timeout);
  1479. break;
  1480. case 2:
  1481. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_2_icon_timeout);
  1482. break;
  1483. case 3:
  1484. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_3_icon_timeout);
  1485. break;
  1486. case 4:
  1487. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_4_icon_timeout);
  1488. break;
  1489. case 5:
  1490. pixtel_UI_start_timer(DJ_ICON_FADE_TIME, mmi_motion_dj_shake_5_icon_timeout);
  1491. break;
  1492. }
  1493. if(idx < DJ_NUM_OF_INSTRUMENT_ENTRY)
  1494. {
  1495. mdi_audio_mma_stop_midi(g_dj_cntx.aud_handle[idx]);
  1496. mdi_audio_mma_play_midi(g_dj_cntx.aud_handle[idx]);
  1497. }
  1498. else
  1499. {
  1500. mdi_audio_mma_stop_wav(g_dj_cntx.aud_handle[idx]);
  1501. mdi_audio_mma_play_wav(g_dj_cntx.aud_handle[idx]);
  1502. }
  1503. mmi_motion_dj_draw_items();
  1504. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1505. return;
  1506.    }
  1507. }
  1508. /*****************************************************************************
  1509. * FUNCTION
  1510. *  mmi_motion_dj_auto_play_finish_hdlr()
  1511. * DESCRIPTION
  1512. *   key  press handler
  1513. * PARAMETERS
  1514. *  mdi_result IN audio handle
  1515. *  result IN play result 
  1516. * RETURNS
  1517. *   void
  1518. * GLOBALS AFFECTED
  1519. *   nil
  1520. *****************************************************************************/
  1521. #if 0
  1522. /* under construction !*/
  1523. /* under construction !*/
  1524. /* under construction !*/
  1525. /* under construction !*/
  1526. /* under construction !*/
  1527. /* under construction !*/
  1528. /* under construction !*/
  1529. /* under construction !*/
  1530. /* under construction !*/
  1531. /* under construction !*/
  1532. /* under construction !*/
  1533. /* under construction !*/
  1534. /* under construction !*/
  1535. /* under construction !*/
  1536. /* under construction !*/
  1537. /* under construction !*/
  1538. /* under construction !*/
  1539. /* under construction !*/
  1540. /* under construction !*/
  1541. /* under construction !*/
  1542. /* under construction !*/
  1543. /* under construction !*/
  1544. /* under construction !*/
  1545. /* under construction !*/
  1546. /* under construction !*/
  1547. /* under construction !*/
  1548. /* under construction !*/
  1549. /* under construction !*/
  1550. /* under construction !*/
  1551. /* under construction !*/
  1552. /* under construction !*/
  1553. /* under construction !*/
  1554. /* under construction !*/
  1555. /* under construction !*/
  1556. /* under construction !*/
  1557. /* under construction !*/
  1558. /* under construction !*/
  1559. /* under construction !*/
  1560. /* under construction !*/
  1561. /* under construction !*/
  1562. /* under construction !*/
  1563. #endif
  1564. /*****************************************************************************
  1565. * FUNCTION
  1566. *  mmi_motion_dj_auto_icon_timeout()
  1567. * DESCRIPTION
  1568. *   time out to darw small auto icon
  1569. * PARAMETERS
  1570. *  void
  1571. * RETURNS
  1572. *   void
  1573. * GLOBALS AFFECTED
  1574. *   nil
  1575. *****************************************************************************/
  1576. static void mmi_motion_dj_auto_icon_timeout(void)
  1577. {
  1578. /*----------------------------------------------------------------*/
  1579.    /* Local Variables                                                */
  1580.    /*----------------------------------------------------------------*/
  1581. S32 i;
  1582.    /*----------------------------------------------------------------*/
  1583.    /* Code Body                                                      */
  1584.    /*----------------------------------------------------------------*/
  1585. /* find the auto icon, draw unselect icon */
  1586. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1587. {
  1588. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_AUTO)
  1589. {
  1590. g_dj_cntx.draw_state[i].is_trigger_sel = FALSE;
  1591. mmi_motion_dj_draw_items();
  1592. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1593. return;
  1594. }
  1595. }
  1596. }
  1597. /*****************************************************************************
  1598. * FUNCTION
  1599. *  mmi_motion_dj_shake_0_icon_timeout()
  1600. * DESCRIPTION
  1601. *   time out to darw small shake icon
  1602. * PARAMETERS
  1603. *  void
  1604. * RETURNS
  1605. *   void
  1606. * GLOBALS AFFECTED
  1607. *   nil
  1608. *****************************************************************************/
  1609. static void mmi_motion_dj_shake_0_icon_timeout(void)
  1610. {
  1611.    /*----------------------------------------------------------------*/
  1612.    /* Code Body                                                      */
  1613.    /*----------------------------------------------------------------*/
  1614. g_dj_cntx.draw_state[0].is_trigger_sel = FALSE;
  1615. mmi_motion_dj_draw_items();
  1616. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1617. }
  1618. /*****************************************************************************
  1619. * FUNCTION
  1620. *  mmi_motion_dj_shake_1_icon_timeout()
  1621. * DESCRIPTION
  1622. *   time out to darw small shake icon
  1623. * PARAMETERS
  1624. *  void
  1625. * RETURNS
  1626. *   void
  1627. * GLOBALS AFFECTED
  1628. *   nil
  1629. *****************************************************************************/
  1630. static void mmi_motion_dj_shake_1_icon_timeout(void)
  1631. {
  1632.    /*----------------------------------------------------------------*/
  1633.    /* Code Body                                                      */
  1634.    /*----------------------------------------------------------------*/
  1635. g_dj_cntx.draw_state[1].is_trigger_sel = FALSE;
  1636. mmi_motion_dj_draw_items();
  1637. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1638. }
  1639. /*****************************************************************************
  1640. * FUNCTION
  1641. *  mmi_motion_dj_shake_2_icon_timeout()
  1642. * DESCRIPTION
  1643. *   time out to darw small shake icon
  1644. * PARAMETERS
  1645. *  void
  1646. * RETURNS
  1647. *   void
  1648. * GLOBALS AFFECTED
  1649. *   nil
  1650. *****************************************************************************/
  1651. static void mmi_motion_dj_shake_2_icon_timeout(void)
  1652. {
  1653.    /*----------------------------------------------------------------*/
  1654.    /* Code Body                                                      */
  1655.    /*----------------------------------------------------------------*/
  1656. g_dj_cntx.draw_state[2].is_trigger_sel = FALSE;
  1657. mmi_motion_dj_draw_items();
  1658. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1659. }
  1660. /*****************************************************************************
  1661. * FUNCTION
  1662. *  mmi_motion_dj_shake_3_icon_timeout()
  1663. * DESCRIPTION
  1664. *   time out to darw small shake icon
  1665. * PARAMETERS
  1666. *  void
  1667. * RETURNS
  1668. *   void
  1669. * GLOBALS AFFECTED
  1670. *   nil
  1671. *****************************************************************************/
  1672. static void mmi_motion_dj_shake_3_icon_timeout(void)
  1673. {
  1674.    /*----------------------------------------------------------------*/
  1675.    /* Code Body                                                      */
  1676.    /*----------------------------------------------------------------*/
  1677. g_dj_cntx.draw_state[3].is_trigger_sel = FALSE;
  1678. mmi_motion_dj_draw_items();
  1679. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1680. }
  1681. /*****************************************************************************
  1682. * FUNCTION
  1683. *  mmi_motion_dj_shake_4_icon_timeout()
  1684. * DESCRIPTION
  1685. *   time out to darw small shake icon
  1686. * PARAMETERS
  1687. *  void
  1688. * RETURNS
  1689. *   void
  1690. * GLOBALS AFFECTED
  1691. *   nil
  1692. *****************************************************************************/
  1693. static void mmi_motion_dj_shake_4_icon_timeout(void)
  1694. {
  1695.    /*----------------------------------------------------------------*/
  1696.    /* Code Body                                                      */
  1697.    /*----------------------------------------------------------------*/
  1698. g_dj_cntx.draw_state[4].is_trigger_sel = FALSE;
  1699. mmi_motion_dj_draw_items();
  1700. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1701. }
  1702. /*****************************************************************************
  1703. * FUNCTION
  1704. *  mmi_motion_dj_shake_5_icon_timeout()
  1705. * DESCRIPTION
  1706. *   time out to darw small shake icon
  1707. * PARAMETERS
  1708. *  void
  1709. * RETURNS
  1710. *   void
  1711. * GLOBALS AFFECTED
  1712. *   nil
  1713. *****************************************************************************/
  1714. static void mmi_motion_dj_shake_5_icon_timeout(void)
  1715. {
  1716.    /*----------------------------------------------------------------*/
  1717.    /* Code Body                                                      */
  1718.    /*----------------------------------------------------------------*/
  1719. g_dj_cntx.draw_state[5].is_trigger_sel = FALSE;
  1720. mmi_motion_dj_draw_items();
  1721. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1722. }
  1723. /*****************************************************************************
  1724. * FUNCTION
  1725. *  mmi_motion_dj_play_key_press_handler()
  1726. * DESCRIPTION
  1727. *   key  press handler
  1728. * PARAMETERS
  1729. *  key_id IN key_id
  1730. * RETURNS
  1731. *   void
  1732. * GLOBALS AFFECTED
  1733. *   nil
  1734. *****************************************************************************/
  1735. static void mmi_motion_dj_play_key_press_handler(U16 key_id)
  1736. {
  1737. /*----------------------------------------------------------------*/
  1738.    /* Local Variables                                                */
  1739.    /*----------------------------------------------------------------*/
  1740. S32 i;
  1741.    /*----------------------------------------------------------------*/
  1742.    /* Code Body                                                      */
  1743.    /*----------------------------------------------------------------*/
  1744. g_dj_cntx.is_key_pressed[key_id] = TRUE;
  1745. for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1746. {
  1747. if(g_dj_cntx.event_list[i].key == key_id)
  1748. {
  1749. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_PRESS)
  1750. {
  1751. g_dj_cntx.draw_state[i].is_trigger_sel = TRUE;
  1752. g_dj_cntx.draw_state[i].is_key_sel  = TRUE;
  1753. if(i < DJ_NUM_OF_INSTRUMENT_ENTRY)
  1754. {
  1755. mdi_audio_mma_stop_midi(g_dj_cntx.aud_handle[i]);
  1756. mdi_audio_mma_play_midi(g_dj_cntx.aud_handle[i]);
  1757. }
  1758. else
  1759. {
  1760. mdi_audio_mma_stop_wav(g_dj_cntx.aud_handle[i]);
  1761. mdi_audio_mma_play_wav(g_dj_cntx.aud_handle[i]);
  1762. }
  1763. }
  1764. else if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_SHAKE)
  1765. {
  1766. g_dj_cntx.draw_state[i].is_key_sel = TRUE;
  1767. }
  1768. mmi_motion_dj_draw_items();
  1769. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1770. return;
  1771. }
  1772. }
  1773. }
  1774. /*****************************************************************************
  1775. * FUNCTION
  1776. *  mmi_motion_dj_play_key_release_handler()
  1777. * DESCRIPTION
  1778. *   key  release handler
  1779. * PARAMETERS
  1780. *  key_id IN key_id
  1781. * RETURNS
  1782. *   void
  1783. * GLOBALS AFFECTED
  1784. *   nil
  1785. *****************************************************************************/
  1786. static void mmi_motion_dj_play_key_release_handler(U16 key_id)
  1787. {
  1788. /*----------------------------------------------------------------*/
  1789.    /* Local Variables                                                */
  1790.    /*----------------------------------------------------------------*/
  1791. S32 i;
  1792.    /*----------------------------------------------------------------*/
  1793.    /* Code Body                                                      */
  1794.    /*----------------------------------------------------------------*/
  1795. g_dj_cntx.is_key_pressed[key_id] = FALSE;
  1796.    for(i = 0 ; i < DJ_NUM_OF_ALL_ENTRY; i++)
  1797. {
  1798. if(g_dj_cntx.event_list[i].key == key_id)
  1799. {
  1800. if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_PRESS)
  1801. {
  1802. g_dj_cntx.draw_state[i].is_trigger_sel = FALSE;
  1803. g_dj_cntx.draw_state[i].is_key_sel  = FALSE;
  1804. }
  1805. else if(g_dj_cntx.event_list[i].trigger == DJ_TRIGGER_SHAKE)
  1806. {
  1807. g_dj_cntx.draw_state[i].is_key_sel = FALSE;
  1808. }
  1809. mmi_motion_dj_draw_items();
  1810. gdi_layer_blt_previous(0, 0, UI_device_width-1, UI_device_height-1);
  1811. return;
  1812. }
  1813. }
  1814. #define DJ_KEY_HANDLER(__key__,__KEY__)
  1815. static void mmi_motion_dj_play_key_##__key__##_press(void)
  1816. {
  1817. mmi_motion_dj_play_key_press_handler(DJ_KEY_##__KEY__);
  1818. }
  1819. static void mmi_motion_dj_play_key_##__key__##_release(void)
  1820. {
  1821. mmi_motion_dj_play_key_release_handler(DJ_KEY_##__KEY__);
  1822. }
  1823. DJ_KEY_HANDLER(0,0)
  1824. DJ_KEY_HANDLER(1,1)
  1825. DJ_KEY_HANDLER(2,2)
  1826. DJ_KEY_HANDLER(3,3)
  1827. DJ_KEY_HANDLER(4,4)
  1828. DJ_KEY_HANDLER(5,5)
  1829. DJ_KEY_HANDLER(6,6)
  1830. DJ_KEY_HANDLER(7,7)
  1831. DJ_KEY_HANDLER(8,8)
  1832. DJ_KEY_HANDLER(9,9)
  1833. DJ_KEY_HANDLER(star,STAR)
  1834. DJ_KEY_HANDLER(pound,POUND)
  1835. #endif /* IS_DJ_BASE_MOTIONGAME */
  1836. #endif /* _MMI_MOTION_DJ_C */