lightbulb_outline Please take our October 2018 developer survey. Start survey

InputDriver.Builder

public static class InputDriver.Builder
extends Object

java.lang.Object
   ↳ com.google.android.things.userdriver.input.InputDriver.Builder


Builder class for InputDriver objects.

Summary

Public constructors

InputDriver.Builder()

Constructs a new builder.

Public methods

InputDriver build()

Build an InputDriver.

InputDriver.Builder setAxisConfiguration(int axis, int min, int max, int fuzz, int flat)

Configure an absolute axis supported by this driver.

InputDriver.Builder setName(String name)

Set the name of the input driver.

InputDriver.Builder setProductId(int productId)

Set the product id for the driver.

InputDriver.Builder setSupportedKeys(int[] supportedKeyCodes)

Set the keys supported by this driver.

InputDriver.Builder setVendorId(int vendorId)

Set the vendor id for the driver.

Inherited methods

From class java.lang.Object

Public constructors

InputDriver.Builder

InputDriver.Builder ()

Constructs a new builder.

Returns
A new InputDriver.Builder instance.

Public methods

build

InputDriver build ()

Build an InputDriver. Builds an InputDriver with the provided characteristics.

Returns
InputDriver A new InputDriver object.

setAxisConfiguration

InputDriver.Builder setAxisConfiguration (int axis, 
                int min, 
                int max, 
                int fuzz, 
                int flat)

Configure an absolute axis supported by this driver. This method should be called for each axis supported.

Parameters
axis int: One of the axis constants from MotionEvent . Currently only X and Y are supported.

min int: An inclusive minimum value of positions on this axis.

max int: An inclusive maximum value of positions on this axis.

fuzz int: An int to denote the error tolerance of the axis measurements.

flat int: An int denoting the extent of the center flat position.

Returns
InputDriver.Builder The same builder instance.

Throws
IllegalArgumentException if |axis| is not supported or max <= min.

setName

InputDriver.Builder setName (String name)

Set the name of the input driver.

Parameters
name String: A String representing the name of the driver. If a name is not provided, one will be auto-generated.

Returns
InputDriver.Builder The same builder instance.

setProductId

InputDriver.Builder setProductId (int productId)

Set the product id for the driver. A product id uniquely identifies which product within the address space of a given vendor, identified by the device's vendor id. A value of 0 will indicates a product id is not available.

Parameters
productId int: An int representing the input device. Defaults to 0.

Returns
InputDriver.Builder The same builder instance.

setSupportedKeys

InputDriver.Builder setSupportedKeys (int[] supportedKeyCodes)

Set the keys supported by this driver.

Parameters
supportedKeyCodes int: An array of key codes representing the keys this input driver supports. The codes must be values from KeyEvent.

Returns
InputDriver.Builder The same builder instance.

Throws
IllegalArgumentException if any of the key codes are not recognized key codes.

setVendorId

InputDriver.Builder setVendorId (int vendorId)

Set the vendor id for the driver. A vendor id uniquely identifies the company who manufactured the device. A value of 0 indicates a vendor id is not available.

Parameters
vendorId int: An int representing the vendor code. Defaults to 0.

Returns
InputDriver.Builder The same builder instance.