How to avoid the Thumb Joystick values from returning to original position

Hi

I´m new to programming in C, sorry for the bad and messy code.

I´m trying to move a square in a 32X16 LED matrix. The problem is that I can just move the square 1 pixel and then it will return to its original position.
What I want to achieve is moving the square in a direction “x” ,“y” and stay in that coordinate until I move again the thumbjoystick.

Here is the code:

#include <HT1632.h>
#include <images.h>


int mapY(int y);
int joystickY(int jy), joystickX(int jx);
int jx, mapeoX, x, jy, mapeoY, y;
int posY, posX;



void setup() {
  
  Serial.begin(9600);
  HT1632.begin(2,5,4,6);
  pinMode(3,INPUT);
  digitalWrite(3,HIGH);
  
}

void loop() {
      
    analogRead(0);
    analogRead(1);
    digitalRead(3);

    HT1632.drawTarget(BUFFER_BOARD(2));
    HT1632.clear();
    HT1632.drawImage(IMG_cuadro4X4, IMG_cuadro4X4_WIDTH,  IMG_cuadro4X4_HEIGHT, joystickX(jx), joystickY(jy));
    HT1632.render(); 
    
    Serial.print(mapY(y));
    Serial.println();
    Serial.print(mapX(x));
    Serial.println();

}
////////******************/////////////////////////////////////////////////////////////////////////////////////
int mapY(int y){
  
  mapeoY;
  mapeoY=map(analogRead(0),0,1023,0,16);    
  return mapeoY;
}

int mapX(int x){
  mapeoX;
  mapeoX=map(analogRead(1),0,1023,0,32);
  return mapeoX; 
}
////////******************/////////////////////////////////////////////////////////////////////////////////////
int joystickY(int jy){
  int i;
  int posY=1;
 
  if(mapY(y)>=8 && mapY(y)<17){ 
    
      posY=posY+(i++);
      return posY; 
    }
    else{
    
        if (mapY(y)<=6 && mapY(y)>0){
       
          posY=posY+(i--);
          return posY;
        
      }
  }
  
}  
///////******************/////////////////////////////////////////////////////////////////////////////////////

int joystickX(int jx){
  int i;
  int posX=0;
 
  if(mapX(x)>=15 && mapX(x)<17){ 
    
      posX=posX+(i++);
      return posX; 
    }
    else{
    
        if (mapX(x)<=14 && mapX(x)>0){
       
          posX=posX+(i--);
          return posX;
        
      }
  }
  
}

Any ideas ?

Thanks