are you saying subtract 1023 from X?
No. Subtract x from 1023.
If you swap X and Y, X now ranges from from 0 to 1023 (1 to 3). To make the values range from 1023 to 0 (3 to 1) instead, subtract the value from 1023. 1023 - 0 = 1023. 1023 - 1023 = 0.
Lets use some variables to make this clear. You have hMin and hMax for the horizontal axis, and vMin and vMax for the vertical axis.
The points on the initial diagram:
1 = hMin, vMin
2 = hMax, vMin
3 = hMin, vMax
4 = hMax, vMax
You want the points to be:
3 = hMin, vMin
1 = hMax, vMin
4 = hMin, vMax
2 = hMax, vMax
You have some reading h, v. h increases down the screen, and v increases to the right. You want the values to increase to the right, and down the screen.
int h, v;
// Swap h and v
int temp = h;
h = v;
v = temp;
If h is 0 and v is 0 (point 1 on view 1), which you want to become hMax, vMin (point 3 on view 2). v is already vMin, but h is at the opposite end of the scale, so h needs to be set to hMax - h.
If h is 1023 and v is 0 (point 2 on view 1), which you want to become hMax, vMax (point 2 on view 2), but v is at the opposite end of the scale, so v needs to be set to vMax - v.
So:
h = hMax - h;
v = vMax - v;