unifying

package
v0.0.0-...-e383ded Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2020 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOGITECH_DEVICE_CAPS_LINK_ENCRYPTION     = LogitechDeviceCapabilities(1 << 0)
	LOGITECH_DEVICE_CAPS_UNIFYING_COMPATIBLE = LogitechDeviceCapabilities(1 << 2) // if not set pairing aborts with "not Unifying compatible"

)
View Source
const (
	USB_REPORT_TYPE_DJ_SHORT_LEN         = 15
	USB_REPORT_TYPE_DJ_LONG_LEN          = 32
	USB_REPORT_TYPE_DJ_SHORT_PAYLOAD_LEN = 12
	USB_REPORT_TYPE_DJ_LONG_PAYLOAD_LEN  = 29

	USB_REPORT_TYPE_HIDPP_SHORT_LEN         = 7
	USB_REPORT_TYPE_HIDPP_LONG_LEN          = 20
	USB_REPORT_TYPE_HIDPP_SHORT_PAYLOAD_LEN = 4
	USB_REPORT_TYPE_HIDPP_LONG_PAYLOAD_LEN  = 17
)
View Source
const (
	DJ_REPORT_RF_TYPE_BITFIELD_KEYBOARD         = 0x00000002
	DJ_REPORT_RF_TYPE_BITFIELD_MOUSE            = 0x00000004
	DJ_REPORT_RF_TYPE_BITFIELD_CONSUMER_CONTROL = 0x00000008
	DJ_REPORT_RF_TYPE_BITFIELD_POWER_KEYS       = 0x00000010
	DJ_REPORT_RF_TYPE_BITFIELD_MEDIA_CENTER     = 0x00000100
	DJ_REPORT_RF_TYPE_BITFIELD_KEYBOARD_LEDS    = 0x00004000
	DJ_REPORT_RF_TYPE_BITFIELD_HIDPP_SHORT      = 0x00010000 //not on USB as HID report, but in respective RF report
	DJ_REPORT_RF_TYPE_BITFIELD_HIDPP_LONG       = 0x00020000 //not on USB as HID report, but in respective RF report
)
View Source
const (
	UNIYING_WIRELESS_NOTIFICATIONS_P0_BATTERY_STATUS_MASK = (1 << 4)

	UNIYING_WIRELESS_NOTIFICATIONS_P1_WIRELESS_NOTIFICATIONS_MASK = (1 << 0)
	UNIYING_WIRELESS_NOTIFICATIONS_P1_SOFTWARE_PRESENT_MASK       = (1 << 3)
)

for write/read parameters of short read/write from/to wireless notification register (0x00)

View Source
const (
	VID             gousb.ID = 0x046d
	PID_UNIFYING    gousb.ID = 0xc52b //cu0007, cu0008, cu0012
	PID_CU0016_R500 gousb.ID = 0xc540 //cu0016
	//	PID_CU0010           gousb.ID = 0xc534
	PID_CU0016_SPOTLIGHT gousb.ID = 0xc53e //R-R0011
	PID_CU0014_R400      gousb.ID = 0xc538 //R-R0011
	PID_CU0007_G700      gousb.ID = 0xc531 //G700/G700s

	PID_BOOT_LOADER_NORDIC          gousb.ID = 0xaaaa //CU0007, tested BOT01.02_B0014 / RQR12.01_B0019 and BOT01.02_B0015 / RQR12.01_B0019; HW_PLATFORM_ID: nRF24LU1+
	PID_BOOT_LOADER_NORDIC2         gousb.ID = 0x0003 //CU0007, tested BOT01.02_B0014 / RQR12.01_B0019 and BOT01.02_B0015 / RQR12.01_B0019; HW_PLATFORM_ID: nRF24LU1+
	PID_BOOT_LOADER_TI              gousb.ID = 0xaaac //CU0008 (JNZCU0008), tested BOT03.01_B0008 / RQR24.01_B0023
	PID_BOOT_LOADER_TI_NANO         gousb.ID = 0xaaad //CU0012, tested BOT03.03_B0009 / RQR24.07_B0030
	PID_BOOT_LOADER_LIGHTSPEED_G603 gousb.ID = 0xaabe //CU0008 (JNZCU0008a), tested BOT03.02_B0009 / RQR39.04_B0036
	PID_BOOT_LOADER_TI_SPOTLIGHT    gousb.ID = 0xaad3 //CU0016, tested BOT03.02_B0009 / RQR41.00_B0004
	PID_BOOT_LOADER_TI_R500         gousb.ID = 0xaae1 //CU0016, tested BOT03.02_B0009 / RQR45.00_B0002
)

