Home  Contents

keyboard:setWheel

Keyboard Core4 Lua Event System

SYNOPSIS

#include <lua/sidekick-pins.lh>
#include <lua/scancode.lh>
  1. kbdhandle:setWheel(wheel, pin1, pin2, scancode1, scancode2, [flags])
  2. kbdhandle:setWheel(wheel)

DESCRIPTION

The V4 Controller has support for up to five rotary encoders, which must be connected to two generic I/O pins each.

The wheel parameter numbers the wheel from 0 ··· 4.

The values of pin1 and pin2 indicate the pin numbers of the two quadrature signals from the encoder.

There are different types of encoders available. Optical encoders usually report a single signal edge per 'click' of the wheel (flags = 0). Mechanical encoders often report two (flags = 1) or four (flags = 3) signal edges per 'click'. The flags parameter must be specified accordingly, default is 0.

Wheel events are reported as a simulated key-down/key-up pair. The value of scancode1 is used for a forward/clockwise turn, while scancode2 reports the reverse/anti-clockwise direction. To assign a generic scancode, use SCANCODE(KEY_xxx), using one of the scancode definitions from lua/scancode.lh

The second form of the command, with no further parameters, disables the specified wheel.

NOTES

The V4½ controller does not support rotary encoders.

It is recommended to stick to the definition that says scancode1 is for forward and scancode2 is for reverse direction. If you get the event reports swapped, you should swap the values for pin1 and pin2, not the scancodes.

EXAMPLE

An example use is a rotary encoder on inputs 0 and 1 with the button on input 2.

>  > 
kbdhandle:setWheel(0, SKIO_IN0, SKIO_IN1, SCANCODE(KEY_DOWN), SCANCODE(KEY_UP), 1) kbdhandle:setButton(0, SKIO_IN2, SCANCODE(KEY_ENTER))

SEE ALSO