Capture and remap a button click in HUniKit
The MCU acts as an interface between your vehicle’s CAN bus system and your Android head unit. Whenever a button is pressed in the vehicle, a CAN bus signal is generated. The MCU intercepts this signal and forwards it to Android.
Each MCU manufacturer uses its own protocol and packet format for communicating with Android. The Android firmware included with your aftermarket head unit contains a system service that receives these signals and maps them to predefined actions.
When a button is pressed, the corresponding CAN bus message is transmitted through the vehicle network. The MCU captures this message and forwards it to Android using a specific byte sequence. To remap a button, this byte sequence must first be identified.
1. Initially, the live monitor may display a large amount of unrelated traffic. These signals can represent various CAN bus messages or general Android hardware events. Since they are not related to the button you want to remap, they should be filtered out to reduce noise and simplify analysis.
2. Once the monitor is clear, press the desired button and observe the newly generated signal. In most cases, the captured byte sequence will correspond directly to that button. Keep in mind that some MCUs transmit separate signals for a button press and a button release event. If this is the case, both signals should be captured so they can later be prevented from being passed back to the firmware.
3. Add the identified byte sequences to your mapper and verify that the application correctly recognizes the button events in the Event Monitor.
4. You can now remap the button to your preferred action. If the button generates both a press and release signal, assign one of them to a “No Action” event and map the other to the desired function. This prevents unintended secondary actions from being triggered.