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

📄 touchscreen.c

📁 MTK6225
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *   TouchScreen.c
 *
 * Project:
 * --------
 *   MAUI
 *
 * Description:
 * ------------
 *   Low-level Touch Screen API - interface between driver or PC simulator
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#include "MMI_features.h"

/* Save stroke data in filesystem for analysis of recognition rate */
#undef MMI_PEN_SAVE_STROKE_IN_FILE

/*****************************************************************************
 * In case that handwriting area is overlapped with an editor, we need to 
 * define a way to move cursor inside the editor.
 *
 * Three approaches are supported:
 *
 * 1. !defined(MMI_PEN_SUPPORT_STROKE_LONGTAP) and single-block --> (MMI_PEN_STROKE_MIN_OFFSET > 0)
 *
 * In the first stroke (after mmi_pen_begin_strokes_of_character()), 
 * stroke down in handwriting area is translated to Pen Down event first until pen is 
 * moved across predefined distance MMI_PEN_STROKE_MIN_OFFSET.
 *
 * For example, driver events are converted to MMI events in the first stroke like:
 *
 * STROKE_DOWN, STROKE_UP --> MMI_PEN_EVENT_DOWN, MMI_PEN_EVENT_UP
 *       (stroke buffer is empty, handwriting area is reset to default)
 *
 * STROKE_DOWN, STROKE_MOVE (< MMI_PEN_STROKE_MIN_OFFSET), STROKE_UP --> 
 *       MMI_PEN_EVENT_DOWN, MMI_PEN_EVENT_UP
 *       (the STROKE_MOVE before STROKE_UP is dropped, 
 *        stroke buffer is empty, handwriting area is reset to default)
 *
 * STROKE_DOWN, STROKE_MOVE (> MMI_PEN_STROKE_MIN_OFFSET), STROKE_UP -->
 *       MMI_PEN_EVENT_DOWN, MMI_PEN_EVENT_ABORT, MMI_PEN_STROKE_DOWN, 
 *                           MMI_PEN_STROKE_MOVE, MMI_PEN_STROKE_UP
 *       (The original Pen Down event is aborted, and the first stroke is created)
 *
 * 2. !defined(MMI_PEN_SUPPORT_STROKE_LONGTAP) and multi-block --> 
 * 
 * Handwriting area and non-handwriting area are not overlapped. This is the simplest case.
 *
 * Unnecessary to translate driver pen events.
 *
 * 3. defined(MMI_PEN_SUPPORT_STROKE_LONGTAP) --> (MMI_PEN_STROKE_MIN_OFFSET == 0)
 *
 * In the first stroke (after mmi_pen_begin_strokes_of_character()), 
 * stroke down are translated to Stroke Down event directly. However, when pen stays at the 
 * pen down position within MMI_PEN_SKIP_STROKE_LONGTAP_OFFSET after MMI_PEN_STROKE_LONGTAP_TIME,
 * Stroke LongTap event is generated. Editor will interpret the subsequent 
 * Stroke Move events as editor cursor control commands.
 *
 * For example, driver events are converted to MMI events in the first stroke like:
 *
 * STROKE_DOWN, STROKE_UP --> MMI_PEN_STROKE_DOWN, MMI_PEN_STROKE_UP
 *       (The first stroke is created, and stroke buffer is not empty.)
 *
 * STROKE_DOWN, STROKE_MOVE, STROKE_UP --> 
 *       MMI_PEN_STROKE_DOWN, MMI_PEN_STROKE_MOVE, MMI_PEN_STROKE_UP
 *       (The first stroke is created, and stroke buffer is not empty.)
 *
 * STROKE_DOWN, STROKE_MOVE (1st), STROKE_LONGTAP, STROKE_MOVE (2nd), STROKE_UP -->
 *       MMI_PEN_STROKE_DOWN, MMI_PEN_STROKE_MOVE (1st), MMI_PEN_STROKE_LONGTAP, 
 *       MMI_PEN_STROKE_MOVE (2nd), MMI_PEN_STROKE_UP
 *       (The first stroke is aborted, handwriting area is reset to default, 
 *        Stroke buffer is cleared.)
 *       (NOTE: after STROKE_LONGTAP, we decrease the sampling rate to MMI_PEN_SAMPLING_PERIOD_1)
 *
 * Note that after the first stroke is created, STROKE_LONGTAP events generated by driver are ignored.
 *
 ****************************************************************************/

#if ( defined(__MMI_TOUCH_SCREEN__) || defined(__MMI_HANDWRITING_PAD__)) && !defined(__MTK_TARGET__)

