Ejemplo n.º 1
0
HPEXPORT int HPCALL hpcables_exit(void) {
    int res;
    hid_exit();
    res = ERR_SUCCESS;
    hpcables_info(_("%s: exit succeeded"), __FUNCTION__);
    return res;
}
Ejemplo n.º 2
0
int doScan() {
	struct hid_device_info *devs, *cur_dev;
	
	if (hid_init()) {
		return -1;
	};

	devs = hid_enumerate(0x0, 0x0);
	for (cur_dev = devs ; cur_dev; cur_dev = cur_dev->next) {
		printf("====>\n");
		printf("\tvendor_id: %04hx\n", cur_dev->vendor_id);
		printf("\tproduct_id: %04hx\n", cur_dev->product_id);
		printf("\tpath: %s\n", cur_dev->path);
		printf("\tserial_number: %ls\n", cur_dev->serial_number);
		printf("\tmanufacturer string: %ls\n", cur_dev->manufacturer_string);
		printf("\tproduct string: %ls\n", cur_dev->product_string);
		printf("\trelease number: %hx\n", cur_dev->release_number);
		printf("\tinterface number%d\n",  cur_dev->interface_number);
		if (cur_dev->vendor_id == RELAY_VENDOR_ID || cur_dev->product_id == RELAY_PRODUCT_ID)
		{
			// will not work with more than one realy per card
			unsigned int state = relay_get_state(cur_dev->path);
			switch (state) {
				case 0: printf("\tstate off\n"); break;
				case 1: printf("\tstate on\n"); break;
				default: printf("\tstate unknown\n"); break;
			}
		}
		printf("\n");
	}
	hid_free_enumeration(devs);
	hid_exit();

	return 0;
}
Ejemplo n.º 3
0
HidEnumerator::~HidEnumerator() {
    qDebug() << "Deleting HID devices...";
    while (m_devices.size() > 0) {
        delete m_devices.takeLast();
    }
    hid_exit();
}
Ejemplo n.º 4
0
int main(int argc, char* argv[]) {
  // Enumerate and print the HID devices on the system
  struct hid_device_info *devs, *cur_dev;

  hid_init();
  devs = hid_enumerate(0x0, 0x0);
  cur_dev = devs;
  while (cur_dev) {
    printf("Device Found\n");
    printf("  VID PID:      %04hx %04hx\n",
        cur_dev->vendor_id, cur_dev->product_id);
    printf("  Page/Usage:   0x%x/0x%x (%d/%d)\n",
        cur_dev->usage_page, cur_dev->usage,
        cur_dev->usage_page, cur_dev->usage);
    printf("\n");
    printf("  Manufacturer: %ls\n", cur_dev->manufacturer_string);
    printf("  Product:      %ls\n", cur_dev->product_string);
    printf("  Device path:  %s%s%s\n",
        QUOTE, cur_dev->path, QUOTE);
    printf("\n");

    cur_dev = cur_dev->next;
  }
  hid_free_enumeration(devs);

  hid_exit();
  return 0;
}
Ejemplo n.º 5
0
//-------------------------------------------------------------------------------------
LapTrainer::~LapTrainer(void)
{
	num_res= simball.DisconnectFromSimBall(0);
	hid_free_enumeration(simball.device); //we free enumeration
	Sleep (50);
	hid_exit();
}
Ejemplo n.º 6
0
// Same thing - clean up
int touchmouse_shutdown(void)
{
	// TODO: add some checking to see if all device handles have been closed,
	// and try to close them all?  This would involve keeping a list of
	// currently-open devices.  Not hard.
	return hid_exit();
}
Ejemplo n.º 7
0
static void freeDevice(LPCUSBSIO_I2C_Ctrl_t *dev)
{
    LPCUSBSIO_I2C_Ctrl_t *curDev = g_Ctrl.devList;
    
    if (curDev == dev) {
        g_Ctrl.devList = dev->next;
    }
    else {
        while (curDev) {
            if (curDev->next == dev) {
                /* update linked list */
                curDev->next = dev->next;
                break;
            }
        }
    }
    framework_FreeMem(dev);

    /* unload HID library if all devices are closed. */
    if (g_Ctrl.devList == NULL) {
        hid_free_enumeration(g_Ctrl.devInfoList);
        hid_exit();
    }
    
}
void Sbs2EmocapDataReader::resetHandle()
{
#ifdef Q_OS_MAC
    hid_close(handle);
    hid_exit();
    handle = hid_open(0x1234, 0xed02, NULL);
#endif
}
Ejemplo n.º 9
0
int hid_change_skin(const char *filename)
{
    int ret1, ret2;
	
	ret1 = hid_exit();
	ret2 = hid_init();
	
	return ret1 | ret2;
}
Ejemplo n.º 10
0
MantaUSB::~MantaUSB(void)
{
   Disconnect();
   mantaList.remove(this);
   if(mantaList.empty())
   {
      hid_exit();
   }
}
int main(int argc, char* argv[])
{
	int res;
	int i;

	// Initialize the hidapi library
	printf("Starting to initialize HID library...\n");
	res = hid_init();
	printf("Initialized HID library.\n");

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	printf("Trying to open device...\n");
	handle = hid_open(0x04d8, 0x003f, NULL);
	if(handle != NULL) {
		printf("Opened device successfully.\n");
	} else {
		printf("Could not open device.\n");
		exit(EXIT_FAILURE);
	}
	read_device_info();

	toggle_led1();

	printf("Button is %spressed.\n", get_push1_state() ? "" : "not ");

	printf("The decimal result is %d\n", get_pot1_val());

	// Register signal handler
	if (signal(SIGINT, sig_handler) == SIG_ERR) {
        printf("\nCan't catch SIGINT\n");
        exit(EXIT_FAILURE);
	}

	// Enter ncurses mode
	initialize_display();

	// Main loop
	while(1) {
		int a;
		a = (int)((100 / 1023.0) * get_pot1_val()); 
		print_percent_bar(2, a);
		refresh();
		sleep(0.1);
	}

	// Leave ncurses mode
	end_display();

	// Unregister signal handler
	signal(SIGINT, SIG_DFL);

	// Finalize the hidapi library
	res = hid_exit();

	return 0;
}
Ejemplo n.º 12
0
int main(int argc, char* argv[])
{
	int res;
	unsigned char buf[RELAY_COMMAND_SIZE];
	hid_device *handle;
	unsigned char command;

	if (argc != 2) {
		fprintf(stderr, "usage: %s [on|off]\n", argv[0]);
		exit(1);
	}
	if (strcmp(argv[1], "on") == 0) {
		command = RELAY_STATE_ON;
	} else if (strcmp(argv[1], "off") == 0) {
		command = RELAY_STAT_OFF;
	} else if (strcmp(argv[1], "scan") == 0) {
		return doScan();
	} else {
		fprintf(stderr, "usage: %s [on|off]\n", argv[0]);
		exit(1);
	}

	if (hid_init()) {
		fprintf(stderr, "can't init hid lib\n");
		exit(1);
	}

	// Set up the command buffer.
	memset(buf,0x00,sizeof(buf));
	buf[1] = command;
	buf[2] = RELAY_NUMBER;
	

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	////handle = hid_open(0x4d8, 0x3f, L"12345");
	handle = hid_open(RELAY_VENDOR_ID, RELAY_PRODUCT_ID,  NULL);
	if (!handle) {
		printf("unable to open device\n");
 		return 1;
	}

	res = hid_write(handle, buf, sizeof(buf));

	if (res < 0) {
		printf("Unable to send command\n");
	}


	hid_close(handle);

	/* Free static HIDAPI objects. */
	hid_exit();

	exit(0);
}
Ejemplo n.º 13
0
int HID_API_EXPORT hid_init(void)
{
	if (!hid_mgr) {
		if (init_hid_manager() < 0) {
			hid_exit();
			return -1;
		}
	}
	return 0;
}
Ejemplo n.º 14
0
/**
 * u2fh_devs_done:
 * @devs: device handle, from u2fh_devs_init().
 *
 * Release all resources associated with @devs.  This function must be
 * called when you are finished with a device handle.
 */
