⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jvm_event_adaptor.c

📁 java 1.1 gemini 08_16
💻 C
📖 第 1 页 / 共 5 页
字号:
    /*----------------------------------------------------------------*/
    tp_virtual_direction = is_direction;
}


/*****************************************************************************
 * FUNCTION
 *  set_java_level_virtual_direction
 * DESCRIPTION
 *  
 * PARAMETERS
 *  is_direction        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void set_java_level_virtual_direction(kal_bool is_direction)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (tp_virtual_direction && java_level_tp_virtual && !is_direction)
    {
        if (tp_virtual_last_pressed_key_code != 0)
        {
            jvm_keypad_insert(tp_virtual_last_pressed_key_code, KEY_EVENT_UP);
            tp_virtual_last_pressed_key_code = 0;
        }
    }
    java_level_tp_virtual = is_direction;
}


/*****************************************************************************
 * FUNCTION
 *  jvm_tp_fetch
 * DESCRIPTION
 *  
 * PARAMETERS
 *  x           [?]     [?]
 *  y           [?]     [?]
 *  type        [?]     [?]
 * RETURNS
 *  
 *****************************************************************************/
kal_bool jvm_tp_fetch(kal_uint16 *x, kal_uint16 *y, kal_uint16 *type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    kal_bool result = KAL_FALSE;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    if (TP_RINGSIZE > 0)
    {
        /*
         * We can enter critical-section only when have keyevent,
         * * worst case is to process the incoming kevent next loop but
         * * would be better for performance.
         */
        kal_take_mutex(jvm_tp_mutex);
        *x = jvm_tp_ring_buffer[TP_READER].x;
        *y = jvm_tp_ring_buffer[TP_READER].y;
        *type = jvm_tp_ring_buffer[TP_READER].type;

        /* kal_trace(TRACE_GROUP_9, FUNC_JVM_TP_FETCH,*x,*y,*type); */

        TP_READER = TP_INC_READER;
        TP_RINGSIZE--;
        result = KAL_TRUE;

        kal_give_mutex(jvm_tp_mutex);
    }

    return result;
}


