Monday, November 8, 2010

Clawmotia and QML: Moving the TV

Some may know that Clawmotia is my MythTV remote control which started back in the n810 days. For a bit of fun while recovering from jet lag I decided to port Clawmotia over to using QML and take advantage of some of the n900's capabilities such as the accelerometer. Shown below is controlling the playback speed by moving the device. Apologies for the flicking video, it seems mythtv doesn't like the mov file in software playback much, but the Bunny is free to use so he made the audition.

Controlling MythTV with an n900 accelerometer from Ben Martin on Vimeo.



The normal functions from the older qedje remote are also available on the main page shown in the video below. I have now put the cursor keys into a submenu which is opened by both the joystick and menu buttons, the latter first getting mythtv to open the menu and then changing the remote configuration to show the cursor key submenu. This explains the vacant positions in the grid in the new design -- submenu shuffle has given me a few extra spots to play with. Also the settings can be set in the program itself now instead of the old edit the launcher file and set environment variables. I would like to make the volume adjustment use a popup slider and also route the hardware vol +/- keys to mythtv, but I'm still working out how to do the later.

Clawmotia QML: The Qt MythTV remote control from Ben Martin on Vimeo.



Interestingly, the big "oh no" moments came when I tried to do trivial things from QML such as reading a file (the accelerometer in /sys). I would have thought that QFile was available but it seems not. Perhaps it is from dedicated javascript files or I'm just doing it wrong^TM. I also notice that the simulator doesn't update that /sys file so you have to test that on the device :/

I also bumped into other things like hooking up signals bidirectionally which would need pass by reference or similar to make it useful in custom QML elements. I might also make some data bound classes to use with QSettings, it seems like an idea for a QString like class to update the QSettings automatically when you assign new data to it.

I also tinkered in Nokias SDK environment for this but reverted to emacs and js-mode because there are just too many things my hands are used to happening that don't in the SDK editor. Though for QML stuff I suspect I need to update my elisp to have better "add property" support so the get/set/signal/member declarations are all added from a "QString foo" input. I have part of that done but need to revisit it.

2 comments:

thp said...

The simulator only simulates accelerometer data that is read by QtMobility, and using QtMobility also has the advantage of making your app more portable, as you do not have to special-case the path of the accelerometer.

The accelerometer support is in QtMobility's sensor module.

monkeyiq said...

I'll have to look more at QtMobility. Thanks for the heads up. If anyone has a link to some QML code using it that would be great, otherwise I'll poke around in due course.