void
u2fh_devs_done (u2fh_devs * devs)
{
  if (devs == NULL)
    return;

  close_devices (devs);
  free (devs->devs);
  hid_exit ();

  free (devs);
}
Ejemplo n.º 15
0
/** Finalize the HID TEMPer types. */
bool tempered_type_hid_exit( char **error )
{
	if ( hid_exit() != 0 )
	{
		if ( error != NULL )
		{
			*error = strdup( "Error shutting down the HID API." );
		}
		return false;
	}
	return true;
}
Ejemplo n.º 16
0
int HID_API_EXPORT hid_init(void)
{
#ifndef HIDAPI_USE_DDK
	if (!initialized) {
		if (lookup_functions() < 0) {
			hid_exit();
			return -1;
		}
		initialized = TRUE;
	}
#endif
	return 0;
}
Ejemplo n.º 17
0
int hid_switch_fullscreen(void)
{
	if(options.view != VIEW_FULL)
	{
		set_scale(options.view = VIEW_FULL);
		
		hid_exit();
		hid_init();

		gdk_window_fullscreen(main_wnd->window);
	}

	return 0;
}
Ejemplo n.º 18
0
void signal_callback_handler(int signum)
{
	printf("Exiting on signal %d\n", signum);

	if(handle)
	{
		hid_close(handle);
		handle = NULL;
		hid_exit();
	}

	// Terminate program
	exit(0);
}
Ejemplo n.º 19
0
int hid_switch_large_view(void)
{
	if(options.view != VIEW_LARGE)
	{
		set_scale(options.view = VIEW_LARGE);		
		
		hid_exit();
		hid_init();
		
		//gdk_window_unfullscreen(main_wnd->window);
	}

    return 0;
}
Ejemplo n.º 20
0
int hid_switch_normal_view(void)
{
	if(options.view != VIEW_NORMAL)
	{
		set_scale(options.view = VIEW_NORMAL);

		hid_exit();
		hid_init();
		
		//gdk_window_unfullscreen(main_wnd->window);
	}

    return 0;
}
Ejemplo n.º 21
0
int HID_API_EXPORT hid_init(void)
{
#ifndef HIDAPI_USE_DDK
	if (!initialized) {
//        DebugClearText ();
        if (lookup_functions() < 0) {
			hid_exit();
            DebugAppendText ("initialized FAILED\n");

            return -1;
		}
		initialized = TRUE;
        DebugAppendText ("initialized = TRUE;\n");
	}
#endif
	return 0;
}
Ejemplo n.º 22
0
int main(int argc, char* argv[])
{
	//==================================================//
    // Check to make sure enough arguments are input:   //
    //==================================================//    
    if (argumentCheck(argc, argv) != 0) {
        return -1;
    }

	//==================================================//
    // Open USB HID:		                            //
    //==================================================//
    if (hidOpen() != 0) {
        return -1;
    }

	//==================================================//
    // Create Log File:                                 //
    //==================================================//
    if (logSetup(argv) != 0) {
        return -1;
    }

	//==================================================//
    // System ready...                                  //
    //==================================================//
    printf("\nREADY! Now logging...\n\n");

    //==================================================//
    // Run until error or user-terminated:              //
    //==================================================//
    int run = 1;
	while (run) {
		readTask();
		run = KB.kbhit() ? 0 : 1;
	}

	//==================================================//
    // Closing house-keeping tasks:                     //
    //==================================================//
	hid_close(hHID);
	fclose(fOutput);
	hid_exit();

	return EXIT_SUCCESS;
}
Ejemplo n.º 23
0
int main()
{
    hid_init();

    struct hid_device_info *hid_dev = hid_enumerate(0, 0);
    while (hid_dev) {
        std::printf("HID device: VID=%x PID=%x Path=%s Product string: \"%S\"\n",
                    hid_dev->vendor_id,
                    hid_dev->product_id,
                    hid_dev->path,
                    hid_dev->product_string);
        hid_dev = hid_dev->next;
    }

    hid_exit();
    return 0;
}
Ejemplo n.º 24
0
static void run(bool verbose, bool diagnostic, bool proxy_log) {
    hid_init();
    zsys_set_logsender(LOG_PUB_ENDPOINT);
//    zsys_set_logsystem(true);
    twps_server_t *self = twps_new(verbose, proxy_log);
    assert(self);
    self->diagnostic = diagnostic;
    zpoller_t *poller = zpoller_new(self->printer_store_sub, NULL);
    while (!zctx_interrupted) {
        void *which = zpoller_wait(poller, 200);
        if (which == self->printer_store_sub) {
            s_loop_handle_printer_store_sub(self);
        }
    }
    zpoller_destroy(&poller);
    twps_destroy(&self);
    hid_exit();
}
Ejemplo n.º 25
0
static int energymon_finish_osp_local(energymon* em) {
  if (em == NULL || em->state == NULL) {
    errno = EINVAL;
    return -1;
  }

  int err_save = 0;
  energymon_osp* state = (energymon_osp*) em->state;

#ifdef ENERGYMON_OSP_USE_POLLING
  if (state->poll_sensors) {
    // stop sensors polling thread and cleanup
    state->poll_sensors = 0;
#ifndef __ANDROID__
    pthread_cancel(state->thread);
#endif
    err_save = pthread_join(state->thread, NULL);
  }
#endif
#ifdef ENERGYMON_OSP_STOP_ON_FINISH
  if (em_osp_request_startstop(state)) {
    perror("energymon_finish_osp_local: Failed to request start/stop");
    err_save = errno && !err_save ? errno : err_save;
  }
#endif
  errno = 0;
  hid_close(state->device);
  if (errno) {
    perror("energymon_finish_osp_local: hid_close");
    err_save = !err_save ? errno : err_save;
  }
  if (hid_exit()) {
    perror("energymon_finish_osp_local: hid_exit");
    err_save = errno && !err_save ? errno : err_save;
  }
  free(em->state);
  em->state = NULL;
  errno = err_save;
  return errno ? -1 : 0;
}
Ejemplo n.º 26
0
Archivo: rift.c Proyecto: Fsmv/OpenHMD
static void destroy_driver(ohmd_driver* drv)
{
	LOGD("shutting down driver");
	hid_exit();
	free(drv);
}
Ejemplo n.º 27
0
void DAPLUGCALL Daplug_exit(){
    winusbExit();
    hid_exit();
}
Ejemplo n.º 28
0
	Program::~Program()
	{
		hid_exit();
	}
