enumerate

Top  Previous  Next

enumerate allows you to query the currently attached USB-HID devices.

Definition

deviceInfoList = hid.enumerate( vendorId, productId )

Parameters

Name

Type

Description

vendorId

number

the vendor id or 0 for all vendors.

productId

number

the product id or 0 for all products.

deviceInfoList

table

Table with device information.

DeviceInfoList

Name

Type

Description

path

string

The path to the USB device, for use in hid.open()

vendorId

number

The vendor Id

productId

number

The product Id

serial

string

The device serial number

manufacturer

string

The manufacturer string

product

string

The product string

interfaceNumber

number

The interface number

Example

table.print( hid.enumerate(0,0) )

 

With only one USB device attached:

 

Thu Jan 2 09:39:10 2014        { -- #0

Thu Jan 2 09:39:10 2014           [1] = { -- #1

Thu Jan 2 09:39:10 2014              ["path"] = "\\\\?\\hid#vid_20a0&pid_413f&mi_00#7&f979fa9&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}",

Thu Jan 2 09:39:10 2014              ["manufacturer"] = "Promixis, LLC",

Thu Jan 2 09:39:10 2014              ["productId"] = 16703,

Thu Jan 2 09:39:10 2014              ["product"] = "Promixis, LLC",

Thu Jan 2 09:39:10 2014              ["interfaceNumber"] = 0,

Thu Jan 2 09:39:10 2014              ["serial"] = "A4931313633351612171",

Thu Jan 2 09:39:10 2014              ["vendorId"] = 8352,

Thu Jan 2 09:39:10 2014           } -- #1,

Thu Jan 2 09:39:10 2014        } -- #0

 

Note that it's not always possible to get HID reports from mouse and keyboard, specifically Microsoft Windows will block this.