Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8584641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:49:15+00:00 2026-06-11T21:49:15+00:00

I use the following code to set the sensitivity of the trackball public class

  • 0

I use the following code to set the sensitivity of the trackball

public class Main extends UiApplication {

    public static void main(String[] args) {
        Main theApp = new Main();
        theApp.enterEventDispatcher();
    }

    public Main() {
        if (Trackball.isSupported()) {
            Trackball.setFilter(Trackball.FILTER_ACCELERATION);
            Trackball.setSensitivityX(20);
            Trackball.setSensitivityY(20);
        }
        pushScreen(new LoginScreen());
    }
}

Here’s the screen used:

public class LoginScreen extends MainScreen {
    public LoginScreen() {
        super(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_VERTICAL_SCROLLBAR);
        add(...) // SOME COMPONENTS ARE ADDED HERE
    }
}

When I check the sensitivity of trackball in LoginScreen using Trackball.getSensitivityX() and Trackball.getSensitivityY() in navigationMovement, it returns “2147483647”, meanwhile if I checked it after setting it immediately in Main it returns “20” !


So I moved the setting block inside the LoginScreen itself as follows:

 public class LoginScreen extends MainScreen {
        public LoginScreen() {
            super(MainScreen.NO_VERTICAL_SCROLL | MainScreen.NO_VERTICAL_SCROLLBAR);
            if (Trackball.isSupported()) {
                Trackball.setFilter(Trackball.FILTER_ACCELERATION);
                Trackball.setSensitivityX(20);
                Trackball.setSensitivityY(20);
            }
            add(...) // SOME COMPONENTS ARE ADDED HERE
        }
    }

It also returns “2147483647” via using Trackball.getSensitivityX() and Trackball.getSensitivityY() in navigationMovement.


Finally, based on some web searches, I moved the condition inside the navigationMovement as follows:

protected boolean navigationMovement(int dx, int dy, int status, int time) {
        if (Trackball.isSupported()) {
            Trackball.setFilter(Trackball.FILTER_ACCELERATION);
            Trackball.setSensitivityX(20);
            Trackball.setSensitivityY(20);
        }
        return super.navigationMovement(dx, dy, status, time);      
    }

the problem becomes that the navigation movement jumps from field at index 0 to index 2 to index 4 … etc bypassing on field with each movement !

How to correctly set the sensitivity of trackball for a screen ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:49:16+00:00Added an answer on June 11, 2026 at 9:49 pm

    I also can’t understand this API design, in my experience these methods didn’t work. As a workaround, you can call the following methods in Screen class:

    Screen.setTrackballSensitivityXOffset
    Screen.setTrackballSensitivityYOffset
    Screen.setTrackballFilter

    With the first two methods, you can add an offset passed as parameter to the current user sensitivity. Values are in the range [-100, 100], and the special value Integer.MAX_VALUE is also allowed to set the value as “unset”. (Don’t ask me what unset means).

    Now comes the hacky part. Assuming 100 is the max value for sensitivity, if we’d like to set it to 100, we first need to obtain the difference between the desired value and the actual value. Then you set the sensitivity offset to the screen. For the sake of brevity, I’m not checking the value is in range:

    int desiredSensitivityX = 100;  //your value here
    int offsetX = desiredSensitivityX  - Trackball.getSensitivityXForSystem(); // make sure offset is not out of range
    this.setTrackballSensitivityXOffset(offsetX); //here "this" is your screen
    

    You could put that code inside the screen constructor. It only works for that screen. Once you leave that screen, the sensitivity (actually the offset) goes back to normal.

    Finally, the last method, also in screen class, allows you to set a trackball filter only for that screen. So you can put this line in your constructor:

    this.setTrackballFilter(Trackball.FILTER_ACCELERATION);
    

    and it should be back to normal after you leave your screen.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have use following code. public class InsertionExample extends Activity { private final
I use following code for guarantee startTime variable set once only: public class Processor
i am new to android development. I am use the following code to set
I use the following code: Calendar calendar = new GregorianCalendar(0,0,0); calendar.set(Calendar.YEAR, 1942); calendar.set(Calendar.MONTH, 3);
To use custom layout file in my app I'm using this following code, set
I use the following code to set an alarm. struct itimerval timer; struct sigaction
I use the following code to set markers on my map: var latLngs =
I use the following code to add cocos2d scene to a viewcontroller - (void)viewDidLoad
I use the following code to set the font for further usage in various
In my app I use the following code to set a value of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.