README

haptic

Go Reference

Haptic feedback for Gio applications

Status

Experimental, but working. API is not stable, so use go modules to lock to a particular version.

On non-supported OSes, the API is the same but does nothing. This makes it easier to write cross-platform code that depends on haptic.

Why is the API weird?

We can't interact with the JVM from the same OS thread that runs your Gio event processing. Rather than accidentally allow you to deadlock by calling these methods the wrong way, they're written to be safe to invoke from your normal Gio layout code without deadlock. This means that all of the work needs to occur on other goroutines.

Documentation

Overview

Package haptic implements haptic feedback support for gio.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buzzer

type Buzzer struct {
}

Buzzer provides methods to trigger haptic feedback. On OSes other than android, all methods are no-ops.

func NewBuzzer

func NewBuzzer(_ *app.Window) *Buzzer

NewBuzzer constructs a buzzer.

func (*Buzzer) Buzz

func (b *Buzzer) Buzz() bool

Buzz attempts to trigger a haptic vibration without blocking. It returns whether or not it was successful. If it returns false, it is safe to retry. On unsupported platforms, it always returns true.

func (*Buzzer) Errors

func (b *Buzzer) Errors() <-chan error

Errors returns a channel of errors from trying to interface with the JVM. This channel will close when Shutdown() is invoked.

func (*Buzzer) SetView

func (b *Buzzer) SetView(_ uintptr)

Update does nothing on platforms other than Android. See the documentation with GOOS=android for information on using this method correctly on that platform.

func (*Buzzer) Shutdown

func (b *Buzzer) Shutdown()

Shutdown stops the background event loop that interfaces with the JVM. Call this when you are done with a Buzzer to allow it to be garbage collected. Do not call this method more than per Buzzer.