Packagecc.cote.jmulator
Classpublic class Emulator
InheritanceEmulator Inheritance flash.events.EventDispatcher
Subclasses Ipac2, Ipac4, IpacVe

The Emulator class is an abstract class which is used, and extended by, the classes in the the emulators sub-package. It provides various functionalities to simplify the process of working with keyboard emulators (also called encoders). By using one of its subclasses, you will be freed from researching keyboard codes. You will be able to simply listen to events bearing the same names as the labels on the board you use. The class also offers additional functionalities such as selective typematic management and the choice between receiving all events, only ON events or only OFF events.

See also

cc.cote.jmulator.EmulatorEvent
cc.cote.jmulator.emulators
flash.events.EventDispatcher
http://cote.cc/projects/jmulator


Public Properties
 PropertyDefined By
  capsLock : Boolean
[read-only] Indicates if the capsLock key is currently engaged (true) or not (false)
Emulator
  jsonLabelMap : String
[read-only] A JSON representation of the board label to keyboard key mappings (useful for debugging)
Emulator
  map : Dictionary
A Dictionary object that specifies the mappings between key codes (as sent by the board) and event names
Emulator
  numLock : Boolean
[read-only] Indicates if the numLock key is currently engaged (true) or not (false)
Emulator
  triggering : String = both
A string that identifies which type of events should be triggered by the Emulator object.
Emulator
  typematic : Boolean = false
A boolean specifying whether or not to ignore the OS typematic feature.
Emulator
Public Methods
 MethodDefined By
  
Emulator(listenOn:InteractiveObject, typematic:Boolean = true, triggering:String = both)
The Emulator class simplifies interfacing with a variety of keyboard emulators/encoders
Emulator
  
isActive(input:String):Boolean
Returns the current status (activated or not) of a specific board input
Emulator
Public Constants
 ConstantDefined By
  INPUT_ANY : String = any
[static] Constant associated with any input.
Emulator
  TRIGGER_BOTH : String = both
[static] A string constant to specify that both "on" and "off" states should be triggering the dispatch of events
Emulator
  TRIGGER_OFF : String = off
[static] A string constant to specify that only "off" states should be triggering the dispatch of events
Emulator
  TRIGGER_ON : String = on
[static] A string constant to specify that only "on" states should be triggering the dispatch of events
Emulator
Property Detail
capsLockproperty
capsLock:Boolean  [read-only]

Indicates if the capsLock key is currently engaged (true) or not (false)


Implementation
    public function get capsLock():Boolean
jsonLabelMapproperty 
jsonLabelMap:String  [read-only]

A JSON representation of the board label to keyboard key mappings (useful for debugging)


Implementation
    public function get jsonLabelMap():String
mapproperty 
public var map:Dictionary

A Dictionary object that specifies the mappings between key codes (as sent by the board) and event names

numLockproperty 
numLock:Boolean  [read-only]

Indicates if the numLock key is currently engaged (true) or not (false)


Implementation
    public function get numLock():Boolean
triggeringproperty 
public var triggering:String = both

A string that identifies which type of events should be triggered by the Emulator object. It can be set to trigger events when inputs are activated only, when they are deactivated only or on both activation and deactivation (TRIGGER_ON, TRIGGER_OFF or TRIGGER_BOTH).

The default value is TRIGGER_BOTH.

typematicproperty 
public var typematic:Boolean = false

A boolean specifying whether or not to ignore the OS typematic feature. If typematic is enabled (it usually is), a stream of identical characters is generated when the user holds down a key for a period of time.

The default value is false.

Constructor Detail
Emulator()Constructor
public function Emulator(listenOn:InteractiveObject, typematic:Boolean = true, triggering:String = both)

The Emulator class simplifies interfacing with a variety of keyboard emulators/encoders

Parameters
listenOn:InteractiveObject — An InteractiveObject to attach the keyboard listener to. Usually this is the Stage.
 
typematic:Boolean (default = true) — Whether or not to use the OS typematic feature. When the typematic feature is enabled, the OS repeatedly sends keydown events when a key is being held down
 
triggering:String (default = both) — Triggering method : on button press only (TRIGGER_ON), on button release only (TRIGGER_OFF) or on both press and release (TRIGGER_BOTH)

Throws
Error — The Emulator class cannot be instantiated directly. Use a subclass from the emulators package
Method Detail
isActive()method
public function isActive(input:String):Boolean

Returns the current status (activated or not) of a specific board input

Parameters

input:String — Board input label

Returns
Boolean — A boolean indicating if the input is in active mode (true) or inactive mode (false)
Constant Detail
INPUT_ANYConstant
public static const INPUT_ANY:String = any

Constant associated with any input. Allows listening to all inputs at once. Since static properties are not inherited, it also needs to be defined in board classes.

TRIGGER_BOTHConstant 
public static const TRIGGER_BOTH:String = both

A string constant to specify that both "on" and "off" states should be triggering the dispatch of events

TRIGGER_OFFConstant 
public static const TRIGGER_OFF:String = off

A string constant to specify that only "off" states should be triggering the dispatch of events

TRIGGER_ONConstant 
public static const TRIGGER_ON:String = on

A string constant to specify that only "on" states should be triggering the dispatch of events