-/* track the mouse in a joystick manner : not perfect but it works */
-static void trackmouse(ModeInfo * mi)
-{
- firestruct *fs = &fire[MI_SCREEN(mi)];
- /* we keep static values (not per screen) for the mouse stuff: in general you have only one mouse :-> */
- static int max[2] = { 0, 0 };
- static int min[2] = { 0x7fffffff, 0x7fffffff }, center[2];
- Window r, c;
- int rx, ry, cx, cy;
- unsigned int m;
-
- (void) XQueryPointer(MI_DISPLAY(mi), MI_WINDOW(mi),
- &r, &c, &rx, &ry, &cx, &cy, &m);
-
- if (max[0] < cx)
- max[0] = cx;
- if (min[0] > cx)
- min[0] = cx;
- center[0] = (max[0] + min[0]) / 2;
-
- if (max[1] < cy)
- max[1] = cy;
- if (min[1] > cy)
- min[1] = cy;
- center[1] = (max[1] + min[1]) / 2;
-
- if (fabs(center[0] - (float) cx) > 0.1 * (max[0] - min[0]))
- fs->alpha += 2.5 * (center[0] - (float) cx) / (max[0] - min[0]);
- if (fabs(center[1] - (float) cy) > 0.1 * (max[1] - min[1]))
- fs->beta += 2.5 * (center[1] - (float) cy) / (max[1] - min[1]);
-
- /* oops: can't get those buttons */
- if (m & Button4Mask)
- fs->v += 0.01;
- if (m & Button5Mask)
- fs->v -= 0.01;
-
-}