Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mouse(4) — NEWS-os 3.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

MOUSE(4)  —  UNIX Programmer’s Manual

NAME

mouse − NEWS mouse device interface

SYNOPSIS

ms0 at iop addr ffe550 intr 40

/dev/mouse

#include <sys/time.h>
#include <newsiop/mouse.h>

DESCRIPTION

Mouse is the mouse device interface on NEWS. 

The interface provides two modes, sample or event.  In event mode, the inteface maintains a queue of mouse event reports.  When mouse is opened, the interface is set to sample mode and mouse coordinates is set to (0, 0).  Mode can be changed using ioctl() described below.  When mouse is closed, the interface is reset to sample mode.  When the mode of the interface is set from event mode to sample mode, mouse event queue is flushed. 

In sample mode, mouse data returned by read() system call is defined in headef file <newsiop/msreg.h> as follows,

struct ms_data {
    int     md_sw;  /∗ mouse button ∗/
#define     MS_BUTNL    0x04
#define     MS_BUTNM    0x02
#define     MS_BUTNR    0x01
    int     md_x;   /∗ x coordinate ∗/
    int     md_y;   /∗ y coordinate ∗/
};

md_sw encodes the mouse button status and down position is encoded as ’1’(i.e, if ( md_sw & MS_BUTNL) is true, the left button is in down positon and so on).  The number of mouse data returned is multiple of sizeof(struct ms_data), although request for multiple mouse data at a time is not useful in this mode. 

In event mode, mouse data returned by read() system call is mouse event report defined as follows,

/∗
 ∗ mouse event report
 ∗event report is queued when mouse is put in event mode
 ∗by using MSIOCSETEM ioctl()
 ∗/
struct ms_event {
    struct ms_data    mse_data;   /∗ mouse X, Y and button status ∗/
    char              mse_trig;   /∗ trigger that caused this event ∗/
#define MSE_MOTION    0           /∗ mouse movement ∗/
#define MSE_BUTTON    1           /∗ mouse buttons ∗/
#define MSE_KEY       2           /∗ keyboard keys ∗/
    char              mse_dir;    /∗ key or button direction ∗/
#define MSE_DOWN      0           /∗ down ∗/
#define MSE_UP        1           /∗ up ∗/
#define MSE_UNKOWN    2           /∗ unkown ∗/
    char              mse_code;   /∗ key or button code ∗/
#define MSE_BUTNR     0           /∗ right button ∗/
#define MSE_BUTNM     1           /∗ middle button ∗/
#define MSE_BUTNL     2           /∗ left button ∗/
    struct timeval    mse_time;   /∗ time when this event occurred ∗/
};

The number of mouse event reports returned by read() system call is multiple of sizeof(struct ms_event).  Currently, the number of mouse event report queue maintained in the interface is 128.  Mse_data is a mouse data same as returned in sample mode.  Mse_trig is a trigger which has caused the event, and one of mouse motion (MSE_MOTION), mouse button status changed (MSE_BUTTUN), or keyborad key status changed (MSE_KEY).  Mse_dir is the direction (up or down) of mouse button or keyboard key change and not meaningful when mse_trig is MSE_MOTION.  mse_code is a code of mouse button (if mse_trig is MSE_BUTTON) or keyboard key (if mse_trig is MSE_KEY).  See <newsiop/mouse.h> for key code.  Finally, mse_time is the time when this event occurred.  The format of time is defined in <sys/time.h>

You can simulate mouse motion by writing to mouse.  Data format for mouse position to write is,

struct ms_coord {
    int     mc_x;   /∗ x coordinate ∗/
    int     mc_y;   /∗ y coordinate ∗/
} ms_coord;

IOCTL

MSIOCSETEM exchanges between two modes and defines an event mask. 

 #define     MS_EMEVENT  0x80    /∗ 1 −> event mode ∗/
#define     MS_EMKEY    0x40    /∗ keyboard key changes −> event ∗/
#define     MS_EMMOTION 0x10    /∗ coordinates changes −> event ∗/
#define     MS_EMBUTNL  0x04    /∗ left button changes −> event ∗/
#define     MS_EMBUTNM  0x02    /∗ mid button changes −> event ∗/
#define     MS_EMBUTNR  0x01    /∗ right button changes −> event ∗/

 int eventmask;
ioctl(fildes, MSIOCSETEM, &eventmask);
 

MS_EMEVENT controls mode.  If MS_EMEVENT is OFF, the interface is set to sample mode, and if it is ON, the interface is set to event mode.  When MS_EMEVENT is ON, the other bits specified which trigger will cause events. 

MSIOCGETEM get current setting of event mask. 

 int eventmask;
ioctl(fildes, MSIOCGETEM, &eventmask);
 

MSIOCSETXY set current mouse position. 

 struct ms_coord ms_coord;
ioctl(fildes, MSIOCSETXY, &ms_coord);
 

MSIOCFLUSH flush the event queue. 

ioctl(fildes, MSIOCFLUSH);

MSIOCSETPARAM
set mouse parameter. A mouse paramter has two componets, mp_delta and mp_mag.  When a mouse is moved more than mp_delta, amount that exceeds mp_delta is multiplied by mp_mag.  The initial setting of mp_delta is 5 and mp_mag 3. 

 /∗ strct ms_param:
 ∗when mouse is moved more than mp_delta, amount that exceeds
 ∗the mp_delta is magnified by mp_mag(>0)
 ∗/
struct ms_param {
    int    mp_delta;/∗ threshold for magnification ∗/
    int   mp_mag;/∗ magnifying factor ∗/
};
 

struct ms_param ms_param;
ioctl(fildes, MSIOCSETPARAM, &ms_param);
 

FILES

/dev/mouse

NEWS-OSRelease 3.3

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026