Scrolling Trackball

The goal of this example is to demonstrate how to setup use a trackball to scroll instead of move the cursor using a Driver Configuration. Driver configurations are available only for devices that use ControllerMate's keyboard/mouse driver. ControllerMate cannot modify the behavior of another vendor's keyboard/mouse driver or one that is included with OS X.

This example will create a driver configuration for the Kensington USB/PS2 Trackball that disables the scrolling axes to allow them to be used to trigger the scrolling function of a Virtual Mouse. A button on the trackball will be used to alternate between normal mouse behavior and the custom scrolling behavior.

First, locate the Driver Configuration item for the Kensington USB/PS2 Trackball in the Palette window. Create a new driver configuration by dragging that item to the Editor window.


Next, disable the new driver configuration to prevent the changes that are about to made from taking effect immediately.

Select the new driver configuration in the Editor window and select the Mouse Axes tab.

In the Axes area, select "Cursor Disabled" from the Cursor popup menu. When this driver configuration is enabled, the trackball will not control the cursor.

Next, create a new Page named "Control".

On the "Control" page, add a Button building block for Button #4 on the trackball.

Create a Toggle building block and connect it to the Button block.

Create a Properties building block for the trackball's driver configuration and connect it to the Toggle building block. The easiest way to create a pre-configured Properties block is to drag an item from the list of Programming Items in the Editor window onto the page's grid.

With these building blocks in place, pressing Button #4 on the trackball will enable the driver configuration – thus disabling the trackball's ability to control the cursor. Pressing the button a second time will disable the configuration and restore the normal cursor behavior.

After the operation of the button has been verified, press Button #4 on the trackball until the driver configuration is disabled and the trackball controls the cursor normally.


The next step is to create a new virtual mouse.

Right-click in the list of Programming Items and select Create Virtual Device ‣ Virtual Mouse.

Enable the Wheel and Z-Axis options for the virtual mouse.

Next, create a second programming Page named "Scrolling Trackball". Disable the "Scrolling Trackball" page to prevent the building blocks that are about to be added from controlling the virtual mouse immediately.

On the "Scrolling Trackball" page, create Axis building blocks for the X-Axis and Y-Axis on the trackball.

Create two Accumulator building blocks and attach one to each of the Axis blocks.

Create two Division building blocks and attach one to each of the Accumulator blocks. Set the Divide by value of the Division building blocks to –20.00.

Create two Delta (Number) building blocks and attach one to each of the Division building blocks.

Create Virtual Axis building blocks for the Z-Axis and Wheel on the virtual mouse. Connect the Z-Axis block to the string of building blocks attached to the trackball's X-Axis. Connect the Wheel block to the string of building blocks attached to the trackball's Y-Axis.

The net effect of each series of building blocks is that all position changes from the trackball are added together, then divided by –20. Changes to the result of that division are sent to the virtual mouse as scroll wheel movement. Performing the division with a negative number has the effect of reversing the direction of the scrolling.

The last task is to enable the "Scrolling Trackball" page when the trackball driver configuration is enabled.


On the "Control" page, add a Properties building block for the "Scrolling Trackball" page to the Properties block for the driver configuration.


At this point, when Button #4 is pressed, the trackball will stop controlling the cursor and the scrolling building blocks will be enabled. Moving the scroll ball will control the virtual mouse's scrolling. Pressing Button #4 a second time will restore the normal operation of the trackball and disable the scrolling building blocks.

When the trackball is scrolling, if either the horizontal or vertical scrolling occurs in the wrong direction, it can be reversed by changing the Divide by value of the corresponding Division building block from a negative number to a positive number.

The sensitivity of the scrolling can be changed by changing the size of the Divide by value of the corresponding Division building block. Larger values will decrease the sensitivity, smaller values will increase the sensitivity.