First you would want to contain the bird to a small crate or box so it can't move around much and get some rest. Then if you suspect a leg injury such as dislocation, your bird should be seen by a veterinarian right away.
My best advice is to please take it to an Avian Vet. They can do a further diagnoses on the leg to see if it is dislocated and if there are any further problems with the leg or bird. I can only imagine this is not pleasant for the bird or you. Good luck.