Variables

View Source
var (
	ErrReceiverInBootloaderMode = errors.New("detected Logitech receiver seems to run in bootloader mode")
)

Functions

func KeyData2Key

func KeyData2Key(keydata []byte) (key []byte, err error)

Types

type BootloaderCommand

type BootloaderCommand byte
const (
	BOOTLOADER_COMMAND_ERROR                               BootloaderCommand = 0x01
	BOOTLOADER_COMMAND_NORDIC_READ                         BootloaderCommand = 0x10
	BOOTLOADER_COMMAND_NORDIC_WRITE                        BootloaderCommand = 0x20
	BOOTLOADER_COMMAND_NORDIC_ERASE_PAGE                   BootloaderCommand = 0x30
	BOOTLOADER_COMMAND_REBOOT                              BootloaderCommand = 0x70
	BOOTLOADER_COMMAND_GET_MEMORY_INFO                     BootloaderCommand = 0x80
	BOOTLOADER_COMMAND_GET_BOOTLOADER_VERSION_STRING       BootloaderCommand = 0x90
	BOOTLOADER_COMMAND_FLASH_READ_SIGNATURE                BootloaderCommand = 0xb0
	BOOTLOADER_COMMAND_TI_WRITE_TO_RAM_BUFFER              BootloaderCommand = 0xc0
	BOOTLOADER_COMMAND_TI_WRITE_TO_RAM_BUFFER_INVALID_ADDR BootloaderCommand = 0xc1
	BOOTLOADER_COMMAND_TI_WRITE_TO_RAM_BUFFER_OVERFLOW     BootloaderCommand = 0xc2
	BOOTLOADER_COMMAND_TI_FLASH                            BootloaderCommand = 0xd0
	BOOTLOADER_COMMAND_FLASH_INVALID_ADDR                  BootloaderCommand = 0xd1
	BOOTLOADER_COMMAND_FLASH_WRONG_CRC                     BootloaderCommand = 0xd2
	BOOTLOADER_COMMAND_FLASH_PAGE0_INVALID                 BootloaderCommand = 0xd3
	BOOTLOADER_COMMAND_FLASH_RAM_INVALID_ORDER             BootloaderCommand = 0xd4
	BOOTLOADER_COMMAND_TI_FLASH_WRITE_SIGNATURE            BootloaderCommand = 0xe0
)

type BootloaderReport

type BootloaderReport struct {
	Cmd  BootloaderCommand
	Addr uint16
	Len  byte
	Data [28]byte
}

func (*BootloaderReport) FromWire

func (r *BootloaderReport) FromWire(payload []byte) (err error)

func (*BootloaderReport) String

func (r *BootloaderReport) String() (res string)

func (*BootloaderReport) ToWire

func (r *BootloaderReport) ToWire() (payload []byte, err error)

type BootloaderSubCommandFlash

type BootloaderSubCommandFlash byte
const (
	BOOTLOADER_SUB_COMMAND_FLASH_ERASE_ALL        BootloaderSubCommandFlash = 0x00
	BOOTLOADER_SUB_COMMAND_FLASH_WRITE_RAM_BUFFER BootloaderSubCommandFlash = 0x01
	BOOTLOADER_SUB_COMMAND_FLASH_CLEAR_RAM_BUFFER BootloaderSubCommandFlash = 0x02
	BOOTLOADER_SUB_COMMAND_FLASH_CHECK_CRC        BootloaderSubCommandFlash = 0x03
)

type DJReport

type DJReport struct {
	ReportID   USBReportType
	DeviceID   byte
	Type       DJReportType
	Parameters []byte
}

func (*DJReport) FromWire

func (r *DJReport) FromWire(payload []byte) (err error)

func (*DJReport) IsCommand

func (r *DJReport) IsCommand() bool

func (*DJReport) IsDJ

func (r *DJReport) IsDJ() bool

func (*DJReport) IsHIDPP

func (r *DJReport) IsHIDPP() bool

func (*DJReport) IsNotification

func (r *DJReport) IsNotification() bool

func (*DJReport) IsRFReport

func (r *DJReport) IsRFReport() bool

