RebeccaHid2 Sample code to use the HidDiscoverer

From CSWiki
Jump to: navigation, search

//sample code
new HidDiscoverer @=> HidDiscoverer h;
if (!h.init(0)) {
	me.exit();
}
spork ~h.setup();

HidIn hi;
// structure to hold HID messages
HidMsg msg;

// open keyboard
if( !hi.openKeyboard( 0 ) ) me.exit();
// successful! print name of device
<<< "keyboard '", hi.name(), "' ready" >>>;

hi => now;

spork ~h.stopSetupAndStartRun();

for (0 => int i; i < 100; i++) {
	h.extractFeatures() @=> float f[];
	<<< "FEATURES" >>>;
	for (0 => int i; i < f.size(); i++) {
		<<< f[i] >>>;
	}
	.2::second => now;

}	

h.stop();

<<< "Done.">>>;