USB Interfaces

 

Keyboard

For most keyboard related actions use methods from InputStickKeyboard class (com.inputstick.api.basic).

 

public static void pressAndRelease(byte modifier, byte key);

Press and release key combination specified by modifier and key. Sends three HID keyboard reports: modifier pressed, modifier and key pressed, all keys released. For modifier and key codes see com.inputstick.api.hid.HIDKeycodes.

Example:

InputStickKeyboard.pressAndRelease((byte)(HIDKeycodes.CTRL_LEFT | HIDKeycodes.ALT_LEFT), HIDKeycodes.KEY_DELETE);

will result in sending following reports: CTRL and ALT pressed, CTRL, ALT and DELETE pressed, all keys released.

 

public static void typeASCII(String toType);

Type text assuming USB host uses en-US keyboard layout. All characters which cannot be entered using the layout will be skipped.

Note: in most cases user should provide information about what keyboard layout is used by USB host and appropriate keyboard layout should be used, see: Keyboard layouts.

Example:

typeASCII("hello\nworld");

This will result in typing: hello (Enter) world.

typeASCII("test:ąęü123");

This will result in typing: test123, since other characters cannot be obtained using en-US layout.

 

public static void customReport(byte modifier, byte key0, byte key1, byte key2, byte key3, byte key4, byte key5);

Sends custom keyboard report. Use this method when you need multiple keys pressed at the same time (modifier keys and up to 6 keys).

Example:

InputStickKeyboard.customReport((byte)0, HIDKeycodes.KEY_A, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);

will result in key "A" being pressed. Key will not be released until another keyboard report is sent.

 

InputStickKeyboard.customReport((byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0);   

sending such report will release all keys.

 

public static boolean isNumLock();

Returns true if NumLock LED is set to ON by USB host, otherwise false is returned.

 

public static boolean isCapsLock();

Returns true if CapsLock LED is set to ON by USB host, otherwise false is returned.

 

public static boolean isScrollLock();

Returns true if ScrollLock LED is set to ON by USB host, otherwise false is returned.

 

public static void toggleNumLock();

Same as pressing NumLock key.

 

public static void toggleCapsLock();

Same as pressing CapsLock key.

 

public static void toggleScrollLock();

Same as pressing ScrollLock key.

 

public static void addKeyboardListener(InputStickKeyboardListener listener);

Register InputStickKeyboardListener when you are interested in receiving callback when USB host changes state of keyboard LEDs (NumLock, CaspLock or ScrollLock).

 

public static void removeKeyboardListener(InputStickKeyboardListener listener);

Removed listener.

 

Mouse

For all mouse related actions use methods from InputStickMouse class (com.inputstick.api.basic).

 

public static void move(byte x, byte y);

Moves mouse pointer by x and y. Result will depend on USB host's settings (sensitivity etc).

 

public static void click(byte button, int n);

Clicks button (BUTTON_LEFT, BUTTON_RIGHT, BUTTON_MIDDLE) n times.

 

public static void scroll(byte wheel);

Moves scroll wheel. Note: will not work if USB host set mode to BOOT PROTOCOL (when in BIOS).

 

public static void customReport(byte buttons, byte x, byte y, byte wheel);

Sends custom mouse report. Note: after button is set, USB host will assume it is constantly being pressed until another mouse report is received.

 

Consumer control

For all consumer control related actions use methods from InputStickConsumer class (com.inputstick.api.basic).

 

public static void consumerAction(int action);

Sends usage code from USB HID consumer control page. Use for launching applications, playback and volume control. Results will depend on USB host. For more list of codes see:

http://www.usb.org/developers/hidpage/Hut1_12v2.pdf (consumer page)

 

public static void systemAction(byte action);

Sends usage code form USB HID system control page. Use only for SYSTEM_POWER_DOWN, SYSTEM_SLEEP and SYSTEM_WAKEUP.

 

public static void systemPowerDown();

Usually it should be the same as pressing power button. Result will depend on USB host's settings.

Same as: systemAction(SYSTEM_POWER_DOWN);   

 

public static void systemSleep();

Requests USB host to go into sleep mode. Result will depend on USB host's settings: going into sleep mode, turning screen off.

Same as: systemAction(SYSTEM_SLEEP);   

 

public static void systemWakeUp();

Requests USB host to wake up. Result will depend on USB host's settings. You should also check: wakeUpUSBHost() from InputStickHID class.

Same as: systemAction(SYSTEM_WAKEUP);

 

Gamepad

For all gamepad related actions use methods from InputStickGamepad class (com.inputstick.api.basic).

 

public static void customReport(byte buttons1, byte buttons2, byte x, byte y, byte z, byte rX);

Sends USB gamepad report. Use buttons1 to send information about gamepad buttons 0-7, buttons2 for gamepad buttons 8-15.

Note: to reduce latency gamepad reports are not buffered, instead are directly sent to appropriate USB endpoint. Do not send gamepad reports more often than one every 4ms. In most cases increasing this value will provide better results.

 

 

Zobacz także:

gallery

Blog

gallery

YouTube

GooglePlay

AppStore

Ta strona korzysta z plików cookies. Dowiedz się więcej. Regulamin sklepu. Copyright © 2017 InputStick. All Rights Reserved. Joomla! is Free Software released under the GNU GPL. Template by RocketTheme. Wszystkie nazwy oraz znaki towarowe są własnością ich prawowitych właścicieli i są umieszczone jedynie w celach informacyjnych.