Friday, July 12, 2013

Android input device use keylayout file and input device configure file to map the key with the potential buttons. Here is a list of configuration to finish.

1 the device_name.kl

key 2    BACK   VIRTUAL WAKE
  1. number 2 is linux key code number, defined the file input.h and used at device driver.
  2. BACK is Android key code name, used by the app.  

2 the device_name.idc

  1. device.internal = 1
  2. keyboard.layout = mpr121
  3. keyboard.builtIn = 1
Put these 2 files in /system/usr/keylayout and /system/use/idc.

3 EventHub.cpp

This is the file calling the file device_name.kl and connect the physical button with the app press. In the function openDevice(deviceName), il uses the device name defined in the driver file, the parameter input_dev->name, this name must be the same as the one for the .kl and .idc.
input_dev->name = "mpr121";
mpr121.kl, mpr121.idc.

const char* root = getenv("ANDROID_ROOT");
        snprintf(keylayoutFilename, sizeof(keylayoutFilename),
                 "%s/usr/keylayout/%s.kl", root, tmpfn);
If the name is not correct, the default file qwerty.kl will be used.

4 system.prop

Change the system property to use the keylayout file
android.keylayout.mpr121=/system/usr/keylayout/mpr121.kl
location:device/company_name/product/











No comments:

Post a Comment