1. A method performed in a portable electronic device, the method comprising: controlling how hardware sensor output is available to a process resulting from execution of a software application by a processor of the portable electronic device, as follows: providing samples of the hardware sensor output sampled during time periods throughout which the process is running in foreground to the process at a sampling rate higher than a threshold; and providing samples of the hardware sensor output sampled during time periods throughout which the process is running in background to the process at a sampling rate lower than the threshold, wherein the hardware sensor output is indicative of orientation or motion or both of the portable electronic device within an environment, and the hardware sensor output is produced by a hardware sensor integrated in the portable electronic device, wherein the portable electronic device comprises a hardware user-input component integrated in the portable electronic device, the hardware user-input component having multiple elements operable to accept user input through touch, and wherein the process runs in the foreground during times when an operating system of the portable electronic device is operable to notify the process of any detected first touch events involving the elements, and the process runs in the background during times when the operating system is operable not to notify the process of any detected second touch events involving the elements.