diff --git a/Controllers/TecknetController/TecknetController.cpp b/Controllers/TecknetController/TecknetController.cpp index 357ccced..15487dab 100644 --- a/Controllers/TecknetController/TecknetController.cpp +++ b/Controllers/TecknetController/TecknetController.cpp @@ -26,21 +26,20 @@ static unsigned char tecknet_speed_mode_data[][9] = TecknetController::TecknetController(hid_device* dev_handle, char *_path) { - const int szTemp = 256; - wchar_t tmpName[szTemp]; - - dev = dev_handle; - - hid_get_manufacturer_string(dev, tmpName, szTemp); - std::wstring wName = std::wstring(tmpName); - device_name = std::string(wName.begin(), wName.end()); - - hid_get_product_string(dev, tmpName, szTemp); - wName = std::wstring(tmpName); - device_name.append(" ").append(std::string(wName.begin(), wName.end())); - + dev = dev_handle; location = _path; + /*---------------------------------------------------------*\ + | Get device name from HID manufacturer and product strings | + \*---------------------------------------------------------*/ + wchar_t name_string[HID_MAX_STR]; + + hid_get_manufacturer_string(dev, name_string, HID_MAX_STR); + device_name = StringUtils::wstring_to_string(name_string); + + hid_get_product_string(dev, name_string, HID_MAX_STR); + device_name.append(" ").append(StringUtils::wstring_to_string(name_string)); + current_mode = TECKNET_MODE_DIRECT; current_speed = TECKNET_SPEED_NORMAL; current_brightness = TECKNET_BRIGHTNESS_HIGH; diff --git a/Controllers/TecknetController/TecknetController.h b/Controllers/TecknetController/TecknetController.h index 3b8e5b33..9fde8d69 100644 --- a/Controllers/TecknetController/TecknetController.h +++ b/Controllers/TecknetController/TecknetController.h @@ -14,9 +14,10 @@ #include #include +#define HID_MAX_STR 255 #define TECKNET_COLOUR_MODE_DATA_SIZE (sizeof(tecknet_colour_mode_data[0]) / sizeof(tecknet_colour_mode_data[0][0])) -#define TECKNET_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ])) -#define TECKNET_PACKET_LENGTH 0x10 //16 bytes +#define TECKNET_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ])) +#define TECKNET_PACKET_LENGTH 0x10 //16 bytes enum {