-
Notifications
You must be signed in to change notification settings - Fork 1
Description
In development currently.
This is, lets say "inspired by" someone else's work, found here;
https://forum.xda-developers.com/android-auto/android-head-units/joying-2gb-steering-wheel-key-t3543390
So the problem with the SWI controls interface, is that it only provides a very rigid subset of the appropriate set of tasks that should be possible via the steering wheel buttons interface.
The above link is to a modified version of the package that maps steering wheel buttons to various actual functions. It is a good start, but it is also severely limited.
Limitations of the FACTORY system;
Lacks the ability to map many useful functions to steering wheel buttons. Things like HOME, BACK, OVERVIEW, etc.
Limitations of the MODIFIED version;
- It works by breaking the flow of the factory version, and sending a keycode over to a SHELL SCRIPT. This means overhead and processing delay,
- In order to preserve some factory functions that interact specifically with a bunch of factory programs, like the AMFM radio application -- think being able to map buttons to functions like switching frequencies, it was not able to free up enough available "keycodes" to map against a steering wheel with "a lot" of buttons. I think it is limited to EIGHT or fewer truly programmable buttons, whereas my steering wheel has 11 buttons. This means that I was forced to map more of the buttons to these "preserved" functions than I want. Since I always have the AM radio on, it will ALWAYS consume these functions, and my buttons are therefore useless.
So I'm going to change the approach of this quite dramatically compared to the current modified version and do it like this;
-- No more shell script. I'm going to use SystemProperties to store the functions I want mapped to the mcukeys.
-- The SystemProperties will be of the form "persist.mcu.keyname" and will have either a string or integer value as defined;
0: DEFAULT FUNCTION
0: inject key event of that specific value
-1: send this key to the shell script
<-1: this key will support -val MULTI-FUNCTIONs via MULTI-PRESS. For instance; -3: this key supports 3 functions.
{string}: of the form "package/classname" -- the activity component that should be launched with this key.
For multi-press modes, there must also match up an equal number of additional system properties that define the different functions of this key, for example;
persist.mcu.mode = -3
persist.mcu.mode.1 = 0
persist.mcu.mode.2 = 3
persist.mcu.mode.3 = "com.google.android.apps.maps/com.google.android.maps.MapsActivity"
Where single press performs DEFAULT FUNCTION, double press injects a keycode of "3" (HOME), and triple press will launch Google Maps.
The way this will work, is it will keep an integer array that stores the number of times that a key has been pressed. When a function is executed, it will reset the value in that array to 0.
When a button is pressed, it will increment the array by 1, and pass the NEW value of that cell into a THREAD, which will sleep for a fixed short time, and check if the value in the array has been updated. IF IT HAS NOT, then it will look up the function to perform from the system property, do it, and then reset the array cell to zero. If it HAS been updated, then we do nothing, because the thread started by the next button press will look after it.
It might be necessary to also store a value indicating the time that a "first press" was issued, so our thread dies before it resets the counter to zero, but it happened more than, say, 5 seconds ago, then we can reset it at that point.
I will also make it able to map more than one set of the "default" functions to a single button. For example, I would like to take the next and back buttons and make them such that ONE press is "next frequency", TWO press is "next saved channel", and THREE press is "seek next". Or something to that effect. I think maybe what I will do is use string value MCU#, so for instance....
persist.mcu.up = -3
persist.mcu.up.1 = 0
persist.mcu.up.2 = MCU4
persist.mcu.up.3 = MCU7
Where MCU4 would correspond to the 4th mcuKey function, and MCU7 would correspond to the 7th.
All of this should be possible through modification to HandlerMain.class, which fortunately, appears to have decompiled correctly, so I should be able to modify it in the Java code and then mix it into the smali code.