Game key mapper

Hello,
Can anyone help out with some hints how to build a decent key mapping interface in a game. Basically a game has some default keys pre-set. A user needs to change those keys. What I've been trying so far is a JDialog with a bunch of JTextFields in which they can enter a key. Using a keyListener it interprets the key and I know what they've pressed. The hard part is how to display what they have just entered...
I'm trying to somehow display it in the same text field while erazing the previous input and putting something different and couldn't find anything related yet.
For example when I press left arrow key it should type "Left arrow" and if I press a after that it should erase "Left arrow" and just put "a".
Does anyone know how this could be done?
thanks in advance

Here - I wrote this for you. It is designed to be easy to both add new descriptions of keys, and to associate actions to key presses on a field. You might want to use it directly, or more probably just use it to get ideas about one way of doing it. I decided to avoid using a textfield to make it look a bit nicer, but you might want to make it a bit simpler.
public class KeySetupFrame extends JFrame
  public KeySetupFrame()
    setupFrame();
  public static void main(String[] args)
    new KeySetupFrame();
  private void setupFrame()
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel panel = new JPanel(new GridLayout(3,3,10,10));
    panel.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Select Keys"),
            BorderFactory.createEmptyBorder(10,10,10,10)));
    c.add(panel, BorderLayout.CENTER);
    Font titleFont = new Font("Comic", Font.PLAIN, 12);
    Font keyFont = new Font("Comic", Font.BOLD, 30);
    panel.add(new JPanel());
    panel.add(new KeyField("Up", UP, titleFont, keyFont));
    panel.add(new JPanel());
    panel.add(new KeyField("Left", LEFT, titleFont, keyFont));
    panel.add(new KeyField("Fire", FIRE, titleFont, keyFont));
    panel.add(new KeyField("Right", RIGHT, titleFont, keyFont));
    panel.add(new JPanel());
    panel.add(new KeyField("Down", DOWN, titleFont, keyFont));
    panel.add(new JPanel());
    setBounds(600, 900, 600, 300);     // bottom right of my screen so my boss can't see that i'm not writing his software
    setVisible(true);
  // mappings
  private static Map keyNames = new HashMap();
  static
    keyNames.put(new Integer(KeyEvent.VK_LEFT), "Left Arrow");    // need to wrap the key codes
    keyNames.put(new Integer(KeyEvent.VK_RIGHT), "Right Arrow");
    keyNames.put(new Integer(KeyEvent.VK_UP), "Up Arrow");
    keyNames.put(new Integer(KeyEvent.VK_DOWN), "Down Arrow");
    keyNames.put(new Integer(KeyEvent.VK_SPACE), "Space Bar");
  // inner classes
  class KeyField extends JPanel implements KeyListener, MouseListener
    KeyField(String name, KeyAction action, Font title, Font key)
      controlName = name;
      keyAction = action;
      titleFont = title;
      keyFont = key;
      addKeyListener(this);
      addMouseListener(this);
    public void paint(Graphics g)
      // write the name of the control at the top, then a description of the selected key
      Dimension size = getSize();
      // use top 5th as title
      Rectangle titleRect = new Rectangle(0, 0, size.width, size.height / 5);
      g.setColor(hasFocus() ? Color.pink : Color.yellow);
      g.fillRect(titleRect.x, titleRect.y, titleRect.width, titleRect.height);
      g.setColor(Color.black);
      g.setFont(titleFont);
      Point titleAnchor = getTextAnchor(controlName, g.getFontMetrics(), titleRect);
      g.drawString(controlName, titleAnchor.x, titleAnchor.y);
      // and the rest for the key depiction
      Rectangle keyRect = new Rectangle(0, size.height / 5, size.width, (size.height / 5) * 4);
      g.setColor(Color.white);
      g.setFont(keyFont);
      g.fillRect(keyRect.x, keyRect.y, keyRect.width, keyRect.height);
      if(key != null)
        g.setColor(Color.green);
        Point keyAnchor = getTextAnchor(key, g.getFontMetrics(), keyRect);
        g.drawString(key, keyAnchor.x, keyAnchor.y);
    public void keyTyped(KeyEvent e)
    public void keyPressed(KeyEvent e)
    public void keyReleased(KeyEvent e)
      // see what string this key is mapped to
      Integer keyCode = new Integer(e.getKeyCode());
      String mapping = (String)keyNames.get(keyCode);
      if(mapping != null)
        key = mapping;              // if we found a match, store description for the paint method
      else
        key = String.valueOf(e.getKeyChar());     // if none, then just try to get its char. you might want to do a bit more validation in here
      // execute the action
      keyAction.executeKeyAction(e.getKeyCode());
      // show the changes
      repaint();
    public void mouseClicked(MouseEvent e)
      requestFocus();
      getParent().repaint();
    public void mousePressed(MouseEvent e)
      requestFocus();
      getParent().repaint();
    public void mouseReleased(MouseEvent e)
      requestFocus();
      getParent().repaint();
    public void mouseEntered(MouseEvent e)
    public void mouseExited(MouseEvent e)
    private Point getTextAnchor(String text, FontMetrics metrics, Rectangle area)
      Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight());
      int xOffset = (area.width - textSize.width) / 2;
      int yOffset = (area.height - textSize.height) / 2;
      return new Point(xOffset, area.height - yOffset);   // remember text is drawn from BOTTOM of rect, so translate
    private String controlName;
    private KeyAction keyAction;
    private Font titleFont;
    private Font keyFont;
    private String key;
   * use implementations of this to perform an action when a key is set. this will be where you call code that sets
   * the control options in your code.
   * you assign one of these for each field - it's basically a way of attaching an action to a field, and because
   * it's an interface you can create new KeyFields that do different things without adjusting the KeyField code. you
   * just need to pass in a different implementation of KeyAction.
  interface KeyAction
    void executeKeyAction(int keyCode);
  static KeyAction LEFT = new KeyAction()
    public void executeKeyAction(int keyCode)
      System.out.println("keyCode: " + keyCode + " selected for LEFT control");
  static KeyAction RIGHT = new KeyAction()
    public void executeKeyAction(int keyCode)
      System.out.println("keyCode: " + keyCode + " selected for RIGHT control");
  static KeyAction UP = new KeyAction()
    public void executeKeyAction(int keyCode)
      System.out.println("keyCode: " + keyCode + " selected for UP control");
  static KeyAction DOWN = new KeyAction()
    public void executeKeyAction(int keyCode)
      System.out.println("keyCode: " + keyCode + " selected for DOWN control");
  static KeyAction FIRE = new KeyAction()
    public void executeKeyAction(int keyCode)
      System.out.println("keyCode: " + keyCode + " selected for FIRE control");
  }AND AN UNFORMATTED VERSION THAT YOU CAN CHOP & PASTE
