Accelerometer
The accelerometer appears to be a "KXSD9 SERIES Tri-Axis, 2g, 4g, 6g, 8g, User Selectable, Ultra Low Power Digital" http://www.kionix.com/accelerometers/accelerometer-KXSD9.html
<source lang="text"> root@castle:/sys/class/input/input5# cat name kxsd9_accelerometer </source>
more info: <source lang="text"> root@castle:/sys/class/input/input5# cat uevent PHYSDEVPATH=/class/i2c-adapter/i2c-3/3-0018 PHYSDEVBUS=i2c PHYSDEVDRIVER=kxsd9_accelerometer PRODUCT=18/1/1/100 NAME="kxsd9_accelerometer" EV==9 ABS==7 MODALIAS=input:b0018v0001p0001e0100-e0,3,kra0,1,2,mlsfw </source>
and at the very least you could adjust the low pass filter used, or the threshold for waking up:
<source lang="text"> root@castle:/sys/class/input/input5# ls -al drwxr-xr-x 6 root root 0 Jun 11 17:47 . drwxr-xr-x 8 root root 0 Jun 11 17:47 .. -rw-r--r-- 1 root root 4096 Jun 11 23:58 accelerometer_filter_frequency -rw-r--r-- 1 root root 4096 Jun 11 23:58 accelerometer_motion_wake_up_threshold drwxr-xr-x 2 root root 0 Jun 11 23:58 capabilities lrwxrwxrwx 1 root root 0 Jun 11 23:58 device -> ../../../class/i2c-adapter/i2c-3/3-0018 drwxr-xr-x 3 root root 0 Jun 11 23:49 event5 drwxr-xr-x 2 root root 0 Jun 11 23:58 id lrwxrwxrwx 1 root root 0 Jun 11 23:58 input:event5 -> ../../../class/input/input5/event5 -r--r--r-- 1 root root 4096 Jun 11 23:58 modalias -rw-r--r-- 1 root root 0 Jun 11 23:50 mode -r--r--r-- 1 root root 4096 Jun 11 23:53 name -r--r--r-- 1 root root 4096 Jun 11 23:58 phys -rw-r--r-- 1 root root 4096 Jun 11 23:58 poll_interval drwxr-xr-x 2 root root 0 Jun 11 23:58 power lrwxrwxrwx 1 root root 0 Jun 11 23:58 subsystem -> ../../../class/input -rw-r--r-- 1 root root 4096 Jun 11 23:58 uevent -r--r--r-- 1 root root 4096 Jun 11 23:58 uniq </source>
More accelerometer info
There's a library called libhidaccelerometer.so -- so it's treated as an HID class of devices. There is no dbus activity when you move the device, so this probably a much lower level service. Makes sense: you don't want zillions of dbus messages firing off whenever someone moves.
Looking in running processes, I notice /usr/bin/hidd, which references a configuration file /etc/hidd/HidPlugins.xml
In this file, two sockets are mentioned: /var/tmp/hidd/AccelerometerCmdSocket /var/tmp/hidd/AccelerometerEventSocket
These are UNIX DGRAM sockets, which are open on the device.
Sample code
Taken from boydell's Magic 8 Ball app:
In his first-assistant.js (... = code skips) <source lang="javascript"> ...
this.controller.listen(this.controller.sceneElement, Mojo.Event.tap, this.handleTap.bind(this)); this.controller.listen(document, 'shakestart', this.handleShakeStart.bind(this)); this.controller.listen(document, 'shaking', this.handleShaking.bind(this)); this.controller.listen(document, 'shakeend', this.handleShakeEnd.bind(this));
... FirstAssistant.prototype.handleShakeStart = function(event) {
this.setBall(); this.hideMessage(); Event.stop(event);
}
FirstAssistant.prototype.handleShaking = function(event) {
this.setBall(); this.hideMessage(); Event.stop(event);
}
FirstAssistant.prototype.handleShakeEnd = function(event) {
this.showRandomMessage(); Event.stop(event);
</source>
To increase the resolution to 30Hz, use this snippet (requires WebOS 1.3.5 or above):
<source lang="javascript">
this.controller.stageController.setWindowProperties("fastAccelerometer");
</source>