nl.kbna.dioscuri.module.mouse
Class Mouse

java.lang.Object
  extended by nl.kbna.dioscuri.module.Module
      extended by nl.kbna.dioscuri.module.ModuleDevice
          extended by nl.kbna.dioscuri.module.ModuleMouse
              extended by nl.kbna.dioscuri.module.mouse.Mouse

public class Mouse
extends ModuleMouse

An implementation of a mouse module.

See Also:
Metadata module ******************************************** general.type : mouse general.name : PS/2 compatible Mouse general.architecture : Von Neumann general.description : Models a PS2 compatible mouse general.creator : Koninklijke Bibliotheek, Nationaal Archief of the Netherlands general.version : 1.0 general.keywords : Mouse, Keyboard, PS/2 general.relations : Motherboard, Keyboard general.yearOfIntroduction : 1987 general.yearOfEnding : general.ancestor : DE-9 RS-232 serial mouse general.successor : USB mouse Notes: - mouse uses keyboard controller. Therefore, a keyboard controller is always required when using this mouse. - all controller aspects are implemented in keyboard: (mouse is only pointing device but not controller) + I/O ports + IRQ handling

Field Summary
private  MouseBuffer buffer
           
(package private)  byte buttonStatus
           
private  boolean debugMode
           
(package private)  int delayed_dx
           
(package private)  int delayed_dy
           
(package private)  int delayed_dz
           
private  Emulator emu
           
(package private)  boolean expectingMouseParameter
           
(package private)  boolean imMode
           
(package private)  int imRequest
           
private  boolean isObserved
           
private  ModuleKeyboard keyboard
           
(package private)  byte lastMouseCommand
           
private static java.util.logging.Logger logger
           
static int MODULE_ID
           
static java.lang.String MODULE_NAME
           
static java.lang.String MODULE_TYPE
           
private  java.lang.String[] moduleConnections
           
private  ModuleMotherboard motherboard
           
private static int MOUSE_BUFFER_INITSIZE
           
private static byte MOUSE_CMD_ACK
           
private static byte MOUSE_CMD_COMPLETION
           
private static byte MOUSE_CMD_ID
           
private static byte MOUSE_CMD_RESEND
           
private static int MOUSE_MODE_REMOTE
           
private static int MOUSE_MODE_RESET
           
private static int MOUSE_MODE_STREAM
           
private static int MOUSE_MODE_WRAP
           
private static int MOUSE_TYPE_IMPS2
           
private static int MOUSE_TYPE_PS2
           
(package private)  boolean mouseEnabled
           
(package private)  int mouseMode
           
(package private)  int mousePreviousMode
           
(package private)  int mouseType
           
(package private)  int resolutionCpmm
           
(package private)  byte sampleRate
           
(package private)  int scaling
           
private  int updateInterval
           
 
Constructor Summary
Mouse(Emulator owner)
          Class constructor
 
Method Summary
 void controlMouse(byte value)
           
private  boolean enqueueData(byte b1, byte b2, byte b3, byte b4)
           
 java.lang.String[] getConnection()
          Returns a String[] with all names of modules it needs to be connected to
 byte[] getData(Module requester)
          Returns data from this module
 byte getDataFromBuffer()
           
 boolean getDebugMode()
          Returns the status of the debug mode toggle
 java.lang.String getDump()
          Returns a dump of this module
 int getID()
          Returns the ID of the module
 byte getIOPortByte(int portAddress)
          Return a byte from I/O address space at given I/O port
 byte[] getIOPortDoubleWord(int portAddress)
          Return a double word from I/O address space at given port
 byte[] getIOPortWord(int portAddress)
          Return a word from I/O address space at given port
 java.lang.String getName()
          Returns the name of the module
private  byte getResolutionByte()
           
private  byte getStatusByte()
           
 java.lang.String getType()
          Returns the type of the module
 int getUpdateInterval()
          Retrieve the interval between subsequent updates
 boolean isBufferEmpty()
           
 boolean isConnected()
          Checks if this module is connected to operate normally
 boolean isObserved()
          Returns the status of observed toggle
 void mouseMotion(int delta_x, int delta_y, int delta_z, byte buttonState)
           
 boolean reset()
          Default inherited reset.
 boolean setConnection(Module mod)
          Sets up a connection with another module
 boolean setData(byte[] data, Module sender)
          Set data for this module
 boolean setData(java.lang.String[] data, Module sender)
          Set String[] data for this module
 void setDebugMode(boolean status)
          Sets the debug mode toggle
 void setIOPortByte(int portAddress, byte data)
          Set a byte in I/O address space at given port
 void setIOPortDoubleWord(int portAddress, byte[] dataDoubleWord)
          Set a double word in I/O address space at given port
 void setIOPortWord(int portAddress, byte[] dataWord)
          Set a word in I/O address space at given port
 void setObserved(boolean status)
          Sets the observed toggle
 void setUpdateInterval(int interval)
          Defines the interval between subsequent updates
 void start()
          Starts the module
 void stop()
          Stops the module
 void storeBufferData(boolean forceEnqueue)
           
 void update()
          Update device
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

