public class

KeyboardManager

extends Object
java.lang.Object
   ↳ com.datalogic.device.input.KeyboardManager

Class Overview

This class provides access to keyboard related methods of the device.

Summary

Nested Classes
class KeyboardManager.VScanCode Virtual key scan codes. 
Constants
int TRIGGER_ID_AUTOSCAN ID for AutoScan trigger.
int TRIGGER_ID_FRONT ID for Front trigger.
int TRIGGER_ID_LEFT ID for Left trigger.
int TRIGGER_ID_MOTION ID for Motion trigger.
int TRIGGER_ID_PISTOL ID for Pistol trigger.
int TRIGGER_ID_RIGHT ID for Right trigger.
Public Constructors
KeyboardManager()
This is the constructor of KeyboardManager.
Public Methods
int clearAllMappings()
Removes all the configured mappings.
int clearMapping(VScanEntry scanCode)
Removes a single active mapping.
int disableKey(VScanEntry scanCode, boolean disable)
Disables completely a single physical key, through the VScanEntry data structure.
AdvancedKeyboard getAdvancedKeyboard()
Returns the AdvancedKeyboard object, which can be used to customize the keyboard configuration, read info about the currently installed keyboard and listen to some keyboard events.
List<Trigger> getAvailableTriggers()
Returns the available triggers in the device.
Intent getIntent(VScanEntry scanCode)
Returns current mapping between a physical key and an Intent.
KeyCodeEntry getKeyCode(VScanEntry scanCode)
Returns current mapping between a physical scan code key and an Android key code.
static int[][] getKeyboardLayout()
Returns the physical keyboard layout.
Map<VScanEntry, Intent> getMappedIntents()
Provides a Map< VScanEntry, android.content.Intent > containing all the stored and active Android Intent mappings.
Map<VScanEntryKeyCodeEntry> getMappedKeyCodes()
Provides a Map< VScanEntry, KeyCodeEntry> containing all the stored and active Android key codes mappings.
Map<VScanEntry, Character> getMappedUnicodes()
Provides a Map< VScanEntry, Character> containing all the stored and active Character mappings.
Character getUnicode(VScanEntry scanCode)
Returns current mapping between a physical key and a unicode character.
boolean isInputLocked()
Tells if the input from keyboard is locked.
boolean isKeyDisabled(VScanEntry scanCode)
Checks if a physical key is disabled.
int lockInput(boolean lock)
Locks or unlocks the input from keyboard and physical buttons.
int mapIntent(VScanEntry scanCode, Intent intent)
Assigns an Intent to a physical key.
int mapKeyCode(VScanEntry scanCode, KeyCodeEntry keyCode)
Assigns a virtual key code to a physical key.
int mapUnicode(VScanEntry scanCode, Character c)
Assigns a unicode character to a physical key.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int TRIGGER_ID_AUTOSCAN

Added in revision 5

ID for AutoScan trigger.

Constant Value: 4 (0x00000004)

public static final int TRIGGER_ID_FRONT

Added in revision 5

ID for Front trigger.

Constant Value: 3 (0x00000003)

public static final int TRIGGER_ID_LEFT

Added in revision 5

ID for Left trigger.

Constant Value: 0 (0x00000000)

public static final int TRIGGER_ID_MOTION

Added in revision 11

ID for Motion trigger.

Constant Value: 5 (0x00000005)

public static final int TRIGGER_ID_PISTOL

Added in revision 5

ID for Pistol trigger.

Constant Value: 2 (0x00000002)

public static final int TRIGGER_ID_RIGHT

Added in revision 5

ID for Right trigger.

Constant Value: 1 (0x00000001)

Public Constructors

public KeyboardManager ()

Added in revision 1

This is the constructor of KeyboardManager.

Throws
DeviceException in case of error.

Public Methods

public int clearAllMappings ()

Added in revision 1

Removes all the configured mappings. Whenever this method is called, all the current active mappings are cleared and removed.

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int clearMapping (VScanEntry scanCode)

Added in revision 1

Removes a single active mapping. The current active mapping for the selected VScanEntry, if existing, is removed.

Parameters
scanCode a VScanEntry representing the virtual scan code, mapped that must be removed.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int disableKey (VScanEntry scanCode, boolean disable)

Added in revision 1

Disables completely a single physical key, through the VScanEntry data structure. When a key is disabled, no input will be produced whenever key presses are detected. When a key is again re-enabled, is reset to its original value, so any previous mapping is automatically lost.

Parameters
scanCode a VScanEntry representing the virtual scan code, associated to the physical key.
disable a boolean that specifies whether or not the key will be disabled.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public AdvancedKeyboard getAdvancedKeyboard ()

Added in revision 22

Returns the AdvancedKeyboard object, which can be used to customize the keyboard configuration, read info about the currently installed keyboard and listen to some keyboard events.

Returns
  • AdvancedKeyboard object if the device supports it, otherwise it throws an exception if exceptions are enabled through the ErrorManager singleton or null if exceptions are disabled.
Throws
DeviceException in case of unsupported device, when exceptions are enabled through the ErrorManager singleton.

public List<Trigger> getAvailableTriggers ()

Added in revision 5

Returns the available triggers in the device.

Returns
  • List of Trigger objects, each representing one of the supported triggers.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public Intent getIntent (VScanEntry scanCode)

