Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Latest commit

 

History

History
42 lines (33 loc) · 3.05 KB

hs.usb.watcher.md

File metadata and controls

42 lines (33 loc) · 3.05 KB

docs » hs.usb.watcher


Watch for USB device connection/disconnection events

API Overview

  • Constructors - API calls which return an object, typically one that offers API methods
  • new
  • Methods - API calls which can only be made on an object returned by a constructor
  • start
  • stop

API Documentation

Constructors

Signature hs.usb.watcher.new(fn) -> watcher
Type Constructor
Description Creates a new watcher for USB device events
Parameters
  • fn - A function that will be called when a USB device is inserted or removed. The function should accept a single parameter, which is a table containing the following keys:
  • eventType - A string containing either "added" or "removed" depending on whether the USB device was connected or disconnected
  • productName - A string containing the name of the device
  • vendorName - A string containing the name of the device vendor
  • vendorID - A number containing the Vendor ID of the device
  • productID - A number containing the Product ID of the device
Returns
  • A hs.usb.watcher object

Methods

Signature hs.usb.watcher:start() -> watcher
Type Method
Description Starts the USB watcher
Parameters
  • None
Returns
  • The hs.usb.watcher object
Signature hs.usb.watcher:stop() -> watcher
Type Method
Description Stops the USB watcher
Parameters
  • None
Returns
  • The hs.usb.watcher object