   float accelX = clamp(accel.acceleration.x, accelMin, accelMax);
   float accelY = clamp(accel.acceleration.y, accelMin, accelMax);
 
+  // calibrate for the first five loops
   if (calibrationCounter > 5) {
   
+    // Reversing the direction of inputs
     if (accel.acceleration.x < xRange[0] || accel.acceleration.x > xRange[1]) {
-      mx = map(accelY - yNormal, accelMin, accelMax, outMax, outMin);
+      mx = map(accelY - yNormal, accelMin, accelMax, outMin, outMax);
     }
     
     if (accel.acceleration.y < yRange[0] || accel.acceleration.y > yRange[1]) {
-      my = map(accelX - xNormal, accelMin, accelMax, outMax, outMin);
+      my = map(accelX - xNormal, accelMin, accelMax, outMin, outMax);
     }
-  
+
     Mouse.move(mx, my, 0);
   }
   else {



void touchHandler(int id) {
  Serial.print(id); Serial.println(" touched");
  
  switch(id) {
    case MOUSE_LEFT_PIN:
      Mouse.press(MOUSE_LEFT);
      break;
    case MOUSE_MID_PIN:
      Mouse.press(MOUSE_MIDDLE);
      break;
    case MOUSE_RIGHT_PIN:
      Mouse.press(MOUSE_RIGHT);
      break;
  }
}


void releaseHandler(int id) {
  Serial.print(id); Serial.println(" released");
    
  switch(id) {
    case MOUSE_LEFT_PIN:
      Mouse.release(MOUSE_LEFT);
      break;
    case MOUSE_MID_PIN:
      Mouse.release(MOUSE_MIDDLE);
      break;
    case MOUSE_RIGHT_PIN:
      Mouse.release(MOUSE_RIGHT);
      break;
  }

  
  // Set a max and min value to not do anything
  sensors_event_t accel, mag, gyro, temp;
  lsm.getEvent(&accel, &mag, &gyro, &temp);
}


