Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 18, 2013 8:25 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Apr 25, 2012 4:08 pm 
Offline
Regular

Joined: Thu Sep 22, 2011 4:39 pm
Posts: 165
Location: Belgium
linked to my question on this viewtopic.php?f=21&t=4893

the issue is on the input class for android, the keyevent must be mapped on the keyTyped method and not on the keyDown method
because he can't seem to map the int to a char, which gets you the side effect that your fonts return wrong characters..

this worked for me:

bad:

Code:
/*
    * (non-Javadoc)
    * @see com.badlogic.gdx.InputProcessor#keyDown(int)
    */
   @Override
   public boolean keyDown(final int key) {
      addEvent(new InputEvent() {
         @Override
         public void invoke() {
            for (int i=0;i<keyListeners.size();i++) {
               KeyListener listener = (KeyListener) keyListeners.get(i);
               if (listener.isAcceptingInput()) {
                  listener.keyPressed(key, (char) key);
               }
            }
         }
      });

      return true;
   }

   /*
    * (non-Javadoc)
    * @see com.badlogic.gdx.InputProcessor#keyTyped(char)
    */
   @Override
   public boolean keyTyped(char c) {
      return false;
   }


good:

Code:
/*
    * (non-Javadoc)
    * @see com.badlogic.gdx.InputProcessor#keyDown(int)
    */
   @Override
   public boolean keyDown(final int key) {
      return false;
   }

   /*
    * (non-Javadoc)
    * @see com.badlogic.gdx.InputProcessor#keyTyped(char)
    */
   @Override
   public boolean keyTyped(final char c) {
        addEvent(new InputEvent() {
            @Override
            public void invoke() {
                for (int i=0;i<keyListeners.size();i++) {
                    KeyListener listener = (KeyListener) keyListeners.get(i);
                    if (listener.isAcceptingInput()) {
                        listener.keyPressed(c, c);
                    }
                }
            }
        });
      return false;
   }


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group