Ejemplo n.º 1
0
 FREObject LeapNative_enableGesture(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int gestureClassType;
     FREGetObjectAsInt32(argv[0], &gestureClassType);
     
     bool gestureEnabled = createBoolFromFREObject(argv[1]);
     
     std::cout << "LeapNative_enableGesture called: " << gestureClassType << std::endl;
     
     switch (gestureClassType) {
         case 5:
             device->controller->enableGesture(Gesture::TYPE_SWIPE, gestureEnabled);
             break;
         case 6:
             device->controller->enableGesture(Gesture::TYPE_CIRCLE, gestureEnabled);
             break;
         case 7:
             device->controller->enableGesture(Gesture::TYPE_SCREEN_TAP, gestureEnabled);
             break;
         case 8:
             device->controller->enableGesture(Gesture::TYPE_KEY_TAP, gestureEnabled);
             break;
         default:
             std::cout << "LeapNative_enableGesture: invalid argument" << std::endl;
             break;
     }
     return NULL;
 }
Ejemplo n.º 2
0
    FREObject LeapNative_isGestureEnabled(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
        leapnative::LNLeapDevice* device;
        FREGetContextNativeData(ctx, (void **) &device);
        
        int gestureClassType;
        FREGetObjectAsInt32(argv[0], &gestureClassType);
        
        bool gestureEnabled;

        switch (gestureClassType) {
            case 5:
                gestureEnabled = device->controller->isGestureEnabled(Gesture::TYPE_SWIPE);
                break;
            case 6:
                gestureEnabled = device->controller->isGestureEnabled(Gesture::TYPE_CIRCLE);
                break;
            case 7:
                gestureEnabled = device->controller->isGestureEnabled(Gesture::TYPE_SCREEN_TAP);
                break;
            case 8:
                gestureEnabled = device->controller->isGestureEnabled(Gesture::TYPE_KEY_TAP);
                break;
            default:
                std::cout << "LeapNative_isGestureEnabled: invalid argument" << std::endl;
                gestureEnabled = false;
                break;
        }
        
        return createFREObjectForBool(gestureEnabled);
    }
Ejemplo n.º 3
0
 FREObject LeapNative_getScreenProject(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int screenId;
     FREGetObjectAsInt32(argv[0], &screenId);
     
     double pX;
     FREGetObjectAsDouble(argv[1], &pX);
     
     double pY;
     FREGetObjectAsDouble(argv[2], &pY);
     
     double pZ;
     FREGetObjectAsDouble(argv[3], &pZ);
     
     bool normalize = createBoolFromFREObject(argv[4]);
     
     double clampRatio;
     FREGetObjectAsDouble(argv[5], &clampRatio);
     
     Vector position = Vector((float) pX, (float) pY, (float) pZ);
     
     return device->getScreenProject(screenId, position, normalize, (float) clampRatio);
 }
Ejemplo n.º 4
0
 FREObject LeapNative_getClosestScreenHit(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     double pX;
     FREGetObjectAsDouble(argv[0], &pX);
     
     double pY;
     FREGetObjectAsDouble(argv[1], &pY);
     
     double pZ;
     FREGetObjectAsDouble(argv[2], &pZ);
     
     double dX;
     FREGetObjectAsDouble(argv[3], &dX);
     
     double dY;
     FREGetObjectAsDouble(argv[4], &dY);
     
     double dZ;
     FREGetObjectAsDouble(argv[5], &dZ);
     
     Vector position = Vector((float) pX, (float) pY, (float) pZ);
     Vector direction = Vector((float) dX, (float) dY, (float) dZ);
     
     return device->getClosestScreenHit(position, direction);
 }
Ejemplo n.º 5
0
 void finalizer(FREContext ctx) {
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     if(device != NULL) {
         delete device;
     }
     return;
 }
/**
 * Called when the context is about to be destroyed.
 */
static void ContextFinalizer(FREContext context)
{
    void* sc; 
    if( FREGetContextNativeData(context, &sc) == FRE_OK && sc != NULL )
    {
        delete (SessionContext*)sc;
    }
}
Ejemplo n.º 7
0
 // Hub class start
 FREObject hubAddListener(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     std::cout << "[NATIVE hubAddListener]" << std::endl;
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     device->hub->addListener(device->listener);
     
     return NULL;
 }
Ejemplo n.º 8
0
 //start policy
 FREObject LeapNative_setPolicyFlags(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     uint32_t flags;
     FREGetObjectAsUint32(argv[0], &flags);
     
     return device->setPolicyFlags(flags);
 }
Ejemplo n.º 9
0
 FREObject LeapNative_getClosestScreenHitPointable(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int pointableId;
     FREGetObjectAsInt32(argv[0], &pointableId);
     
     return device->getClosestScreenHitPointable(pointableId);
 }
Ejemplo n.º 10
0
 FREObject LeapNative_getScreenNormal(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int screenId;
     FREGetObjectAsInt32(argv[0], &screenId);
     
     return device->getScreenNormal(screenId);
 }
Ejemplo n.º 11
0
 // Myo class start
 FREObject myoRequestRSSI(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     std::cout << "[NATIVE myoRequestRSSI]" << std::endl;
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     device->myo->requestRssi();
     
     return NULL;
 }
Ejemplo n.º 12
0
	void contextFinalizer(FREContext ctx) {
        leapnative::LNLeapDevice* device;
        FREGetContextNativeData(ctx, (void **) &device);
        if(device != NULL)
        {
            delete device;
        }
        std::cout << "context finalizer" << std::endl;
		return;
	}
Ejemplo n.º 13
0
 FREObject LeapNative_getConfigType(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     uint32_t len;
     const uint8_t* key = 0;
     FREGetObjectAsUTF8(argv[0], &len, &key);
     
     return device->getConfigType(len, key);
 }
