Update 17 July 2010: Simple application added
The phone can be locked to the landscape orientation by simulating the HW keyboard slide-out, while the keyboard can be actually slid-in.
sendevent /dev/input/event4 5 0 0
It can be useful e.g. when using the Milestone as a navigation device in the car dock while driving on a bumpy road to prevent an accidental switch to the portrait mode.
A slide-in can be simulated this way:
sendevent /dev/input/event4 5 0 1
Or you can actually slide the keyboard out and in when you no longer need the lock.
You can use the simple application attached below. When run, it will simulate the slide-out. To unlock the landscape orientation afterwards, you can simply slide-out and -in the HW keyboard.
The application needs su rights.