OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [mou_dos.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
3
 *
4
 * DOS Mouse Driver, uses int 33h
5
 * Added fix for DJGPP 32 bit compilation
6
 */
7
#include <dos.h>
8
 
9
#ifndef __PACIFIC__
10
#include <bios.h>
11
#endif
12
 
13
#include "device.h"
14
 
15
#define SCALE   1       /* default scaling factor for acceleration WAS 3*/
16
#define THRESH  10      /* default threshhold for acceleration WAS 0*/
17
 
18
static int      MOU_Open(MOUSEDEVICE *pmd);
19
static void     MOU_Close(void);
20
static int      MOU_GetButtonInfo(void);
21
static void     MOU_GetDefaultAccel(int *pscale,int *pthresh);
22
static int      MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz,int *bp);
23
static int      MOU_Poll(void);
24
 
25
MOUSEDEVICE mousedev = {
26
        MOU_Open,
27
        MOU_Close,
28
        MOU_GetButtonInfo,
29
        MOU_GetDefaultAccel,
30
        MOU_Read,
31
        MOU_Poll
32
};
33
 
34
static int mouse_fd;
35
 
36
/*
37
 * Open up the mouse device.
38
 */
39
static int
40
MOU_Open(MOUSEDEVICE *pmd)
41
{
42
        union REGS      regset;
43
 
44
        /* init mouse*/
45
        regset.x.ax = 0;
46
        int86(0x33, &regset, &regset);
47
 
48
        /* set mickey-to-pixel ratio*/
49
        regset.x.ax = 0x0f;
50
        regset.x.cx = 16;       /* # mickeys per 8 pixels x direction (default 8)*/
51
        regset.x.dx = 32;       /* # mickeys per 8 pixels y direction (default 16)*/
52
        int86(0x33, &regset, &regset);
53
 
54
        /* read motion counters to reset*/
55
        regset.x.ax = 0x0b;
56
        int86(0x33, &regset, &regset);
57
 
58
        return 1;
59
}
60
 
61
/*
62
 * Close the mouse device.
63
 */
64
static void
65
MOU_Close(void)
66
{
67
}
68
 
69
/*
70
 * Get mouse buttons supported
71
 */
72
static int
73
MOU_GetButtonInfo(void)
74
{
75
        return MWBUTTON_L | MWBUTTON_M | MWBUTTON_R;
76
}
77
 
78
/*
79
 * Get default mouse acceleration settings
80
 */
81
static void
82
MOU_GetDefaultAccel(int *pscale,int *pthresh)
83
{
84
        *pscale = SCALE;
85
        *pthresh = THRESH;
86
}
87
 
88
/*
89
 * Attempt to read bytes from the mouse and interpret them.
90
 * Returns -1 on error, 0 if either no bytes were read or not enough
91
 * was read for a complete state, or 1 if the new state was read.
92
 * When a new state is read, the current buttons and x and y deltas
93
 * are returned.  This routine does not block.
94
 */
95
static int
96
MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp)
97
{
98
        union REGS      regset;
99
        int             buttons;
100
 
101
        /* read motion counters*/
102
        regset.x.ax = 0x0b;
103
        int86(0x33, &regset, &regset);
104
 
105
        *dx = (short)regset.x.cx;
106
        *dy = (short)regset.x.dx;
107
        *dz = 0;
108
 
109
        /* read button status*/
110
        regset.x.ax = 3;
111
        int86(0x33, &regset, &regset);
112
 
113
        buttons = 0;
114
        if(regset.x.bx & 01)
115
                buttons |= MWBUTTON_L;
116
        if(regset.x.bx & 02)
117
                buttons |= MWBUTTON_R;
118
        if(regset.x.bx & 04)
119
                buttons |= MWBUTTON_M;
120
        *bp = buttons;
121
 
122
        return 1;
123
}
124
 
125
static int
126
MOU_Poll(void)
127
{
128
        return 1;
129
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.