public class KeySetupFrame extends JFrame
public KeySetupFrame()
setupFrame();
public static void main(String[] args)
new KeySetupFrame();
private void setupFrame()
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel panel = new JPanel(new GridLayout(3,3,10,10));
panel.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder("Select Keys"),
BorderFactory.createEmptyBorder(10,10,10,10)));
c.add(panel, BorderLayout.CENTER);
Font titleFont = new Font("Comic", Font.PLAIN, 12);
Font keyFont = new Font("Comic", Font.BOLD, 30);
panel.add(new JPanel());
panel.add(new KeyField("Up", UP, titleFont, keyFont));
panel.add(new JPanel());
panel.add(new KeyField("Left", LEFT, titleFont, keyFont));
panel.add(new KeyField("Fire", FIRE, titleFont, keyFont));
panel.add(new KeyField("Right", RIGHT, titleFont, keyFont));
panel.add(new JPanel());
panel.add(new KeyField("Down", DOWN, titleFont, keyFont));
panel.add(new JPanel());
setBounds(600, 900, 600, 300); // bottom right of my screen so my boss can't see that i'm not writing his software
setVisible(true);
// mappings
private static Map keyNames = new HashMap();
static
keyNames.put(new Integer(KeyEvent.VK_LEFT), "Left Arrow"); // need to wrap the key codes
keyNames.put(new Integer(KeyEvent.VK_RIGHT), "Right Arrow");
keyNames.put(new Integer(KeyEvent.VK_UP), "Up Arrow");
keyNames.put(new Integer(KeyEvent.VK_DOWN), "Down Arrow");
keyNames.put(new Integer(KeyEvent.VK_SPACE), "Space Bar");
// inner classes
class KeyField extends JPanel implements KeyListener, MouseListener
KeyField(String name, KeyAction action, Font title, Font key)
controlName = name;
keyAction = action;
titleFont = title;
keyFont = key;
addKeyListener(this);
addMouseListener(this);
public void paint(Graphics g)
// write the name of the control at the top, then a description of the selected key
Dimension size = getSize();
// use top 5th as title
Rectangle titleRect = new Rectangle(0, 0, size.width, size.height / 5);
g.setColor(hasFocus() ? Color.pink : Color.yellow);
g.fillRect(titleRect.x, titleRect.y, titleRect.width, titleRect.height);
g.setColor(Color.black);
g.setFont(titleFont);
Point titleAnchor = getTextAnchor(controlName, g.getFontMetrics(), titleRect);
g.drawString(controlName, titleAnchor.x, titleAnchor.y);
// and the rest for the key depiction
Rectangle keyRect = new Rectangle(0, size.height / 5, size.width, (size.height / 5) * 4);
g.setColor(Color.white);
g.setFont(keyFont);
g.fillRect(keyRect.x, keyRect.y, keyRect.width, keyRect.height);
if(key != null)
g.setColor(Color.green);
Point keyAnchor = getTextAnchor(key, g.getFontMetrics(), keyRect);
g.drawString(key, keyAnchor.x, keyAnchor.y);
public void keyTyped(KeyEvent e)
public void keyPressed(KeyEvent e)
public void keyReleased(KeyEvent e)
// see what string this key is mapped to
Integer keyCode = new Integer(e.getKeyCode());
String mapping = (String)keyNames.get(keyCode);
if(mapping != null)
key = mapping; // if we found a match, store description for the paint method
else
key = String.valueOf(e.getKeyChar()); // if none, then just try to get its char. you might want to do a bit more validation in here
// execute the action
keyAction.executeKeyAction(e.getKeyCode());
// show the changes
repaint();
public void mouseClicked(MouseEvent e)
requestFocus();
getParent().repaint();
public void mousePressed(MouseEvent e)
requestFocus();
getParent().repaint();
public void mouseReleased(MouseEvent e)
requestFocus();
getParent().repaint();
public void mouseEntered(MouseEvent e)
public void mouseExited(MouseEvent e)
private Point getTextAnchor(String text, FontMetrics metrics, Rectangle area)
Dimension textSize = new Dimension(metrics.stringWidth(text), metrics.getHeight());
int xOffset = (area.width - textSize.width) / 2;
int yOffset = (area.height - textSize.height) / 2;
return new Point(xOffset, area.height - yOffset); // remember text is drawn from BOTTOM of rect, so translate
private String controlName;
private KeyAction keyAction;
private Font titleFont;
private Font keyFont;
private String key;
* use implementations of this to perform an action when a key is set. this will be where you call code that sets
* the control options in your code.
* you assign one of these for each field - it's basically a way of attaching an action to a field, and because
* it's an interface you can create new KeyFields that do different things without adjusting the KeyField code. you
* just need to pass in a different implementation of KeyAction.
interface KeyAction
void executeKeyAction(int keyCode);
static KeyAction LEFT = new KeyAction()
public void executeKeyAction(int keyCode)
System.out.println("keyCode: " + keyCode + " selected for LEFT control");
static KeyAction RIGHT = new KeyAction()
public void executeKeyAction(int keyCode)
System.out.println("keyCode: " + keyCode + " selected for RIGHT control");
static KeyAction UP = new KeyAction()
public void executeKeyAction(int keyCode)
System.out.println("keyCode: " + keyCode + " selected for UP control");
static KeyAction DOWN = new KeyAction()
public void executeKeyAction(int keyCode)
System.out.println("keyCode: " + keyCode + " selected for DOWN control");
static KeyAction FIRE = new KeyAction()
public void executeKeyAction(int keyCode)
System.out.println("keyCode: " + keyCode + " selected for FIRE control");
Should run straight out of the box. Ain't java great?
hth.

