com.monkeycoder.monkeynes.gui
Class ButtonMap

java.lang.Object
  |
  +--com.monkeycoder.monkeynes.gui.ButtonMap

public class ButtonMap
extends Object

This class acts as a mapping between keyboard keys and NES controller buttons.

Originally part of the MonkeyNES project.

Author:
David Stephens

Constructor Summary
ButtonMap()
          Creates a new empty ButtonMap.
 
Method Summary
 void addMapping(int inKeyCode, int inButton)
          Adds a new mapping into this ButtonMap.
 int getButton(int inKeyCode)
          Gets the NES button ID for a given key code.
 String toString()
          Creates a String containing all the mappings in this ButtonMap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ButtonMap

public ButtonMap()
Creates a new empty ButtonMap.

Method Detail

addMapping

public void addMapping(int inKeyCode,
                       int inButton)
Adds a new mapping into this ButtonMap.

Parameters:
inKeyCode - The keyboard key code.
inButton - The ID of the NES button.

getButton

public int getButton(int inKeyCode)
Gets the NES button ID for a given key code. Returns -1 if there is no NES button that maps to the given key code.

Parameters:
inKeyCode - The keyboard key code.
Returns:
The NES button ID or -1 to indicate there was no mapping.

toString

public String toString()
Creates a String containing all the mappings in this ButtonMap.

Overrides:
toString in class Object
Returns:
The String of the mappings.