|
|
DataMuseum.dkPresents historical artifacts from the history of: Regnecentalen RC-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Regnecentalen RC-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T U b
Length: 2609 (0xa31)
Types: TextFile
Notes: UNIX file
Names: »bmse_vpx.c«
└─⟦0cfe73749⟧ Bits:30004154/config.imd SW95707I VP/ix MS-DOS emulator Rel. 1.1
└─⟦0cfe73749⟧ UNIX Filesystem
└─⟦this⟧ »vc/new/usr/vpix/src/bmouse/bmse_vpx.c«
/* @(#)bmse_vpx.c 3.2 - 88/05/25 */
/*
* MODULE: BMSE_VPX
* hardware dependent bus mouse emulation for VPIX
*
* Copyright (c) 1986, 1987 by Phoenix Technologies Ltd
*
*/
/*
***********************************
* INCLUDES AND DEFINES
***********************************
*/
#include "ptypes.h"
#include "v86error.h"
#include <fcntl.h>
#include <sys/mouse.h>
typedef struct mouseinfo MSEPKT;
/*
***********************************
* DATA
***********************************
*/
LOCAL int _fd = -1;
LOCAL BYTE _mouse_path[80];
/*
***********************************
* FUNCTIONS
***********************************
*/
EXTERN VOID xy_bmouse();
EXTERN VOID btn_bmouse();
GLOBAL int bmsemd_init();
GLOBAL int bmsemd_close();
GLOBAL VOID bmsemd_read();
GLOBAL int bmsemd_release();
GLOBAL int bmsemd_acquire();
/*
***********************************
* ENTRY POINTS
***********************************
*/
/*
* FUNCTION: BMSEMD_INIT
* Bus mouse initialization
*
* INPUT PARAMETERS
* path -- path name for mouse device
* OUTPUT PARAMETERS
* returns -- OK or ERR
*/
GLOBAL int bmsemd_init( path )
char *path;
{
strcpy (_mouse_path, path);
return (bmsemd_acquire ());
}
GLOBAL int bmsemd_acquire()
{
MSEPKT pkt;
if ( (_fd = open(_mouse_path,O_RDONLY)) == -1 )
v86error( VERR_WARNING, MOUSE_OPEN_ERR, errno, _mouse_path );
else if ( ioctl(_fd,VPC_MOUSE_READ,&pkt) == -1 )
{
v86error( VERR_WARNING, MOUSE_INIT_ERR );
close( _fd );
_fd = -1;
}
return( _fd == -1 ? ERR : OK );
}
/*
* FUNCTION: BMSEMD_CLOSE
* Bus mouse shutdown
*
* INPUT PARAMETERS
* none
* OUTPUT PARAMETERS
* returns -- OK or ERR
*/
GLOBAL int bmsemd_close()
{
return (bmsemd_release ());
}
GLOBAL int bmsemd_release()
{
int rc = ERR;
if ( _fd != -1 )
{
rc = close( _fd );
_fd = -1;
}
return( rc );
}
/*
* FUNCTION: BMSEMD_READ
* a routine to call when mouse data is available
*
* INPUT PARAMETERS
* none
* OUTPUT PARAMETERS
* none
*/
GLOBAL VOID bmsemd_read()
{
MSEPKT pkt;
if ( _fd == -1 || ioctl(_fd,VPC_MOUSE_READ,&pkt) == -1 )
{
#ifdef DEBUG
v86error(VERR_WARNING,"unable to get mouse data");
#endif
return;
}
if ( pkt.status & MOVEMENT ) /* if the mouse moved */
xy_bmouse( pkt.xmotion, pkt.ymotion );
if ( pkt.status & BUT1CHNG ) /* if button 1 changed */
btn_bmouse( 0, (int)(pkt.status & BUT1STAT) );
if ( pkt.status & BUT2CHNG ) /* if button 2 changed */
btn_bmouse( 1, (int)(pkt.status & BUT2STAT) );
if ( pkt.status & BUT3CHNG ) /* if button 3 changed */
btn_bmouse( 2, (int)(pkt.status & BUT3STAT) );
}