Added in revision 1

Returns current mapping between a physical key and an Intent.

Parameters
scanCode a VScanEntry representing the virtual scan code.
Returns
  • Intent used to launch an Android activity through the Context.startActivity(Intent intent) method. Returns null in case there is no association.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.
See Also

public KeyCodeEntry getKeyCode (VScanEntry scanCode)

Added in revision 1

Returns current mapping between a physical scan code key and an Android key code.

Parameters
scanCode a VScanEntry representing the virtual scan code.
Returns
  • KeyCodeEntry representing an Android key code and meta state. Returns null in case there is no association.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public static int[][] getKeyboardLayout ()

Added in revision 1

Returns the physical keyboard layout. It can be used by application for keyboard remapping.

Returns
  • Cubic grid of scan codes, representing the physical keyboard present. If a row does not span the entire length, 0's or -1's will fill those spots.

public Map<VScanEntry, Intent> getMappedIntents ()

Added in revision 1

Provides a Map< VScanEntry, android.content.Intent > containing all the stored and active Android Intent mappings.

Returns
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public Map<VScanEntryKeyCodeEntry> getMappedKeyCodes ()

Added in revision 1

Provides a Map< VScanEntry, KeyCodeEntry> containing all the stored and active Android key codes mappings.

Returns
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public Map<VScanEntry, Character> getMappedUnicodes ()

Added in revision 1

Provides a Map< VScanEntry, Character> containing all the stored and active Character mappings.

Returns
  • Map< VScanEntry, Character> the corresponding saved mappings. Null is returned if there aren't any mappings saved.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public Character getUnicode (VScanEntry scanCode)

Added in revision 1

Returns current mapping between a physical key and a unicode character.

Parameters
scanCode a VScanEntry representing the virtual scan code.
Returns
  • unicode character. Returns null in case there is no association.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.
See Also

public boolean isInputLocked ()

Added in revision 1

Tells if the input from keyboard is locked.

Returns
  • boolean it returns whether or not the keyboard is locked.

public boolean isKeyDisabled (VScanEntry scanCode)

Added in revision 5

Checks if a physical key is disabled.

Parameters
scanCode a VScanEntry representing the virtual scan code, associated to the physical key.
Returns
  • boolean True in case the key is disabled, false otherwise or in case of error.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int lockInput (boolean lock)

Added in revision 1

Locks or unlocks the input from keyboard and physical buttons.

Parameters
lock boolean it specifies whether or not the keyboard will be locked.
Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int mapIntent (VScanEntry scanCode, Intent intent)

Added in revision 1

Assigns an Intent to a physical key. If a mapping for the desired physical key is already assigned and saved, it will be overridden.

Parameters
scanCode a VScanEntry representing the virtual scan code.
intent Intent used to launch an Android activity through the Context.startActivity(Intent intent) method.

Example code to make Camera Activity capture an image on the front scan trigger pressure:
(new KeyboardManager()).mapIntent(new VScanEntry(VScanCode.VSCAN_FRONT_TRIGGER), new Intent(MediaStore.ACTION_IMAGE_CAPTURE));

Example code to make BarcodeManager capture a barcode on the front scan trigger pressure and to stop capturing on the front scan trigger release:
(new KeyboardManager()).mapIntent(new VScanEntry(VScanCode.VSCAN_FRONT_TRIGGER), new Intent(BarcodeManager.ACTION_START_DECODE));

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.
See Also

public int mapKeyCode (VScanEntry scanCode, KeyCodeEntry keyCode)

Added in revision 1

Assigns a virtual key code to a physical key. If a mapping for the desired physical key is already assigned and saved, it will be overridden.

Parameters
scanCode a VScanEntry representing the virtual scan code.
keyCode a KeyCodeEntry representing the Android key code and meta state.

Example code to avoid any keyboard event on the left scan trigger pressure:
(new KeyboardManager()).mapKeyCode(new VScanEntry(VScanCode.VSCAN_LEFT_TRIGGER), new KeyCodeEntry(KeyEvent.KEYCODE_UNKNOWN));

Example code to map the left scan trigger to the Android left trigger button key code:
(new KeyboardManager()).mapKeyCode(new VScanEntry(VScanCode.VSCAN_LEFT_TRIGGER), new KeyCodeEntry(KeyEvent.KEYCODE_BUTTON_L1));

Example code to map the enter key to the Android home key code:
(new KeyboardManager()).mapKeyCode(new VScanEntry(VScanCode.VSCAN_RIGHT_ENTER), new KeyCodeEntry(KeyEvent.KEYCODE_HOME));

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.

public int mapUnicode (VScanEntry scanCode, Character c)

Added in revision 1

Assigns a unicode character to a physical key. If a mapping for the desired physical key is already assigned and saved, it will be overridden.

Parameters
scanCode a VScanEntry representing the virtual scan code.
c unicode character

Example code to assign a Thai unicode character to the physical key '1':
(new KeyboardManager()).mapUnicode(new VScanEntry(VScanCode.VSCAN_1), '\\u0e01');

Returns
  • int SUCCESS in case of success, otherwise a possible error code, matching one of the DeviceException error constants.
Throws
DeviceException in case of error, when exceptions are enabled through the ErrorManager singleton.
See Also