package module
Version: v0.0.0-...-261c727 Latest Latest

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

Go to latest
Published: Jan 5, 2022 License: MIT, Unlicense Imports: 1 Imported by: 2



Go Reference

Haptic feedback for Gio applications


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.



Package haptic implements haptic feedback support for gio.



This section is empty.


This section is empty.


This section is empty.


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.

Jump to

Keyboard shortcuts

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