Android local input key event

Source: Internet
Author: User

1. initialize key ing (File framework/base/libs/UI/eventhub. cpp)

Eventhub: opendevice ()

-----> // Snprintf (keylayoutfilename, sizeof (keylayoutfilename ),
// "% S/usr/keylayout/% S. KL", root, tmpfn); confirm the key ing file name. The key ing file is in (definition of Qwerty. KL full keyboard)

// A. android_root/usr/keylayout/*. KL in the root file system

// B. Under the respective project directories in the source code, such as device/product/*. KL

Keylayoutmap: load () parses the key ing configuration file to complete key ing initialization and other operations,

Generate a key ing, m_keys, vector Member, in keylayoutmap.

The main process is:

A. parse each line of *. KL to get the ing string between the underlying keycode and the key mapped to the Android system.

B. obtain the corresponding Android keycode from keycodes [] using the android string (keycodelabels. h)

C. Bind the original keycode and the obtained Android keycode to the m_keys vector member.

 

2. Obtain the event (File framework/base/libs/UI/eventhub. cpp)

Eventhub: getevent ()

---> // Read input data from the input file

Keylayoutmap: Map () parses the input data read, and obtains the key code required by Android from m_keys, a vector member in the initialized keylayoutmap.

The parsing code is as follows:

Ssize_t Index = m_keys.indexofkey (scancode); // obtain the key code from the input data and obtain the index corresponding to the vector.
Const key & K = m_keys.valueat (INDEX); // you can use the index to find the android keycode mapped to it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.