SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Macros | Functions
hid-libusb.h File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <locale.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <fcntl.h>
#include <pthread.h>
#include <wchar.h>
#include <libusb-1.0/libusb.h>
#include "iconv.h"
#include "../fcdhid/hidapi.h"
+ Include dependency graph for hid-libusb.h:

Go to the source code of this file.

Classes

struct  input_report
 
struct  hid_device_
 
struct  lang_map_entry
 

Macros

#define LOG(...)   do {} while (0)
 
#define DETACH_KERNEL_DRIVER
 
#define LANG(name, code, usb_code)   { name, code, usb_code }
 

Functions

uint16_t get_usb_code_for_current_locale (void)
 
int HID_API_EXPORT hid_init (void)
 Initialize the HIDAPI library. More...
 
int HID_API_EXPORT hid_exit (void)
 Finalize the HIDAPI library. More...
 
struct hid_device_info HID_API_EXPORThid_enumerate (unsigned short vendor_id, unsigned short product_id)
 Enumerate the HID Devices. More...
 
void HID_API_EXPORT hid_free_enumeration (struct hid_device_info *devs)
 Free an enumeration Linked List. More...
 
hid_devicehid_open (unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
 Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. More...
 
hid_device *HID_API_EXPORT hid_open_path (const char *path)
 Open a HID device by its path name. More...
 
int HID_API_EXPORT hid_write (hid_device *dev, const unsigned char *data, size_t length)
 Write an Output report to a HID device. More...
 
int HID_API_EXPORT hid_read_timeout (hid_device *dev, unsigned char *data, size_t length, int milliseconds)
 Read an Input report from a HID device with timeout. More...
 
int HID_API_EXPORT hid_read (hid_device *dev, unsigned char *data, size_t length)
 Read an Input report from a HID device. More...
 
int HID_API_EXPORT hid_set_nonblocking (hid_device *dev, int nonblock)
 Set the device handle to be non-blocking. More...
 
int HID_API_EXPORT hid_send_feature_report (hid_device *dev, const unsigned char *data, size_t length)
 Send a Feature report to the device. More...
 
int HID_API_EXPORT hid_get_feature_report (hid_device *dev, unsigned char *data, size_t length)
 Get a feature report from a HID device. More...
 
void HID_API_EXPORT hid_close (hid_device *dev)
 Close a HID device. More...
 
int HID_API_EXPORT_CALL hid_get_manufacturer_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Manufacturer String from a HID device. More...
 
int HID_API_EXPORT_CALL hid_get_product_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Product String from a HID device. More...
 
int HID_API_EXPORT_CALL hid_get_serial_number_string (hid_device *dev, wchar_t *string, size_t maxlen)
 Get The Serial Number String from a HID device. More...
 
int HID_API_EXPORT_CALL hid_get_indexed_string (hid_device *dev, int string_index, wchar_t *string, size_t maxlen)
 Get a string from a HID device, based on its string index. More...
 
HID_API_EXPORT const wchar_t *HID_API_CALL hid_error (hid_device *dev)
 Get a string describing the last error which occurred. More...
 

Macro Definition Documentation

◆ DETACH_KERNEL_DRIVER

#define DETACH_KERNEL_DRIVER

Definition at line 66 of file hid-libusb.h.

◆ LANG

#define LANG (   name,
  code,
  usb_code 
)    { name, code, usb_code }

Definition at line 1227 of file hid-libusb.h.

◆ LOG

#define LOG (   ...)    do {} while (0)

Definition at line 62 of file hid-libusb.h.

Referenced by hid_read_timeout().

Function Documentation

◆ get_usb_code_for_current_locale()

uint16_t get_usb_code_for_current_locale ( void  )

Definition at line 1365 of file hid-libusb.h.

1366 {
1367  char *locale;
1368  char search_string[64];
1369  char *ptr;
1370  struct lang_map_entry *lang;
1371 
1372  /* Get the current locale. */
1373  locale = setlocale(0, NULL);
1374  if (!locale)
1375  return 0x0;
1376 
1377  /* Make a copy of the current locale string. */
1378  strncpy(search_string, locale, sizeof(search_string));
1379  search_string[sizeof(search_string)-1] = '\0';
1380 
1381  /* Chop off the encoding part, and make it lower case. */
1382  ptr = search_string;
1383  while (*ptr) {
1384  *ptr = tolower(*ptr);
1385  if (*ptr == '.') {
1386  *ptr = '\0';
1387  break;
1388  }
1389  ptr++;
1390  }
1391 
1392  /* Find the entry which matches the string code of our locale. */
1393  lang = lang_map;
1394  while (lang->string_code) {
1395  if (!strcmp(lang->string_code, search_string)) {
1396  return lang->usb_code;
1397  }
1398  lang++;
1399  }
1400 
1401  /* There was no match. Find with just the language only. */
1402  /* Chop off the variant. Chop it off at the '_'. */
1403  ptr = search_string;
1404  while (*ptr) {
1405  *ptr = tolower(*ptr);
1406  if (*ptr == '_') {
1407  *ptr = '\0';
1408  break;
1409  }
1410  ptr++;
1411  }
1412 
1413 #if 0 /* TODO: Do we need this? */
1414  /* Find the entry which matches the string code of our language. */
1415  lang = lang_map;
1416  while (lang->string_code) {
1417  if (!strcmp(lang->string_code, search_string)) {
1418  return lang->usb_code;
1419  }
1420  lang++;
1421  }
1422 #endif
1423 
1424  /* Found nothing. */
1425  return 0x0;
1426 }
Definition: hid-libusb.c:1227
const char * string_code
Definition: hid-libusb.c:1229
uint16_t usb_code
Definition: hid-libusb.c:1230