Ejemplo n.º 14
0
 FREObject LeapNative_frameTranslationProbability(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int frameId;
     FREGetObjectAsInt32(argv[0], &frameId);
     
     int sinceFrameId;
     FREGetObjectAsInt32(argv[1], &sinceFrameId);
     
     return device->frameProbability(frameId, sinceFrameId, 2);
 }
Ejemplo n.º 15
0
 FREObject hubRun(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     std::cout << "[NATIVE hubRun]" << std::endl;
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int durationMilliseconds;
     FREGetObjectAsInt32(argv[0], &durationMilliseconds);
     
     // Adding native listener
     device->hub->run(durationMilliseconds);
     
     return NULL;
 }
Ejemplo n.º 16
0
 FREObject LeapNative_setConfigFloat(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     uint32_t len;
     const uint8_t* key = 0;
     FREGetObjectAsUTF8(argv[0], &len, &key);
     
     double value;
     FREGetObjectAsDouble(argv[1], &value);
     
     return device->setConfigFloat(len, key, (float)value);
 }
Ejemplo n.º 17
0
 FREObject myoVibrate(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     std::cout << "[NATIVE myoVibrate]" << std::endl;
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int vibrationType;
     FREGetObjectAsInt32(argv[0], &vibrationType);
     myo::Myo::VibrationType vibrationEnum = static_cast<myo::Myo::VibrationType>(vibrationType);
     
     device->myo->vibrate(vibrationEnum);
     
     return NULL;
 }
Ejemplo n.º 18
0
 FREObject LeapNative_setConfigString(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     uint32_t len;
     const uint8_t* key = 0;
     FREGetObjectAsUTF8(argv[0], &len, &key);
     
     uint32_t valueLen;
     const uint8_t* valueArray = 0;
     FREGetObjectAsUTF8(argv[1], &valueLen, &valueArray);
     
     
     return device->setConfigString(len, key, valueLen, valueArray);
 }
Ejemplo n.º 19
0
    //start device class
    FREObject LeapNative_getDeviceDistanceToBoundary(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
        leapnative::LNLeapDevice* device;
        FREGetContextNativeData(ctx, (void **) &device);
        
        double pX;
        double pY;
        double pZ;
        FREGetObjectAsDouble(argv[0], &pX);
        FREGetObjectAsDouble(argv[1], &pY);
        FREGetObjectAsDouble(argv[2], &pZ);

        Vector position = Vector((float) pX, (float) pY, (float) pZ);

        return device->getDeviceDistanceToBoundary(position);
    }
Ejemplo n.º 20
0
 FREObject LeapNative_handScaleProbability(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int handId;
     FREGetObjectAsInt32(argv[0], &handId);
     
     int frameId;
     FREGetObjectAsInt32(argv[1], &frameId);
     
     int sinceFrameId;
     FREGetObjectAsInt32(argv[2], &sinceFrameId);
     
     return device->handProbability(handId, frameId, sinceFrameId, 1);
 }
Ejemplo n.º 21
0
    //start screen class
    FREObject LeapNative_getScreenDistanceToPoint(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
        leapnative::LNLeapDevice* device;
        FREGetContextNativeData(ctx, (void **) &device);

        int screenId;
        double pX;
        double pY;
        double pZ;
        FREGetObjectAsInt32(argv[0], &screenId);
        FREGetObjectAsDouble(argv[1], &pX);
        FREGetObjectAsDouble(argv[2], &pY);
        FREGetObjectAsDouble(argv[3], &pZ);
        
        Vector point = Vector((float) pX, (float) pY, (float) pZ);

        return device->getScreenDistanceToPoint(screenId, point);
    }
Ejemplo n.º 22
0
 FREObject LeapNative_imageWarp(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     int imageId;
     FREGetObjectAsInt32(argv[0], &imageId);
     
     double pX;
     double pY;
     double pZ;
     FREGetObjectAsDouble(argv[1], &pX);
     FREGetObjectAsDouble(argv[2], &pY);
     FREGetObjectAsDouble(argv[3], &pZ);
     
     Vector xy = Vector((float) pX, (float) pY, (float) pZ);
     
     return device->imageWarp(imageId, xy);
 }
Ejemplo n.º 23
0
 FREObject hubWaitForMyo(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     std::cout << "[NATIVE hubWaitForMyo]" << std::endl;
     myonative::MyoDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     device->myo = device->hub->waitForMyo(10000);
     
     // If waitForMyo() returned a null pointer, we failed to find a Myo, so exit with an error message.
     if (!device->myo) {
         std::cout << "[NATIVE hubWaitForMyo] Unable to find a Myo!" << std::endl;
         return NULL;
     }
     
     FREObject freMyo;
     FRENewObject( (const uint8_t*) "com.thalmiclabs.myo.Myo", 0, NULL, &freMyo, NULL);
     
     // We've found a Myo, let's output its MAC address.
     std::cout << std::endl << "[NATIVE hubWaitForMyo]: Connected to Myo." << std::endl;
     
     return freMyo;
 }
Ejemplo n.º 24
0
 FREObject LeapNative_isServiceConnected(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     return device->isServiceConnected();
 }
Ejemplo n.º 25
0
 FREObject LeapNative_getDeviceIsStreaming(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     return device->getDeviceIsStreaming();
 }
Ejemplo n.º 26
0
 FREObject LeapNative_getDeviceVerticalViewAngle(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     return device->getDeviceVerticalViewAngle();
 }
Ejemplo n.º 27
0
 FREObject LeapNative_hasFocus(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
     leapnative::LNLeapDevice* device;
     FREGetContextNativeData(ctx, (void **) &device);
     
     return device->hasFocus();
 }