emu

private Emulator emu

moduleConnections

private java.lang.String[] moduleConnections

motherboard

private ModuleMotherboard motherboard

keyboard

private ModuleKeyboard keyboard

buffer

private MouseBuffer buffer

isObserved

private boolean isObserved

debugMode

private boolean debugMode

updateInterval

private int updateInterval

mouseEnabled

boolean mouseEnabled

mouseType

int mouseType

mouseMode

int mouseMode

mousePreviousMode

int mousePreviousMode

lastMouseCommand

byte lastMouseCommand

expectingMouseParameter

boolean expectingMouseParameter

imRequest

int imRequest

imMode

boolean imMode

sampleRate

byte sampleRate

resolutionCpmm

int resolutionCpmm

scaling

int scaling

delayed_dx

int delayed_dx

delayed_dy

int delayed_dy

delayed_dz

int delayed_dz

buttonStatus

byte buttonStatus

logger

private static java.util.logging.Logger logger

MODULE_ID

public static final int MODULE_ID
See Also:
Constant Field Values

MODULE_TYPE

public static final java.lang.String MODULE_TYPE
See Also:
Constant Field Values

MODULE_NAME

public static final java.lang.String MODULE_NAME
See Also:
Constant Field Values

MOUSE_TYPE_PS2

private static final int MOUSE_TYPE_PS2
See Also:
Constant Field Values

MOUSE_TYPE_IMPS2

private static final int MOUSE_TYPE_IMPS2
See Also:
Constant Field Values

MOUSE_MODE_WRAP

private static final int MOUSE_MODE_WRAP
See Also:
Constant Field Values

MOUSE_MODE_STREAM

private static final int MOUSE_MODE_STREAM
See Also:
Constant Field Values

MOUSE_MODE_REMOTE

private static final int MOUSE_MODE_REMOTE
See Also:
Constant Field Values

MOUSE_MODE_RESET

private static final int MOUSE_MODE_RESET
See Also:
Constant Field Values

MOUSE_CMD_ACK

private static final byte MOUSE_CMD_ACK
See Also:
Constant Field Values

MOUSE_CMD_COMPLETION

private static final byte MOUSE_CMD_COMPLETION
See Also:
Constant Field Values

MOUSE_CMD_ID

private static final byte MOUSE_CMD_ID
See Also:
Constant Field Values

MOUSE_CMD_RESEND

private static final byte MOUSE_CMD_RESEND
See Also:
Constant Field Values

MOUSE_BUFFER_INITSIZE

private static final int MOUSE_BUFFER_INITSIZE
See Also:
Constant Field Values
Constructor Detail

Mouse

public Mouse(Emulator owner)
Class constructor

Method Detail

getID

public int getID()
Returns the ID of the module

Specified by:
getID in class Module
Returns:
string containing the ID of module
See Also:
Module

getType

public java.lang.String getType()
Returns the type of the module

Specified by:
getType in class Module
Returns:
string containing the type of module
See Also:
Module

getName

public java.lang.String getName()
Returns the name of the module

Specified by:
getName in class Module
Returns:
string containing the name of module
See Also:
Module

getConnection

public java.lang.String[] getConnection()
Returns a String[] with all names of modules it needs to be connected to

Specified by:
getConnection in class Module
Returns:
String[] containing the names of modules, or null if no connections

setConnection

public boolean setConnection(Module mod)
Sets up a connection with another module

Specified by:
setConnection in class Module
Parameters:
mod - Module that is to be connected to this class
Returns:
true if connection has been established successfully, false otherwise
See Also:
Module

isConnected

public boolean isConnected()
Checks if this module is connected to operate normally

Specified by:
isConnected in class Module
Returns:
true if this module is connected successfully, false otherwise

reset

public boolean reset()
Default inherited reset. Calls specific reset(int)

Specified by:
reset in class Module
Returns:
boolean true if module has been reset successfully, false otherwise

start

public void start()
Starts the module

Specified by:
start in class Module
See Also:
Module

stop

public void stop()
Stops the module

Specified by:
stop in class Module
See Also:
Module

isObserved

public boolean isObserved()
Returns the status of observed toggle

Specified by:
isObserved in class Module
Returns:
state of observed toggle
See Also:
Module

setObserved

public void setObserved(boolean status)
Sets the observed toggle

Specified by:
setObserved in class Module
Parameters:
status -
See Also:
Module

getDebugMode

public boolean getDebugMode()
Returns the status of the debug mode toggle

