# How to improve gesture detection by JLink for the LeapMotion controller

Building on this thread (where I cannot add anything anymore somehow) and with this nice answer I kind of got swipe detection to work, but it is not very responsive. How to improve (in the sense of making it more robust, sensitive) this code?

   (* this is the directory where LeapSDK is *)
$leapdir = FileNameJoin[{$UserBaseDirectory, "Applications",
"LeapDeveloperKit"}];
If[FileExistsQ[$leapdir], Needs["JLink"]; Block[{nativelibs}, With[{(*the location of the developer kit:*) lmlib = FileNameJoin[{$leapdir, "LeapSDK", "lib"}]},
nativelibs =
FileNameJoin[{lmlib,
Switch[$SystemID, "Windows-x86-64", "x64", "Windows", "x86"]}]; (*now start Java*) JLinkReinstallJava[ JLinkClassPath -> FileNameJoin[{lmlib, "LeapJava.jar"}], JLinkJVMArguments -> "-Djava.library.path=\"" <> nativelibs <> "\""]]]]; controller = JavaNew["com.leapmotion.leap.Controller"]; LoadJavaClass["com.leapmotion.leap.Gesture$Type"];
If[Not[controller@isGestureEnabled[Gesture$TypeTYPEUSWIPE]], controller@enableGesture[Gesture$TypeTYPEUSWIPE]
];
controller@isGestureEnabled[Gesture\$TypeTYPEUSWIPE];
gesturePrint[controller_] := Module[{gesture},
gesture = controller@frame[]@gestures[]@get[0];
If[(gesture@type[]@name[]) === "TYPE_SWIPE",
swipe = JavaNew["com.leapmotion.leap.SwipeGesture", gesture];

{swipe@state[]@toString[],
(swipe@position[]@#) & /@ {getX[], getY[], getZ[]},
(swipe@direction[]@#) & /@ {getX[], getY[], getZ[]},
swipe@speed[]
}]]
ud = .05;
Dynamic[gesturePrint[controller], UpdateInterval -> 0.1]
`
-