Beispiel #1
0
/*
 * usb-find-device (vendor-id product-id -- handle -1 | 0)
 */
void mu_usb_find_device()
{
    int matched;

    /* Enumerate USB device tree, looking for a match */
    matched = enumerate_devices(ST1, TOP);

    /*
     * enumerate_devices only returns failure (-1) if it found a match but
     * couldn't open the device for read & write. Tell the user about the
     * error.
     */
    if (matched < 0) return abort_strerror();

    if (matched == 0)
    {
        /* No match found */
        DROP(1);
        TOP = 0;
    }
    else
    {
        /* Matched; return the device's _open_ file descriptor */
        ST1 = matched;
        TOP = -1;
    }
}
Beispiel #2
0
Input::Input() {
	auto hInst = GetModuleHandle(NULL);
	register_input_window_class(hInst);

	_input_window = CreateWindow(_class_name, TEXT("RawInputWindow"), WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInst, NULL);

	if (_input_window == NULL) {
		std::cout << "Failed to create input window!" << std::endl;
	}
	SetWindowLongPtr(_input_window, GWLP_USERDATA, (LONG_PTR)this);
	ShowWindow(_input_window, SW_HIDE);
	UpdateWindow(_input_window);

	enumerate_devices();

	RAWINPUTDEVICE Rid[2];

	Rid[0].usUsagePage = 0x01; //HID mouse
	Rid[0].usUsage = 0x02;
	Rid[0].dwFlags = RIDEV_INPUTSINK;
	Rid[0].hwndTarget = _input_window;

	Rid[1].usUsagePage = 0x01; //HID keyboard
	Rid[1].usUsage = 0x06;
	Rid[1].dwFlags = RIDEV_INPUTSINK;
	Rid[1].hwndTarget = _input_window;

	if (RegisterRawInputDevices(Rid, 2, sizeof(Rid[0])) == FALSE) {
		std::cout << "Failed to register raw input devices!" << std::endl;
	}
}
void DownloadFromDCWidget::fill_device_list()
{
	int deviceIndex;
	ui.device->clear();
	deviceIndex = enumerate_devices(fillDeviceList, ui.device);
	if (deviceIndex >= 0)
		ui.device->setCurrentIndex(deviceIndex);
}
/*
  Method to activate the tracker (create an instance to the API and the device).
  In case of an error, the deactivate function is called to cleanup and then the error code is returned back to Java.

  return: error code
*/
int activate() {
	//If, for any reason the previous deactivate was not done properly.
	if(api != NULL || device!=NULL) {
		deactivate();
	}

	do_run_main_loop=false;
	main_loop_finished=false;
	tobii_error_t error=TOBII_ERROR_NO_ERROR;

	//Retrieve API version just for informative reasons.
	tobii_version_t version;
    error = tobii_get_api_version( &version );
    if( error == TOBII_ERROR_NO_ERROR )
        printf( "Tobii-4C: Current API version: %d.%d.%d\n", version.major, version.minor, 
            version.revision );

	//Create an instance to the API
    error = tobii_api_create( &api, NULL, NULL );
	if( error != TOBII_ERROR_NO_ERROR ) {
		//cleanup, just to be sure
		deactivate();
		return error;
	}

	//Do device enumeration of 4C devices, if none is found abort with an error.
	//We do this to exclude older Tobii devices e.g. EyeX
	if(enumerate_devices()==0) {
		printf("Tobii-4C: enumerate_devices error: no devices\n");
		return TOBII_ERROR_NOT_AVAILABLE;
	}

	//although we did an enumeration above, simply use the default device --> don't provide deviceURL but use NULL instead.
	error = tobii_device_create( api, NULL, &device );
	printf("Tobii-4C: device != null? : %s\n",device!=NULL? "found device" : "no device"); 
    if( error != TOBII_ERROR_NO_ERROR ) {
		printf("Tobii-4C: tobii_device_create error: %s\n",tobii_error_message(error));
		deactivate();
		return error;
	}

	//Subscribe for the head pose data
    error = tobii_head_pose_subscribe( device, head_pose_callback, 0 );
	if( error != TOBII_ERROR_NO_ERROR ) return error;

	//Subscribe for user presence
	error = tobii_user_presence_subscribe( device, presence_callback, 0 );
	if( error != TOBII_ERROR_NO_ERROR ) printf("Tobii-4C: user_presence subscription error: %s\n",tobii_error_message(error));

	error = tobii_notifications_subscribe( device, notifications_callback, 0 );
	if( error != TOBII_ERROR_NO_ERROR ) printf("Tobii-4C: notifications subscription error: %s\n",tobii_error_message(error));

	//remember activated state
	tracker_activated=true;

	return error;
}
Beispiel #5
0
//Initialize the rack by polling for devices and serial numbers
int APSRack::init() {

	//Create the logger
	FILE* pFile = fopen("libaps.log", "a");
	Output2FILE::Stream() = pFile;

	//Enumerate the serial numbers of the devices attached
	enumerate_devices();

	return 0;
}
Beispiel #6
0
transport_ptr_t find_usb_transport(const usb_context_ptr_t &ctx, const notifier_t *notifier)
{
    device_ptr_t dev;
    TA_INFO() << "Enumerating USB devices";
    while (!dev)
    {
        dev = enumerate_devices(ctx);
        if (!dev || libusb_reset_device(dev.get()) != LIBUSB_SUCCESS)
            notifier->sleep(1000);
        TA_TRACE() << "ACC device not found, retrying";
    }
    TA_INFO() << "Found an ACC device.";
    // Always detach the kernel first
    libusb_set_auto_detach_kernel_driver(dev.get(), 1);

    return transport_ptr_t(new transport_t(ctx, dev, notifier));
}
Beispiel #7
0
int main( int argc, char *argv[] ) {
	camcap_init( );
	
	programName = argv[0];
	
	if ( argc == 1 ) {
		return enumerate_devices( );
	} else if ( argc == 3 ) {
		return capture_image( argv[1], argv[2] );
	} else {
		fprintf( stderr, "Usage:\n" );
		fprintf( stderr, "  Enumerate cameras:     %s\n", programName );
		fprintf( stderr, "  Capture a raw image:   %s <deviceIndex> <filename>\n", programName );
		return 1;
	}
	
	return 0;
}
Beispiel #8
0
/*
 * usb-find-device (vendor-id product-id -- handle -1 | 0)
 */
void mu_usb_find_device()
{
    int matched;

    /* Enumerate USB device tree, looking for a match */
    matched = enumerate_devices(ST1, TOP);

    if (matched < 0) return abort_strerror();

    if (matched == 0)
    {
        /* No match found */
        DROP(1);
        TOP = 0;
    }
    else
    {
        /* Matched; return the device's _open_ file descriptor */
        ST1 = matched;
        TOP = -1;
    }
}