Receiving Events - Logitech Magellan/SPACE MOUSE Classic Programmer's Manual

Logicad3d
Table of Contents

Advertisement

CommandEventNumber;
Event.xclient.data.s[0] = XHigh32( window );
Event.xclient.data.s[1] = XLow32( window );
Event.xclient.data.s[2] =
CommandMessageApplicationWindow; /* =1 */
XSendEvent(display,MagellanWindow,FALSE,0x0000,
&Event);
XFlush(display);
The following table shows the structure of
CommandEvent data.
xclient.data
s[0]
Application Window High 16 bit
s[1]
Application Window Low 16 bit
s[2]
s[3]...s[9]

Receiving Events

When the X-Window driver receives events
from the Magellan/SPACE MOUSE, it copies the
information into a data structure and sends it
to the application as a ClientMessageEvent .
MotionEvents , ButtonPressEvents and
ButtonReleaseEvents may also be sent. The
procedure for after the events have been
intercepted by the application depends on the
particular application. The following program
excerpt shows how the events can be
intercepted by the application. Note that the
reading of the information from the event is
displayed in three phases.
XEvent Event;
XNextEvent(display,&Event);
switch( Event.report)
{
case ClientMessage:
if ( Event.xclient.message_type ==
MotionEventNumber )
/* a 3D motion event is received */;
if ( Event.xclient.message_type ==
ButtonPressEventNumber )
/* a button press event is received */;
if ( Event.xclient.message_type ==
ButtonReleaseEventNumber )
/* a button release event is received */;
break;
};
3D Movement Event
In this event the X-Window driver sends the
application three translational values (X,Y and
Z), three rotational values (A,B and C) and the
period of duration. Each value requires 16 bits.
These values are used to interpret the speed
of the graphical object. The normal range of
these values is about ±400, but increasing the
16-bit Word
1
reserved
sensitivity increases the range to
approximately ±6000. The following program
excerpt reads the movement files out of the
data packet.
int X,Y,Z,A,B,C,Period;
Window MagellanWindow;
MagellanWindow = (Event.xclient.data.s[0] << 16) |
Event.xclient.data.s[1];
X = Event.xclient.data.s[2];
Y = Event.xclient.data.s[3];
Z = Event.xclient.data.s[4];
A = Event.xclient.data.s[5];
B = Event.xclient.data.s[6];
C = Event.xclient.data.s[7];
Period = Event.xclient.data.s[8]; /*e.g. 60 means 60ms
*/
The following table shows the structure of
MotionEvent data.
xclient.data
s[0]
s[1]
s[2]
s[3]
s[4]
s[5]
s[6]
s[7]
s[8]
s[9]
Event of a Pressed Key
Whenever a key on the Magellan/SPACE
MOUSE is pressed, the X-Window driver sends
the number of the pressed key to the
application. The numbered keys (1-8) are
represented by the corresponding numbers.
The star key (*) is represented by 9. The
following program excerpt reads the number of
the pressed key from the event.
int ButtonNumber;
Window MagellanWindow;
MagellanWindow = (Event.xclient.data.s[0] << 16) |
Event.xclient.data.s[1];
ButtonNumber = Event.xclient.data.s[2];
The following table shows the structure of
ButtonPressEvent data.
12
16-bit Word
Magellan Window High 16 bit
Magellan Window Low 16 bit
X Translation
Y Translation
Z Translation
A Rotation
B Rotation
C Rotation
Period
reserved

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Magellan/space mouse plusMagellan/space mouse plus xt

Table of Contents