I looked over your code and compared it to mine and it seems your missing this function.
ps2x.read_gamepad(false, 0);
Add that function in your loop().
I looked over your code and compared it to mine and it seems your missing this function.
ps2x.read_gamepad(false, 0);
Add that function in your loop().