/*****************************************************************************
 * FUNCTION
 *  jvm_tp_insert
 * DESCRIPTION
 *  
 * PARAMETERS
 *  x           [IN]        
 *  y           [IN]        
 *  type        [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void jvm_tp_insert(kal_uint16 x, kal_uint16 y, kal_uint16 type)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_9, FUNC_JVM_TP_INSERT, x, y, type, endKeyPressed);
#ifdef __MMI_TOUCH_SCREEN__
    if (endKeyPressed == KAL_FALSE)
    {
        /* If ring buffer fulled, and "END_Key" pressed, no more touch panel inserted */
        kal_take_mutex(jvm_tp_mutex);
        if (type == MMI_PEN_EVENT_DOWN)
        {
            has_pressed = KAL_TRUE;
        }
        else
        {
            if (type == MMI_PEN_EVENT_UP || type == MMI_PEN_EVENT_MOVE)
            {
                if (has_pressed == KAL_FALSE)
                {
                    kal_give_mutex(jvm_tp_mutex);
                    /* this is not a valid press, just throw the event */
                    return;
                }
                else if (type == MMI_PEN_EVENT_UP)
                {
                    has_pressed = KAL_FALSE;
                }
            }
        }

        if (tp_virtual_direction && java_level_tp_virtual && !jui_widget_is_in_menu())
        {
            if (type == MMI_PEN_EVENT_UP)
            {
                if (tp_virtual_last_pressed_key_code != 0)
                {
                    jvm_keypad_insert(tp_virtual_last_pressed_key_code, KEY_EVENT_UP);
                    tp_virtual_last_pressed_key_code = 0;
                }
            }
            else
            {
                int direction;

                if (x > ((y * screen_diagonal_slope) >> 16))
                {
                    if (x > (jui_widget_get_display_width() - ((y * screen_diagonal_slope) >> 16)))
                    {
                        direction = KEY_RIGHT_ARROW;
                    }
                    else
                    {
                        direction = KEY_UP_ARROW;
                    }
                }
                else
                {
                    if (x > (jui_widget_get_display_width() - ((y * screen_diagonal_slope) >> 16)))
                    {
                        direction = KEY_DOWN_ARROW;
                    }
                    else
                    {
                        direction = KEY_LEFT_ARROW;
                    }
                }
                if (type == MMI_PEN_EVENT_DOWN)
                {
                    kal_get_time(&last_pressed_ticks);
                    tp_virtual_last_pressed_key_code = direction;
                    jvm_keypad_insert((kal_uint16) direction, KEY_EVENT_DOWN);
                }
                else if (type == MMI_PEN_EVENT_MOVE)
                {
                    if (tp_virtual_last_pressed_key_code != 0)
                    {
                        unsigned int current_ticks;

                        kal_get_time(&current_ticks);
                        if (current_ticks - last_pressed_ticks > 12)
                        {
                            jvm_keypad_insert(tp_virtual_last_pressed_key_code, KEY_EVENT_UP);
                            jvm_keypad_insert((kal_uint16) direction, KEY_EVENT_DOWN);
                            tp_virtual_last_pressed_key_code = direction;
                            last_pressed_ticks = current_ticks;
                        }
                    }
                }
            }
        }
        else
        {
            if (TP_RINGSIZE < JVM_TP_RING_BUFFER_SIZE_MASK)
            {
                /* still have room to put the key */
                jvm_tp_ring_buffer[TP_WRITER].x = x;
                jvm_tp_ring_buffer[TP_WRITER].y = y;
                jvm_tp_ring_buffer[TP_WRITER].type = type;
                TP_WRITER = TP_INC_WRITER;
                TP_RINGSIZE++;
            }
            else if (TP_RINGSIZE > 0)
            {
                /* if the event is pen down or pen move, just throw the event */
                if (type == MMI_PEN_EVENT_DOWN)
                {
                    has_pressed = KAL_FALSE;
                    kal_give_mutex(jvm_tp_mutex);
                    return;
                }
                /* do not thing, just drop the pen event */
            }
        }
        kal_give_mutex(jvm_tp_mutex);
    }
#endif /* __MMI_TOUCH_SCREEN__ */ 

    /* If JVM will sleep for message to wakeup, send that */
    if (g_jvm_keypad_need_notify)
    {
        g_jvm_keypad_need_notify = KAL_FALSE;
        jvm_send_keypad_notify_ind();
    }
}

#ifdef __MMI_TOUCH_SCREEN__

extern MMI_BOOL wgui_test_rsk_position(mmi_pen_point_struct pos);
extern MMI_BOOL wgui_test_lsk_position(mmi_pen_point_struct pos);
extern int j2me_get_category_index_by_position(int pen_type, mmi_pen_point_struct pos, kal_bool *is_selected);
static kal_bool lsk_pressed;
static kal_bool rsk_pressed;

/*************************************************************************
 *  prototype
 *************************************************************************/
static void jvm_insert_select(void);
static void jvm_pen_down_hdlr(mmi_pen_point_struct pos);
static void jvm_pen_up_hdlr(mmi_pen_point_struct pos);
static void jvm_pen_move_hdlr(mmi_pen_point_struct pos);
static void jvm_pen_abort_hdlr(mmi_pen_point_struct pos);
static void jvm_pen_repeat_hdlr(mmi_pen_point_struct pos);
static void jvm_pen_long_tap_hdlr(mmi_pen_point_struct pos);

//static void jvm_pen_stroke_down_hdlr(mmi_pen_point_struct pos);   
//static void jvm_pen_stroke_move_hdlr(mmi_pen_point_struct pos);   
//static void jvm_pen_stroke_up_hdlr(mmi_pen_point_struct pos);   
void jvm_register_pen_events(void);
void jvm_unregister_pen_events(void);


