0432219e99
placement. Went back to not allowing the player to be killed by shaft pieces. Initial work on improved keyboard input. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@755 542714f4-19e9-0310-aa3c-eee0fc999fb1
56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
//
|
|
// $Id: KeyTranslatorImpl.java,v 1.1 2001/12/12 16:55:06 shaper Exp $
|
|
|
|
package com.threerings.yohoho.puzzle.util;
|
|
|
|
import com.samskivert.util.HashIntMap;
|
|
|
|
/**
|
|
* A simple implementation of the {@link KeyTranslator} interface that
|
|
* provides facilities for mapping key codes to action command strings for
|
|
* use by the {@link KeyboardManager}.
|
|
*/
|
|
public class KeyTranslatorImpl implements KeyTranslator
|
|
{
|
|
/**
|
|
* Adds a mapping from key press to action command string.
|
|
*/
|
|
public void addPressCommand (int keyCode, String command)
|
|
{
|
|
_press.put(keyCode, command);
|
|
}
|
|
|
|
/**
|
|
* Adds a mapping from key release to action command string.
|
|
*/
|
|
public void addReleaseCommand (int keyCode, String command)
|
|
{
|
|
_release.put(keyCode, command);
|
|
}
|
|
|
|
// documentation inherited
|
|
public boolean hasCommand (int keyCode)
|
|
{
|
|
return (_press.get(keyCode) != null ||
|
|
_release.get(keyCode) != null);
|
|
}
|
|
|
|
// documentation inherited
|
|
public String getPressCommand (int keyCode)
|
|
{
|
|
return (String)_press.get(keyCode);
|
|
}
|
|
|
|
// documentation inherited
|
|
public String getReleaseCommand (int keyCode)
|
|
{
|
|
return (String)_release.get(keyCode);
|
|
}
|
|
|
|
/** The mapping for key presses from key codes to action commands. */
|
|
protected HashIntMap _press = new HashIntMap();
|
|
|
|
/** The mapping for key releases from key codes to action commands. */
|
|
protected HashIntMap _release = new HashIntMap();
|
|
}
|