WSTABLET ( 9 ) OpenBSD Kernel Manual WSTABLET ( 9 )


wstablet, wstablet_input, wstabletdevprint - wscons tablet support


#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wstabletvar.h>

wstablet_input(struct device wstabletdev ,
struct wstablet_tabdata *td , u_int flags);

wstablet_printdev(void *aux , const char *pnp);


The wstablet module is a component of the wscons(9) framework to provide machine-independent
tablet support. Most of the support is provided by the wstablet(4) device driver, which must be a child
of the hardware device driver.


Tablet hardware drivers providing support for wscons tablet devices will make use of the following data types:

struct wstablet_accessops
A structure used to specify the tablet access functions. All tablet device drivers must provide
this structure and pass it to the wstablet(4) child device. It has the following members:

int (*enable)(void *);
int (
*ioctl)(void *v, u_long cmd, void *data,
int flag, struct lwp
void (
*disable)(void *);

The enable member defines the function to be called to enable monitoring device input
movements and passing these events to wscons. The disable member defines the func-
tion to disable input events. The ioctl member defines the function to be called to perform
tablet-specific ioctl calls.

There is a void * cookie provided by the tablet driver associated with these functions,
which is passed to them when they are invoked.

struct wstabletdev_attach_args
A structure used to attach the wstablet(4) child device. It has the following members:

const struct wstablet_accessops *accessops;


wstablet_input(wstabletdev , *td , flags)

Callback from the tablet driver to the wstablet interface driver, providing the device input to create wsevents. Arguments are as follows:

wstabletdev This is the struct device pointer passed from config_found( )
on attaching the child wstablet(4) to specify the tablet device.

td Input values from the hardware device are grouped together within this
struct. Its members contain the hardware's measurements of the stylus de-
vice that is currently active, as well as the device identification string from
this stylus.

OpenBSD 4.4 August 18, 2008 1


OpenBSD Kernel Manual WSTABLET ( 9 ) Note that these features are not available on all tablet devices. If a feature is not available, the corresponding member within the struct should be set to NULL by the hardware driver. During the processing of td, flags is checked to only use available input values (as flagged by the hardware driver).

The members of td are:

btns This specifies the current button status. Bits for pressed buttons
(which will cause the WSCONS_EVENT_TABLET_DOWN
event on wstablet(4) device) should be set, and bits for re-
leased buttons (which will cause the
WSCONS_EVENT_TABLET_UP event) should be zero. The
LSB should contain the button state of either the left-most, or
lowest button. i.e. for a stylus with three buttons, the lowest
(bottom) button is 0x01, the middle button is 0x02, and the high-
est (top) button is 0x03. For a set of buttons on the tablet itself,
the buttons are numbered from left to right, with the first button
as 0x01, two as 0x02, etc.

x Absolute X-axis value to specify the pointer coordinate. Right-
ward (moving the tablet right) is positive.

y Absolute or relative Y-axis value to specify the pointer coordi-
nate. Upward (moving the tablet forward) is positive. Note that
this aspect is opposite from the one used in the X server dix lay-

p Tip pressure of the active stylus.

t Twist (or rotation) value of the active stylus.

tiltX X-axis tilt angle of the active stylus.

tiltY Y-axis tilt angle of the active stylus.

dev_id Identification string from the active stylus.


This argument specifies which members of the td struct have been popu- lated for wstablet_input( ) to create wsevents for. Defined in /sys/dev/wscons/wstabletvar.h, valid values for flags are: WSTABLET_INPUT_SWDEV
A new stylus or tablet device is active.

One or more buttons in td->btns have changed state.

There is input in td->x to process.

There is input in td->y to process.

There is input in td->p to process.

There is input in td->t to process.

OpenBSD 4.4

August 18, 2008 2


OpenBSD Kernel Manual

There is input in td->tiltX to process. WSTABLET_INPUT_TILTY
There is input in td->tiltY to process. WSTABLET_INPUT_MODE


The tablet device has switched operating modes.

wstablet_printdev(aux , pnp)
The default wstablet printing routine used by config_found(). (see autoconf(9)).


Tablet hardware drivers which want to use the wstablet module must be a parent to the wstablet(4) device and provide an attachment interface. To attach the wstablet(4) device, the tablet driver must allocate and populate a wstabletdev_attach_args structure with the supported operations and callbacks and call config_found( ) to perform the attach (see autoconf(9)).


When a tablet-input event is received, the device driver must perform any necessary movement decoding to wscons events and pass the events to wscons via wstablet_input().

The wscons framework calls back into the hardware driver by invoking the functions that are specified in the accessops structure. The enable( ) and disable( ) functions are relatively simple and self-ex- planatory. The ioctl( ) function is called by the wscons interface to perform tablet-specific ioctl opera- tions (see ioctl(2)). The argument cmd to the ioctl( ) function specifies the specific command to perform using the data data. Valid commands are listed in sys/dev/wscons/wsconsio.h.


This section describes places within the NetBSD source tree where actual code implementing or using the machine-independent wscons subsystem can be found. All pathnames are relative to /usr/src.

The wscons subsystem is implemented within the directory sys/dev/wscons. The wstablet module itself is implemented within the file sys/dev/wscons/wstablet.c. ioctl(2) operations are listed in sys/dev/wscons/wsconsio.h.


ioctl(2), wscons(4), wstablet(4), autoconf(9), driver(9), intro(9), wscons(9),
wsdisplay(9), wskbd(9)

OpenBSD 4.4 August 18, 2008 3