usbevent

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: MIT Imports: 8 Imported by: 0

README

usb-event

Go reference Release Build Coverage Go report card

A simple Go API for subscribing to USB events on Windows via the Win32 API.

Installation

As usual, simply run:

go get github.com/christowolf/usb-event

Usage

The API aims to be very simple, so this example should be enough to get you started.

Documentation

Rendered for windows/amd64

Overview

Example

Example shows how to use the package.

package main

import (
	"context"
	"log"

	usbevent "github.com/christowolf/usb-event"
)

func main() {
	n, err := usbevent.Register()
	if err != nil {
		log.Fatalf("registration failed: %v\n", err)
	}
	go func() {
		for e := range n.Channel {
			log.Printf("%+v\n\n", e)
		}
	}()
	n.Run(context.Background())
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

type Notifier struct {
	Channel chan winuser.EventInfo
	Hwnd    windows.HWND
}

Functions based on https://gist.github.com/nathan-osman/18c2e227ad00a223b61c0b3c16d452c3.

func Register

func Register() (*Notifier, error)

func (*Notifier) Run

func (n *Notifier) Run(ctx context.Context)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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