func (*DJReport) String

func (r *DJReport) String() (res string)

func (*DJReport) ToWire

func (r *DJReport) ToWire() (payload []byte, err error)

type DJReportType

type DJReportType byte
const (
	DJ_REPORT_TYPE_RF_KEYBOARD          DJReportType = 0x01
	DJ_REPORT_TYPE_RF_MOUSE             DJReportType = 0x02
	DJ_REPORT_TYPE_RF_CONSUMER_CONTROL  DJReportType = 0x03
	DJ_REPORT_TYPE_RF_SYSTEM_CONTROL    DJReportType = 0x04
	DJ_REPORT_TYPE_RF_MSFT_MEDIA_CENTER DJReportType = 0x08
	DJ_REPORT_TYPE_RF_LED               DJReportType = 0x0e

	DJ_REPORT_TYPE_NOTIFICATION_DEVICE_UNPAIRED   DJReportType = 0x40
	DJ_REPORT_TYPE_NOTIFICATION_DEVICE_PAIRED     DJReportType = 0x41
	DJ_REPORT_TYPE_NOTIFICATION_CONNECTION_STATUS DJReportType = 0x42

	DJ_REPORT_TYPE_NOTIFICATION_ERROR DJReportType = 0x7f

	DJ_REPORT_TYPE_CMD_SWITCH_AND_KEEP_ALIVE DJReportType = 0x80
	DJ_REPORT_TYPE_CMD_GET_PAIRED_DEVICES    DJReportType = 0x81
)

func (DJReportType) String

func (t DJReportType) String() string

type DeviceInfo

type DeviceInfo struct {
	DeviceIndex           byte
	DestinationID         byte
	DefaultReportInterval time.Duration
	WPID                  []byte
	DeviceType            DeviceType
	Caps                  LogitechDeviceCapabilities
	Serial                []byte
	RFAddr                []byte
	ReportTypes           ReportTypes
	UsabilityInfo         UsabilityInfo
	RawKeyData            []byte //applies on dongles with WPID 0x8808 (not 0x8802)
	Key                   []byte //derived from keydata

	Name string
}

func (*DeviceInfo) String

func (di *DeviceInfo) String() string

type DeviceType

type DeviceType byte
const (
	DEVICE_TYPE_UNKNOWN   DeviceType = 0x00
	DEVICE_TYPE_KEYBOARD  DeviceType = 0x01
	DEVICE_TYPE_MOUSE     DeviceType = 0x02
	DEVICE_TYPE_NUMPAD    DeviceType = 0x03
	DEVICE_TYPE_PRESENTER DeviceType = 0x04
	DEVICE_TYPE_REMOTE    DeviceType = 0x07
	DEVICE_TYPE_TRACKBALL DeviceType = 0x08
	DEVICE_TYPE_TOUCHPAD  DeviceType = 0x09
	DEVICE_TYPE_TABLET    DeviceType = 0x0a
	DEVICE_TYPE_GAMEPAD   DeviceType = 0x0b
	DEVICE_TYPE_JOYSTICK  DeviceType = 0x0c
)

func (DeviceType) String

func (t DeviceType) String() string

type DongleInfo

type DongleInfo struct {
	NumConnectedDevices byte
	WPID                []byte
	FwMajor             byte
	FwMinor             byte
	FwBuild             uint16
	LikelyProto         byte
	BootloaderMajor     byte
	BootloaderMinor     byte

	Serial []byte
}

func (*DongleInfo) String

func (di *DongleInfo) String() string

type Firmware

type Firmware struct {
	RawData      []byte
	Size         uint16
	StartOffset  uint16
	LastOffset   uint16
	HasBL        bool
	CRC          uint16
	TailPos      uint16
	Signature    [256]byte
	HasSignature bool
	TargetType   FirmwareTargetType
}

func ParseFirmwareBin

func ParseFirmwareBin(binblob []byte) (f *Firmware, err error)

func ParseFirmwareHex

func ParseFirmwareHex(ihex_file_path string) (f *Firmware, err error)

func (*Firmware) AddSignature

func (f *Firmware) AddSignature(sig []byte) (err error)

func (*Firmware) BaseImage

func (f *Firmware) BaseImage() (img []byte, err error)

func (*Firmware) BaseImageDowngradeFromBL0302ToBL0301

func (f *Firmware) BaseImageDowngradeFromBL0302ToBL0301() (patched_baseimage []byte, err error)

