// The algorithm used to search for categories in MTK, and finally obtain the array value corresponding to g_categories_controls_map.
U8 * dm_search_control_set (s32 category_id, S16 ** default_coordinate_set_p) <br/> {<br/>/* variable */<br/>/* local variables */<br/>/* variable */<br/> u8 min = 0, max = 0, mid = 0; <br/>/* ---------------------------------------------------------------- */<br/>/* Code body */<br/> /* Optional */<br/>/* mmi_assert (category_id); */<br/> If (category_id = 0) <br/>{< br/> return NULL; <br/>}< br/> max = dm_get_control_sets_count (); <br/>/* Set max as Max number of records */<br/> min = 0; <br/> * default_coordinate_set_p = NULL; <br/> while (Min <= max) <br/>{< br/> mid = (MAX + min)> 1; <br/> If (g_categories_contro Ls_map [Mid]. category_id = (2010) category_id) <br/>{< br/> # ifdef _ mmi_screen_rotate __< br/> mmi_dbg_assert (! Mmi_frm_is_screen_width_height_swapped () | <br/> g_categories_controls_map [Mid]. rotated_coordinate_set_p); <br/> If (mmi_frm_is_screen_width_height_swapped () & g_categories_controls_map [Mid]. rotated_coordinate_set_p) <br/>{< br/> * default_coordinate_set_p = g_categories_controls_map [Mid]. rotated_coordinate_set_p; <br/>}< br/> else <br/>{< br/> * default_coordinate_set_p = g_categories_controls_map [Mid]. default_coordinate_set_p; <br/>}< br/> # else/* _ mmi_screen_rotate _ */<br/> * default_coordinate_set_p = g_categories_controls_map [Mid]. default_coordinate_set_p; <br/> # endif/* _ mmi_screen_rotate _ */<br/> return g_categories_controls_map [Mid]. control_set_p; <br/>}< br/> else if (g_categories_controls_map [Mid]. category_id> (2010) category_id) <br/>{< br/> max = mid-1; <br/>}< br/> else <br/>{< br/> min = Mid + 1; <br/>}< br/> mmi_assert (0); <br/> return NULL; <br/>}/ * end of dm_search_control_set */
// Set coordinate_set for the coordinates of categories, which is the same as the search method in the preceding section.
<Br/> S16 * dm_search_coordinate_set (s32 scrid) <br/> {<br/>/* variable */<br/>/* local variables */<br/>/* variable */<br/> s32 startindex = 0; <br/> s32 endindex = dm_get_coordinate_sets_count (); <br/>/* response */<br/>/* Code body */<br/>/* response */<br/> while (endindex> = startindex) <br/> {<br/> s32 middleindex = (endindex + startindex)> 1; <br/> If (g_screenid_coordinate_sets_map [middleindex]. screen_id = scrid) <br/>{< br/> return g_screenid_coordinate_sets_map [middleindex]. coordinate_set_p; <br/>}< br/> else if (g_screenid_coordinate_sets_map [middleindex]. screen_id> scrid) <br/>{< br/> endindex = middleindex-1; <br/>}< br/> else <br/> {<br/> startindex = middleindex + 1; <br/>}< br/> return NULL; <br/>}/ * end of dm_search_coordinate_set */<br/>