File: mouse.cxx

package info (click to toggle)
curves 0.8.7
  • links: PTS
  • area: main
  • in suites: slink
  • size: 704 kB
  • ctags: 1,001
  • sloc: cpp: 6,197; ansic: 519; makefile: 270; sh: 192; fortran: 149
file content (108 lines) | stat: -rw-r--r-- 2,888 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* mouse.cxx
     $Id: mouse.cxx,v 1.3 1998/02/23 06:35:45 elf Exp $

   written by Marc Singer
   12 November 1996

   This file is part of the project CurVeS.  See the file README for
   more information.

   Copyright (C) 1996 Marc Singer

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   in a file called COPYING along with this program; if not, write to
   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
   02139, USA.

   -----------
   DESCRIPTION
   -----------

*/

#include "std.h"

#include "mouse.h"

bool LMouse::g_fConnected;

void LMouse::init (void)
{
#if defined (USE_GPM_MOUSE)
  Gpm_Connect gpmconnect;
  memset (&gpmconnect, 0, sizeof (gpmconnect));

				// -- Trap all events
  gpmconnect.eventMask=~0;
  gpmconnect.defaultMask=0;
  gpmconnect.maxMod=~0;
  gpmconnect.minMod=0;

  if (Gpm_Open (&gpmconnect, 0) >= 0) {
    g_fConnected = true;
    gpm_handler = handler;
    TRACE((T_MOUSE_INFO, "gpm mouse handler installed"));
  }
  else
    TRACE((T_MOUSE_INFO, "failed to install gpm mouse handler"));
#endif
}

#if defined (use_gpm_mouse)
int LMouse::handler (Gpm_Event* pEvent, void* pvUser)
{
  switch (GPM_BARE_EVENTS (pEvent->type)) {
  case GPM_MOVE:
    TRACE((T_MOUSE_TRACE, "mouse move <%04x> [%2d %2d] [%3d %3d]", 
       pEvent->type,
       pEvent->x, pEvent->y, pEvent->dx, pEvent->dy));
    break;
  case GPM_DRAG:
    TRACE((T_MOUSE_TRACE, "mouse drag <%04x> [%2d %2d] [%3d %3d]", 
       pEvent->type,
       pEvent->x, pEvent->y, pEvent->dx, pEvent->dy));
    break;
  case GPM_DOWN:
    TRACE((T_MOUSE_TRACE, "mouse down <%04x> [%2d %2d] [%3d %3d] %d %d", 
       pEvent->type,
       pEvent->x, pEvent->y, pEvent->dx, pEvent->dy, 
       pEvent->buttons, pEvent->modifiers));
    break;
  case GPM_UP:
    TRACE((T_MOUSE_TRACE, "mouse up   <%04x> [%2d %2d] [%3d %3d] %d %d", 
       pEvent->type,
       pEvent->x, pEvent->y, pEvent->dx, pEvent->dy, 
       pEvent->buttons, pEvent->modifiers));
    break;
  default:
    TRACE((T_MOUSE_TRACE, "<0x%x> b %d  m %d  [%d %d] [%d %d]  t %d", 
       pvUser,
       pEvent->buttons, pEvent->modifiers, 
       pEvent->x, pEvent->y,
       pEvent->dx, pEvent->dy, pEvent->type));
    break;
  }
  return 0;
}
#endif

void LMouse::release_this (void)
{
  if (g_fConnected) {
#if defined (USE_GPM_MOUSE)
    Gpm_Close ();
#endif
    g_fConnected = false;
  }
}