Skip to content

Input Sources

Valentin Simonov edited this page Jul 30, 2017 · 11 revisions

In TouchScript all input comes from Input Sources, i.e. objects implementing IInputSource interface. After a touch gets into the system TouchScript treats it the same as all the others no matter what input source was used.

Right now the library includes the following input sources:

  • StandardInput — implements mobile touch input, desktop touch input and mouse input,
  • TUIOInput — listens to an UDP socket for TUIO messages from network,
  • There used to be other input sources but they all are merged into StandardInput since TouchScript 7.0.

If at the start of a game there're no input sources in the scene, an instance of StandardInput is added.

Adding a new input source

If you want to route touches from any external source or you have any other idea how to create touches, you should implement a new Input Source. This way you can be sure that all other components of TouchScript will work with your touches the same way as they work with all other input sources.

Before implementing your own input source you should check out how some other input source works. For example, StandardInput might be a good example.

If you are extending provided InputSource class you just need to call:

Every Input Source must register itself to TouchManager.Instance using AddInput method. InputSource class does it automatically.

If an input source wants to get updates from TouchManager it must implement UpdateInput method which is called by TouchManager every frame at the beginning of update cycle in specific order.

Another method which must be implemented by an input source is CancelTouch which is called by TouchScript when a touch is cancelled internally and if this touch should be returned to the system.

You can’t perform that action at this time.