12
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
16-bit Word
s[0]
Application Window High 16 bit
s[1]
Application Window Low 16 bit
s[2]
1
s[3]...s[9]
reserved
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
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
16-bit Word
s[0]
Magellan Window High 16 bit
s[1]
Magellan Window Low 16 bit
s[2]
X Translation
s[3]
Y Translation
s[4]
Z Translation
s[5]
A Rotation
s[6]
B Rotation
s[7]
C Rotation
s[8]
Period
s[9]
reserved
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.
Содержание Magellan/SPACE MOUSE Classic
Страница 1: ......