Best way to emulate a rotary encoder wheel?

or something like this