Which Joystick Pressed UI Button

So I need to find out which joystick pressed a UI button .

something like…

onClick(Input name){

Debug.Log(name+" clicked" + gameobject.name); //  "joystick 1 clicked Button1"
}

Will I found a good solution (as far as I know) , attach this script on the Button.
We are checking where (position) the event system is selecting with the Button’s own position, if they are the same it means we are clicking on the button that has this script.

if someone has any notes or improvements please let me know. I only tested this with one PS4 controller ( I only have 1) .

 private void Update()
    {
 

        thisPosition = EventSystem.current.currentSelectedGameObject.GetComponent<Transform>().position;

      Debug.Log(thisPosition.Equals(myPos));

        //For Player1
        if (Input.GetButton("PS4_X_P" + playerImages[0].playerNoImg) && (thisPosition == myPos))
        {
            playerImages[0].GetComponent<Image>().sprite = buttonImage.sprite;
            Debug.Log(buttonImage.name);
        }

        //For Player2 
        if (Input.GetButton("PS4_X_P" + playerImages[1].playerNoImg) && (thisPosition == myPos))
        {
            playerImages[1].GetComponent<Image>().sprite = buttonImage.sprite;
            Debug.Log(playerImages[0]);


        }

    }