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

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [drivers/] [mou_dos.c] - Diff between revs 674 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 674 Rev 1765
/*
/*
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
 * Copyright (c) 1999 Greg Haerr <greg@censoft.com>
 *
 *
 * DOS Mouse Driver, uses int 33h
 * DOS Mouse Driver, uses int 33h
 * Added fix for DJGPP 32 bit compilation
 * Added fix for DJGPP 32 bit compilation
 */
 */
#include <dos.h>
#include <dos.h>
 
 
#ifndef __PACIFIC__
#ifndef __PACIFIC__
#include <bios.h>
#include <bios.h>
#endif
#endif
 
 
#include "device.h"
#include "device.h"
 
 
#define SCALE   1       /* default scaling factor for acceleration WAS 3*/
#define SCALE   1       /* default scaling factor for acceleration WAS 3*/
#define THRESH  10      /* default threshhold for acceleration WAS 0*/
#define THRESH  10      /* default threshhold for acceleration WAS 0*/
 
 
static int      MOU_Open(MOUSEDEVICE *pmd);
static int      MOU_Open(MOUSEDEVICE *pmd);
static void     MOU_Close(void);
static void     MOU_Close(void);
static int      MOU_GetButtonInfo(void);
static int      MOU_GetButtonInfo(void);
static void     MOU_GetDefaultAccel(int *pscale,int *pthresh);
static void     MOU_GetDefaultAccel(int *pscale,int *pthresh);
static int      MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz,int *bp);
static int      MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz,int *bp);
static int      MOU_Poll(void);
static int      MOU_Poll(void);
 
 
MOUSEDEVICE mousedev = {
MOUSEDEVICE mousedev = {
        MOU_Open,
        MOU_Open,
        MOU_Close,
        MOU_Close,
        MOU_GetButtonInfo,
        MOU_GetButtonInfo,
        MOU_GetDefaultAccel,
        MOU_GetDefaultAccel,
        MOU_Read,
        MOU_Read,
        MOU_Poll
        MOU_Poll
};
};
 
 
static int mouse_fd;
static int mouse_fd;
 
 
/*
/*
 * Open up the mouse device.
 * Open up the mouse device.
 */
 */
static int
static int
MOU_Open(MOUSEDEVICE *pmd)
MOU_Open(MOUSEDEVICE *pmd)
{
{
        union REGS      regset;
        union REGS      regset;
 
 
        /* init mouse*/
        /* init mouse*/
        regset.x.ax = 0;
        regset.x.ax = 0;
        int86(0x33, &regset, &regset);
        int86(0x33, &regset, &regset);
 
 
        /* set mickey-to-pixel ratio*/
        /* set mickey-to-pixel ratio*/
        regset.x.ax = 0x0f;
        regset.x.ax = 0x0f;
        regset.x.cx = 16;       /* # mickeys per 8 pixels x direction (default 8)*/
        regset.x.cx = 16;       /* # mickeys per 8 pixels x direction (default 8)*/
        regset.x.dx = 32;       /* # mickeys per 8 pixels y direction (default 16)*/
        regset.x.dx = 32;       /* # mickeys per 8 pixels y direction (default 16)*/
        int86(0x33, &regset, &regset);
        int86(0x33, &regset, &regset);
 
 
        /* read motion counters to reset*/
        /* read motion counters to reset*/
        regset.x.ax = 0x0b;
        regset.x.ax = 0x0b;
        int86(0x33, &regset, &regset);
        int86(0x33, &regset, &regset);
 
 
        return 1;
        return 1;
}
}
 
 
/*
/*
 * Close the mouse device.
 * Close the mouse device.
 */
 */
static void
static void
MOU_Close(void)
MOU_Close(void)
{
{
}
}
 
 
/*
/*
 * Get mouse buttons supported
 * Get mouse buttons supported
 */
 */
static int
static int
MOU_GetButtonInfo(void)
MOU_GetButtonInfo(void)
{
{
        return MWBUTTON_L | MWBUTTON_M | MWBUTTON_R;
        return MWBUTTON_L | MWBUTTON_M | MWBUTTON_R;
}
}
 
 
/*
/*
 * Get default mouse acceleration settings
 * Get default mouse acceleration settings
 */
 */
static void
static void
MOU_GetDefaultAccel(int *pscale,int *pthresh)
MOU_GetDefaultAccel(int *pscale,int *pthresh)
{
{
        *pscale = SCALE;
        *pscale = SCALE;
        *pthresh = THRESH;
        *pthresh = THRESH;
}
}
 
 
/*
/*
 * Attempt to read bytes from the mouse and interpret them.
 * Attempt to read bytes from the mouse and interpret them.
 * Returns -1 on error, 0 if either no bytes were read or not enough
 * Returns -1 on error, 0 if either no bytes were read or not enough
 * was read for a complete state, or 1 if the new state was read.
 * was read for a complete state, or 1 if the new state was read.
 * When a new state is read, the current buttons and x and y deltas
 * When a new state is read, the current buttons and x and y deltas
 * are returned.  This routine does not block.
 * are returned.  This routine does not block.
 */
 */
static int
static int
MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp)
MOU_Read(MWCOORD *dx, MWCOORD *dy, MWCOORD *dz, int *bp)
{
{
        union REGS      regset;
        union REGS      regset;
        int             buttons;
        int             buttons;
 
 
        /* read motion counters*/
        /* read motion counters*/
        regset.x.ax = 0x0b;
        regset.x.ax = 0x0b;
        int86(0x33, &regset, &regset);
        int86(0x33, &regset, &regset);
 
 
        *dx = (short)regset.x.cx;
        *dx = (short)regset.x.cx;
        *dy = (short)regset.x.dx;
        *dy = (short)regset.x.dx;
        *dz = 0;
        *dz = 0;
 
 
        /* read button status*/
        /* read button status*/
        regset.x.ax = 3;
        regset.x.ax = 3;
        int86(0x33, &regset, &regset);
        int86(0x33, &regset, &regset);
 
 
        buttons = 0;
        buttons = 0;
        if(regset.x.bx & 01)
        if(regset.x.bx & 01)
                buttons |= MWBUTTON_L;
                buttons |= MWBUTTON_L;
        if(regset.x.bx & 02)
        if(regset.x.bx & 02)
                buttons |= MWBUTTON_R;
                buttons |= MWBUTTON_R;
        if(regset.x.bx & 04)
        if(regset.x.bx & 04)
                buttons |= MWBUTTON_M;
                buttons |= MWBUTTON_M;
        *bp = buttons;
        *bp = buttons;
 
 
        return 1;
        return 1;
}
}
 
 
static int
static int
MOU_Poll(void)
MOU_Poll(void)
{
{
        return 1;
        return 1;
}
}
 
 

powered by: WebSVN 2.1.0

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