×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    17

    Detecting joystick movements, Basic questions

    Hi, I am developing a synchronisable organiser, but can't seem to find any documentation for event detection of joystick movement, specifically LEFT and RIGHT movements.
    e.g for detecting SELECT I would use:

    public void commandAction(Command c, Displayable s)
    {
    else if (c == List.SELECT_COMMAND)
    {
    }
    }

    Is there an equivalent constant to SELECT_COMMAND that enables be to detect Left or Right joystick movements?

    Alternatively where can I find documentation on the APIs involved in this?

    Many thanks for any light shedded on this!

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Tampere / Finland
    Posts
    201
    Hello,

    In MIDP 1.0 High Level UI, all the components are framed and developers can't personalize their own UI components, detecting joystick movemont is not supported. In Low Level UI, developers can use keyPressed(int keyCode) to detect the Right softkey or Left softkey, here is the example code from sun WTK:

    public void keyPressed(int keyCode) {

    int action = getGameAction(keyCode);

    switch (action) {
    case LEFT:
    // Reduce the number of threads
    if (numBalls > 0) {

    // decrement the counter
    numBalls = numBalls - 1;

    // stop the thread and remove the reference to it
    balls[numBalls].stop = true;
    balls[numBalls] = null;
    }
    break;

    case RIGHT:
    // Increase the number of threads
    if (numBalls < balls.length) {

    // create a new ball and start it moving
    balls[numBalls] =
    new SmallBall(this, 0, 0, width, height-12-20);
    new Thread(balls[numBalls]).start();

    // increment the counter
    numBalls = numBalls + 1;
    }
    break;

    case UP:
    // Make them move faster
    SmallBall.faster();
    break;

    case DOWN:
    // Make them move slower
    SmallBall.slower();
    break;
    }
    repaint();
    }

    Regards,
    Kui

Posting Permissions

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