brackets keycodes...

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

brackets keycodes...

Post by mike76 »

Hi

Can someone tell me please what EKEY_CODE
have bracket keys in Irrlicht?

I mean these two brackets: [ and ]

Could't find these two in Irrlicht docs nor in Keycodes.h


thx,
-mike
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

there is no key code for them !!!
that's because they are a combination of two keys (Alt + 8 and Alt + 9)...
so check for irr::KEY_MENU && irr::KEY_KEY_8 and irr::KEY_MENU && irr::KEY_KEY_9 !!! ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

won't work,
even irr::KEY_MENU itself gives no response.

well, it's not a big problem
i 'll use other keys..



-mike
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

realy ??? :shock:
for me it works !!! ;)

I used the event receiver from the movement tutorial though (same as the MastEventReceiver I think):

Code: Select all

class MyEventReceiver : public IEventReceiver{
public:
  virtual bool OnEvent(const SEvent& event){
    if (event.EventType == irr::EET_KEY_INPUT_EVENT)
      KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;

    return false;
  }

  virtual bool IsKeyDown(EKEY_CODE keyCode) const{
    return KeyIsDown[keyCode];
  }

  MyEventReceiver(){
    for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
      KeyIsDown[i] = false;
  }

private:
  bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
and in the main loop i do this:

Code: Select all

	while(device->run()){
    if(receiver.IsKeyDown(irr::KEY_MENU) && receiver.IsKeyDown(irr::KEY_KEY_8)){
      printf("pressed [\n");
    }else if(receiver.IsKeyDown(irr::KEY_MENU) && receiver.IsKeyDown(irr::KEY_KEY_9)){
      printf("pressed ]\n");
    }
  }
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

nope...

I even did copy & paste it (just to test your code)
into the 04 Movement example (these lines in main-loop from your post)
and it didn't work... (with the original receiver of corse, exactly as above)

Im using standard 101/102 keyboard , (english, QWERTY layout).
all under XP.


As i said, its not SO big problem, but I wanted only to mention this.



-mike


PS. my 'ALT' keys do work :)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

You can check SEvent.KeyInput.Char for these keys, even if there isn't a keycode for them
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

mike76 wrote:nope...

I even did copy & paste it (just to test your code)
into the 04 Movement example (these lines in main-loop from your post)
and it didn't work... (with the original receiver of corse, exactly as above)

Im using standard 101/102 keyboard , (english, QWERTY layout).
all under XP.
hu, that's strange... :shock:
I'm also using XP with a standard keyboard, but german layout (QWERTZ)...
you can also try it with KEY_RMENU (I'm in doubt for KEY_LMENU though)...
even if you use bitplane's advice or other keys I'm realy curious why it does work for me, but not for you !?!?! :shock:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

Ok, I put this:

Code: Select all

printf(" key=%d    char=%d  \n", event.KeyInput.Key,  event.KeyInput.Char);
into my Reciever to see what codes (if any) it returns.
and for [ =91 and for ] =93
-their ASCII codes, and its ok.
Of corse still no response for ALT keys ( KEY_MENU / KEY_RMENU / KEY_LMENU )
it this way, and keys like SHIFT/ CONTROL wont work too!
printing their ASCII codes gives their numbers (for CONTROL=17 and SHIFT= 16)
But using like this:

Code: Select all

if (receiver.IsKeyDown(irr::KEY_SHIFT)  )
//................. do something........

do nothing,
(no matter if: KEY_RSHIFT, KEY_LSHIFT or KEY_LCONTROL , KEY_RCONTROL etc... )

What have I noticed is, that this key: \ + | (its just left side from BACKSPACE) and called "KEY_SEPARATE" (right?) wont work in Irrlicht too here.
What is interesting, its its ASCII code is.... 92 !

It looks like, keys with ASCII codes: 91, 92 and 93 and SHIFT, CONTROL , ALT wont work for me in Irrlicht, all other keys (even so "exotic" like Pause/Break, ScrollLock , function-keys or Numpads...) are working properly.


As I said, forget this, its not very important to me (I can use [ and ] and \ through their ASCII codes , and ALTs... oh well...


-mike

PS.
my system (win XP/SP2) is German one but my keyboard is "interational" (without any national chars, no german chars, no english pound etc.) its standard QWERTY.
Besides Irrlicht was always everything ok. ( im not sure now, but under SDL was it ok too.)
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

If you don't mind using Win32 API you can use
if (GetAsyncKeyState(VK_LMENU)<0)

oh and you can also do
if (GetAsyncKeyState(219)<0)
for [ and
if (GetAsyncKeyState(221)<0)
for ].
mike76
Posts: 14
Joined: Wed Jan 07, 2009 10:01 pm

Post by mike76 »

I added to myreceiver little function which returns the key code directly:
and now I can use like this:

Code: Select all

  if (receiver.returnCode()==221  ........  
for [ ] and |


Strange anyway, but thanks. :)

-mike
Post Reply