×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    61

    MIDP1.0: Which (Nokia) phone support 'multiple' keypresses?

    Code using the MIDP1.0 implementation on my Nokia 3650 can track multiple key-presses by keeping track of keyPressed() and keyReleased() call-backs:
    (in pseudo-codes)

    Press key 1: keyPressed(key1) is called
    (only key 1 is pressed)
    Press key 2: keyPressed(key2) is called
    (both key 1 and key 2 are pressed now)
    Release key 1: keyReleased(key1)
    (only key 2 is pressed)
    etc...

    This is my question: Which Series40/Series60 phones have the same behaviour?
    I can not test it on the SDKs, since keypresses can only be done by using the computer's mouse on the emulators... and i have only one.. :-)

    I need this functionality for an app that uses the pound-key as a kind-of 'SHIFT' key-modifier.

    Thank you very much!

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    It's not what device, but what firmware. I had a 3510i that didn't support multiple keypresses (v.3.xx, I can't remember exactly), and then I changed it to one with a newer firmware (v.4.44) and it did support multiple keypresses.

    shmoove

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    3

    Every Phone supports this

    Hi,

    there are some things to redesign, but it isn't realy difficult. You just have to take an array to save your key states and some variables to find your keys in your array again.

    int MyKeys array[2] = { 0 , 0 }; // state 0 = released, 1 = pressed
    int left = 1;
    int fire = 2;

    You have to use keyPressed and keyReleased. So, if you get a keyPressed event you just switch the keyState to pressed an on keyReleased to unpressed.

    public keyPressed (int keyCode) {
    switch (keyCode) {
    case Canvas.LEFT:
    MyKeys[left] = 1;
    case Canvas.FIRE:
    MyKeys[fire] = 1;
    }
    }

    public keyReleased (int keyCode) {
    switch (keyCode) {
    case Canvas.LEFT:
    MyKeys[left] = 0;
    case Canvas.FIRE:
    MyKeys[fire] = 0;
    }
    }

    And in your mainloop you decide what to do:

    while () {
    if (MyKey[left] == 1)
    XX.turnleft();

    if (MyKey[fire] == 1)
    XX.fire();
    }

    I hope, this could help. I am just starting with Java and I don't know the Syntax exactly.

    hf Motte

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    Yeah, that's the coding alright, but some firmware versions of some phones won't fire the second keyPressed() if a key is already pressed. In that case there's really not much you can do, no matter how you code it.
    If you write a game that depends on something like that to work properly, then you'll be losing many users with the older phones. You have to code defensively.
    A good example of that defensive coding is MotoGP. There is an option in the settings menu to have automatic breaking and accelerating. Without that option playing on a phone that doesn't support multiple keypresses is almost impossible, since you won't be able to accelerate/break and turn at the same time. Another example are many shooters where there is an autofire option, again, with the same logic that on older phones you won't be able to shoot and move simultaneously without it.

    shmoove

  5. #5
    Regular Contributor
    Join Date
    Apr 2003
    Posts
    61
    Thanks guys for your answers.

    I'll design the MIDlet to be able to use both, with a setting to provide an alternative not to use it. The user-interface will be a bit more 'awkward' without the ability to use double key presses but still functional.

    Have a happy new year !
    Gelukkig Nieuw Jaar!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •