I'm working on a smart glasses project that is using an Intrinsyc Open-q 2500 SOM (connected to a custom breakout board) that utilises a Snapdragon processor, running a custom Android SDK (Oreo 8.1) made for smart watches.

To navigate through the Android UI, as well as applications, we are hoping to use a IQS223 touch sensor chip, which will output high for a short period when a gesture is detected. E.g If a swipe forward is detected it will set pin1 (connected to GPIO1 of SOM) to high for 80ms, or if a TAP is detected it will set pin2 (connected to GPIO2 of SOM) to high for 80ms.

I've read it is possible to connect navigate/control an application via an external keyboard. All interactive widgets are focusable, meaning that the selected widget is highlighted (via a glow or appearance change). Therefore, It seems I should be able to fire a keyboard event on detection of a GPIO input change, and use that event to trigger an action. E.g. on detection of a high input on GPIO1 I'd fire a "Enter" keypress event.

My question is how would I go about doing this for the main Android UI (navigation of settings, selecting an app from main menu etc.)? i.e I want to set the main Android UI to be focusable (if possible) so I can navigate/control the device by simulating keypresses, which are fired when an input level changes on a certain GPIO pin.

Is there an alternate method to achieving this?

  • In the direction of @Puspam answer, have you looked at building your own Accessibility Service to handle the GPIO input translation. – Morrison Chang Jul 18 at 0:52
  • Thanks @MorrisonChang, this looks like the information I was looking for. It looks like I will be able to bind a keypress event (generated by the GPIO input) to a navigation action by creating an Accessibility Service. – jfbghn Jul 18 at 2:25
  • If you can/need to do a Custom ROM, then see: source.android.com/devices/input/touch-devices for considerations regarding touch driver. – Morrison Chang Jul 18 at 2:31
  • Great! that also looks like it'll be useful. We do a have a custom ROM provided by Intrinsyc, so it's just a matter of setting up the DT/Driver to generate a specific keypress event on GPIO input level change. – jfbghn Jul 18 at 2:35

The functionality which you are looking for is available under the Accessibility settings. It is called Switch access, Universal switch and many more, just search for the term switch after going to System settings -> Accessibility. Then, follow the on-screen instructions for setting it up.

| improve this answer | |
  • Okay so Android does have the capability to operate in the desired way. Does that mean I would have to go to kernel level and assign keypress events to GPIOs connected to the touch sensor? Then I could generate the keypress when I set up switch access and it will detect the fired event? – jfbghn Jul 16 at 23:14
  • If you want only a single switch, then the headphone (earphone) jack can help. 4-pin earphone jacks can implement a switch which can be seen near the mic. some smartphones can detect that key. But it is not guaranteed to work on all phones. – Puspam Jul 17 at 5:39
  • You can also use the USB OTG functionality as it is present in all recent smartphones. USB devices can be connected to the phone and the OS can detect the keypress. So, you can use a USB interface to connect your sensor to the phone, for eg. Arduino. You can find the necessary settings in the Accessibility menu. In my phone, there is an option called USB switch. – Puspam Jul 17 at 5:41
  • Thanks for your suggestions, they are definitely helping steer us towards the right place. The issue is that the touch sensor chip is actually on a PCB that is used to break out the SOM and provide additional peripherals (camera, display etc.) - meaning that the touch sensor outputs are actually connected directly to 3 of the SOM's GPIO ports. In other words, we need a way to to control the UI via GPIO input changes. – jfbghn Jul 17 at 23:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.