Convert accelerometer data into mouse coordinates.

I am using an acceleormeter mpu6050 with my Arduino Uno to make an accellerometer controlled mouse.
I have the acclerometer values in the x, y and z directions. I need to calculate the distance travelled by the accelerometer and convert it to coordinates for my mouse pointer.

void loop() 
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  int vx = map(ax, -20000, 20000, 90, -90);
  int vy = map(ay, -20000, 20000, 90, -90);

I am using the getMotion() function to get the acceleration in x and y direction every 10ms.

What I need to do now is the detect a change in the acceleration in x or y direction and after calculating the distance travelled change the mouse pointer location using another program.

I am unable to find any source that would tell me how to do that. Please let me know how the distance can be calculated. For now i only want the updated cursor position and will factor in the mouse angle later.
Thank you in advance for any help you can provide.

To get from acceleration values to position values generally requires double numerical integration. The results using an Arduino class IMU have not shown good results. The low measurement values coupled with drift and noise quickly produces false results. Before tackling this project, you should familiarize yourself with the physics and mathematics in this link.

You certainly could threshold the response on the acceleration value so that a stationary device cannot
drift, and use that to recalibrate. You would need two modes - one where the acceleration is close to
zero, and you then deem it to be zero, and cause the velocity value to decay towards zero (gliding stop).

The other mode, when the accelerometer is thrashing around you double-integrate to maintain velocity and