Hi,
Can we identify keypad type of device using j2me (without calling any key pressed of canvas)?
Please tell me if there is any direct or indirect way for this.
Thanks in Advance,
William
Hi,
Can we identify keypad type of device using j2me (without calling any key pressed of canvas)?
Please tell me if there is any direct or indirect way for this.
Thanks in Advance,
William
There are many varieties of keypad, and no way to tell which you have.
I have spent much time searching solution for the problem. See this:
http://discussion.forum.nokia.com/fo...d.php?t=146480
There may be other reasons you want to know about the keypad. Games programmers, for example, may want to know the layout of the directional or numeric keys.
As examples:
A Nokia 3510i and its variants have only a two directional dpad, not four. Some devices have a four-way pad, but with no centre-click. Some Blackberry devices have a trackball instead of a pad.
Sony Ericsson devices have a specialised "back" key, which gets attached to certain kinds of Command object (rather than a softkey).
Some games use numeric keys for direction (especially if eight directions are required. This is a problem on devices like the Nokia 3650, Nokia 7600 or Siemens SX1, which do not have the conventional numeric layout. Similarly, some devices with QWERTY keyboards have the numeric keys in a conventional layout embedded in the QWERTY keys, while others have a separate numeric row.
Softkeys can vary in number, and can be at the bottom of the screen or the side. User interface convention can vary ("select" on the left for Nokias or on the right for some Motorolas).
And so on.
These don't necessarily have the same impact as QWERTY/numeric, but they can affect usability and user documentation.
The purpose of this for me is that I want to make a Textbox for user input on canvas (don't know about purpose of swaroopprajapat). So the "layout" of keys doesn't matter. What matters is that for which key press, what ASCII value is passed to keyPressed event. Lets say ASCII value 50 is passed to keyPressed twice and that too very fast. Now, on Numeric keypad this should put "b" on Textbox while on QWERTY keypad, this should put "22". Considering this purpose, I think there are only 3 types of keypad:
I don't know anything about QWERTY keypad with 2 keys on single button.
If you know anything regarding this topic, please post...
I don't think there is any standardized way (like properties) to get to know this. It's so much unsupported that all documentation says that you shouldn't use anything but native components (i.e. not Canvas based ones) for input. But that is of course crazy these days.
What you can do is that you can actually query the device type/platform and dynamically configure your application based on that. You could include several implementations and/or configurations for the key mappings, but it shouldn't be that bad as most of the devices will have the numeric keypad and you only need to handle the few qwerty ones.
These are SonyEricsson phones, like the P1 or the m600i. They have two keys on one physical button but your software shouldn't be concerned because there are actually two micro switches per button. So indeed it's just a way to spare on physical space but still it has a separate hardware key for every single letter. (The buttons can be pressed on the left or the right side.)I don't know anything about QWERTY keypad with 2 keys on single button.
Thanks atleta. Hope same is the case with phones of other companies like Blackberry
After lots & lots of trial & error, I got one way to find out whether keypad is Numeric or QWERTY. Please let me know if this will work on all phones or not...
It works on Nokia 2626 (Numeric) as well as on Nokia E61i (QWERTY)Code:if((MyCanvas.getGameAction(48) == 0) && (MyCanvas.getGameAction(49) == 0) && (MyCanvas.getGameAction(50) == 0) && (MyCanvas.getGameAction(51) == 0) && (MyCanvas.getGameAction(52) == 0) && (MyCanvas.getGameAction(53) == 0) && (MyCanvas.getGameAction(54) == 0) && (MyCanvas.getGameAction(55) == 0) && (MyCanvas.getGameAction(56) == 0) && (MyCanvas.getGameAction(57) == 0)){ //QWERTY Keypad; } else{ //Numeric Keypad; }
Nice hack, but I think you'd have to test on all devices or at least read the developer documentation for them anyway. You can't be sure of anything.
I don't know what you mean. Yes, you can identify blackberries and once you did, you can use your specific strategy. You may want to have a look at lwuit.dev.java.net. That's a 'lightweight' (i.e. pure java, non-native) GUI toolkit and they do provide editable components like text fields, etc. I haven't tried them on a qwerty phone yet (I have a blackberry), but it quite probably works.Hope same is the case with phones of other companies like Blackberry
Hi,
I tested this on Sony 990 and it didn't work for that. But I guess I found the correct way of doing that:Code:if((MyCanvas.getGameAction(48) == 0) && (MyCanvas.getGameAction(49) == 0) && (MyCanvas.getGameAction(50) == 0) && (MyCanvas.getGameAction(51) == 0) && (MyCanvas.getGameAction(52) == 0) && (MyCanvas.getGameAction(53) == 0) && (MyCanvas.getGameAction(54) == 0) && (MyCanvas.getGameAction(55) == 0) && (MyCanvas.getGameAction(56) == 0) && (MyCanvas.getGameAction(57) == 0)){ //QWERTY Keypad; } else{ //Numeric Keypad; }
I tested this on Sony 990 and it worked fine, I hope it should work for you also.Code:protected static boolean isNumericKeyPad() { try { for (int i = 65; i < (65 + 26); i++) { MyCanvas.getKeyName(i); } if(MyCanvas.getGameAction((int)'A') == Canvas.LEFT && MyCanvas.getGameAction((int)'D') == Canvas.RIGHT && MyCanvas.getGameAction((int)'W') == Canvas.UP && MyCanvas.getGameAction((int)'Z') == Canvas.DOWN) { return false; } return true; } catch (Exception e) { return true; } }
Thanks for giving replays.
Swaroop
Last edited by swaroopprajapat; 2009-01-01 at 06:07.