Character leaning while running?

So pretty much I want my character to change animation based on the way he is turning, I’m using a joystick and was wondering hows the best way to detect when he is moving left or right or just moving forward. I was originally getting the angle of the character and comparing to the angle he was in the previous tick but it turns out to be pretty stutterery and weird. This is what I got atm.

As you can see its pretty bad. I also need to stop the arms flailing after he exits the state.

I think* you can use linear velocity to tell which direction it is moving

btw nice character designs

At each frame you determine how the objects direction gets changed (by evaluating the users input). Would it make sense to use this input (or its outcome) to calculate the leaning too?

S̶o̶ ̶I̶ ̶t̶h̶i̶n̶k̶ ̶i̶ ̶m̶i̶g̶h̶t̶ ̶j̶u̶s̶t̶ ̶t̶r̶y̶ ̶i̶t̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶j̶o̶y̶s̶t̶i̶c̶k̶ ̶i̶n̶p̶u̶t̶ ̶i̶n̶s̶t̶e̶a̶d̶ ̶o̶f̶ ̶t̶h̶e̶ ̶a̶n̶g̶l̶e̶ ̶t̶h̶e̶ ̶p̶l̶a̶y̶e̶r̶ ̶i̶s̶ ̶f̶a̶c̶i̶n̶g̶ ̶a̶f̶t̶e̶r̶ ̶t̶h̶e̶ ̶c̶a̶l̶c̶u̶l̶a̶t̶i̶o̶n̶ ̶t̶h̶e̶ ̶j̶o̶y̶s̶t̶i̶c̶k̶ ̶i̶n̶p̶u̶t̶.̶ ̶W̶i̶l̶l̶ ̶a̶l̶s̶o̶ ̶m̶a̶k̶e̶ ̶a̶ ̶s̶o̶r̶t̶ ̶o̶f̶ ̶d̶e̶a̶d̶z̶o̶n̶e̶ ̶a̶s̶ ̶t̶h̶e̶ ̶j̶o̶y̶s̶t̶i̶c̶k̶ ̶w̶i̶l̶l̶ ̶n̶o̶t̶ ̶a̶l̶w̶a̶y̶s̶ ̶b̶e̶ ̶c̶o̶m̶p̶l̶e̶t̶e̶l̶y̶ ̶s̶t̶r̶a̶i̶g̶h̶t̶ ̶w̶h̶e̶n̶ ̶h̶e̶ ̶i̶s̶ ̶r̶u̶n̶n̶i̶n̶g̶ ̶f̶o̶r̶w̶a̶r̶d̶,̶ ̶(̶p̶r̶o̶b̶a̶b̶l̶y̶ ̶l̶i̶k̶e̶ ̶a̶ ̶.̶2̶ ̶g̶r̶e̶a̶t̶e̶r̶ ̶t̶h̶a̶n̶,̶ ̶l̶e̶s̶s̶ ̶t̶h̶a̶n̶ ̶s̶o̶r̶t̶a̶ ̶t̶h̶i̶n̶g̶)̶ ̶f̶o̶r̶w̶a̶r̶d̶ ̶c̶o̶u̶l̶d̶ ̶a̶l̶s̶o̶ ̶b̶e̶ ̶l̶e̶f̶t̶ ̶r̶i̶g̶h̶t̶ ̶u̶p̶ ̶o̶r̶ ̶d̶o̶w̶n̶,̶ ̶d̶e̶p̶e̶n̶d̶i̶n̶g̶ ̶o̶n̶ ̶t̶h̶e̶ ̶c̶a̶m̶e̶r̶a̶.̶

still using the angle but * by 10 to get a nicer number that does jitter to fast. MY current problem now is this.

if ang < player["playerAng"]:                
                player["playerDir"] = "Left"
elif ang > player["playerAng"]:
                player["playerDir"] = "Right"

How would I get the direction to just be forward?