0

How to decrease sensitivity of onTouch ? I have a custom remote with a virtual touch pad on it. The problem is that when I move finger over the touch pad the mouse cursor moves very fast. So is there a way to decrease that movement speed ?

I have googled the problem and in some articles there is written that it is possible only if the phone is rooted.

public void onTouch(View v, MotionEvent event) {
    KeyImageView mKeyImageView= (KeyImageView)v;
    int width = mKeyImageView.getWidth();
    int height = mKeyImageView.getHeight();
    Log.d(TAG,"onTouch:"+width+" "+height+" "+RemoteIME.mService.getWidth()+" "+RemoteIME.mService.getHeigt());
    int touch_x = switchTouchXY((int)event.getX(), width, RemoteIME.mService.getWidth());
    int touch_y = switchTouchXY((int)event.getY(), height, RemoteIME.mService.getHeigt());
    Touch mTouch = new Touch(RemoteIME.mService, event.getAction(), touch_x, touch_y);
    sendCmdMessage(SendThread.CMD_SEND_TOUCH, 0, 0, mTouch);
}

public int switchTouchXY(int touch, int source, int target) {
    return (touch * target / source);
}
abrutsze
  • 496
  • 1
  • 8
  • 24
  • 3
    Why can't you scale the coordinates/deltas yourself in `onTouch()`? I'm not sure why you'd wanna try to change that at the system level. – Mike M. Jan 16 '18 at 06:00
  • Mike M, thanks for a response! Can you give a little bet more information or an example, please ? – abrutsze Jan 16 '18 at 06:07
  • 1
    Um, not really. I mean, nothing really specific. I assume you're somehow passing the `MotionEvent`'s x and y, or maybe their deltas, to whatever's controlling your mouse cursor. Surely there's some relatively simple math you can do on the (x,y)/deltas (however you're handling it) before you hand that off, yeah? – Mike M. Jan 16 '18 at 06:19
  • Hello @abrutsze You can Tracking Touch and Pointer Movements. https://developer.android.com/training/gestures/movement.html – Vrushali Raut Jan 16 '18 at 06:31
  • Hello, Vrushali Raut. Yeap, but the problem is that I don't really understand how to decrease the speed. Please wait a second I'll attach my code. – abrutsze Jan 16 '18 at 06:35
  • Vrushali Raut, Mike M, can you have a look on my code, please. – abrutsze Jan 16 '18 at 06:39
  • 1
    Mike M, I just get what you want to say and that solved my problem :) Thank you !!! – abrutsze Jan 16 '18 at 07:05

0 Answers0