Firmware images are either meant for <=BOT03.01 (unsigned) or BOT03.02 (signed) Images for BOT03.01 have a start address of 0x0400 and end address of 0x6bff, while images for BOT03.02 start at 0x0400 and end at 0x63ff.

It wouldn't be a good idea to convert an image for BOT03.01 to BOT03.02, because no valid signature could be provided after modding the image (bootloader only allows flashing with signature).

Downgrading an image for BOT03.02 to BOT03.01 is possible, though, because there is no signature check. The following steps have to be done, in order to downgrade an image: 1) the image has to be resized from 0x6000 bytes to 0x6800 bytes (change last address from 0x63ff to 0x6bff), this involves:

  • appending 0xFF bytes
  • moving the end marker '\xfe\xac\xad\xde' to the new image end location
  • recalculate the CRC for the new image (uint16 in directly before end marker)

2) Patching the image

If the resized image would be flashed onto a device with bootloader 03.01, it would run exactly once - for successive boots, the dongle would be stuck in bootloader mode. This is because all firmwares assume that device data has to be stored in one of the two flash pages, directly following the firmware end-address.

A firmware for BOT03.01 (ending at 0x6bff) assumes device data at 0x6c00/0x7000. A firmware for BOT03.02 (ending at 0x63ff) assumes device data at 0x6400/0x6800.

The Texas Instruments Unifying receivers use a 8051 compatible MCU. This MCU runs a "Harvard Architecture", which means code and data storage are physically separated. The TI CC2544 has a memory mapping, where the 32KB flash storage are re-mapped into "external data" (XDATA), starting at address 0x8000. That means from MCU perspective (runtime) firmware code has the same mapping as in a firmware file (code at offset 0x0400 in firmware, maps to code at offset 0x0400 in CODE Memory at runtime). Once a firmware is flashed, the whole mix of code and data contained in the firmware file, could be accessed by the MCU as DATA, too (remember: code and data are two dedicated address spaces, both starting from 0x0000 on this architecture). In contrast to the CODE memory - where the flash content is mapped to 0x0000, the flash content for DATA memory is mapped to 0x8000. This means if the firmware file address 0x0400 is accessed as code, it maps to 0x0400. If it is accessed as data it maps to 0x8400 (=0x0400 + 0x8000).

So why is all of this of importance? Because code accessing data at 0x6400/0x6800 has to be patched to access 0x6c00/0x7000, instead (to allow re-targeting from BOT03.02 to BOT03.01). As this memory regions are considered to contain device data, they are accessed as data. This again means: The code accessing this regions has to add an offset of 0x8000. Thus for firmwares build for BOT03.02, device data access goes to 0xe400/0xe800, which has to be remapped to access addresses 0xec00/0xf000, in order to get compatible to BOT03.01.

Data access to those offsets are mostly done utilizing the DPTR register, thus the following kind of instructions could be easily patched:

	BOT03.02 version:
        90e400         mov dptr, #0xe400
        e0             movx a, @dptr

	Downgraded version for BOT03.01
        90e400         mov dptr, #0xe400
        e0             movx a, @dptr

Beside several `mov DPTR,<XDATA address>` instructions, more complicated code needs to be adjusted in addition (mostly loop counters and code using only the MSB part of the device data address). Because of this, it is not easy to implement a generic patching system, working in search-and-replace-fashion. So the following method is only an attempt to automatically patch a firmware for downgrade. It does not give any guarantees for a working results.

func (*Firmware) ParseFirmwareNordic

func (f *Firmware) ParseFirmwareNordic() (err error)

func (*Firmware) ParseFirmwareTI

func (f *Firmware) ParseFirmwareTI() (err error)

func (*Firmware) String

func (f *Firmware) String() string

type FirmwareMajor

type FirmwareMajor byte
const (
	FIRMWARE_MAJOR_UNIFYING_NORDIC      FirmwareMajor = 0x12
	FIRMWARE_MAJOR_G700_NORDIC          FirmwareMajor = 0x21
	FIRMWARE_MAJOR_UNIFYING_TI          FirmwareMajor = 0x24
	FIRMWARE_MAJOR_LIGHTSPEED_TI        FirmwareMajor = 0x39
	FIRMWARE_MAJOR_SPOTLIGHT_CLICKER_TI FirmwareMajor = 0x41
	FIRMWARE_MAJOR_R500_CLICKER_TI      FirmwareMajor = 0x45
)