/*****************************************************************************
 * FUNCTION
 *  jvm_insert_select
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
static void jvm_insert_select(void)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    jvm_keypad_insert(KEY_SEND, KEY_EVENT_DOWN);
    jvm_keypad_insert(KEY_SEND, KEY_EVENT_UP);
}


/*****************************************************************************
 * FUNCTION
 *  jvm_pen_down_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  pos     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void jvm_pen_down_hdlr(mmi_pen_point_struct pos)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_9, FUNC_JVM_PEN_DOWN_HDLR, jui_widget_is_in_fullscreen(), jui_widget_is_in_menu());
    lsk_pressed = KAL_FALSE;
    rsk_pressed = KAL_FALSE;
    if (!jui_widget_is_in_fullscreen() || jui_widget_is_in_menu())
    {
        if (wgui_test_lsk_position(pos))
        {
            jvm_keypad_insert(KEY_LSK, KEY_EVENT_DOWN);
            lsk_pressed = KAL_TRUE;
            return;
        }
        else if (wgui_test_rsk_position(pos))
        {
            jvm_keypad_insert(KEY_RSK, KEY_EVENT_DOWN);
            rsk_pressed = KAL_TRUE;
            return;
        }
    }
    if (jui_widget_is_in_menu())
    {
        mmi_pen_point_struct p;
        kal_bool is_selected;

        j2me_lcd_mutex_lock();
        p.x = pos.x;
        if (jui_widget_is_in_fullscreen())
        {
            p.y = pos.y;
        }
        else
        {
            if (pos.y >= MMI_status_bar_height)
            {
                p.y = (S16) (pos.y - MMI_status_bar_height);
            }
            else
            {
                p.y = 0;
            }
        }
        jui_widget_set_current_menu_index(j2me_get_category_index_by_position(MMI_PEN_EVENT_DOWN, p, &is_selected));
        j2me_lcd_mutex_unlock();
        /* if anything is scrolling... we should stop those scrolling */
        gui_fixed_text_menuitem_stop_scroll();
        gui_fixed_icontext_list_menuitem_stop_scroll();
        gui_fixed_icontext_menuitem_stop_scroll();
        gui_fixed_twostate_menuitem_stop_scroll();

        return;
    }
#if defined (__MMI_MAINLCD_128X128__) || defined (__MMI_MAINLCD_128X160__) || defined (MMI_SHOW_STATUS_ICON_IN_TITLE)
    jvm_tp_insert(pos.x, pos.y, MMI_PEN_EVENT_DOWN);
#else /* defined (__MMI_MAINLCD_128X128__) || defined (__MMI_MAINLCD_128X160__) || defined (MMI_SHOW_STATUS_ICON_IN_TITLE) */ 
    if (!jui_widget_is_in_fullscreen()) /* normal mode, no status icons */
    {
        if (pos.y < MMI_status_bar_height)
        {
            jvm_tp_insert(pos.x, 0, MMI_PEN_EVENT_DOWN);
        }
        else
        {
            jvm_tp_insert(pos.x, (S16) (pos.y - MMI_status_bar_height), MMI_PEN_EVENT_DOWN);
        }
    }
    else
    {
        jvm_tp_insert(pos.x, pos.y, MMI_PEN_EVENT_DOWN);
    }
#endif /* defined (__MMI_MAINLCD_128X128__) || defined (__MMI_MAINLCD_128X160__) || defined (MMI_SHOW_STATUS_ICON_IN_TITLE) */ 
}


/*****************************************************************************
 * FUNCTION
 *  jvm_pen_up_hdlr
 * DESCRIPTION
 *  
 * PARAMETERS
 *  pos     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
static void jvm_pen_up_hdlr(mmi_pen_point_struct pos)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    kal_trace(TRACE_GROUP_9, FUNC_JVM_PEN_UP_HDLR, jui_widget_is_in_menu());
    if (lsk_pressed)
    {
        jvm_keypad_insert(KEY_LSK, KEY_EVENT_UP);
        lsk_pressed = KAL_FALSE;
        return;
    }
    else if (rsk_pressed)
    {
        jvm_keypad_insert(KEY_RSK, KEY_EVENT_UP);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -