def map_finger(x, y, orig_width, orig_height, map_width, map_height):
    """Map touchscreen coordinates to new axes


    reMarkable is assumed to be laying horizontally on left edge.

    Finger coordinate axes      Mapped coordinate axes
     x ---+                     +--- x
          |                     |
          |                     |
          y                     y


    Coordinates are mapped so that the entire desktop screen fits onto reMarkable


           Monitor wider than reMarkable    Monitor narrower than remarkable

       ---    +-------------------+-+          +-------------------+-+
        |     |                   |o|          |   MMMMMMMMMMMMM   |o|
        |     |MMMMMMMMMMMMMMMMMMM| |          |   MMMMMMMMMMMMM   | |
      height  |MMMMMMMMMMMMMMMMMMM|o|          |   MMMMMMMMMMMMM   |o|
        |     |MMMMMMMMMMMMMMMMMMM| |          |   MMMMMMMMMMMMM   | |
        |     |                   |o|          |   MMMMMMMMMMMMM   |o|
       ---    +-------------------+-+          +-------------------+-+

              |----- width -------|

                             M = monitor mapped area
    """
    x = orig_width - x
    ratio_width, ratio_height = (map_width / orig_width, map_height /
        orig_height)
    scaling = ratio_width if ratio_width > ratio_height else ratio_height
    return scaling * (x - (orig_width - map_width / scaling) / 2), scaling * (y
         - (orig_height - map_height / scaling) / 2)
