There are several threads on this forum about this stuff. In short, camera motion can be detected from image stabilization sensors (on cameras which have them), and some of it has already been proven to work but doesn't exist in CHDK trunk builds yet.
The orientation sensor on the other hand is not suitable for this purpose (unless your motion happens to be spinning the camera around randomly), as it only has a few discrete states.