mirror of
https://github.com/RPCS3/hidapi.git
synced 2026-07-19 21:43:36 -04:00
Linux: Don't set locale if it's already been set
Adapted from a patch received from Axel Rohde <axel.rohde@gmail.com>
This commit is contained in:
+8
-2
@@ -385,8 +385,16 @@ static char *make_path(libusb_device *dev, int interface_number)
|
||||
int HID_API_EXPORT hid_init(void)
|
||||
{
|
||||
if (!usb_context) {
|
||||
const char *locale;
|
||||
|
||||
/* Init Libusb */
|
||||
if (libusb_init(&usb_context))
|
||||
return -1;
|
||||
|
||||
/* Set the locale if it's not set. */
|
||||
locale = setlocale(LC_CTYPE, NULL);
|
||||
if (!locale)
|
||||
setlocale(LC_CTYPE, "");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -413,8 +421,6 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||
struct hid_device_info *root = NULL; // return object
|
||||
struct hid_device_info *cur_dev = NULL;
|
||||
|
||||
setlocale(LC_ALL,"");
|
||||
|
||||
hid_init();
|
||||
|
||||
num_devs = libusb_get_device_list(usb_context, &devs);
|
||||
|
||||
+11
-5
@@ -164,8 +164,6 @@ static int get_device_string(hid_device *dev, const char *key, wchar_t *string,
|
||||
struct stat s;
|
||||
int ret = -1;
|
||||
|
||||
setlocale(LC_ALL,"");
|
||||
|
||||
/* Create the udev object */
|
||||
udev = udev_new();
|
||||
if (!udev) {
|
||||
@@ -205,7 +203,13 @@ end:
|
||||
|
||||
int HID_API_EXPORT hid_init(void)
|
||||
{
|
||||
/* Nothing to do for this in the Linux/hidraw implementation. */
|
||||
const char *locale;
|
||||
|
||||
/* Set the locale if it's not set. */
|
||||
locale = setlocale(LC_CTYPE, NULL);
|
||||
if (!locale)
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -223,8 +227,8 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
|
||||
|
||||
struct hid_device_info *root = NULL; // return object
|
||||
struct hid_device_info *cur_dev = NULL;
|
||||
|
||||
setlocale(LC_ALL,"");
|
||||
|
||||
hid_init();
|
||||
|
||||
/* Create the udev object */
|
||||
udev = udev_new();
|
||||
@@ -404,6 +408,8 @@ hid_device * HID_API_EXPORT hid_open_path(const char *path)
|
||||
{
|
||||
hid_device *dev = NULL;
|
||||
|
||||
hid_init();
|
||||
|
||||
dev = new_hid_device();
|
||||
|
||||
if (kernel_version == 0) {
|
||||
|
||||
Reference in New Issue
Block a user