func (FirmwareMajor) String

func (fm FirmwareMajor) String() string

type FirmwareTargetType

type FirmwareTargetType byte
const (
	FIRMWARE_TARGET_TYPE_UNKNOWN FirmwareTargetType = 0x00
	FIRMWARE_TARGET_TYPE_NORDIC  FirmwareTargetType = 0x01
	FIRMWARE_TARGET_TYPE_TI      FirmwareTargetType = 0x02
)

type HidPPErrorCode

type HidPPErrorCode byte
const (
	HIDPP_ERROR_CODE_NO_ERROR              HidPPErrorCode = 0x00
	HIDPP_ERROR_CODE_UNKNOWN               HidPPErrorCode = 0x01
	HIDPP_ERROR_CODE_INVALID_ARGUMENT      HidPPErrorCode = 0x02
	HIDPP_ERROR_CODE_OUT_OF_RANGE          HidPPErrorCode = 0x03
	HIDPP_ERROR_CODE_HW_ERROR              HidPPErrorCode = 0x04
	HIDPP_ERROR_CODE_LOGITECH_INTERNAL     HidPPErrorCode = 0x05
	HIDPP_ERROR_CODE_INVALID_FEATURE_INDEX HidPPErrorCode = 0x06
	HIDPP_ERROR_CODE_INVALID_FUNCTION_ID   HidPPErrorCode = 0x07
	HIDPP_ERROR_CODE_BUSY                  HidPPErrorCode = 0x08
	HIDPP_ERROR_CODE_UNSUPPORTED           HidPPErrorCode = 0x09
)

func (HidPPErrorCode) String

func (t HidPPErrorCode) String() string

type HidPPMsg

type HidPPMsg struct {
	ReportID   USBReportType
	DeviceID   byte
	MsgSubID   HidPPMsgSubID
	Parameters []byte
}

func (*HidPPMsg) FromWire

func (r *HidPPMsg) FromWire(payload []byte) (err error)

func (*HidPPMsg) IsDJ

func (r *HidPPMsg) IsDJ() bool

func (*HidPPMsg) IsHIDPP

func (r *HidPPMsg) IsHIDPP() bool

func (*HidPPMsg) String

func (r *HidPPMsg) String() (res string)

func (*HidPPMsg) ToWire

func (r *HidPPMsg) ToWire() (payload []byte, err error)

type HidPPMsgSubID

type HidPPMsgSubID byte
const (
	HIDPP_MSG_ID_DEVICE_DISCONNECTION         HidPPMsgSubID = 0x40
	HIDPP_MSG_ID_DEVICE_CONNECTION            HidPPMsgSubID = 0x41
	HIDPP_MSG_ID_RECEIVER_LOCKING_INFORMATION HidPPMsgSubID = 0x4a

	HIDPP_MSG_ID_SET_REGISTER_REQ      HidPPMsgSubID = 0x80
	HIDPP_MSG_ID_SET_REGISTER_RSP      HidPPMsgSubID = 0x80
	HIDPP_MSG_ID_GET_REGISTER_REQ      HidPPMsgSubID = 0x81
	HIDPP_MSG_ID_GET_REGISTER_RSP      HidPPMsgSubID = 0x81
	HIDPP_MSG_ID_SET_LONG_REGISTER_REQ HidPPMsgSubID = 0x82
	HIDPP_MSG_ID_SET_LONG_REGISTER_RSP HidPPMsgSubID = 0x82
	HIDPP_MSG_ID_GET_LONG_REGISTER_REQ HidPPMsgSubID = 0x83
	HIDPP_MSG_ID_GET_LONG_REGISTER_RSP HidPPMsgSubID = 0x83

	HIDPP_MSG_ID_ERROR_MSG HidPPMsgSubID = 0x8f
)

func (HidPPMsgSubID) String

func (t HidPPMsgSubID) String() string

type HidPPRegister