Specified by:
getDebugMode in class Module
Returns:
state of debug mode toggle
See Also:
Module

setDebugMode

public void setDebugMode(boolean status)
Sets the debug mode toggle

Specified by:
setDebugMode in class Module
Parameters:
status -
See Also:
Module

getData

public byte[] getData(Module requester)
Returns data from this module

Specified by:
getData in class Module
Parameters:
Module - requester, the requester of the data
Returns:
byte[] with data
See Also:
Module

setData

public boolean setData(byte[] data,
                       Module sender)
Set data for this module

Specified by:
setData in class Module
Parameters:
byte[] - containing data
Module - sender, the sender of the data
Returns:
true if data is set successfully, false otherwise
See Also:
Module

setData

public boolean setData(java.lang.String[] data,
                       Module sender)
Set String[] data for this module

Specified by:
setData in class Module
Parameters:
String[] - data
Module - sender, the sender of the data
Returns:
boolean true is successful, false otherwise
See Also:
Module

getDump

public java.lang.String getDump()
Returns a dump of this module

Specified by:
getDump in class Module
Returns:
string
See Also:
Module

getUpdateInterval

public int getUpdateInterval()
Retrieve the interval between subsequent updates

Specified by:
getUpdateInterval in class ModuleDevice
Returns:
int interval in microseconds

setUpdateInterval

public void setUpdateInterval(int interval)
Defines the interval between subsequent updates

Specified by:
setUpdateInterval in class ModuleDevice
Parameters:
int - interval in microseconds

update

public void update()
Update device

Specified by:
update in class ModuleDevice

getIOPortByte

public byte getIOPortByte(int portAddress)
                   throws ModuleException,
                          ModuleUnknownPort,
                          ModuleWriteOnlyPortException
Description copied from class: ModuleDevice
Return a byte from I/O address space at given I/O port

Specified by:
getIOPortByte in class ModuleDevice
Returns:
byte containing the data at given I/O address port
Throws:
ModuleException
ModuleUnknownPort
ModuleWriteOnlyPortException

setIOPortByte

public void setIOPortByte(int portAddress,
                          byte data)
                   throws ModuleException,
                          ModuleUnknownPort
Description copied from class: ModuleDevice
Set a byte in I/O address space at given port

Specified by:
setIOPortByte in class ModuleDevice
Throws:
ModuleException
ModuleUnknownPort

getIOPortWord

public byte[] getIOPortWord(int portAddress)
                     throws ModuleException,
                            ModuleUnknownPort,
                            ModuleWriteOnlyPortException
Description copied from class: ModuleDevice
Return a word from I/O address space at given port

Specified by:
getIOPortWord in class ModuleDevice
Returns:
byte[] containing the word at given I/O address port
Throws:
ModuleException
ModuleUnknownPort
ModuleWriteOnlyPortException

setIOPortWord

public void setIOPortWord(int portAddress,
                          byte[] dataWord)
                   throws ModuleException,
                          ModuleUnknownPort
Description copied from class: ModuleDevice
Set a word in I/O address space at given port

Specified by:
setIOPortWord in class ModuleDevice
Throws:
ModuleException
ModuleUnknownPort

getIOPortDoubleWord

public byte[] getIOPortDoubleWord(int portAddress)
                           throws ModuleException,
                                  ModuleUnknownPort,
                                  ModuleWriteOnlyPortException
Description copied from class: ModuleDevice
Return a double word from I/O address space at given port

Specified by:
getIOPortDoubleWord in class ModuleDevice
Returns:
byte[] containing the double word at given I/O address port
Throws:
ModuleException
ModuleUnknownPort
ModuleWriteOnlyPortException

setIOPortDoubleWord

public void setIOPortDoubleWord(int portAddress,
                                byte[] dataDoubleWord)
                         throws ModuleException,
                                ModuleUnknownPort
Description copied from class: ModuleDevice
Set a double word in I/O address space at given port

Specified by:
setIOPortDoubleWord in class ModuleDevice
Throws:
ModuleException
ModuleUnknownPort

isBufferEmpty

public boolean isBufferEmpty()
Specified by:
isBufferEmpty in class ModuleMouse

storeBufferData

public void storeBufferData(boolean forceEnqueue)
Specified by:
storeBufferData in class ModuleMouse

getDataFromBuffer

public byte getDataFromBuffer()
Specified by:
getDataFromBuffer in class ModuleMouse

controlMouse

public void controlMouse(byte value)
Specified by:
controlMouse in class ModuleMouse

mouseMotion

public void mouseMotion(int delta_x,
                        int delta_y,
                        int delta_z,
                        byte buttonState)

getStatusByte

private byte getStatusByte()

getResolutionByte

private byte getResolutionByte()

enqueueData

private boolean enqueueData(byte b1,
                            byte b2,
                            byte b3,
                            byte b4)