Interaction






Historical Highlights

Vannevar Bush - MEMEX

Ivan Sutherland - Sketchpad

MIT - Spacewar

Douglas Engelbart - NLS (oNLine System)

Xerox PARC - Star






Types of Devices






Common Devices






Reading Devices

Polling

Event driven






Feedback

Change in response to users' actions

Lets users know that they're interacting

Immediate, simple response often useful

Can be visual, auditory, haptic






Latency

Delay between an action and its result

Humans very aware of latency > ~ 100 milliseconds

Many delays inherent in different stages of hardware/software
"End-to-end" latency = total delay

Long latency slows up user
Irregular latency even worse


Latency is distinct from update speed






Resolution

Measure of how many distinct values a device can report


On/off switch = 1 bit resolution


"Non-analog" joystick = 3 values (+1, 0, -1) for X and for Y

8 bit resolution joystick = 256 possible values for X and for Y

16 bit resolution joystick = 65536 possible values for X and for Y






Noise

Signal = the information we want to communicate to the computer (e.g. button state, pointer position)

Noise = variations in the signal, outside of our control

Examples:

Applications may need to allow for noise in input data






Fitts' Law

From human movement research - Paul Fitts, 1954

Predicts time needed to move from a starting position to a target - e.g. to point at something

D = distance to target
W = width of target







GLUT Devices






GLUT Keyboard Functions

glutKeyboardFunc(func) Called when a 'character' key is hit
glutSpecialFunc(func) Called when a 'special' key is hit
glutKeyboardUpFunc(func) Called when a 'character' key is released
glutSpecialUpFunc(func) Called when a 'special' key is released
glutGetModifiers() Returns state of shift, control, alt keys when event happened
glutIgnoreKeyRepeat(val) Tells GLUT whether to ignore automatic keyboard repeat





GLUT Keyboard Callback

All keyboard callback functions take the form:

    def func(key, x, y):
         ...

key is the key pressed or released - either a single-character string (e.g. 'a'), or a special-key constant (e.g. GLUT_KEY_UP)

x, y is the mouse pointer location when the key event occurred


Note: in Python, the same function can be used for both normal & special keys






glutGetModifiers

glutGetModifiers() returns a bit-mask value
i.e. a combination of flags

Possible flags are GLUT_ACTIVE_SHIFT, GLUT_ACTIVE_CTRL, and GLUT_ACTIVE_ALT

Test a flag with the & operator. e.g.:

    if glutGetModifiers() & GLUT_ACTIVE_CTRL:
        doSomethingForCtrlKey()





GLUT Mouse Functions

glutMouseFunc(func) Called when a mouse button is pressed
glutMotionFunc(func) Called when mouse moves, while button pressed
glutPassiveMotionFunc(func) Called when mouse moves, with no button pressed
glutGetModifiers() Returns state of shift, control, alt keys when event happened





GLUT Mouse Callback

Mouse-button callback functions take the form:

    def func(button, state, x, y):
         ...

button is the button pressed or released - one of GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON, or GLUT_RIGHT_BUTTON

state is GLUT_DOWN if the button was pressed, or GLUT_UP if it was released

x, y is the mouse pointer location when the button was pressed or released






GLUT Motion Callback

Mouse-motion callback functions take the form:

    def func(x, y):
         ...

x, y is the new mouse pointer location






Other GLUT Device Functions

glutJoystickFunc(func, t) Called every t milliseconds with current joystick state
glutTabletMotionFunc(func) Called when the tablet puck is moved
glutTabletButtonFunc(func) Called when a tablet button is pressed or released
glutDialsFunc(func) Called when a dial is turned (dial/button box)
glutButtonBoxFunc(func) Called when a dial/button box button is pressed or released





Widgets

Typical computer GUIs (graphical user interfaces) use "widgets"

Higher-level interface, built on top of basic devices plus graphics display

Examples:

Most reproduce the functionality of physical devices






GLUT Menus

GLUT provides simple pop-up menus

A menu is attached to a mouse button, and appears whenever that button is pressed

If a menu entry is selected, a callback is called with a value associated with that entry

Menus can include sub-menus






GLUT Menu Functions

id = glutCreateMenu(func) Starts defining a new menu (or submenu)
glutAddMenuEntry(label, value) Adds a selectable entry to the current menu
glutAddSubMenu(label, id) Adds a submenu to the current menu
glutAttachMenu(button) Defines mouse button to pop-up the current menu

Examples:
  menu0.py
  menu1.py
  menu2.py






GLUT Menu Notes

Each menu has a unique ID - a number

ID primarily needed when creating submenus

Value associated with a menu entry must be a single integer

Menus can be changed dynamically
(See glutSetMenu, glutRemoveMenuItem, glutChangeToMenuEntry, glutChangeToSubMenu)

Menus can also be attached & detached from buttons dynamically (See glutDetachMenu)



Creative Commons License
This document is by Dave Pape, and is released under a Creative Commons License.