type HidPPRegister byte
const (
	DONGLE_HIDPP_REGISTER_WIRELESS_NOTIFICATIONS HidPPRegister = 0x00
	DONGLE_HIDPP_REGISTER_CONNECTION_STATE       HidPPRegister = 0x02
	DONGLE_HIDPP_REGISTER_PAIRING                HidPPRegister = 0xb2
	DONGLE_HIDPP_REGISTER_DEVICE_ACTIVITY        HidPPRegister = 0xb3
	DONGLE_HIDPP_REGISTER_PAIRING_INFORMATION    HidPPRegister = 0xb5
	DONGLE_HIDPP_REGISTER_FIRMWARE_UPDATE        HidPPRegister = 0xf0
	DONGLE_HIDPP_REGISTER_FIRMWARE_INFO          HidPPRegister = 0xf1
	DONGLE_HIDPP_REGISTER_SECRET_MEMDUMP         HidPPRegister = 0xd4
)

func (HidPPRegister) String

func (t HidPPRegister) String() string

type LocalUSBDongle

type LocalUSBDongle struct {
	UsbCtx     *gousb.Context
	Dev        *gousb.Device
	Config     *gousb.Config
	IfaceHIDPP *gousb.Interface
	EpInHidPP  *gousb.InEndpoint
	// contains filtered or unexported fields
}

func NewLocalUSBDongle

func NewLocalUSBDongle() (res *LocalUSBDongle, err error)

func (*LocalUSBDongle) Close

func (u *LocalUSBDongle) Close()

func (*LocalUSBDongle) DisablePairing

func (u *LocalUSBDongle) DisablePairing() (err error)

func (*LocalUSBDongle) DumpFlashByte

func (u *LocalUSBDongle) DumpFlashByte(addr uint16) (res byte, err error)

Dumps memory from flash / flash info page using undocumented register 0xd4

func (*LocalUSBDongle) DumpRawKeyData

func (u *LocalUSBDongle) DumpRawKeyData(devID byte) (res []byte, err error)

func (*LocalUSBDongle) EnablePairing

func (u *LocalUSBDongle) EnablePairing(timeOutSeconds byte, devNumber byte, blockTillOff bool) (err error)

func (*LocalUSBDongle) GetAllConnectedDevices

func (u *LocalUSBDongle) GetAllConnectedDevices() (devices []DeviceInfo, err error)

func (*LocalUSBDongle) GetDeviceActivityCounters

func (u *LocalUSBDongle) GetDeviceActivityCounters() (activityCounters []byte, err error)

func (*LocalUSBDongle) GetDevicePairingInfo

func (u *LocalUSBDongle) GetDevicePairingInfo(deviceID byte) (res DeviceInfo, err error)

func (*LocalUSBDongle) GetDongleInfo

func (u *LocalUSBDongle) GetDongleInfo() (res DongleInfo, err error)

func (*LocalUSBDongle) GetNumPairedDevices

func (u *LocalUSBDongle) GetNumPairedDevices() (numPairedDevices byte, err error)

func (*LocalUSBDongle) GetReceiverBLMajorMinorVersion

func (u *LocalUSBDongle) GetReceiverBLMajorMinorVersion() (maj byte, min byte, err error)

func (*LocalUSBDongle) GetReceiverFirmwareBuildVersion

func (u *LocalUSBDongle) GetReceiverFirmwareBuildVersion() (build uint16, err error)

func (*LocalUSBDongle) GetReceiverFirmwareMajorMinorVersion

func (u *LocalUSBDongle) GetReceiverFirmwareMajorMinorVersion() (maj FirmwareMajor, min byte, err error)

func (*LocalUSBDongle) GetSetInfo

func (u *LocalUSBDongle) GetSetInfo() (set SetInfo, err error)

func (*LocalUSBDongle) HIDPP_Send

func (u *LocalUSBDongle) HIDPP_Send(deviceID byte, id HidPPMsgSubID, parameters []byte) (err error)

func (*LocalUSBDongle) HIDPP_SendAndCollectResponses

func (u *LocalUSBDongle) HIDPP_SendAndCollectResponses(deviceID byte, id HidPPMsgSubID, parameters []byte) (responseReports []USBReport, err error)

func (*LocalUSBDongle) OpenDeviceWithVID

func (u *LocalUSBDongle) OpenDeviceWithVID(vid gousb.ID) (*gousb.Device, error)

func (*LocalUSBDongle) ReceiveUSBReport

func (u *LocalUSBDongle) ReceiveUSBReport(timeoutMillis int) (msg USBReport, err error)

func (*LocalUSBDongle) SendUSBReport

func (u *LocalUSBDongle) SendUSBReport(msg USBReport) (err error)

func (*LocalUSBDongle) SetShowInOut

