Touch event processing method, terminal and storage medium
By sending touch event data directly to the terminal, the problem of terminal response latency is solved, thus avoiding waiting for the recognition algorithm to determine the type and improving the smoothness of touch operation and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-10-17
- Publication Date
- 2026-04-17
AI Technical Summary
When a terminal detects touch events, the time required for the recognition algorithm to identify the type of touch event is relatively long, resulting in a delay in responding to user touch operations, which reduces smoothness and user experience.
After the event packaging thread sends the touch data of the touch event to the knuckle thread, the touch event is sent directly to the event dispatch thread, avoiding waiting for the recognition algorithm to determine the touch event type and reducing the waiting time of the event dispatch thread.
It reduces the latency in responding to user touch operations, improves the smoothness of responding to user touch operations, and enhances the user experience.
Smart Images

Figure CN121880041A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a touch event processing method, a terminal, and a storage medium. Background Technology
[0002] With the diversification of terminal functions, most terminals on the market (such as mobile phones and tablets) now support knuckle gestures. Users can trigger specific functions by using their knuckles to operate on the terminal's touchscreen. For example, tapping, double-tapping, or drawing circles with the knuckles on the terminal's touchscreen can activate functions such as screenshotting and screen recording.
[0003] When a terminal detects a touch event, it loads a recognition algorithm based on various sensor and touch information to identify the type of touch event, determining whether it is a joint-type event, a finger-type event, or a stylus-type event. The terminal's execution of the recognition algorithm to complete the touch event type detection typically takes varying degrees of time, increasing the latency in responding to user touch operations, reducing the smoothness of the response, and ultimately degrading the user experience. Summary of the Invention
[0004] The purpose of this application is to provide a touch event processing method, a terminal, and a storage medium to reduce the latency in responding to user touch operations, improve the smoothness of responding to user touch operations, and thus enhance the user experience. The specific technical solution is as follows:
[0005] Firstly, in order to achieve the above objectives, embodiments of this application provide a touch event processing method, which is applied to a terminal, and the method includes:
[0006] After detecting a touch event through the event packaging thread, the touch data of the touch event is sent to the knuckle thread, and the touch event carrying a preset tag is sent to the event dispatch thread.
[0007] After detecting the touch event through the knuckle thread and obtaining the touch data of the touch event, the recognition algorithm is loaded to process the touch data of the touch event to obtain the touch type of the touch event, which is used as the target type.
[0008] The target type of the touch event is sent to the event dispatch thread via the knuckle thread;
[0009] Upon receiving the touch event sent by the event packaging thread and the target type sent by the knuckle thread, the event dispatch thread modifies the preset marker of the touch event to the target type and dispatches the touch event according to the target type of the touch event.
[0010] As can be seen from the above, the technical solution provided in this embodiment allows the event packaging thread to send the touch data of the touch event to the knuckle thread, and then directly send the touch event to the event distribution thread. It does not require waiting for the recognition algorithm to determine the target type of the touch event before sending the touch event to the event distribution thread. This can save the waiting time of the event distribution thread, thereby reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0011] In one embodiment of this application, the target type includes any one of: knuckle type, finger type, and stylus type;
[0012] The step of distributing the touch event according to the target type of the touch event includes:
[0013] When the target type is a finger type or a stylus type, the touch event is distributed to the target application currently running on the terminal through the event distribution thread, and the target application responds to the touch event;
[0014] When the target type is a knuckle type, the touch event is distributed to the knuckle event processing module of the terminal through the event distribution thread, and the touch event is responded to through the knuckle event processing module.
[0015] As can be seen from the above, the technical solution provided in this embodiment determines the touch type of the touch event and responds to the touch event according to the touch type, thereby improving the smoothness of responding to user touch operations and thus improving the user experience.
[0016] In one embodiment of this application, the touch data includes: coordinate information, capacitance information, and acceleration information of the touch event;
[0017] Before sending the touch data of the touch event to the knuckle thread and sending the touch event carrying a preset tag to the event dispatch thread after the touch event is detected by the event packaging thread, the method further includes:
[0018] After a touch event is detected by the touch screen, the touch event and its coordinate information are sent to the event packaging thread via the touch screen, and the touch event and its tolerance information are also sent to the knuckle thread via the touch screen.
[0019] After detecting a touch event through the event packaging thread, the touch data of the touch event is sent to the knuckle thread, including:
[0020] After detecting a touch event through the event packaging thread, the coordinate information of the touch event is sent to the knuckle thread;
[0021] After detecting the touch event through the knuckle thread and obtaining the touch data of the touch event, a recognition algorithm is loaded to process the touch data of the touch event to obtain the touch type of the touch event, which is used as the target type, including:
[0022] After detecting a touch event through the knuckle thread, the acceleration information of the touch event is obtained;
[0023] After obtaining the coordinate information, tolerance information, and acceleration information of the touch event through the knuckle thread, the recognition algorithm is loaded to process the coordinate information, tolerance information, and acceleration information of the touch event to obtain the touch type of the touch event, which is used as the target type.
[0024] As can be seen from the above, the technical solution provided in this embodiment involves the event packaging thread sending the coordinate information of the touch event to the knuckle thread, the touchscreen sending the capacitance information of the touch event to the knuckle thread, the knuckle thread obtaining the acceleration information of the touch event, and processing the coordinate information, capacitance information, and acceleration information of the touch event to obtain the touch type of the touch event. This can accurately determine the touch type of the touch event and respond to the touch event according to the touch type, thereby improving the smoothness of responding to user touch operations and thus improving the user experience.
[0025] In one embodiment of this application, the step of sending the coordinate information of the touch event to the knuckle thread after detecting the touch event through the event packaging thread includes:
[0026] After the event packaging thread detects a touch event, it calls the Updata function to send the coordinate information of the touch event to the knuckle thread.
[0027] In one embodiment of this application, sending the target type of the touch event to the event dispatch thread via the knuckle thread includes:
[0028] The target type of the touch event is sent to the event dispatch thread by calling the GetResult function through the knuckle thread.
[0029] In one embodiment of this application, the event packaging thread is an InputReader thread; and the event dispatching thread is an InputDispatcher thread.
[0030] In one embodiment of this application, the touch event is a Down event;
[0031] The method further includes:
[0032] After the event packaging thread detects a specified event, it sends the specified event carrying a preset tag to the event dispatch thread; wherein, the specified touch event is a Move event or a Raise event;
[0033] After receiving the specified event sent by the event packaging thread, the event dispatch thread modifies the preset flag of the specified event to the target type of the Down event corresponding to the specified event, and dispatches the specified event according to the target type of the specified event.
[0034] As can be seen from the above, the technical solution provided in this embodiment does not require the knuckle thread to reload the recognition algorithm to identify the touch type of the specified event, saving the processing time of touch events, further reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0035] Secondly, embodiments of this application also provide a terminal, including:
[0036] One or more processors and memory;
[0037] The memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the terminal to execute any of the above-described touch event handling methods.
[0038] Thirdly, embodiments of this application also provide a computer-readable storage medium including a computer program that, when the computer program is run on a terminal, causes the terminal to execute any of the touch event processing methods described above.
[0039] Fourthly, embodiments of this application also provide a computer program product, the computer program product comprising executable instructions, which, when executed on a terminal, cause the terminal to execute any of the touch event processing methods described above.
[0040] Fifthly, embodiments of this application also provide a chip system applied to a terminal. The chip system includes one or more processors, which are used to invoke computer instructions to cause the terminal to input data into the chip system and execute any of the touch event processing methods described above to process the data and output the processing result.
[0041] The beneficial effects of the solutions provided in the embodiments of the second, third, fourth and fifth aspects above can be found in the beneficial effects of the solutions provided in the embodiments of the first aspect above. Attached Figure Description
[0042] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 A structural diagram of a terminal provided in an embodiment of this application;
[0044] Figure 2 A software structure block diagram of a terminal provided in an embodiment of this application;
[0045] Figure 3 A schematic diagram illustrating an application scenario of the first touch event handling method provided in this application embodiment;
[0046] Figure 4 A flowchart of the first touch event handling method provided in the embodiments of this application;
[0047] Figure 5 A flowchart illustrating the second touch event handling method provided in this application embodiment;
[0048] Figure 6 A schematic diagram of the first type of thread interaction interface provided in the embodiments of this application;
[0049] Figure 7 A flowchart of the third touch event handling method provided in the embodiments of this application;
[0050] Figure 8 A schematic diagram of a second type of thread interaction interface provided in an embodiment of this application;
[0051] Figure 9 A flowchart of the fourth touch event handling method provided in the embodiments of this application;
[0052] Figure 10 A schematic diagram illustrating an application scenario of the second touch event handling method provided in this application embodiment;
[0053] Figure 11 for Figure 10 The flowchart illustrates the touch event distribution process in the application scenario shown.
[0054] Figure 12 for Figure 3 The flowchart illustrates the touch event distribution process in the application scenario shown.
[0055] Figure 13 A flowchart of a touch event handling method provided for related technologies;
[0056] Figure 14 In accordance with Figure 13 Timing diagram of each thread when handling touch events;
[0057] Figure 15 A flowchart illustrating the fifth touch event handling method provided in this application embodiment;
[0058] Figure 16 In accordance with Figure 15 Timing diagram of each thread when handling touch events;
[0059] Figure 17 This is a structural diagram of a chip system provided in an embodiment of this application. Detailed Implementation
[0060] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0061] To facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with essentially the same function and effect. For example, "first instruction" and "second instruction" are used to distinguish different user instructions and do not limit their order. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.
[0062] It should be noted that, in this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0063] The touch event processing method provided in this application is applied to a terminal. The terminal can be a mobile phone, tablet computer, personal digital assistant (PDA), smartwatch, wearable electronic device, augmented reality (AR) device, virtual reality (VR) device, robot, smart glasses, or other terminal equipped with a touchscreen. This allows the terminal to respond to user touch events according to the method provided in this application, thereby improving the user experience.
[0064] For example, Figure 1A structural diagram of terminal 100 is shown. Terminal 100 may include a processor 110, a display screen 120, a camera 130, internal memory 140, a Subscriber Identification Module (SIM) card interface 150, a Universal Serial Bus (USB) interface 160, a charging management module 170, a battery management module 171, a battery 172 with battery cells and battery protection devices, a sensor module 180, a mobile communication module 190, a wireless communication module 200, antenna 1, and antenna 2, etc. The sensor module 180 may include a pressure sensor 180A, a fingerprint sensor 180B, a touch sensor 180C, an ambient light sensor 180D, etc.
[0065] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the terminal 100. In other embodiments of this application, the terminal 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0066] Processor 110 may include one or more processing units, such as a Central Processing Unit (CPU), an Application Processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent components or integrated into one or more processors. In some embodiments, terminal 100 may also include one or more processors 110. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution. In other embodiments, processor 110 may also include a memory for storing instructions and data. For example, the memory in processor 110 may be a cache memory. This memory can store instructions or data that processor 110 has just used or is repeatedly used. If processor 110 needs to reuse the instruction or data, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the terminal 100 in processing data or executing instructions.
[0067] In some embodiments, the processor 110 may include one or more interfaces. These interfaces may include an Inter-Integrated Circuit (I2C) interface, an Inter-Integrated Circuit Sound (I2S) interface, a Pulse Code Modulation (PCM) interface, a Universal Asynchronous Receiver / Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI) interface, a General-Purpose Input / Output (GPIO) interface, a SIM card interface, and / or a USB interface, etc. The USB interface 160 is a USB standard-compliant interface, specifically a Mini USB interface, a Micro USB interface, a USB Type-C interface, etc. The USB interface 160 can be used to connect a charger to charge the terminal 100, and can also be used for data transfer between the terminal 100 and peripheral devices. The USB interface 160 can also be used to connect headphones for audio playback.
[0068] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are for illustrative purposes only and do not constitute a structural limitation on the terminal 100. In other embodiments of this application, the terminal 100 may also adopt different interface connection methods or a combination of multiple interface connection methods as described in the above embodiments.
[0069] The wireless communication function of terminal 100 can be implemented through antenna 1, antenna 2, mobile communication module 190, wireless communication module 200, modem processor and baseband processor.
[0070] Antennas 1 and 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0071] Terminal 100 implements display functions through a GPU, display screen 120, and application processor. The GPU is a microprocessor for image processing, connected to the display screen 120 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0072] The display screen 120 is used to display images, videos, etc. The display screen 120 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the terminal 100 may include one or more display screens 120.
[0073] In some embodiments of this application, when the display panel uses materials such as OLED, AMOLED, and FLED, the above-mentioned Figure 1 The display screen 120 can be bent. Here, "the display screen 120 can be bent" means that the display screen can be bent to any angle at any point and held at that angle. For example, the display screen 120 can be folded in half horizontally from the middle, or vertically from the middle.
[0074] The display screen 120 of terminal 100 can be a flexible screen. Currently, flexible screens are attracting much attention due to their unique characteristics and enormous potential. Compared to traditional screens, flexible screens are highly flexible and bendable, providing users with new interaction methods based on their bendability and meeting more user needs for terminals. For terminals equipped with foldable displays, the foldable display can switch between a small screen in folded mode and a large screen in unfolded mode at any time. Therefore, users are increasingly using split-screen functionality on terminals equipped with foldable displays.
[0075] Terminal 100 can perform shooting functions through ISP, camera 130, video codec, GPU, display 120 and application processor, wherein camera 130 includes a front camera and a rear camera.
[0076] The ISP is used to process data fed back from the camera 130. For example, during shooting, when the shutter is opened, light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can perform algorithmic optimization of image noise, brightness, and color. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 130.
[0077] Camera 130 is used to capture photos or videos. An object is projected onto a photosensitive element through a lens, generating an optical image. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to an ISP (Internet Service Provider) for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP (Digital Signal Processor) for processing. The DSP converts the digital image signal into standard red-green-blue (RGB), YUV, or other image signals. In some embodiments, terminal 100 may include one or N cameras 130, where N is a positive integer greater than 1.
[0078] A digital signal processor (DSP) is used to process digital signals. Besides digital image signals, it can also process other digital signals. For example, when terminal 100 selects a frequency point, the DSP can perform Fourier transforms on the frequency energy.
[0079] Video codecs are used to compress or decompress digital video. Terminal 100 may support one or more video codecs. Thus, terminal 100 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, and MPEG 4.
[0080] NPU stands for Neural Network (NN) computing processor. By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs can enable intelligent cognitive applications in terminals, such as image recognition, facial recognition, speech recognition, and text understanding.
[0081] The internal memory 140 can be used to store one or more computer programs, which include instructions. The processor 110 can execute the instructions stored in the internal memory 140, thereby causing the terminal 100 to perform the image generation method provided in some embodiments of this application, as well as various applications and data processing. The internal memory 140 may include a program storage area and a data storage area. The program storage area may store the operating system; it may also store one or more applications (such as a gallery, contacts, etc.). The data storage area may store data created by the terminal 100 during use (such as photos, contacts, etc.). Furthermore, the internal memory 140 may include high-speed random access memory and non-volatile memory, such as one or more disk storage components, flash memory components, Universal Flash Storage (UFS), etc. In some embodiments, the processor 110 can execute the touch event processing method provided in the embodiments of this application, as well as other applications and data processing, by running instructions stored in the internal memory 140 and / or instructions stored in memory disposed in the processor 110.
[0082] The internal memory 140 can be used to store the relevant program of the touch event processing method provided in the embodiments of this application. The processor 110 can be used to call the relevant program of the touch event processing method stored in the internal memory 140 when displaying information, and execute the touch event processing method of the embodiments of this application.
[0083] The sensor module 180 may include a pressure sensor 180A, a fingerprint sensor 180B, a touch sensor 180C, an ambient light sensor 180D, etc.
[0084] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be disposed on display screen 120. Pressure sensor 180A can be of many types, such as resistive pressure sensor, inductive pressure sensor, or capacitive pressure sensor. A capacitive pressure sensor can include at least two parallel plates with conductive material. When force is applied to pressure sensor 180A, the capacitance between the electrodes changes, and terminal 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 120, terminal 100 detects the touch operation based on pressure sensor 180A. Terminal 100 can also calculate the touch position based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS is executed; when a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS is executed.
[0085] The fingerprint sensor 180B is used to collect fingerprints. The terminal 100 can use the collected fingerprint characteristics to perform functions such as unlocking, accessing the app lock, taking photos, and answering calls.
[0086] Touch sensor 180C, also known as a touch device, can be disposed on display screen 120. The touch sensor 180C and display screen 120 together form a touchscreen, also known as a touch display. Touch sensor 180C is used to detect touch operations applied to or near it. Touch sensor 180C can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 120. In other embodiments, touch sensor 180C may also be disposed on the surface of terminal 100, and in a different location from display screen 120.
[0087] The ambient light sensor 180D is used to sense the ambient light intensity. The terminal 100 can adaptively adjust the brightness of the display screen 120 based on the sensed ambient light intensity. The ambient light sensor 180D can also be used to automatically adjust the white balance during shooting. The ambient light sensor 180D can also transmit environmental information about the device's location to the GPU.
[0088] The ambient light sensor 180D is also used to acquire the brightness, light ratio, color temperature, and other parameters of the environment in which the camera 130 captures images.
[0089] Figure 2This is a software architecture block diagram for a terminal to which this application's embodiments apply. The terminal's software system can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. A layered architecture divides the terminal's software system into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the software system can be divided into three layers: the application layer, the application framework layer, and the hardware abstract layer (HAL).
[0090] The application layer can include a series of application packages. The application layer runs applications by calling the application programming interface (API) provided by the application framework layer. For example... Figure 2 As shown, the application package may include multiple applications, such as camera, clock, browser, and music programs. Understandably, the port of each of these applications can be used to receive data.
[0091] The application framework layer provides APIs and a programming framework for applications within the application layer. The application framework layer includes predefined functions. For example... Figure 2 As shown, the application framework layer may include a window manager, content provider, view system, resource manager, notification manager, and Dynamic Host Configuration Protocol (DHCP) module, etc.
[0092] The driver layer is the layer between hardware and software, used to drive the hardware and make it work. Multiple drivers can be installed in the driver layer to operate the hardware. Examples include camera drivers, display drivers, audio drivers, and sensor drivers.
[0093] In addition, the terminal also includes a hardware layer, which may include a camera, speaker, display screen and battery, etc. The hardware layer is connected to the driver layer.
[0094] The following describes the application scenarios of the touch event handling method provided in the embodiments of this application.
[0095] like Figure 3 As shown, the terminal displays the communication interface between the instant messaging application and contact 1. The user taps on this interface with their knuckle. Correspondingly, the capacitance of the terminal's touchscreen changes. When the touchscreen capacitance changes, a touch event can be confirmed.
[0096] Touch event distribution relies on the Android Input framework, which collects touch events from the Linux Input driver and then packages and distributes them. The packaging and distribution of touch events in the Android Input framework corresponds to two core threads: the InputReader thread and the InputDispatcher thread.
[0097] See Figure 4 When the touchscreen at the hardware layer detects a touch event, it reports the event to the corresponding device driver (i.e., the display driver) at the driver layer. The InputReader thread at the system runtime layer calls the EventHub object to listen to the display driver and calls the getEvents function to extract touch events. The InputReader thread obtains touch events, such as clicks and swipes, through the EventHub object. The InputReader thread packages the touch events and passes them to the InputDispatcher thread. Upon receiving a touch event, the InputDispatcher thread dispatches it to the InputManagerService at the application framework layer. The InputManagerService finds the target window and dispatches the touch event to the target application at the application layer for a response.
[0098] Touch events are represented using the Motion Event class. The Motion Event class has a member variable that represents the touch type of the touch event. Touch types include: Finger, Stylus, and Knuckle.
[0099] A complete touch event flow is: Down, Move, Up. To avoid confusion between knuckle-type and finger-type touch events, the touch event needs to be marked before the down event is dispatched through the InputReader thread, that is, the touch type of the touch event needs to be determined first.
[0100] In related technologies, such as Figure 5As shown, after the InputReader thread obtains the touch event, it also needs to obtain the touch type of the touch event from the FingerSense module. The FingerSense module needs to load a recognition algorithm to process the touch data of the touch event to obtain the touch type of the touch event. Figure 6 As shown, the FingerSense module sends the touch type of the touch event to the InputReader thread through the GetResult function. The GetResult function is a predefined interface function used by the InputReader thread to obtain the touch type. After obtaining the type of the touch event, the InputReader thread marks the touch type of the touch event and dispatches the marked touch event to the InputDispatcher thread.
[0101] However, during the aforementioned process, the InputReader thread is in a blocked state during the time period when the FingerSense module identifies the touch event type, meaning the InputReader thread needs to wait for a relatively long time (e.g., Figure 5 The delay in sending touch events to the InputDispatcher thread (due to the blocking time of the InputReader thread) increases the latency of the terminal's response to user touch operations, reduces the smoothness of the terminal's response to user touch operations, and degrades the user experience.
[0102] To address the aforementioned issues, the touch event processing method provided in the application embodiment involves the event packaging thread (i.e., the InputReader thread) sending the touch data of the touch event to the knuckle thread, and then directly sending the touch event to the event dispatch thread. This eliminates the need to wait for the recognition algorithm to determine the target type of the touch event before sending it to the event dispatch thread (i.e., the InputDispatcher thread). This saves the waiting time of the event dispatch thread, thereby reducing the latency in responding to user touch operations, improving the smoothness of responding to user touch operations, and ultimately enhancing the user experience.
[0103] Next, the touch event processing method provided in this application will be described in detail through specific embodiments.
[0104] In one embodiment of this application, see [link to embodiment]. Figure 7 , Figure 7 A flowchart of a touch event handling method provided in this application embodiment, the method being applied to a terminal, and the method may include the following steps:
[0105] S701: After detecting a touch event through the event packaging thread, it sends the touch data of the touch event to the knuckle thread and sends the touch event carrying a preset tag to the event dispatch thread.
[0106] S702: After detecting a touch event through the knuckle thread and obtaining the touch data of the touch event, the recognition algorithm is loaded to process the touch data of the touch event and obtain the touch type of the touch event as the target type.
[0107] S703: The target type for sending touch events to the event dispatch thread via the knuckle thread.
[0108] S704: After receiving a touch event sent by the event packaging thread and the target type sent by the knuckle thread, the event dispatch thread modifies the preset flag of the touch event to the target type and dispatches the touch event according to the target type of the touch event.
[0109] As can be seen from the above, the technical solution provided in this embodiment allows the event packaging thread to send the touch data of the touch event to the knuckle thread, and then directly send the touch event to the event distribution thread. It does not require waiting for the recognition algorithm to determine the target type of the touch event before sending the touch event to the event distribution thread. This can save the waiting time of the event distribution thread, thereby reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0110] For steps S701 and S702, the event packaging thread is the InputReader thread, which is used to acquire user touch events on the terminal. The event dispatch thread is the InputDispatcher thread, which is used to dispatch touch events according to their touch type. The knuckle thread is a thread started in the FingerSense module used to identify the touch type of touch events.
[0111] like Figure 8 As shown, the FingerSense module starts a knuckle thread, which defines an `Updata` function and a `GetResult` function. The event packaging thread reports the touch data of the touch event to the knuckle thread through the `Updata` function, which is a predefined interface function used by the `InputReader` thread to report touch data. The knuckle thread uses the `GetResult` function to inform the event dispatch thread of the touch event type, which is a predefined interface function used by the `InputDispatcher` thread to obtain the touch type.
[0112] Users perform various touch operations on the terminal's touchscreen, such as clicking with their fingers, tapping with their knuckles, or drawing with a stylus. Upon detecting a touch event, the terminal dispatches the touch event through an event packaging thread, a knuckle thread, and an event dispatch thread, and then responds to the touch event.
[0113] In some embodiments, the touch data includes: coordinate information, capacitance information, and acceleration information of the touch event. The coordinate information includes the position where the user performs a touch operation on the terminal's touchscreen. The capacitance information includes the capacitance of the touchscreen after the user performs a touch operation on the terminal's touchscreen. The acceleration information includes the acceleration of the terminal in a target direction, which is perpendicular to the terminal's touchscreen, when the user performs a touch operation on the terminal's touchscreen.
[0114] Accordingly, before step S701, the method may further include the following steps: after detecting a touch event through the touch screen, sending the touch event and the coordinate information of the touch event to the event packaging thread through the touch screen, and sending the touch event and the tolerance information of the touch event to the knuckle thread through the touch screen.
[0115] Accordingly, step S701 may include the following steps: after detecting a touch event through the event packaging thread, sending the coordinate information of the touch event to the knuckle thread.
[0116] Accordingly, step S702 may include the following steps: after detecting a touch event through the knuckle thread, obtaining the acceleration information of the touch event; after obtaining the coordinate information, capacitance information and acceleration information of the touch event through the knuckle thread, loading the recognition algorithm to process the coordinate information, capacitance information and acceleration information of the touch event to obtain the touch type of the touch event as the target type.
[0117] The touchscreen scans capacitance information every few milliseconds according to the touch sampling rate period. If a change in capacitance is detected, a touch event is determined to have occurred, and the touch event is reported to the corresponding device driver. Furthermore, the touchscreen sends the coordinate information of the touch event to the event packaging thread and the capacitance information of the touch event to the knuckle thread.
[0118] Touch events are monitored via an EventHub object, and the event packaging thread is awakened upon detecting a touch event. Once the event packaging thread detects a touch event, it directly sets the touch event's tool type to a preset flag, for example, setting the touch event's tool type to pending. Then, it sends the touch event marked as pending to the event dispatch thread, waking up the event dispatch thread to begin event dispatch preparation.
[0119] Furthermore, upon detecting a touch event, the event packaging thread calls the Update function to send the coordinate information of the touch event to the knuckle thread. Correspondingly, after detecting a touch event, the knuckle thread receives the capacitance information of the touch event reported by the touchscreen, as well as the coordinate information of the touch event sent by the event packaging thread. Then, the knuckle thread obtains the acceleration (ACC) information of the touch event.
[0120] The terminal's touchscreen is equipped with an accelerometer, for example, a linear variable differential transformer (LVDT). This accelerometer includes an ACC sensor. Accordingly, the accelerometer can collect the terminal's acceleration information.
[0121] Acceleration information includes the terminal's acceleration along the X, Y, and Z axes. The X-axis is the horizontal direction of the plane containing the touchscreen, the Y-axis is the vertical direction of the plane containing the touchscreen, and the Z-axis is the vertical direction passing through the touchscreen. The terminal's acceleration changes when the user interacts with the touchscreen, and the changes in acceleration vary depending on the type of touch event performed.
[0122] Accordingly, after the knuckle thread obtains the coordinate information, capacitance information, and acceleration information of the touch event, it loads the recognition algorithm to process the coordinate information, capacitance information, and acceleration information of the touch event to obtain the touch type of the touch event, which is used as the target type.
[0123] As can be seen from the above, the technical solution provided in this embodiment involves the event packaging thread sending the coordinate information of the touch event to the knuckle thread, the touchscreen sending the capacitance information of the touch event to the knuckle thread, the knuckle thread obtaining the acceleration information of the touch event, and processing the coordinate information, capacitance information, and acceleration information of the touch event to obtain the touch type of the touch event. This can accurately determine the touch type of the touch event and respond to the touch event according to the touch type, thereby improving the smoothness of responding to user touch operations and thus improving the user experience.
[0124] For steps S703 and S704, the target type includes any one of the following: knuckle type, finger type, and stylus type.
[0125] When the target type is knuckle type, it indicates that the user is using their knuckle to operate the device's touchscreen. When the target type is finger type, it indicates that the user is using their finger to operate the device's touchscreen. When the target type is stylus type, it indicates that the user is using a stylus to operate the device's touchscreen.
[0126] Different types of touch events require different responses from the terminal. Therefore, the knuckle thread calls the GetResult function to send the target type of the touch event to the event dispatch thread. Correspondingly, upon receiving the touch event from the event packaging thread and the target type from the knuckle thread, the event dispatch thread modifies the preset flag of the touch event to the target type. For example, if the target type is "finger," the pending flag of the touch event is changed to "Finger." If the target type is "knuckle," the pending flag is changed to "Knuckle." If the target type is "stylus," the pending flag is changed to "Stylus."
[0127] Then, the event dispatch thread dispatches the touch events according to the target type of the touch event.
[0128] See Figure 9 The FingerSense module starts a knuckle thread to identify the touch type of touch events. After the InputReader thread sends the touch data of the touch event to the knuckle thread, it does not block and continues to package the event, sending the packaged touch event to the InputDispatcher thread. After the knuckle thread obtains the touch data of the touch event, it loads the recognition algorithm to determine the target type of the touch event. The InputDispatcher thread receives the touch event sent by the InputReader thread and prepares for event dispatch. After receiving the target type from the knuckle thread, it then performs event dispatch.
[0129] In the above process, the InputReader thread's event packaging and the knuckle thread's running of the recognition algorithm operate in parallel for a period of time, as do the InputDispatcher thread's event dispatch preparation and the knuckle thread's running of the recognition algorithm. This parallelism can save waiting time. Figure 9 In the process, the Block time of the InputDispatcher thread is less than Figure 5 The Block time of the InputReader thread. The Block time of the InputDispatcher thread is the time required to wait for the knuckle thread in the FingerSense module to send the target type of the touch event.
[0130] As can be seen, the touch event handling method provided in this application embodiment can reduce the waiting time of the InputDispatcher thread, thereby reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0131] In some embodiments, step S704 may include the following steps:
[0132] When the target type is a finger or stylus, the touch event is dispatched to the target application currently running on the terminal through the event dispatch thread, and the target application responds to the touch event.
[0133] When the target type is knuckle type, the touch event is distributed to the knuckle event handling module of the terminal through the event dispatch thread, and the touch event is responded to through the knuckle event handling module.
[0134] When the target type of a touch event is a finger or stylus, it indicates that the user is interacting with the target application currently running on the device. The event dispatch thread dispatches the touch event to the target application currently running on the device, and the target application responds to the touch event.
[0135] For example, Figure 10 In the middle, the terminal displays the communication interface between the instant messaging application and contact 1. The user operates on this interface with their finger. This operation is performed on the instant messaging application and requires a response from the instant messaging application. The terminal then responds accordingly. Figure 11 The method shown handles finger-type touch events.
[0136] Touch events include drop, move, and lift actions. Figure 11 The touch events include Down, Move, and Up events. When a Down event is detected, and the target type of the touch event is identified as a finger according to the method provided in this application embodiment, the event dispatch thread dispatches the Down event to the application for response. If the subsequent Move and Up events are also of the finger type, the event dispatch thread dispatches the Move and Up events to the application for response.
[0137] When the target type of a touch event is knuckle type, it indicates that the user is operating on the entire display interface of the terminal, such as tapping the terminal's touchscreen to take a screenshot. The event dispatch thread dispatches the touch event to the knuckle event handling module in the terminal's operating system. The knuckle event handling module is a functional module used to handle knuckle event settings, and thus, the touch event can be responded to by the knuckle event handling module.
[0138] For example, Figure 3 In the middle, the terminal displays the communication interface of the instant messaging application and contact 1. The user operates on this interface with their knuckles. This operation is performed on the entire display interface of the terminal and requires a response from the terminal's operating system. The terminal then follows... Figure 12 The method shown handles knuckle-type touch events.
[0139] Touch events include drop, move, and lift actions. Figure 12The touch events include Down, Move, and Up events. When a Down event is detected, and the target type of the touch event is identified as a knuckle type according to the method provided in this application embodiment, the Down event is intercepted and not dispatched to the application for response. Instead, it is dispatched to the knuckle event handling module according to the knuckle type, where the knuckle event handling module responds to the Down event. For subsequent Move and Up events, which are also knuckle types, the event dispatch thread dispatches the Move and Up events to the knuckle event handling module for response.
[0140] As can be seen from the above, the technical solution provided in this embodiment determines the touch type of the touch event and responds to the touch event according to the touch type, thereby improving the smoothness of responding to user touch operations and thus improving the user experience.
[0141] In some embodiments, the touch event is a Down event. The method may further include the following steps:
[0142] After the event packaging thread detects a specified event, it sends the specified event carrying a preset flag to the event dispatch thread. The specified touch event is either a Move event or an Up event.
[0143] After receiving a specified event from the event packaging thread, the event dispatch thread modifies the preset flag of the specified event to the target type of the Down event corresponding to the specified event, and dispatches the specified event according to the target type of the specified event.
[0144] The complete process of a touch event includes Down, Move, and Up events. For the same touch event, the touch type of the Down, Move, and Up events is the same. Therefore, the knuckle thread loading recognition algorithm only needs to identify the touch type of the Down event. The Down, Move, and Up events of the same touch event have the same identifier, such as having the same touch ID. The event packaging thread and the event dispatch thread determine the Down, Move, and Up events of the same touch event based on the Touch ID.
[0145] Subsequently, after the event packaging thread detects a specified event (i.e., a Move event or an Up event) that belongs to the same touch event as the Down event, it can directly send the specified event carrying a preset flag to the event dispatch thread. After receiving the specified event sent by the event packaging thread, the event dispatch thread directly modifies the preset flag of the specified event to the target type of the Down event corresponding to the specified event, and dispatches the specified event according to the target type of the specified event.
[0146] As can be seen from the above, the technical solution provided in this embodiment does not require the knuckle thread to reload the recognition algorithm to identify the touch type of the specified event, saving the processing time of touch events, further reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0147] See Figure 13 , Figure 13 A flowchart of a touch event handling method provided for related technologies.
[0148] The terminal's touchscreen detects user touch actions and detects touch (ROI) events (i.e., touch events in the aforementioned embodiments) through the touch listening thread (Aptouch daemon). After listening to the ROI event, it sends out the ROI event to wake up the waiting touchscreen thread (Wait tp thread) (i.e., the knuckle thread in the aforementioned embodiments) and the InputReader thread in the knuckle frame (i.e., the FingerSense module in the aforementioned embodiments).
[0149] After the Wait tp thread detects a ROI or touch event, it enters a locked state. This is the process where the Wait tp thread acquires the ACC data required for the ROI event. The Wait tp thread requests acceleration from the accelerometer (Request ACC) and waits for the acceleration to be ready (Wait ACC ready). The accelerometer returns an acceleration file (ACC file) to the Wait tp thread, which then reads the acceleration file (Read ACC file) and sets new acceleration data (Set ACC data new). This means inputting the newly acquired acceleration data into the classification algorithm (i.e., the recognition algorithm in the aforementioned embodiment). Then, the Wait tp thread enters an unlocked state and begins the next loop, processing subsequent ROI events in the same way.
[0150] After the InputReader thread listens for the ROI event, it enters the Lock state. This means the InputReader thread waits to acquire the ACC data required for the ROI event. The InputReader thread then determines whether it has acquired the new ACC data required for ClassfulTouch. If not, i.e., the new ACC data has not been acquired, the InputReader thread requests ACC from the accelerometer and waits for ACC preparation to complete. The accelerometer returns an accelerometer file to the InputReader thread, which then reads the ACC file, acquiring the new ACC data. Finally, the InputReader thread enters the Unlock state, which allows it to proceed with its subsequent steps.
[0151] If so, meaning new ACC data is obtained, the InputReader thread sets the ACC data to old (Set ACCdata old), which means inputting the obtained acceleration data into the classification algorithm and marking it as already processed acceleration data. Then, the InputReader thread enters the unlock state, which allows it to proceed with its subsequent processes.
[0152] The InputReader thread then proceeds to the next stage of its process. It reads the touch file (Readroi file), which contains the tolerance information of the ROI events. It also loads the classification algorithm file (FS Classification alg) to process the coordinate, acceleration, and tolerance information of the touch events, determining the touch type of the ROI event. Once this processing ends, the InputReader thread sends the ROI events and touch type to the InputDispatcher thread. The InputDispatcher thread then dispatches the ROI events according to their touch types.
[0153] See Figure 14 , Figure 14 In accordance with Figure 13 This is a timing diagram showing the filtering and tracking of each thread when handling touch events. The Android UI (Android.ui) is represented by the FingerSense module.
[0154] Figure 14In the event that a ROI event is detected at 00:00:03, the InputReader thread and the Wait tp thread in the FingerSense module are awakened. Accordingly, the InputReader thread starts running, and the Wait tp thread also begins running.
[0155] Then, the Wait tp thread begins acquiring ACC data. During this process, due to mutual exclusion between the InputReader thread and the Wait tp thread (Contending for pthread mutex), the Wait tp thread starts acquiring ACC data while the InputReader thread enters a waiting state. After the Wait tp thread acquires the ACC data and inputs it into the classification algorithm, the InputReader thread loads the classification algorithm to determine the touch type of the ROI event, and continues running. After obtaining the ROI event touch type, the InputDispatcher thread begins running, meaning the InputReader thread sends the ROI event and touch type to the InputDispatcher thread. The InputDispatcher thread then dispatches the ROI event according to the touch type.
[0156] The "Contending for pthread mutex" period in the timing diagram above represents the waiting time for the InputReader thread. This means that the InputReader thread needs to wait a relatively long time before distributing touch events to the InputDispatcher thread, which increases the latency of the terminal's response to user touch operations, reduces the smoothness of the terminal's response to user touch operations, and degrades the user experience.
[0157] See Figure 15 , Figure 15 A flowchart of a touch event handling method provided in an embodiment of this application.
[0158] The terminal's touchscreen detects user touch actions and detects touch (ROI) events (i.e., touch events in the aforementioned embodiments) through a touch listening thread. After listening to an ROI event, it wakes up the waiting touchscreen thread (Wait tp thread) (i.e., the knuckle thread in the aforementioned embodiments) and the InputReader thread in the knuckle frame (i.e., the FingerSense module in the aforementioned embodiments).
[0159] After the Wait TP thread detects ROI and touch events, it requests acceleration from the accelerometer and waits for the acceleration to be ready (Wait ACC ready). The accelerometer returns an acceleration file to the Wait TP thread, which then reads the acceleration file (Read ACC file). Next, the Wait TP thread reads the touch file (Read roifile), which contains the capacitance information of the ROI events, and obtains the raw touch data (raw-touch), which contains the coordinate information of the ROI events.
[0160] After the InputReader thread listens for the ROI event, it prepares the raw-touch and updates it, sending the raw-touch to the Wait TP thread to wake it up. Then, the InputReader thread returns to its own processing flow, which involves setting a preset flag for the ROI event and sending it to the InputDispatcher thread to wake it up.
[0161] If the InputReader thread listens for the ROI event before the Wait tp thread and is ready to complete the raw touch, the InputReader thread can wake up the Wait tp thread when the Wait tp thread listens for the ROI event. If the InputReader thread listens for the ROI event after the Wait tp thread and is ready to complete the raw touch, the InputReader thread can wake up the Wait tp thread when the Wait tp thread acquires the raw touch.
[0162] The Wait tp thread retrieves the coordinate, capacitance, and acceleration information of the ROI event and loads the classification algorithm file (FS Classification alg) to process the coordinate, acceleration, and capacitance information of the touch event, obtaining the touch type of the ROI event and updating the recognition result (i.e., touch type) of the ROI event for the touch identifier (Touch ID). Then, the Wait tp thread wakes up the InputDispatcher thread, that is, it sends the touch type of the ROI event for that Touch ID to the InputDispatcher thread. The InputDispatcher thread waits for the recognition to complete based on the Touch ID, and upon receiving the touch type of the ROI event for that Touch ID, it obtains the recognition result based on the Touch ID. In other words, the InputDispatcher thread modifies the preset identifier of the ROI event for that Touch ID to the received touch type, and the processing flow ends. Subsequently, the InputDispatcher thread distributes the ROI events according to the touch type.
[0163] See Figure 16 , Figure 16 In accordance with Figure 15 This is a timing diagram of the Filtertrack for each thread when handling touch events. The Wait tp thread is the knuckle thread in the FingerSense module.
[0164] Figure 16 In the event that a ROI event is detected at 00:00:02, the InputReader thread and the Wait tp thread in the FingerSense module are awakened. Accordingly, the InputReader thread starts running, and the Wait tp thread also begins running.
[0165] After the InputReader thread starts running, it passes the knuckle parameter (i.e., ...) to the Wait tp thread. Figure 16 The process (marked by C) is executed, and a preset flag is set for the ROI event. The ROI event with the preset flag is then sent to the InputDispatcher thread. The InputDispatcher thread starts running and prepares for event dispatch.
[0166] After the Wait tp thread starts running, it waits for touchscreen events (Wait tp touch), which means it waits for ACC data. After the Wait tp thread obtains the ACC data and inputs it into the classification algorithm, it loads the classification algorithm to determine the touch type of the ROI event. The Wait tp thread then sends the ROI event and touch type to the InputDispatcher thread. The InputDispatcher thread obtains the classification result from the finger touch (FingerSense get classifyresult) and, after obtaining the touch type of the ROI event, distributes the ROI event according to the touch type.
[0167] The process marked C in the timing diagram above represents the time period during which the InputReader thread passes the knuckle parameter to the Wait tp thread. This time period is the waiting time of the InputReader thread. It can be seen that the waiting time of the InputReader thread is significantly reduced, which can save the waiting time of the event dispatch thread, thereby reducing the latency of responding to user touch operations, improving the smoothness of responding to user touch operations, and thus improving the user experience.
[0168] In a specific implementation, this application also provides a terminal, which includes one or more processors and a memory; the memory is coupled to one or more processors, and the memory is used to store computer program code, which includes computer instructions, and one or more processors call the computer instructions to cause the terminal to perform some or all of the steps in the above method embodiments.
[0169] This application also provides a computer-readable storage medium including a computer program that, when run on a terminal, causes the terminal to perform some or all of the steps described in the method embodiments. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0170] In a specific implementation, this application also provides a computer program product, which includes executable instructions. When the executable instructions are executed on a terminal, the terminal performs some or all of the steps in the above method embodiments.
[0171] like Figure 17As shown, this application also provides a chip system applied to a terminal. The chip system includes one or more processors 1701. The processors 1701 are used to call computer instructions to cause the terminal to input data to be processed into the chip system. The chip system processes the data based on the touch event processing method provided in the embodiments of this application and outputs the processing result.
[0172] In one possible implementation, the chip system also includes input and output interfaces for inputting and outputting data.
[0173] The various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or a combination of these implementation methods. Embodiments of this application can be implemented as computer programs or program code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0174] Program code can be applied to input instructions to execute the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a Digital Signal Processor (DSP), a microcontroller, an Application Specific Integrated Circuit (ASIC), or a microprocessor.
[0175] The program code can be implemented using a high-level procedural language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0176] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, CD-ROMs, compact disc read-only memory (CD-ROMs), magneto-optical disks, read-only memory, random access memory, erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagated signals. Therefore, machine-readable media includes any type of machine-readable medium suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0177] In the accompanying drawings, some structural or methodological features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be necessary. Rather, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the accompanying drawings. Furthermore, including structural or methodological features in a particular figure does not imply that such features are required in all embodiments, and in some embodiments, these features may be omitted or may be combined with other features.
[0178] It should be noted that all units / modules mentioned in the device embodiments of this application are logical units / modules. Physically, a logical unit / module can be a physical unit / module, a part of a physical unit / module, or a combination of multiple physical units / modules. The physical implementation of these logical units / modules themselves is not the most important factor; the combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed in this application. Furthermore, to highlight the innovative aspects of this application, the above-described device embodiments of this application have not introduced units / modules that are not closely related to solving the technical problems proposed in this application. This does not mean that the above-described device embodiments do not contain other units / modules.
[0179] It should be noted that in the examples and description of this patent, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one" does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0180] Although this application has been illustrated and described with reference to certain preferred embodiments thereof, those skilled in the art should understand that various changes in form and detail may be made thereto without departing from the spirit and scope of this application.
Claims
1. A method for processing touch events, the method comprising: The method is applied to a terminal, and the method includes: After detecting a touch event through the event packaging thread, the touch data of the touch event is sent to the knuckle thread, and the touch event carrying a preset tag is sent to the event dispatch thread. After detecting the touch event through the knuckle thread and obtaining the touch data of the touch event, the recognition algorithm is loaded to process the touch data of the touch event to obtain the touch type of the touch event, which is used as the target type. The target type of the touch event is sent to the event dispatch thread via the knuckle thread; Upon receiving the touch event sent by the event packaging thread and the target type sent by the knuckle thread, the event dispatch thread modifies the preset marker of the touch event to the target type and dispatches the touch event according to the target type of the touch event.
2. The method of claim 1, wherein, The target type includes any one of the following: knuckle type, finger type, and stylus type; The step of distributing the touch event according to the target type of the touch event includes: When the target type is a finger type or a stylus type, the touch event is distributed to the target application currently running on the terminal through the event distribution thread, and the target application responds to the touch event; When the target type is a knuckle type, the touch event is distributed to the knuckle event processing module of the terminal through the event distribution thread, and the touch event is responded to through the knuckle event processing module.
3. The method of claim 1, wherein, The touch data includes: coordinate information, capacitance information, and acceleration information of the touch event; Before sending the touch data of the touch event to the knuckle thread and sending the touch event carrying a preset tag to the event dispatch thread after the touch event is detected by the event packaging thread, the method further includes: After a touch event is detected by the touch screen, the touch event and its coordinate information are sent to the event packaging thread via the touch screen, and the touch event and its tolerance information are also sent to the knuckle thread via the touch screen. After detecting a touch event through the event packaging thread, the touch data of the touch event is sent to the knuckle thread, including: After detecting a touch event through the event packaging thread, the coordinate information of the touch event is sent to the knuckle thread; After detecting the touch event through the knuckle thread and obtaining the touch data of the touch event, a recognition algorithm is loaded to process the touch data of the touch event to obtain the touch type of the touch event, which is used as the target type, including: After detecting a touch event through the knuckle thread, the acceleration information of the touch event is obtained; After obtaining the coordinate information, tolerance information, and acceleration information of the touch event through the knuckle thread, the recognition algorithm is loaded to process the coordinate information, tolerance information, and acceleration information of the touch event to obtain the touch type of the touch event, which is used as the target type.
4. The method according to claim 3, characterized in that, After detecting a touch event through the event packaging thread, sending the coordinate information of the touch event to the knuckle thread includes: After the event packaging thread detects a touch event, it calls the Updata function to send the coordinate information of the touch event to the knuckle thread.
5. The method of claim 1, wherein, The target type of sending the touch event to the event dispatch thread via the knuckle thread includes: The target type of the touch event is sent to the event dispatch thread by calling the GetResult function through the knuckle thread.
6. The method according to any one of claims 1 to 5, characterized in that, The event packaging thread is the InputReader thread; the event dispatching thread is the InputDispatcher thread.
7. The method according to any one of claims 1 to 5, characterized in that, The touch event is a Down event; The method further includes: After the event packaging thread detects a specified event, it sends the specified event carrying a preset tag to the event dispatch thread; wherein, the specified touch event is a Move event or a Raise event; After receiving the specified event sent by the event packaging thread, the event dispatch thread modifies the preset flag of the specified event to the target type of the Down event corresponding to the specified event, and dispatches the specified event according to the target type of the specified event.
8. A terminal, characterized by comprising: include: One or more processors and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the terminal to perform the method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, Includes a computer program that, when run on a terminal, causes the terminal to perform the method of any one of claims 1-7.
10. A computer program product, characterised in that, The computer program product includes executable instructions that, when executed on a terminal, cause the terminal to perform the method of any one of claims 1-7.
11. A chip system, characterized by The chip system is applied to a terminal. The chip system includes one or more processors. The processors are used to call computer instructions to cause the terminal to input data into the chip system and execute the method described in any one of claims 1-7 to process the data and output the processing result.