pehrlich / LeapMotionDetect

Small <1k JS helper library to detect LeapMotion device via websockets, and if present load the LeapJS library for full functionality.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LeapMotionDetect

A small (<800 bytes) JavaScript helper library for working with LeapMotion JS in situations where it may be more appropriate to first detect the capabilities of the browser and presence of a LeapMotion device with a lighter footprint prior to loading the full library.

Specifically this helper library first checks if the users browser is capable of native websocket communication and if so, checks for the presence of a LeapMotion device. If present, it will then load the minimized LeapJS library to allow for full interactive control and information of the LeapMotion device in your application and return true in the callback function supplied. If not present (or websockets are unavailable), it will return false to the callback function supplied.

Perfect for Advertisements and other lightweight apps, games, etc. that need to be mindful of resource usage, bandwidth, etc.

USAGE:

function myApp(LeapPresent, args) { console.log("Leap is available: "+LeapPresent); console.log("Callback args: "+args); }

LeapMotionDetect(myApp, "dummy");

Above working example contained within index.html.

About

Small <1k JS helper library to detect LeapMotion device via websockets, and if present load the LeapJS library for full functionality.


Languages

Language:JavaScript 100.0%