func (u *LocalUSBDongle) SetShowInOut(show bool)

func (*LocalUSBDongle) SwitchToBootloader

func (u *LocalUSBDongle) SwitchToBootloader() (build uint16, err error)

func (*LocalUSBDongle) Unpair

func (u *LocalUSBDongle) Unpair(deviceIndex byte) (err error)

type LogitechDeviceCapabilities

type LogitechDeviceCapabilities byte

func (LogitechDeviceCapabilities) String

func (caps LogitechDeviceCapabilities) String() (res string)

type ReportTypes

type ReportTypes uint32
const (
	REPORT_TYPES_KEYBOARD     ReportTypes = 1 << 1
	REPORT_TYPES_MOUSE        ReportTypes = 1 << 2
	REPORT_TYPES_MULTIMEDIA   ReportTypes = 1 << 3
	REPORT_TYPES_POWER_KEYS   ReportTypes = 1 << 4
	REPORT_TYPES_MEDIA_CENTER ReportTypes = 1 << 8
	REPORT_TYPES_KEYBOARD_LED ReportTypes = 1 << 14
	REPORT_TYPES_SHORT_HIDPP  ReportTypes = 1 << 16
	REPORT_TYPES_LONG_HIDPP   ReportTypes = 1 << 17
)

func (*ReportTypes) FromSlice

func (rt *ReportTypes) FromSlice(sl []byte) (err error)

func (ReportTypes) String

func (rt ReportTypes) String() string

type SetInfo

type SetInfo struct {
	Dongle           DongleInfo
	ConnectedDevices []DeviceInfo
}

func (*SetInfo) AddDevice

func (si *SetInfo) AddDevice(d DeviceInfo)

func (SetInfo) Store

func (si SetInfo) Store(filename string) (err error)

func (*SetInfo) StoreAutoname

func (si *SetInfo) StoreAutoname() (err error)

func (*SetInfo) String

func (si *SetInfo) String() (res string)

type USBBootloaderDongle

type USBBootloaderDongle struct {
	UsbCtx   *gousb.Context
	Dev      *gousb.Device
	Config   *gousb.Config
	IfaceHID *gousb.Interface
	EpInHid  *gousb.InEndpoint
	// contains filtered or unexported fields
}

func NewUSBBootloaderDongle

func NewUSBBootloaderDongle() (res *USBBootloaderDongle, err error)

func (*USBBootloaderDongle) CheckFirmwareCrcAndSignatureTI

func (u *USBBootloaderDongle) CheckFirmwareCrcAndSignatureTI() (err error)

func (*USBBootloaderDongle) ClearRAMBufferTI

func (u *USBBootloaderDongle) ClearRAMBufferTI() (err error)

func (*USBBootloaderDongle) Close

func (u *USBBootloaderDongle) Close()

func (*USBBootloaderDongle) EraseFlashNordic

func (u *USBBootloaderDongle) EraseFlashNordic(FlashAddr uint16) (err error)

func (*USBBootloaderDongle) EraseFlashTI

func (u *USBBootloaderDongle) EraseFlashTI() (err error)

func (*USBBootloaderDongle) FlashReceiver

func (u *USBBootloaderDongle) FlashReceiver(firmware *Firmware) (err error)

func (*USBBootloaderDongle) FlashReceiverNordic

func (u *USBBootloaderDongle) FlashReceiverNordic(firmware *Firmware) (err error)

func (*USBBootloaderDongle) FlashTIReceiverTI

func (u *USBBootloaderDongle) FlashTIReceiverTI(firmware *Firmware) (err error)

func (*USBBootloaderDongle) GenericCommandTI

func (u *USBBootloaderDongle) GenericCommandTI(cmd BootloaderCommand, addr uint16, data []byte) (err error)

func (*USBBootloaderDongle) GetBLVersionString

func (u *USBBootloaderDongle) GetBLVersionString() (versionString string, maj, min, build uint16, err error)

func (*USBBootloaderDongle) GetFirmwareMemoryInfo

func (u *USBBootloaderDongle) GetFirmwareMemoryInfo() (fwStartAddr, fwEndAddr, fwFlashWriteBufferSize uint16, err error)

func (*USBBootloaderDongle) ReadFirmwareSliceFromFlashNordic

func (u *USBBootloaderDongle) ReadFirmwareSliceFromFlashNordic(ramBufAddr uint16, sliceLen byte) (err error, firmwareSlice []byte)

