Implement KeyEvent-Callback by Mapping Air Actions
Learn how to implement KeyEvent-Callbacks on your S Pen Remote by mapping the Air Actions on a car racing game.
S Pen connects via Bluetooth Low Energy (BLE) to a device and the S Pen Framework manages the connection.
BLE events are converted by the S Pen Framework into KeyEvents before sending to the app.
Apps are able to handle S Pen events by reusing existing KeyEvent-Callback without adding other interfaces.
Collecting and Sending S Pen Remote Events to Apps
The S Pen Framework collects and manages KeyEvents to be received by the app, and are defined in .xml format before making them public.
Below is the process of the S Pen Remote Event handling and sending S Pen Remote Event-defined KeyEvents to apps:
- A BLE event is sent to the S Pen Framework.
- The S Pen Framework checks for the foreground app and looks for the KeyEvent that the app made public.
- The found KeyEvent is sent to the app's KeyEvent-Callback.
- The app performs the actions defined in the KeyEvent.