1: /* $Header: cursor.c,v 10.3 86/02/01 15:46:34 tony Rel $ */
2: /* cursor.c various stuff with the mouse & cursor
3: *
4: * StoreCursor Creates a cursor
5: * FreeCursor Frees the storage taken by a cursor
6: * LoadCursor Loads a bitmap to use as cursor
7: * InitMouse Initialize the mouse
8: * SetCursorPosition Forces cursor to a particular position
9: * SetMouseCharacteristics Controls speed of cursor relative to mouse
10: *
11: */
12:
13: /****************************************************************************
14: * *
15: * Copyright (c) 1983, 1984 by *
16: * DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts. *
17: * All rights reserved. *
18: * *
19: * This software is furnished on an as-is basis and may be used and copied *
20: * only with inclusion of the above copyright notice. This software or any *
21: * other copies thereof may be provided or otherwise made available to *
22: * others only for non-commercial purposes. No title to or ownership of *
23: * the software is hereby transferred. *
24: * *
25: * The information in this software is subject to change without notice *
26: * and should not be construed as a commitment by DIGITAL EQUIPMENT *
27: * CORPORATION. *
28: * *
29: * DIGITAL assumes no responsibility for the use or reliability of its *
30: * software on equipment which is not supplied by DIGITAL. *
31: * *
32: * *
33: ****************************************************************************/
34:
35: #include "vs100.h"
36: #include "vsioctl.h"
37:
38: extern vsIoAddr *VSAddr;
39: extern BitMap screen;
40: extern char FBMap[];
41:
42: char *Xalloc(), *AllocateSpace();
43:
44: CURSOR *StoreCursor (func, image, fore, back, mask, xoff, yoff)
45: register BITMAP *image, *mask;
46: int func, fore, back, xoff, yoff;
47: {
48: register CURSOR *cursor;
49: register CursPriv *data;
50:
51: cursor = (CURSOR *) Xalloc (sizeof (CURSOR));
52: cursor->width = image->width;
53: cursor->height = image->height;
54: cursor->xoff = xoff;
55: cursor->yoff = yoff;
56: cursor->xmin = xoff;
57: cursor->ymin = yoff;
58: cursor->xmax = screen.bm_width - (image->width - xoff);
59: cursor->ymax = screen.bm_height - (image->height - yoff);
60: cursor->refcnt = 1;
61: data = (CursPriv *) Xalloc (sizeof (CursPriv));
62: data->image = image;
63: image->refcnt++;
64: if (data->mask = mask)
65: mask->refcnt++;
66: if (fore & 1)
67: func += 0x20;
68: if (back & 1)
69: func += 0x10;
70: data->map = FBMap[func];
71: cursor->data = (caddr_t) data;
72: return (cursor);
73: }
74:
75: FreeCursor (cursor)
76: register CURSOR *cursor;
77: {
78: register CursPriv *data;
79: register BITMAP *bm;
80:
81: data = CDATA(cursor);
82: if ((bm = data->image) && --bm->refcnt == 0)
83: FreeBitmap (bm);
84: if ((bm = data->mask) && --bm->refcnt == 0)
85: FreeBitmap (bm);
86: free ((caddr_t) cursor);
87: }
88:
89: LoadCursor (cursor)
90: register CURSOR *cursor;
91: {
92: register CursPriv *data;
93: register BITMAP *bm;
94: register LoadCursorPacket *lcp;
95:
96: lcp = (LoadCursorPacket *) AllocateSpace (sizeof (LoadCursorPacket));
97: if (lcp == NULL) return;
98: #define h ((PacketHeader *) lcp->lcp_head)
99: #define src ((SubBitmap *) lcp->lcp_source.image)
100: #define msk ((SubBitmap *) lcp->lcp_sourceMask)
101: #define pat ((Halftone *) lcp->lcp_source.pattern)
102: #define size ((Extent *) lcp->lcp_maskSize)
103:
104: data = CDATA(cursor);
105: h->ph_cursorMod.m_source = 1;
106: h->ph_cursorMod.m_map = MAPTYPE(data->map);
107: h->ph_opcode = LOAD_CURSOR;
108: *(long *) h->ph_next = NULL;
109:
110: bm = data->image;
111: *(caddr_t *) src->sb_address = BDATA(bm)->vsPtr;
112: src->sb_height = bm->height;
113: src->sb_width = bm->width;
114: src->sb_bitsPerPixel = 1;
115: src->sb_x = src->sb_y = 0;
116: size->e_height = bm->height;
117: size->e_width = bm->width;
118:
119: if (bm = data->mask) {
120: h->ph_cursorMod.m_mask = 1;
121: *(caddr_t *) msk->sb_address = BDATA(bm)->vsPtr;
122: msk->sb_height = bm->height;
123: msk->sb_width = bm->width;
124: msk->sb_bitsPerPixel = 1;
125: msk->sb_x = msk->sb_y = 0;
126: } else
127: h->ph_cursorMod.m_mask = 0;
128: *(short *) lcp->lcp_map.literal = MAPLIT(data->map);
129:
130: lcp->lcp_blink = 0;
131: lcp->lcp_tip_x = cursor->xoff;
132: lcp->lcp_tip_y = cursor->yoff;
133: lcp->lcp_center_x = cursor->xoff;
134: lcp->lcp_center_y = cursor->yoff;
135:
136: WritePacket ((caddr_t) lcp);
137: #undef h
138: #undef src
139: #undef msk
140: #undef pat
141: #undef size
142: }
143:
144: InitMouse ()
145: {
146: register AttachCursorPacket *acp;
147: register SetPointingDeviceReportingPacket *spdp;
148:
149: acp = (AttachCursorPacket *) AllocateSpace (sizeof (AttachCursorPacket));
150: if (acp == NULL) return;
151: #define h ((PacketHeader *) acp->acp_head)
152:
153: h->ph_modifier.emptymod = 0;
154: h->ph_opcode = ATTACH_CURSOR;
155: *(long *) h->ph_next = NULL;
156:
157: acp->acp_device = 1;
158:
159: WritePacket ((caddr_t) acp);
160: #undef h
161:
162: spdp = (SetPointingDeviceReportingPacket *) AllocateSpace (sizeof (SetPointingDeviceReportingPacket));
163: if (spdp == NULL) return;
164: #define h ((PacketHeader *) spdp->spdp_head)
165:
166: h->ph_modifier.emptymod = 0;
167: h->ph_opcode = SET_POINTING_DEVICE_REPORTING;
168: *(long *) h->ph_next = NULL;
169:
170: spdp->spdp_enable = 1;
171:
172: WritePacket ((caddr_t) spdp);
173: #undef h
174: }
175:
176: SetCursorPosition(pos)
177: register vsCursor *pos;
178: {
179: register SetCursorPositionPacket *scp;
180:
181: scp = (SetCursorPositionPacket *) AllocateSpace (sizeof (SetCursorPositionPacket));
182: if (scp == NULL) return;
183: #define h ((PacketHeader *) scp->scp_head)
184: #define loc ((Point *) scp->scp_position)
185:
186: h->ph_modifier.emptymod = 0;
187: h->ph_opcode = SET_CURSOR_POSITION;
188: *(long *) h->ph_next = NULL;
189:
190: loc->p_x = pos->x;
191: loc->p_y = pos->y;
192:
193: WritePacket ((caddr_t) scp);
194: VSAddr->mouse = *pos;
195: #undef h
196: #undef loc
197: }
198:
199: SetMouseCharacteristics (threshold, acceleration)
200: int threshold, acceleration;
201: {
202: register SetMouseCharacteristicsPacket *smp;
203:
204: smp = (SetMouseCharacteristicsPacket *) AllocateSpace (sizeof (SetMouseCharacteristicsPacket));
205: if (smp == NULL) return;
206: #define h ((PacketHeader *) smp->smc_head)
207:
208: h->ph_mouseMod.m_tracking = 1;
209: h->ph_opcode = SET_MOUSE_CHARACTERISTICS;
210: *(long *) h->ph_next = NULL;
211:
212: smp->smc_scale = acceleration;
213: smp->smc_threshold = threshold;
214:
215: WritePacket ((caddr_t) smp);
216: #undef h
217: }
Defined functions
Defined macros
h
defined in line
206; used 23 times
loc
defined in line
184; used 3 times
msk
defined in line
100; used 7 times
pat
defined in line
101; used 1 times
size
defined in line
102; used 3 times
src
defined in line
99; used 7 times