func (*USBBootloaderDongle) ReadSignatureSliceTI

func (u *USBBootloaderDongle) ReadSignatureSliceTI(signatureAddr uint16, len byte) (err error)

func (*USBBootloaderDongle) Reboot

func (u *USBBootloaderDongle) Reboot() (err error)

func (*USBBootloaderDongle) ReceiveUSBReport

func (u *USBBootloaderDongle) ReceiveUSBReport(timeoutMillis int) (msg BootloaderReport, err error)

func (*USBBootloaderDongle) SendUSBReport

func (u *USBBootloaderDongle) SendUSBReport(msg BootloaderReport) (err error)

func (*USBBootloaderDongle) SetShowInOut

func (u *USBBootloaderDongle) SetShowInOut(show bool)

func (*USBBootloaderDongle) StoreRAMBufferToFlashAddrTI

func (u *USBBootloaderDongle) StoreRAMBufferToFlashAddrTI(FlashAddr uint16) (err error)

func (*USBBootloaderDongle) WriteFirmwareSliceToFlashNordic

func (u *USBBootloaderDongle) WriteFirmwareSliceToFlashNordic(ramBufAddr uint16, firmwareSlice []byte) (err error)

func (*USBBootloaderDongle) WriteFirmwareSliceToRAMBufferTI

func (u *USBBootloaderDongle) WriteFirmwareSliceToRAMBufferTI(ramBufAddr uint16, firmwareSlice []byte) (err error)

func (*USBBootloaderDongle) WriteSignatureSliceNordic

func (u *USBBootloaderDongle) WriteSignatureSliceNordic(signatureAddr uint16, signatureSlice []byte) (err error)

func (*USBBootloaderDongle) WriteSignatureSliceTI

func (u *USBBootloaderDongle) WriteSignatureSliceTI(signatureAddr uint16, signatureSlice []byte) (err error)

type USBReport

type USBReport interface {
	FromWire(payload []byte) (err error)
	ToWire() (payload []byte, err error)
	IsHIDPP() bool
	IsDJ() bool

	fmt.Stringer
}

type USBReportType

type USBReportType byte
const (
	USB_REPORT_TYPE_DJ_SHORT    USBReportType = 0x20
	USB_REPORT_TYPE_DJ_LONG     USBReportType = 0x21
	USB_REPORT_TYPE_HIDPP_SHORT USBReportType = 0x10
	USB_REPORT_TYPE_HIDPP_LONG  USBReportType = 0x11
)

func (USBReportType) String

func (t USBReportType) String() string

type UsabilityInfo

type UsabilityInfo byte
const (
	USABILITY_INFO_RESERVED                                    UsabilityInfo = 0x0
	USABILITY_INFO_PS_LOCATION_ON_THE_BASE                     UsabilityInfo = 0x1
	USABILITY_INFO_PS_LOCATION_ON_THE_TOP_CASE                 UsabilityInfo = 0x2
	USABILITY_INFO_PS_LOCATION_ON_THE_EDGE_OF_TOP_RIGHT_CORNER UsabilityInfo = 0x3
	USABILITY_INFO_PS_LOCATION_OTHER                           UsabilityInfo = 0x4
	USABILITY_INFO_PS_LOCATION_ON_THE_TOP_LEFT_CORNER          UsabilityInfo = 0x5
	USABILITY_INFO_PS_LOCATION_ON_THE_BOTTOM_LEFT_CORNER       UsabilityInfo = 0x6
	USABILITY_INFO_PS_LOCATION_ON_THE_TOP_RIGHT_CORNER         UsabilityInfo = 0x7
	USABILITY_INFO_PS_LOCATION_ON_THE_BOTTOM_RIGHT_CORNER      UsabilityInfo = 0x8
	USABILITY_INFO_PS_LOCATION_ON_THE_TOP_EDGE                 UsabilityInfo = 0x9
	USABILITY_INFO_PS_LOCATION_ON_THE_RIGHT_EDGE               UsabilityInfo = 0xa
	USABILITY_INFO_PS_LOCATION_ON_THE_LEFT_EDGE                UsabilityInfo = 0xb
	USABILITY_INFO_PS_LOCATION_ON_THE_BOTTOM_EDGE              UsabilityInfo = 0xc
)

func (UsabilityInfo) String

func (ui UsabilityInfo) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL