FastTRAPDevice.mesa
Copyright Ó 1991, 1992 by Xerox Corporation. All rights reserved.
Bier, November 6, 1991 10:42 am PST
Contents: Routines for creating instances of the FastTRAP trackball and representing the state of such a device.
DIRECTORY
DeviceClassTypes, DeviceTypes, Rope;
FastTRAPDevice:
CEDAR
DEFINITIONS =
BEGIN
Device: TYPE = DeviceTypes.Device;
DeviceClass: TYPE = DeviceClassTypes.DeviceClass;
DeviceState: TYPE = DeviceTypes.DeviceState;
DeviceStateChange: TYPE = DeviceTypes.DeviceStateChange;
KeyName: TYPE = {left, middle, right};
Class Routines
CreateFastTRAP:
PROC [name: Rope.
ROPE]
RETURNS [device: Device];
Create a data structure representing a particular physical FastTRAP. Calls class.create[class].
AllocateState:
PROC [device: Device]
RETURNS [deviceState: DeviceState];
Allocates storage representing the state of this keyboard when all of its keys are up, the trackball is at 0,0, and the thumbwheel is at 0. Each DeviceState is immutable, so they may be freely stored in long-term storage.
Representing FastTRAP State Changes
KeyChange: PROC [key: KeyName, down: BOOL] RETURNS [change: DeviceStateChange];
TrackballChange: PROC [deltaX, deltaY: INTEGER] RETURNS [change: DeviceStateChange];
ThumbwheelChange: PROC [delta: INTEGER] RETURNS [change: DeviceStateChange];
StateAfterChange: PROC [deviceState: DeviceState, change: DeviceStateChange] RETURNS [newDeviceState: DeviceState];
ChangeKind: TYPE = {key, trackball, wheel};
ExpandedChange:
TYPE =
RECORD [
contents:
SELECT kind: ChangeKind
FROM
key => [key: KeyName, down: BOOL],
trackball => [deltaX, deltaY: INTEGER],
wheel => [delta: INTEGER]
ENDCASE
];
UnpackChange: PROC [change: DeviceStateChange] RETURNS [expanded: ExpandedChange];
Convenience State Changes
KeyNewState: PROC [deviceState: DeviceState, key: KeyName, down: BOOL] RETURNS [newDeviceState: DeviceState];
TrackballNewState: PROC [deviceState: DeviceState, deltaX, deltaY: INTEGER] RETURNS [newDeviceState: DeviceState];
ThumbwheelNewState: PROC [deviceState: DeviceState, delta: INTEGER] RETURNS [newDeviceState: DeviceState];
IsDown: PROC [deviceState: DeviceState, key: KeyName] RETURNS [BOOL];
GetTrackball: PROC [deviceState: DeviceState] RETURNS [x, y: INTEGER];
GetThumbwheel: PROC [deviceState: DeviceState] RETURNS [wheel: INTEGER];
END.