Similar Messages

  • Game keys in custom item

    hi i am trying to implement a basic game action key in my keypressed method but it says it cant find the game action key of FIRE
    Here is my code below. cant i use the game keys such has LEFT RIGHT UP DOWN FIRE keys?
    [code]
    private Image button;
        private blackjack root;
        /** Creates a new instance of validate */
        public validate( String label,  blackjack midlet)
            super( label );
            this.root = midlet;
        // Returns the minimal height of the content
        // area.
        protected int getMinContentHeight()
            return 40;
        // Returns the minimal width of the content
        // area.
        protected int getMinContentWidth()
            return 40;
        // Returns the preferred height of the content
        // area. A tentative value for the opposite
        // dimension -- the width -- is passed to aid
        // in the height calculation. The tentative value
        // should be ignored if it is -1.
        protected int getPrefContentHeight( int width )
            return getMinContentHeight();
        // Returns the preferred width of the content
        // area. A tentative value for the opposite
        // dimension -- the height -- is passed to aid
        // in the width calculation. The tentative value
        // should be ignored if it is -1.
        protected int getPrefContentWidth( int height )
            return getMinContentWidth();
        // Draws the item's content area, whose dimensions
        // are given by the width and height parameters.
        protected void paint( Graphics g, int width, int height )
            try
                button = Image.createImage("/validate.png");
            } catch (IOException ex)
                ex.printStackTrace();
    //        g.setColor( 255, 255, 255 );
    //        g.fillRect( 0, 0, width, height );
    protected void keyPressed(int k)
             int g = getGameAction( k );
            if( g == FIRE || k == 10  )
                //login to the game
                root.login();
        }[/code]

    FIRE is a static field of Canvas, you need to refer to it in your code as Canvas.FIRE.
    From the API for CustomItem:
    Key event methods are passed the keyCode indicating the key on which the event occurred. Implementations must provide means for the user to generate events with key codes Canvas.KEY_NUM0 through Canvas.KEY_NUM9, Canvas.KEY_STAR, and Canvas.KEY_POUND. Implementations may also deliver key events for other keys, include device-specific keys. The set of keys available to a CustomItem may differ depending upon whether commands have been added to it.
    Support for detection of the FIRE key is not mandated.
    db

  • How do I get a game key

    I purchased Civ V from mac app store, I need the registration key to register this game with steam, how do I get it?

    Mac App Store content is not supposed to require passwords, serial numbers or keys. Did you possibly install a trial version of this game on your Mac prior to this purchase.
    If you read the details about the game on its page in the Mac App Store it states that the game is not Steam encrypted.

  • Game key codes

    Hello all
    I have a vi that gives virtual key codes to the Call Library Function Node, to control the cursor keys. The codes are: 37(left), 38(up) and 39(right), which are the ASCII (decimal) values. Using this output I want to control any kind of game running on windows. However, the program is able to move the cursor keys on applications such as MsWord and Notepad, it is not able to control cursor keys for game.
    So here is my question: Do games, like nfs all have different key codes, or do they have common key codes? Since games do not accept ASCII values, then what are the key codes that they use? Any urgent help would be appreciated.
    Regards,
    Ashutosh

    Hi ashu,
    first: 37-39 (left to right) are not ASCII values of the keys (37=%, 38=&, 39=')! These numbers seem to be scancodes of the keyboard (although mine gives different values for the cursor keys, while 37-39 corresponds to K-Ö on a German keyboard). The operating system translates scancodes to corresponding chars using the currently used keyboard setting (keyboard layout).
    second: Games often don't use OS routines for input devices. So they read the scancode with their own routines and kindly ignore OS wishes...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • N96 game keys in non-ngage apps

    Hi,
    I really love the fact that the media keys double as game control keys in N-Gage, but I's love to be able to use them in other games and applications as well. Is there any way to assign these keys for use in non-N-Gage applications?

    That actually depands on the developer of the games itself if they have added the options to use the keys in their program.
    Then you may use it or activate it in the settings of the games itself.
    Mark me a KUDOS if this has helped...

  • [solved]PS3 Sixaxis and Steam (USB)

    The sixaxis controller works with Steam out of the box!  The problem is that the buttons are just a little off. 
    What I've done so far:
    Disabled Joystick control of mouse cursor (It was interfering with what I wanted to do)
    Plugged in my sixaxis and hit the PS button (the pad won't do anything until you hit the button)
    Ran HL2 Beta (which runs flawlessly by the way) and played around a bit.  I can look, move, jump, shoot, use and duck.  It's almost perfect! Much better than the Sixaxis control support for Windows7!  The problem is that I can't run fast...  and the button layout is just a little weird. (A couple of the buttons do exactly the same thing, and I suspect that other controls are missing)
    I suspect that the problem is that the PC gaming world revolves around MS and their 360 controller.
    Googling, I found this thread:  http://supermeatboy.com/forum/index.php?topic=2389.0    They are attempting to remap the keys to be more like the 360 controller.  Keep in mind that I don't know if this will actually solve the problem.  I followed the directions (although I'm not sure that HL2 uses SDL at all) and nothing changed.  (Maybe that's just evidence that HL2 doesn't use SDL)
    Any suggestions?
    PS:  I get the same results with L4D2.  HL1 doesn't work so well.  The controls do something, but they need to be calibrated specifically for that game or something (my character looks at the floor and spins in a circle)
    PPS:  I think that Qjoypad might be a practical work-around.  I just think that it would be a shame to use a work around when a more elegant solution might be available.
    PPPS:  I plan to update the wiki if I get this working properly.
    Last edited by Convergence (2013-06-19 14:57:44)

    No luck with L4D2, but I got it to work perfectly in HL2.  You just need to use the in-game key mapper.  (I don't know how I missed that)

  • How can I assign a function key on my IMAC's wired keyboard to enter my email address in documents or on internet forms?

    I'm trying to set up my wired IMAC keyboard to create shortcuts to enter my email adresses into emails or into web forms.  I was able to do this when I was working with PCs but can't find direction on the process for the MAC.  There seems to be 7 unused Function Keys at the top of the keyboard that are srrving no apparent purpose so logic tells me they must be available for sutomization.
    Please help. My fingers are tired...

    I don't think you can with the standard Mac OS X tools / sys prefs..
    You have to step into the realm of 3rd party key mapper tools.
      I'm reluctant to go there..
    I'm happy being able to remap option to be my command key
      using the standard System Preferences ->Keyboard..
    but.. googling a bit shows some 3rd party tools..
    https://pqrs.org/macosx/keyremap4macbook/
    http://superuser.com/questions/37042/remapping-of-keys-in-mac-os-x
    http://lifehacker.com/5882684/the-best-keyboard-remapper-for-mac-os-x

  • The Print Screen Key under Windows

    I just picked up my Apple aluminum keyboard (with the numeric keypad) and absolutely think it's the bomb. I have gotten to the point where any other keyboard just isn't as easy to use, and I do a LOT of typing at work.
    That being said, there are a few keys that I use on a routine basis that don't seem to work under the Apple aluminum keyboard. I found a workaround for the Insert key (press left shift key and the zero (0) on the numeric keypad) and that's fixed, but I am at a loss to find an equivalent keypress for the Print Screen key.
    I see a lot of solutions online that recommend obtaining key mapper software to make the keyboard work, but this is a locked-down environment in which all software of that kind will not work; it is therefore not an option in this case.
    I'm thinking that, since there is a key equivalent for the Insert key, chances are strong that there is also a key equivalent for the Print Screen key. So, does anyone know which key combination that might be?
    Thanks in advance.

    Art Brymer wrote:
    Agh! The dreaded "Go ahead and install this..." phrase again.
    Not many hardware devices ou there that don't need some sort of driver to be installed.
    Some drivers are provided by the operating system, some from the hardware manufacturer.
    Again, my workplace is a locked-down environment in which NO OUTSIDE SOFTWARE CAN BE INSTALLED. We're not permitted, and can get into serious trouble if we attempt it. So, it's really not worth it to try... and as we don't have "Admin" on the desktops anyway, the chances of it actually working are incredibly slim.
    Again ? First time you tell about it. Like the first time you told about the non-Mac you use with the keyboard...
    In other words, if it ain't in the keyboard itself, as in the "left shift/numeric keypad 0 = Insert" combo, there is nothing I can do.
    I do keep the company-supplied keyboard on the same desk, off to the side, so all I have to do is reach over and hit the required keys, but I really thought there might be a way to do this, so long as someone knew the proper key combos. Perhaps there is no answer.
    Perhaps...
    Stefan

  • Register Custom WebDynpro to FPM (mapper)

    Hi All,
    I have a custom Webdynpro embedded to a Standard WebDynpro, in better words Standard WebDynpro has 3 standard tabs (each tab is a different webdynpro) and I added a 4 tab (custom).
    I want to click Refresh (FPM button) and refresh my custom WebDynpro.
    If I click Refresh the 3 standard tabs  Refresh, but my custom one doesn't.
    How I can register my custom WebDynpro to the mapper of FPM?
    thanks!
    Jason PV

    Try the following code in the init method of your wd.
    * register the mapper to the component
    *  READ TABLE wd_comp_controller->mt_mapper WITH TABLE KEY mapper = wd_this->mo_dodm_ctr_ov_bd TRANSPORTING NO FIELDS.
    *  IF sy-subrc NE 0.
    **  "add the mapper only one time (if several views use the same mapper)
    *    ls_mapper-mapper ?= wd_this->mo_dodm_ctr_ov_bd.
    *    INSERT ls_mapper INTO TABLE wd_comp_controller->mt_mapper.
    *  ENDIF.

  • Sorry to bother - Elder Scrolls key issues

    I'm sorry for adding onto the already numerous problems that are probably coming up with the release of Elder Scrolls online. I however preordered a copy of Elder Scrolls and received the early access key but I'm being told I was also supposed to receive another key to enter that would allow me to set up subscriptions on the account. As of right now my early access has run out and I'm just stuck in a limbo state, being unable to set up a subscription, and being unable to play. Thank you for taking your time to look this matter over.

    Hello Meyerlol,
    Pre-orders for the digital download versions of the game should have received game keys on the release day. I was able to locate your order and can see that there was something holding up its progress. I’m not sure exactly what the issue was, but I was able to contact another team to have it sent through. It is now showing that it is fulfilled so you should receive an email with further instructions. I apologize for any inconvenience this delay has caused.
    Thanks for connecting with us on the forum and please let me know if you have any additional questions.
    Sincerely,
    Matt|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

  • NYKO Air Flow EX and Lego Star Wars

    I read the README file that comes on the CD for Lego Star Wars to find out about game controllers. The Apple store had a NYKO Air Flo EX, so I bought it. This controller is specifically listed in the doc and says that no third party support software is required (supposedly works right from the OS drivers).
    "The controllers listed above function using the built-in Mac OS X drivers. They do not require any device specific or 3rd party services."
    When I start Lego Star Wars, it still only recognizes my keyboard contros. The NYKO controls do nothing. I know the controller is getting power (the fan works) and the NYKO key mapper sees the controller.
    Do I have to map keys for this game? I wouldn't think so, from the README. If I do have to map keys, I feel like I've wasted my money on a game controller.
    iMac G5 20   Mac OS X (10.4.4)  

    Ok, I answered my own question. The Readme file gives you directions for how to uninstall the application. I wondered if there wasn't a setting in a file somewhere that said I had no controller.
    I tried just removing the .plist file from ~/Library/Preferences, but that did not help. The Readme then referenced removing a directory in ~/Library/Application Support. This in error; the directory is actually in your documents directory.
    I removed that directory and the application and reinstalled (I think just removing the directory would have been enough). Now the game sees my controller and plays more fun.
    iMac G5 20   Mac OS X (10.4.4)  

  • How do I properly map my electronic drums to GarageBand?

    Hello,
    I have a set of Yamaha DTXplorer (DTXPL) midi drums, and have a problem using them with the majority of samples for GarageBand.
    The biggest issue is that the Snare Drum doesn't seem to be mapped from the drum set to the software instruments. (Hitting the snare doesn't produce any sound). The other drum parts seem to work fine, just not the Snare Drum.
    Is there any information on how to map my drum set to be completely in synch with GarageBand standards?

    Mapping DTXPLORER MIDI using GarageBand
    Here is the (hopefully) definitive guide for getting a Yamaha DTXPLORER (a.k.a. DT-Explorer, DTXPL) electronic drum set to connect to Apple's GarageBand via MIDI.
    SYMPTOM: When connecting DTXPLORER to GarageBand using MIDI, the snare drum is silent and the bass drum triggers a sort of snare roll instead of a bass hit.
    PROBLEM: The DTXPLORER (for whatever reason) sends out the snare note on G2 (key 31) and the kick note on A2 (key 33). This is a non-standard MIDI key mapping for these instruments.
    SOLUTION: Remap the snare and kick MIDI notes using the freeware app MidiPipe from SubtleSoft (http://homepage.mac.com/nicowald/SubtleSoft/) to the standard GarageBand MIDI keys using the following steps:
    (Note: These settings were tested using GarageBand 3.0.2 and MidiPipe 1.4.1.)
    1. Connect your DTXPLORER via MIDI to GarageBand and verify that GarageBand can record the drum sounds.
    2. Close GarageBand.
    3. Launch MidiPipe. You will create a Pipe that looks like this:
    Midi In
    Key Mapper
    Key Mapper
    Midi Out
    Do so by dragging the appropriate components from the Tools column to the Pipes column in the appropriate order.
    4. Once you've assembled the pipe (with the components in the correct order listed above), configure the settings as follows:
    Midi In:
    - Midi Input: (Your USB or FireWire MIDI device)
    - Options: check "hijack"
    Key Mapper (kick drum):
    - Key In: A2 (33)
    - Key Out: C3 (36)
    - Options: UNcheck "Solo selected "Key In""
    Key Mapper (snare drum):
    - Key In: G2 (31)
    - Key Out: D3 (38)
    - Options: UNcheck "Solo selected "Key In""
    Midi Out:
    - MIDI Output: MidiPipe Output 1
    - Options: UNcheck "Pass Through" and UNcheck "Use Note Off Velocity"
    5. Choose File: Save As and save your pipe to a memorable location. You will need to retrieve this file every time you wish to record your drum set using GarageBand.
    6. Relaunch GarageBand and attempt to record your drum set. The snare and the bass drum should now be mapped correctly!
    Note: If you have having difficulties with the pipe and would like to verify that the key mapping is taking effect, add a "Keyboard" component to the pipe after the "Key Mapper"s. That will give you a visual representation of which key is being triggered for each drum pad.
    MacBook Pro 17"   Mac OS X (10.4.6)   2GB RAM

  • GetKeyStates on emulator

    I'm using Java ME SDK 3.0 and am having problems with getKeyStates() on Vista AND XP.
    In my code I have several different getKeyStates() calls in run(). When I clicked the FIRE button ONCE in one portion, it does NOT clear the FIRE latch, but remains on for about 4 dozen times.
    My work-around is to do the following:
    while ( true )
    key = pollKeyState();
    if ( key == 0 ) break;
    where pollKeyState() returns only one of the 5 "Game" keys - UP, DOWN, etc
    But, after 4 iterations (each responds to FIRE a dozen times) in the run() loop, I get NO response to ANY Game key press.
    Any ideas as to
    1. why I have to use the work-around?
    2. why a limit of say 50 Game key presses exists?

    After the work-around, I then call pollKeyStates() for the FIRE button and continue within run().

  • AS3 Air High Score Help

    Hello everyone, i just came here to ask how to add a high score feature in as3 for android and ios. I want it to display on the main menu of the game. Heres my main file (game.as). I am wondering how i would implement it into that? (as you can see i have tried but failed...) please point me in the right direction on this one I want it to display in a dynamic text field called "bestScore" in a movieclip called "HighScore" the instance name of HighScore is bestScore so idk lol. Im new to as3... My score is in a movieclip called "Score" and the dynamic text field is "scoreDisplay" and the instance name is "gameScore" If that helps. Heres my game.as:
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        function updateDisplay():void
                                  gameScore.scoreDisplay.text = currentValue.toString();
                        function getFinalScore():Number
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]
    Thanks in advance
    -Ben

    hello again, i added that code to the updatedisplay function with the currentValue.toString(); because putting a number there would achieve nothing here, and it works, but it doesnt save the highest score. whatever score is the last score it puts it there, becoming like a last score than a high score feature. heres my game.as again with your help
    [as]
    package
              import flash.display.MovieClip;
              import flash.utils.Timer;
              import flash.events.TimerEvent;
              import flash.ui.Mouse;
              import flash.events.KeyboardEvent;
              import flash.ui.Keyboard;
              import flash.events.Event;
              import flash.media.SoundChannel;
              import flash.net.SharedObject;
              import flash.text.TextField;
              public class Game extends MovieClip
                        static var ship:MovieClip;
                        static var healthMeter:HealthMeter;
                        static var score:Score;
                        static var highScore:HighScore;
                        static var enemyShipTimer:Timer;
                        static var gameOverMenu:GameOverMenu;
                        static var startMenu:StartMenu;
                        static var startButton:StartButton;
                        static var pauseButton:PauseButton;
                        static var playButton:PlayButton;
                        static var mainMenuButton:MainMenuButton;
                        public var currentValue:Number;
                        public var sharedObject:SharedObject;
                        public function Game()
                                  Key.initialize(stage);
                                  ship = new Ship();
                                  healthMeter = new HealthMeter();
                                  var score:Score = new Score();
                                  var highScore:HighScore = new HighScore();
                                  addChild(score);
                                  addChild(highScore);
                                  gameScore.visible = false;
                                  bestScore.visible = true;
                                  healthMeter.x = 2.5;
                                  healthMeter.y = 576;
                                  gameOverMenu = new GameOverMenu();
                                  gameOverMenu.x = 217;
                                  gameOverMenu.y = 244;
                                  addChild(gameOverMenu);
                                  gameOverMenu.visible = false;
                                  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
                                  startMenu = new StartMenu();
                                  mainMenuButton = new MainMenuButton();
                                  startButton = new StartButton();
                                  startMenu.x = 151;
                                  startMenu.y = 111;
                                  startButton.x = 93;
                                  startButton.y = 426;
                                  mainMenuButton.x = 656;
                                  mainMenuButton.y = 483;
                                  addChild(mainMenuButton);
                                  mainMenuButton.visible = false;
                                  stage.addChildAt(startMenu, 0);
                                  addChild(startButton);
                                  startMenu.visible = true;
                                  startButton.visible = true;
                                  startMenu.visible = true;
                                  startButton.addEventListener("mouseDown", newGame);
                                  mainMenuButton.addEventListener("mouseDown", mainMenu);
                                  pauseButton = new PauseButton();
                                  pauseButton.x = 896;
                                  pauseButton.y = 63;
                                  pauseButton.addEventListener("mouseDown", PauseGame);
                                  playButton = new PlayButton();
                                  playButton.x = 896;
                                  playButton.y = 63;
                                  addChild(playButton);
                                  playButton.visible = false;
                                  playButton.addEventListener("mouseDown", PlayGame);
                        static function gameOver()
                                  mainMenuButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  gameOverMenu.visible = true;
                                  enemyShipTimer.stop();
                                  for (var i in EnemyShip.list)
                                            EnemyShip.list[i].kill();
                                  ship.takeDamage(-ship.maxHealth);
                        function newGame(e:Event)
                                  addEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = false;
                                  gameScore.visible = true;
                                  addChild(pauseButton);
                                  addChild(healthMeter);
                                  addChild(mainMenuButton);
                                  enemyShipTimer = new Timer(750);
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  addChild(ship);
                                  healthMeter.visible = true;
                                  startMenu.visible = false;
                                  mainMenuButton.visible = false;
                                  startButton.visible = false;
                                  healthMeter.visible = true;
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                                  gameOverMenu.visible = false;
                                  ship.visible = true;
                                  ship.x = 367;
                                  ship.y = 542;
                                  enemyShipTimer.start();
                                  currentValue = 0;
                                  updateDisplay();
                        function mainMenu(e:Event)
                                  removeEventListener(Event.DEACTIVATE, PauseGame);
                                  bestScore.visible = true;
                                  gameScore.visible = false;
                                  removeChild(mainMenuButton);
                                  removeChild(ship);
                                  healthMeter.visible = false;
                                  startMenu.visible = true;
                                  mainMenuButton.visible = false;
                                  startButton.visible = true;
                                  healthMeter.visible = false;
                                  pauseButton.visible = false;
                                  playButton.visible = false;
                                  ship.takeDamage(ship.maxHealth);
                                  gameOverMenu.visible = false;
                        function PauseGame(e:Event)
                                  enemyShipTimer.removeEventListener("timer", sendEnemy);
                                  stage.frameRate = 0;//
                                  pauseButton.visible = false;
                                  playButton.visible = true;
                        function PlayGame(e:Event)
                                  enemyShipTimer.addEventListener("timer", sendEnemy);
                                  stage.frameRate = 30;//
                                  pauseButton.visible = true;
                                  playButton.visible = false;
                        public function Counter()
                                  reset();
                        function sendEnemy(e:Event)
                                  var enemy = new EnemyShip();
                                  stage.addChildAt(enemy, 0);
                                  addToValue(1);
                        function addToValue( amountToAdd:Number ):void
                                  currentValue = currentValue + amountToAdd;
                                  updateDisplay();
                        function setValue( amount:Number ):void
                                  currentValue = amount;
                                  updateDisplay();
                        function reset():void
                                  currentValue = 0;
                                  updateDisplay();
                        public function updateDisplay():void
                                  TextField(gameScore.getChildByName("scoreDisplay")).text = currentValue.toString();
                                  TextField(bestScore.getChildByName("bestScore")).text = currentValue.toString();
                        function getFinalScore()
                                  return gameScore.currentValue;
                        public function GameOverScreen()
                                  sharedObject = SharedObject.getLocal("natdScores");
                        public function setFinalScore( scoreValue:Number ):void
                                  gameScore.text = scoreValue.toString();
                                  if (sharedObject.data.bestScore == null)
                                            sharedObject.data.bestScore = scoreValue;
                                  else if ( scoreValue > sharedObject.data.bestScore )
                                            sharedObject.data.bestScore = scoreValue;
                                  bestScore.text = sharedObject.data.bestScore.toString();
                                  sharedObject.flush();
    [/as]

  • SL install method 4me

    Here's what I did and it worked really well for me. I decided to install the SL system on a LaCie 320 Big Disk Extreme that I am not using. So being booted from my internal drive, I first installed one partition on the 320 disk, then installed the SL system from the CD. Once the system was installed it automatically booted me into the new system and asked me if I wanted to migrate my files from any source. I selected my internal drive and migrated everything across to the new system disk. It went very well and I have almost everything functioning as it should being booted from the 320 drive running SL. There was even a bonus.
    I have constantly complained that in Leopard my APC Backup failed to register on the computer when connected via USB cable. It had worked fine with Tiger. Well, now with Snow Leopard that function has been restored. Yay!
    Only one item seems to not work. I have come to rely on Function Keys Mapper, which is a small utility that lets you launch applications or files with single stroke from a Function Key. It appears to be broken in SL. I have yet to try other items but I am a bit disappointed with this one.

    I should have added that if I find that everything works, I will merely erase my internal drive and restore all the files from my 320 drive to it.

Maybe you are looking for