SDL now supports "haptic" input: input from something other than a touch screen. This could include trackpads, click-wheels, etc. These kinds of inputs work by knowing which views on the screen are touchable and focusing / highlighting on those areas when the user moves the trackpad or click wheel. When the user selects within a view, the center of that area will be "touched".
Currently, there are no RPCs for knowing which view is highlighted, so your UI will have to remain static (i.e. you should not create a scrolling menu in your SDL app).
SDL has support for automatically detecting focusable views within your UI and sending that data to the head unit. You will still need to tell SDL when your UI changes so that it can re-scan and detect the views to be sent.
The easiest way to use this is by taking advantage of SDL's Presentation class. This will automatically check if the capability is available and instantiate the manager for you. All you have to do is set your layout:
public static class MyPresentation extends SdlRemoteDisplay { public MyPresentation(Context context, Display display) { super(context, display); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.haptic_layout); LinearLayout videoView = (LinearLayout) findViewById(R.id.cat_view); videoView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { // ...Update something on the ui MyPresentation.this.invalidate(); return false; } }); } }
This will go through your view that was passed in and then find and send the rects to the head unit for use. When your UI changes, call invalidate()
from your class that extends SdlRemoteDisplay
.
It is also possible that you may want to create your own rects instead of using the automated methods in the Presentation class. It is important that if sending this data yourself that you also use the SystemCapabilityManager
to check if you are on a head unit that supports this feature. If the capability is available, it is easy to build the area you want to become selectable:
public void sendHapticData() { Rectangle rectangle = new Rectangle() .setX((float) 1.0) .setY((float) 1.0) .setWidth((float) 1.0) .setHeight((float) 1.0); HapticRect hapticRect = new HapticRect() .setId(123) .setRect(rectangle); ArrayList<HapticRect> hapticArray = new ArrayList<HapticRect>(); hapticArray.add(0, hapticRect); SendHapticData sendHapticData = new SendHapticData(); sendHapticData.setHapticRectData(hapticArray); sdlManager.sendRPC(sendHapticData); }
Each SendHapticData
RPC should contain the entirety of all clickable areas to be accessed via haptic controls.