Green’s Dictionary of Slang

dotty adj.

[orig. dial; phr. dotty on one’s pins, unsteady on one’s legs and thence in one’s brain + ? link to dot and carry one n.]
[late 19C+]

1. of a human, unstable, unsteady on one’s feet; of an animal, lame.

2. (also dotty in the dome) eccentric, odd; thus dottiness, eccentricity; dotty homestead, dotty house, a pyschiatric institution.

3. usu. constr. with preps. on/over, in love with, desirous of.

In phrases

off one’s dotty (also off one’s dot)

[late 19C–1920s] mad, eccentric.