Documentation ¶
Overview ¶
Package chimp is a simple input package (mice, tablets etc). Device support will be added when there is a need for it. The initial purpose of the package is to support drawing tablet input for a paint program.
Only Linux is supported at the moment but the Linux device events are converted to another representation exported by this package in a platform independent manner.
Supported devices:
Wacom Bamboo 16FG 6x8 (Linux)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities struct { PositionDevices []PositionDevice Buttons []Button }
Capabilities of device.
func (*Capabilities) HasButton ¶
func (cap *Capabilities) HasButton(button Button) bool
HasButton checks if device has button.
func (*Capabilities) HasPositionDevice ¶
func (cap *Capabilities) HasPositionDevice(device PositionDevice) bool
HasButton checks if device has position device.
func (*Capabilities) String ¶
func (cap *Capabilities) String() string
type Device ¶
type Device interface { // Properties returns properties of device. Properties() Properties // Capabilities returns capabilities of device. Capabilities() *Capabilities // Read event from device. // TODO: Define how to handle errors, reopening device? Read() (Event, error) // Close device. Close() }
Device is any opened input device.
type DeviceInfo ¶
type DeviceInfo struct { Name string // Name of device. Type DeviceType // Device type. Open func() (Device, error) // Function that opens the device. }
DeviceInfo contains some brief device information that can be inspected before deciding to open a device.
func ListDevices ¶
func ListDevices() ([]DeviceInfo, error)
ListDevices lists available input devices that may be opened and used.
type DeviceType ¶
type DeviceType int
DeviceType is an enumeration of basic device types such as "Mouse", "Tablet" etc.
const ( DeviceTypeTablet DeviceType = iota DeviceTypeMouse )
func (DeviceType) String ¶
func (i DeviceType) String() string
type Event ¶
type Event interface { // Time is the time when the event was generated. Time() time.Time // String returns a textual representation of the event. String() string }
Event is implemented by all event types.
type EventButton ¶
type EventButton struct { Timestamp time.Time // Time when event was generated. Button Button // Button code. Pressure float32 // Pressure on button in range [0, 1], 0 or 1 for digital buttons. }
EventButton is generated for everything that can be modeled as a digital or analogue button.
func (*EventButton) String ¶
func (e *EventButton) String() string
func (*EventButton) Time ¶
func (e *EventButton) Time() time.Time
type EventPositionFinger ¶
type EventPositionFinger struct { Timestamp time.Time // Time when event was generated. Coord Coord2D // Finger position, axis are in range [0, 1], origo in upper left corner }
EventPositionFinger is generated for movement of finger on tablet or similar.
func (*EventPositionFinger) String ¶
func (e *EventPositionFinger) String() string
func (*EventPositionFinger) Time ¶
func (e *EventPositionFinger) Time() time.Time
type EventPositionPen ¶
type EventPositionPen struct { Timestamp time.Time // Time when event was generated. Coord Coord2D // Pen position on tablet, axis are in range [0, 1], origo in upper left corner. Distance float32 // Distance of for example pen to tablet in range [0, 1], 0 is on tablet. }
EventPositionPen is generated for movement of pen on a typical 2D tablet.
func (*EventPositionPen) String ¶
func (e *EventPositionPen) String() string
func (*EventPositionPen) Time ¶
func (e *EventPositionPen) Time() time.Time
type PositionDevice ¶
type PositionDevice uint32
PositionDevice is an enumeration of different position device types.
const ( PositionDevicePen PositionDevice = iota PositionDeviceFinger )
func (PositionDevice) String ¶
func (i PositionDevice) String() string
type Properties ¶
type Properties map[Property]PropertyValue
Properties of device.
func (Properties) String ¶
func (props Properties) String() (result string)
type Property ¶
type Property string
Property of device
const ( PropertyDeviceName Property = "device-name" PropertyDeviceType Property = "device-type" PropertyPadWidthMillimeters Property = "pad-width-millimeters" // Width of the pad along the X-axis. PropertyPadHeightMillimeters Property = "pad-height-millimeters" // Width of the pad along the Y-axis. PropertyPadWidthHeightRatio Property = "pad-width-height-ratio" )
type PropertyValue ¶
type PropertyValue interface { // Type returns the property value type as a string, e.g. "string" or "number". Type() string // String returns the property value as a string. // All types can be converted to a string. String() string // Number returns the property value as a float. // Zero is returned when this is not applicable. Number() float64 }
PropertyValue represents property values of different types.
type PropertyValueNumber ¶
type PropertyValueNumber float64
PropertyValueNumber represent numeric property values.
func (PropertyValueNumber) Number ¶
func (val PropertyValueNumber) Number() float64
func (PropertyValueNumber) String ¶
func (val PropertyValueNumber) String() string
func (PropertyValueNumber) Type ¶
func (val PropertyValueNumber) Type() string
type PropertyValueString ¶
type PropertyValueString string
PropertyValueString represent string property values.
func (PropertyValueString) Number ¶
func (val PropertyValueString) Number() float64
func (PropertyValueString) String ¶
func (val PropertyValueString) String() string
func (PropertyValueString) Type ¶
func (val PropertyValueString) Type() string