1gii_pmove_event(3) GGI gii_pmove_event(3)
2
3
4
6 gii_pmove_event : LibGII pointer movement events
7
9 #include <ggi/events.h>
10
11 typedef struct gii_pmove_event {
12
13 COMMON_DATA;
14
15 int32_t x, y; /* absolute/relative position */
16 int32_t z, wheel;
17
18 } gii_pmove_event;
19
20
22 The gii_pmove_event structure is used to report change of pointer posi‐
23 tion. Depending on the event type, the values are either absolute or
24 relative.
25
27 This structure is used for evPtrRelative and evPtrAbsolute events.
28
30 The gii_pmove_event structure describes pointer (mice, etc.) motion in
31 terms of the x, y, z coordinates and the wheel values of the device.
32 The motion described may be relative (offset from the current location)
33 or absolute (a specific location on the 'screen'), depending on whether
34 the event is of type evPtrRelative or evPtrAbsolute, respectively.
35
36 LibGII does not attempt to interpolate or keep track of the current
37 pointer position. (This is the application's responsibility.) LibGII
38 may also report both relative and absolute pointer motion for the same
39 input, which may happen when the mouse is being emulated using a key‐
40 board on an input/target that is normally reports absolute motion.
41
43 Input handling for applications expecting absolute pointer position:
44
45 {
46 static int mousex,mousey;
47
48 ggiEventPoll(vis, emKey|emPointer, NULL);
49 events = ggiEventsQueued(vis, emKey|emPointer);
50
51 while (events--) {
52 ggiEventRead(vis, &event, emKey|emPointer);
53
54 switch(event.any.type) {
55 case evPtrButtonPress:
56 switch(event.pbutton.button) {
57 case GII_PBUTTON_FIRST:
58 do_something_as_appropriate(mousex,mousey);
59 break;
60 case GII_PBUTTON_SECOND:
61 /* ... */
62 }
63 break;
64 case evPtrButtonRelease:
65 /* ... if needed ... */
66 break;
67 case evPtrAbsolute:
68 mousex = event.pmove.x;
69 mousey = event.pmove.y;
70 break;
71 case evPtrRelative:
72 mousex += event.pmove.x;
73 mousey += event.pmove.y;
74 break;
75 }
76
77 /* Constrain mouse in any case */
78 if (mousex < 0) mousex = 0;
79 if (mousey < 0) mousey = 0;
80 if (mousex > xmax) mousex = xmax;
81 if (mousey > ymax) mousey = ymax;
82
83 } /* while */
84 }
85
86
88 gii_event(3)
89
90
91
92libgii-1.0.x 2006-12-30 gii_pmove_event(3)