PEG controllers_events--mudyc: Requirements for handling events of controllers

Author: Matti J. Katila
Date-Created:2003-07-15
Last-Modified:2003-08-07
Revision: 1.7
Status: Current
Scope:Minor
Type:Architecture requirements

New user interfaces need custom controllers. Handling the events of these controllers should be modular, easy and generic from the bottom layer up to top layer where the user is main character.

Issues

Requirements

For a user the controller interface should be easy, say

  • Inverting controller.

    • This mouse wheel works in wrong direction!
  • Automatic calibrating

    • This doesn't work!
  • Bind to any axe or button or modifier from any controller.

    • Bindings should be dynamically changeable while program is running.

      • Button 1, why?
      • Why in vertical, why not in horizontal direction?
      • Modifier with this would be nice..
      • I want that red looking LEGO controller, not that big blue :-)
  • (Scale)

    • Mouse is too slow!

For programming, the control framework should support different models

  • Axis model

    • Absolutely
    • Relative
  • Normal mouse model

    • Point model

      • X and y in screen.
    • Dragging model

      • Close to relative axes model
  • Modifiers

Design

Listeners: the interfaces the API user provides

The user provides listeners for different events. The central binding class is used to multiplex e.g. mouse button events with different modifiers to different listeners.

Mouse drag events may be multiplexed by the location of the original press event through a vob.mouse.MousePressListener:

public interface MousePressListener {
    /** The mouse was pressed down.
     * @param x,y The coordinates.
     * @return If non-null, the return value is the drag listener
     *      to be used if the mouse is dragged from here.
     */
    MouseDragListener pressed(int x, int y);
}

The mouse drag interface is as follows:

public interface MouseDragListener {
    /** Called when the drag is started. This method
     * is called even if this dragListener was received
     * from a MousePressListener to make these easier
     * to program.
     */
    void startDrag(int x, int y);
    /** Called when a drag event is received.
     */
    void drag(int x, int y);
    /** Called when the drag is ended.
     */
    void endDrag(int x, int y);
}

Mouse clicks are handled separately:

public interface MouseClickListener {
/** The mouse was clicked.
  • @param x,y The coordinates.

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 161)

Bullet list ends without a blank line; unexpected unindent.

*/

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 161); backlink

Inline emphasis start-string without end-string.

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 162)

Definition list ends without a blank line; unexpected unindent.

MouseDragListener clicked(int x, int y);

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 163)

Definition list ends without a blank line; unexpected unindent.

}

Separating these three classes allows the easiest assembling of event handling structures at run time.

Multiplexer

The multiplexer sends mouse events it is given to the appropriate listeners.

/** A class to send mouse events to the listeners that want them.

*/

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 175); backlink

Inline emphasis start-string without end-string.
public class MouseMultiplexer {

private static class Direction { private Direction() {} } public static final Direction HORIZONTAL = new Direction(); public static final Direction VERTICAL = new Direction();

public void setListener(int button, int modifiers, String description, MousePressListener l); public void setListener(int button, int modifiers, String description, MouseClickListener l); public void setListener(int button, int modifiers, Direction dir, String description, RelativeAxisListener l);

public void setWheelListener(int modifiers, String description, RelativeAxisListener l);

public boolean deliverEvent(VobMouseEvent e);

System Message: WARNING/2 (../ffdoc/libvob/pegboard/controllers_events--mudyc/peg.rst, line 188)

Definition list ends without a blank line; unexpected unindent.

}