Adding new gpio key event in Oreo 8.1

375 views
Skip to first unread message

Gopinath Sathasivam

unread,
Jun 25, 2018, 11:17:11 AM6/25/18
to android-platform
I am new to android,I want to create an one gpio event and expose that to the application layer.
Can any help to add custom key event or provide the steps ?
Thanks in advance.

Satish Patel

unread,
Jun 26, 2018, 10:13:45 AM6/26/18
to android-...@googlegroups.com
​The good starting point is -

- make sure your key is getting detected using getevent
- first try to map the key using exiting key code e.g. VOL_UP/DOWN etc. inside the device/<>/.kl file
- Once its works fine, add the new key code inside  - frameworks/native/include/android/keycodes.h
 
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
satish patel

Gopinath Sathasivam

unread,
Jun 28, 2018, 11:17:19 AM6/28/18
to android-platform
Thanks for your support.
Getevent -l lists event for newly added key with linux code but it's not mapping the android scan code name like "VOLUMEUP".

I have added in device/<>/gpio-key.kl file and native layer.

For understanding I have commented volume key mapping in device/<>/gpio-keys.kl file and framework/native , if I try getevent-l for volume key ,still "VOLUMEUP" label is mapped with key event.

Do we need to add in any other place to map linux code to android scan code ?

Satish Patel

unread,
Jun 28, 2018, 12:49:50 PM6/28/18
to android-...@googlegroups.com
On Thu, Jun 28, 2018 at 4:13 PM, Gopinath Sathasivam <gopi...@gmail.com> wrote:
Thanks for your support.
Getevent -l lists event for newly added key with linux code but it's not mapping the android scan code name like "VOLUMEUP".

I have added in device/<>/gpio-key.kl file and native layer.

For understanding I have commented volume key mapping in device/<>/gpio-keys.kl  file and framework/native  , if I try getevent-l for volume key ,still "VOLUMEUP" label is mapped with key event.

​what is the output of getevent when you press the gpio key ?
its VOLUME_UP (not VOLUMEUP)

refere 
for more details​

Do we need to add in any other place to map linux code to android scan code ?
--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
satish patel

Gopinath Sathasivam

unread,
Jun 29, 2018, 9:57:25 AM6/29/18
to android-platform
It was typo mistake.actual output for volume key event is "KEY_VOLUME_UP".

But I am wondering how it's possible to get android scan code name "KEY_VOLUME_UP" for event,even after commenting in device/<>/.kl file , linux/input.h and frameworks/native/.

Satish Patel

unread,
Jul 2, 2018, 10:25:06 AM7/2/18
to android-...@googlegroups.com
On Thu, Jun 28, 2018 at 10:59 PM, Gopinath Sathasivam <gopi...@gmail.com> wrote:
It was typo mistake.actual output for volume key event is "KEY_VOLUME_UP".

But I am wondering how it's possible to get android scan code name  "KEY_VOLUME_UP" for event,even after commenting in device/<>/.kl file , linux/input.h and frameworks/native/.
​I am not sure if I am able to get the context in right way, but if you are looking on how keycode are mapped even thought no entry in kl file. Android does make use of Generic.kl file to map this - in case device.kl file is missing and events are coming. In android context its not KEY_ --> its KEYCODE_
 

--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platform+unsubscribe@googlegroups.com.
To post to this group, send email to android-platform@googlegroups.com.
Visit this group at https://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
satish patel
Reply all
Reply to author
Forward
0 new messages