Ejemplo n.º 29
0
int main(int argc, char* argv[])
{
	int res;
	unsigned char buf[256];
	#define MAX_STR 255
	wchar_t wstr[MAX_STR];
	hid_device *handle;
	int i;

#ifdef WIN32
	UNREFERENCED_PARAMETER(argc);
	UNREFERENCED_PARAMETER(argv);
#endif

	struct hid_device_info *devs, *cur_dev;
	
	if (hid_init())
		return -1;

	devs = hid_enumerate(0x0, 0x0);
	cur_dev = devs;	
	while (cur_dev) {
		printf("Device Found\n  type: %04hx %04hx\n  path: %s\n  serial_number: %ls", cur_dev->vendor_id, cur_dev->product_id, cur_dev->path, cur_dev->serial_number);
		printf("\n");
		printf("  Manufacturer: %ls\n", cur_dev->manufacturer_string);
		printf("  Product:      %ls\n", cur_dev->product_string);
		printf("  Release:      %hx\n", cur_dev->release_number);
		printf("  Interface:    %d\n",  cur_dev->interface_number);
		printf("\n");
		cur_dev = cur_dev->next;
	}
	hid_free_enumeration(devs);

	// Set up the command buffer.
	memset(buf,0x00,sizeof(buf));
	buf[0] = 0x01;
	buf[1] = 0x81;
	

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	////handle = hid_open(0x4d8, 0x3f, L"12345");
	handle = hid_open(0x4d8, 0x3f, NULL);
	if (!handle) {
		printf("unable to open device\n");
 		return 1;
	}

	// Read the Manufacturer String
	wstr[0] = 0x0000;
	res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
	if (res < 0)
		printf("Unable to read manufacturer string\n");
	printf("Manufacturer String: %ls\n", wstr);

	// Read the Product String
	wstr[0] = 0x0000;
	res = hid_get_product_string(handle, wstr, MAX_STR);
	if (res < 0)
		printf("Unable to read product string\n");
	printf("Product String: %ls\n", wstr);

	// Read the Serial Number String
	wstr[0] = 0x0000;
	res = hid_get_serial_number_string(handle, wstr, MAX_STR);
	if (res < 0)
		printf("Unable to read serial number string\n");
	printf("Serial Number String: (%d) %ls", wstr[0], wstr);
	printf("\n");

	// Read Indexed String 1
	wstr[0] = 0x0000;
	res = hid_get_indexed_string(handle, 1, wstr, MAX_STR);
	if (res < 0)
		printf("Unable to read indexed string 1\n");
	printf("Indexed String 1: %ls\n", wstr);

	// Set the hid_read() function to be non-blocking.
	hid_set_nonblocking(handle, 1);
	
	// Try to read from the device. There shoud be no
	// data here, but execution should not block.
	res = hid_read(handle, buf, 17);

	// Send a Feature Report to the device
	buf[0] = 0x2;
	buf[1] = 0xa0;
	buf[2] = 0x0a;
	buf[3] = 0x00;
	buf[4] = 0x00;
	res = hid_send_feature_report(handle, buf, 17);
	if (res < 0) {
		printf("Unable to send a feature report.\n");
	}

	memset(buf,0,sizeof(buf));

	// Read a Feature Report from the device
	buf[0] = 0x2;
	res = hid_get_feature_report(handle, buf, sizeof(buf));
	if (res < 0) {
		printf("Unable to get a feature report.\n");
		printf("%ls", hid_error(handle));
	}
	else {
		// Print out the returned buffer.
		printf("Feature Report\n   ");
		for (i = 0; i < res; i++)
			printf("%02hhx ", buf[i]);
		printf("\n");
	}

	memset(buf,0,sizeof(buf));

	// Toggle LED (cmd 0x80). The first byte is the report number (0x1).
	buf[0] = 0x1;
	buf[1] = 0x80;
	res = hid_write(handle, buf, 17);
	if (res < 0) {
		printf("Unable to write()\n");
		printf("Error: %ls\n", hid_error(handle));
	}
	

	// Request state (cmd 0x81). The first byte is the report number (0x1).
	buf[0] = 0x1;
	buf[1] = 0x81;
	hid_write(handle, buf, 17);
	if (res < 0)
		printf("Unable to write() (2)\n");

	// Read requested state. hid_read() has been set to be
	// non-blocking by the call to hid_set_nonblocking() above.
	// This loop demonstrates the non-blocking nature of hid_read().
	res = 0;
	while (res == 0) {
		res = hid_read(handle, buf, sizeof(buf));
		if (res == 0)
			printf("waiting...\n");
		if (res < 0)
			printf("Unable to read()\n");
		#ifdef WIN32
		Sleep(500);
		#else
		usleep(500*1000);
		#endif
	}

	printf("Data read:\n   ");
	// Print out the returned buffer.
	for (i = 0; i < res; i++)
		printf("%02hhx ", buf[i]);
	printf("\n");

	hid_close(handle);

	/* Free static HIDAPI objects. */
	hid_exit();

#ifdef WIN32
	system("pause");
#endif

	return 0;
}
Ejemplo n.º 30
0
WiimoteScannerHidapi::~WiimoteScannerHidapi()
{
  if (hid_exit() == -1)
    ERROR_LOG(WIIMOTE, "Failed to clean up hidapi.");
}