From d982ef5a37720341c268fdac1ab728a1d354761c Mon Sep 17 00:00:00 2001 From: Sebastian Zagrodzki Date: Mon, 27 Mar 2017 23:01:02 +0200 Subject: [PATCH] Add constants for device speed. --- usb/constants.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/usb/constants.go b/usb/constants.go index 70e4dae..b6ee82f 100644 --- a/usb/constants.go +++ b/usb/constants.go @@ -182,3 +182,25 @@ var requestTypeDescription = map[RequestType]string{ func (rt RequestType) String() string { return requestTypeDescription[rt] } + +type DeviceSpeed int + +const ( + DeviceSpeedUnknown DeviceSpeed = C.LIBUSB_SPEED_UNKNOWN + DeviceSpeedLow DeviceSpeed = C.LIBUSB_SPEED_LOW + DeviceSpeedFull DeviceSpeed = C.LIBUSB_SPEED_FULL + DeviceSpeedHigh DeviceSpeed = C.LIBUSB_SPEED_HIGH + DeviceSpeedSuper DeviceSpeed = C.LIBUSB_SPEED_SUPER +) + +var deviceSpeedDescription = map[DeviceSpeed]string{ + DeviceSpeedUnknown: "unknown", + DeviceSpeedLow: "low", + DeviceSpeedFull: "full", + DeviceSpeedHigh: "high", + DeviceSpeedSuper: "super", +} + +func (s DeviceSpeed) String() string { + return deviceSpeedDescription[s] +}