Comments (2)
@djankey
typically you'd use NativeInputAdapter
https://github.com/fljot/Gestouch/blob/features/71-fix-initialization/src/org/gestouch/input/NativeInputAdapter.as to handle input via listening to native MouseEvent
and/or TouchEvent
.
But if you already have some way to send data from TUIO to Starling, you could write some custom Starling-special input adapter that works with Starling events. Use NativeInputAdapter
's source code as reference.
To initialize:
https://github.com/fljot/Gestouch/blob/features/71-fix-initialization/CHANGELOG.md
(that is the most recent version branch)
from gestouch.
Thanks Pavel, it's working...
I'm adding TuioTouchEvent's to Starling TouchProcessor and Gestouch TouchesManager.
TuioTouchEvents are from TUIO ActionScript3 library Tuio-as3 https://code.google.com/archive/p/tuio-as3/downloads
TUIO > Flash connection can be done via one of three connectors (TCP, UDP, LocalConnection).
TCP and LocalConnection are working on my computer with bridge apps (udp-tcp-bridge https://code.google.com/archive/p/udp-tcp-bridge/downloads and udp-flashlc-bridge http://gkaindl.com/software/udp-flashlc-bridge)
Here is my implementation - It's not the prettiest, but it's working :)
// Add this to Starling main class
tuio = new TuioConnector(stage, tuio_ip_address, tuio_port, isTCP, isUDP, isLocalConnection);
tuio.touchesManager = Gestouch.touchesManager;
Gestouch.addDisplayListAdapter(starling.display.DisplayObject, new StarlingDisplayListAdapter());
Gestouch.addTouchHitTester(new StarlingTouchHitTester(Config.starling), -1);
TuioConnector .as
/**
* Created by djankey on 30.01.16.
*/
package utils {
import flash.net.LocalConnection;
import org.tuio.ITuioListener;
import org.tuio.TuioBlob;
import org.tuio.TuioClient;
import org.tuio.TuioCursor;
import org.tuio.TuioObject;
import org.tuio.TuioTouchEvent;
import org.tuio.connectors.LCConnector;
import org.tuio.connectors.TCPConnector;
import org.tuio.connectors.UDPConnector;
import starling.core.Starling;
import starling.display.Stage;
import starling.events.TouchPhase;
import starling.events.TouchProcessor;
import org.gestouch.core.IInputAdapter;
import org.gestouch.core.TouchesManager;
import org.gestouch.core.gestouch_internal;
public class TuioConnector implements ITuioListener, IInputAdapter {
private var _localConnection:LocalConnection;
private var _lcConnector:LCConnector;
private var _udpConnector:UDPConnector;
private var _tcpConnect:TCPConnector;
private var tuioClient:TuioClient;
protected var _stage:Stage;
protected var _touchesManager:TouchesManager;
use namespace gestouch_internal;
public function TuioConnector(stage:Stage, address:String = "127.0.0.1", port:int = 3333, isTCP:Boolean = false, isUDP:Boolean = false, isLocalConnection:Boolean = true) {
_stage = stage;
if (isTCP == true) {
_tcpConnect = new TCPConnector(address, port);
tuioClient = new TuioClient(_tcpConnect);
tuioClient.addListener(this);
} else if (isUDP == true) {
_udpConnector = new UDPConnector(address, port);
tuioClient = new TuioClient(_udpConnector);
tuioClient.addListener(this);
} else if (isLocalConnection == true) {
_localConnection = new LocalConnection();
_localConnection.connect("_MyConnection");
_localConnection.allowDomain('*');
_localConnection.client = this;
_lcConnector = new LCConnector();
tuioClient = new TuioClient(_lcConnector);
tuioClient.addListener(this);
} else {
return;
}
init();
}
public function init():void {
Starling.current.nativeStage.addEventListener(TuioTouchEvent.TOUCH_DOWN, addTuioCursor);
Starling.current.nativeStage.addEventListener(TuioTouchEvent.TOUCH_UP, removeTuioCursor);
Starling.current.nativeStage.addEventListener(TuioTouchEvent.TAP, addTuioCursor);
Starling.current.nativeStage.addEventListener(TuioTouchEvent.TOUCH_MOVE, updateTuioCursor);
//Starling.current.nativeStage.addEventListener(TuioTouchEvent.TOUCH_OVER, addTuioCursor);
//Starling.current.nativeStage.addEventListener(TuioTouchEvent.TOUCH_OUT, removeTuioCursor);
//Starling.current.nativeStage.addEventListener(TuioTouchEvent.ROLL_OVER, addTuioCursor);
//Starling.current.nativeStage.addEventListener(TuioTouchEvent.ROLL_OUT, removeTuioCursor);
}
public function set touchesManager(value:TouchesManager):void {
_touchesManager = value;
}
public function onDispose():void {
_touchesManager = null;
}
public function addTuioCursor(tuioCursor:TuioCursor):void {
var stgX:Number = tuioCursor.x * stgW;
var stgY:Number = tuioCursor.y * stgH;
if(_touchesManager) _touchesManager.onTouchBegin(tuioCursor.sessionID, stgX, stgY);
touchProcessor.enqueue(tuioCursor.sessionID, TouchPhase.BEGAN, stgX, stgY);
}
public function updateTuioCursor(tuioCursor:TuioCursor):void {
var stgX:Number = tuioCursor.x * stgW;
var stgY:Number = tuioCursor.y * stgH;
if (_touchesManager) _touchesManager.onTouchMove(tuioCursor.sessionID, stgX, stgY);
touchProcessor.enqueue(tuioCursor.sessionID, TouchPhase.MOVED, stgX, stgY);
}
public function removeTuioCursor(tuioCursor:TuioCursor):void {
var stgX:Number = tuioCursor.x * stgW;
var stgY:Number = tuioCursor.y * stgH;
if (_touchesManager)_touchesManager.onTouchEnd(tuioCursor.sessionID, stgX, stgY);
touchProcessor.enqueue(tuioCursor.sessionID, TouchPhase.ENDED, stgX, stgY);
}
public function addTuioBlob(tuioBlob:TuioBlob):void {
}
public function updateTuioBlob(tuioBlob:TuioBlob):void {
}
public function removeTuioBlob(tuioBlob:TuioBlob):void {
}
public function addTuioObject(tuioObject:TuioObject):void {
}
public function updateTuioObject(tuioObject:TuioObject):void {
}
public function removeTuioObject(tuioObject:TuioObject):void {
}
public function newFrame(id:uint):void {
}
private function get touchProcessor():TouchProcessor {
return Starling.current.touchProcessor;
}
private function get stgW():Number {
return Starling.current.nativeStage.stageWidth;
}
private function get stgH():Number {
return Starling.current.nativeStage.stageHeight;
}
}
}
from gestouch.
Related Issues (20)
- Limit panning in TransformGesture HOT 2
- DoubleTab and zoom HOT 3
- use Gestouch in Normal As3 HOT 1
- Gestouch suddenly stopped working on Windows 10 with latest Animate CC HOT 2
- How can I use gestouch in starling2 and normal swf file with together ? HOT 1
- freerotation behaviour HOT 4
- SwipeGesture and Drag Drop HOT 1
- swipe container and tap with button scaling up HOT 19
- air error HOT 6
- Errors when using swipe gesture with Starling HOT 2
- Starling.dispose() loses Gestouch swipe HOT 3
- Gestouch with Air18 HOT 8
- Gestouch suddenly stops working HOT 7
- Cannot register CLICK events on items inside an item dragged with Gestouch HOT 2
- example for drag and zoom and rotate. all together with gestouch HOT 10
- Listeners not working in certain circumstances HOT 15
- SingleTap and DoubleTap - suggestions? HOT 3
- Shaky TransformGesture HOT 5
- Dispatch SwipeGesture to repeat Event HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gestouch.