/*****************************************************************************
 *
 * WIN32 integration 
 * PC Simulator & MODIS
 *
 ****************************************************************************/

#include "stdC.h"
#include "PixtelDataTypes.h"
#include "TimerEvents.h"
#include "KeyBrd.h"
#include "FrameworkStruct.h"
#include "EventsGprot.h"
#include "EventsDcl.h"
#include "EventsDef.h"
#include "gui_data_types.h"
#include "gui.h"
#include "IdleAppProt.h"

#include "kal_non_specific_general_types.h"
#include "TouchScreenGprot.h"
#include "DebugInitDef.h"

#include "lcd_sw_rnd.h" /* LCD width/height */
#include "time.h"       /* time() */

#include "gdi_include.h"
#include "ScreenRotationGprot.h"

#include "touch_panel_custom.h" /* get handwriting pad setting */

#if !defined(MMI_ON_WIN32)
static void mmi_pen_MODIS_start_timer(void);
static void mmi_pen_MODIS_flush_queue(void);
#endif /* !defined(MMI_ON_WIN32) */ 

/***************************************************************************** 
* Define
*****************************************************************************/

#define MMI_PEN_MAX_HANDWRITING_REGION (3)

#undef MMI_PEN_UNIT_TEST

/***************************************************************************** 
* Typedef 
*****************************************************************************/

typedef struct
{
    /* mmi_pen_block() & mmi_pen_unblock() */
    U32 is_blocked:1;

    /* mmi_pen_enable() & mmi_pen_disable() */
    U32 is_enabled:1;

    /* mmi_pen_reset() set 'is_pen_down' to 0 */
    U32 is_pen_down:1;

    /* The current pen down/move/up is a stroke */
    U32 is_stroke_event:1;

    /* Checking offset with g_pen_stroke_min_offset */
    U32 is_pending_stroke_event:1;

    /* A first stroke is created. This flag is cleared in mmi_pen_begin_strokes_of_character() */
    U32 is_stroke_created:1;

    /* Stroke LongTap event is generated. */
    U32 is_stroke_longtap_event_generated:1;

    /* Set in mmi_pen_end_strokes_of_character(), 
       do not enqueue incoming strokes until mmi_pen_begin_strokes_of_character() is invoked again */
    U32 is_all_stroke_finished:1;

    /* wait for 1: pen long-tap 0: pen repeat (event-based) */
    U32 is_waiting_long_tap_event:1;

    /* 
     * Set by mmi_pen_change_handwriting_area() and mmi_pen_stop_capture_strokes().
     * Close stroke and reset touch screen when pen is up. 
     */
    U32 reset_stroke_on_pen_up:1;

    /* The position where pen is tapped down */
    mmi_pen_point_struct pen_down_pos;

    /* Block index of handwriting area */
    S32 stroke_down_block_index;

    /* The current pen position */
    mmi_pen_point_struct pen_current_pos;

    /* For Pen Repeat */
    mmi_pen_point_struct pen_repeat_origin_pos;

    /* For stroke */
    S32 num_points_queued;
} mmi_pen_context_struct;

/***************************************************************************** 
* Local Variable
*****************************************************************************/

static mmi_pen_context_struct g_pen_cntx;

static mmi_pen_hdlr g_pen_event_table[MMI_PEN_EVENT_TYPE_MAX];
static mmi_pen_hdlr g_pen_stroke_table[MMI_PEN_STROKE_TYPE_MAX];
static void (*g_pen_stroke_pre_move) (void);
static void (*g_pen_stroke_post_move) (void);

static int g_pen_num_stroke_area;   /* 0 if stroke area is not enabled */
static mmi_pen_handwriting_area_struct g_pen_stroke_areas[MMI_PEN_MAX_HANDWRITING_REGION];
static mmi_pen_handwriting_area_struct g_pen_ext_stroke_area;
static int g_pen_stroke_min_offset;
static S32 g_pen_stroke_max_points;
static mmi_pen_point_struct *g_pen_stroke_points;

/***************************************************************************** 
* Local Function
*****************************************************************************/

static void mmi_pen_MODIS_tp_ind(void *);

/*****************************************************************************
 * FUNCTION
 *  mmi_pen_simulator_fix_point_bound
 * DESCRIPTION
 *  
 * PARAMETERS
 *  x       [IN/OUT]     
 *  y       [INT/OUT]     
 * RETURNS
 *  void
 *****************************************************************************/
static void mmi_pen_simulator_fix_point_bound(S16 *x, S16 *y, MMI_BOOL check_multi_block)

⌨️ 快捷键说明

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