Dance Dance Revolution on the OLPC XO?!?

Originally published on joviko-olpc.blogspot.com January 5, 2008.

Dance Dance Revolution on the OLPC XO?!? Can it be true? Well, sort of. There’s a nice open-source DDR clone called pydance that is fairly XO-friendly. It is written in Python, doesn’t need gamer-l33t hardware to run, and gives a nice imitation of DDR.

Here’s a really lame video I shot of Pydance on the XO:

Here’s the songs I’ve created so far to use with Pydance on the XO:

I tried a few other DDR clones, and they either take a lot of work to get running on the XO, or need high-end hardware features.

I’ve created a first pass at a XO Activity that can be downloaded and installed. I would very much appreciate people trying it out and letting me know if it works for them. I don’t think it requires any software packages installed before it to run, but I could be mistaken, as my XO now has a lot of stuff installed on it, so it is hard for me to tell.

I inclulded a couple of songs and dance tracks with the Activity so you can use it right away. But that does make the download larger, over 8 MB. Both songs are now Creative-Commons licensed; the song “Wolfie” is one that I created, with profound apologies to W. A. Mozart.

The Pydance Activity “.xo” file can be installed via the standard Journal method, but for now I advise using the Terminal and doing it by hand.

Also, the installed Pydance Activity can be run from the “Activity launcher” screen, but it currently has some issues. It is better to run it from the Terminal.

So, without further ado, here is one way to get and run ‘pydance’ on the XO:

  1. Fire up wifi networking on your XO.
  2. Start up the Terminal activity.
  3. In the terminal activity, type in this:

    wget ‘http://joviko.net/download/pydance.xo’

  4. This will take a while, since the file is over 8 MB. If it finishes really quickly, you probably don’t have wifi working on your XO.
  5. Type in this:

    sugar-install-bundle pydance.xo

  6. This will also take a couple of minutes. You should see lots of information about things being extracted, inflated, created, etc.
  7. At the end, you should see:

    /usr/bin/sugar-install-bundle: ‘pydance.xo’ installed.

  8. That’s it! You’re ready to play Pydance!

Now that you have it installed, the best way to run it is from the terminal. This will take a bit of typing:

python Activities/pydance.activity/PydanceActivity.py

HINT: The Terminal program has a very handy “typing autocompletion” feature. You can just type in part of a filename or program name, and press the “tab” key (|<– over –>| on the XO keyboard). This makes typing in the above line faster (“{tab}” means “press the tab key”):

pyt{tab}{space}Ac{tab}pyd{tab}Py{tab}{enter}

When Pydance starts, it should begin by playing music and displaying a menu. (If it doesn’t do this, let me know!) The mouse cursor will disappear. You can move between the menu items with the up and down arrow keys. Go ahead and select “Play Game” by pressing the “enter” key.

On the XO, you’ll want to select a “4 panel” pad (so you can use the arrow keys on the keyboard or on the XO’s display bezel). Use the up and down arrow keys to move to “4 panel” and then press “enter”. Do this again to select “Single” mode (just one player, not two), and “Normal” (not repeating).

Another screen will appear, with the two songs that are available. Select either one using the up and down arrow keys and “enter”. You can change the difficulty level by pressing the left and right arrow keys.

Now get ready! Notice that there are 4 “empty” arrows at the top of the screen. Arrows will slide up from the bottom of the screen and fill the empty arrows. When one of the empty arrows is filled, press the corresponding arrow key on the keyboard (or on the display bezel). Repeat over and over until the song ends. You want to press the key at the exact moment that the arrow at the top of the screen is filled in. The more accurate the timing of the presses, the higher your score.

When you are done playing, press the “solid X” key in the upper-left corner of the keyboard (the Escape key). Do this several times to completely exit from the game.

NOTE: If you run Pydance from the “Activity launcher” screen, there currently are some problems:

  • The game doesn’t completely exit correctly. The icon for the game will be stuck in the “Activity ring”. To fix this, you must restart Sugar (press the “ctrl”, “alt”, and “erase” keys at the same time) which will kill ALL the Activities that are currently running, or restart the XO.
  • The game is really sluggish and stutters when the “DJ” speaks. This still happens a bit when run from the Terminal, but it isn’t nearly so bad.
  • The game’s icon isn’t quite perfect yet. Nobody ever accused me of being a great artist.

Here are some things to try if Pydance doesn’t seem to be working:

  • The “pydance.xo” file might have been corrupted during download. You can check this by running ‘md5sum’ on the file:

    md5sum pydance.xo

    The result should look like this (for the old version, no longer available):

    e50f202a82013cb3f9e752be5b6cfdce pydance.xo

    or like this (for version 2):

    df93ea251a1a1708037897434489d8c3 pydance.xo

  • It could be that the ‘sugar-install-activity’ didn’t finish right. You can try to manually reinstall Pydance from the “.xo” file like this:

    cd
    cd Activities
    unzip -o ../pydance.xo
    cd

 

Quick notes on the OLPC XO Terminal Activity

Originally published on joviko-olpc.blogspot.com January 6, 2008.

Well, I’ve realized that to really figure out what I did right / wrong to get DOSBox sound working on the XO, I’ll need to reimage the OS and start from scratch, and I’m finding all kinds of things to do to avoid going down that road just yet.

One of them is looking at the Terminal Activity as part of my process for learning how to create a good Sugar-friendly Activity. Plus I’m hoping that it might be something that I can hack into the “Sugar wrapper” that can be used to run non-Sugar-ized apps as Activities on the XO without having to put Sugar hooks into their internals. In other words, an Activity that launches from the Sugar “Activity launcher” screen, displays an icon in the “active Activity ring”, runs the non-Sugar app, then tells Sugar to remove the icon from the “ring” when the app exits. This would be very handy for Activity-izing apps like DOSBox and other emulators. And thus for running old freeware DOS and Apple programs on the XO.

Anyway, the Terminal Activity is pretty neat. The source code is very short, consisting of about 200 lines of Python. It uses a Python library called ‘vte’ to do all of the heavy lifting. ‘vte’ is, to put it mildly, a bit underdocumented. ‘vte’ is essentially a Python wrapper around the Gnome VTE widget.

So, to help others who might be curious about how the Terminal Activity does its thing, here are some handy links:

The Terminal Activity source code

earobinson’s example Python vte.Terminal window
He ordered a G1G1 XO in November, so maybe we’ll hear more from him…

The magic of Google code search lets us browse the vte source files
Of particular note: The “README” file, the “python” directory (and “python/vte-demo.py” in particular), and the sparsely populated “doc” directory.

The Gnome VTE Reference Manual
Not as useful as I had hoped, but does list out the API.

Happy hacking.

A couple of handy OLPC XO Sugar utilities

Originally posted on joviko-olpc.blogspot.com January 23, 2008.

I’ve recently been working on a few new Activities for the XO. As a result of this, I’ve discovered that there isn’t a complete set of utilities for dealing with Sugar’s internal tracking and record-keeping of Activities.

You can use the Journal Activity to install the “.xo” files for new Activities. You can use the Sugar Activity toolbar to “remove” an Activity. This removal is far from effective; it oftentimes does not actually delete the Activity’s files in /home/olpc/Activities, and just as often, it doesn’t remove Sugar’s internal record of the Activity.

You can also manually install Activities via the ‘sugar-install-bundle’ utility, which can be run from the command line in the Terminal Activity. However, if you’ve already installed and then removed an Activity, it is very likely that ‘sugar-install-bundle’ will crash, complaining that the Activity already is installed, since Sugar never deleted its internal record of the Activity. This can be very frustrating when you’re testing the installation of a new Activity, and need to remove and reinstall it multiple times.

I ended up poking around in ‘sugar-install-bundle’ (which is a Python script), and discovered that it calls some other Python modules in /usr/lib/python2.5/site-packages/sugar. These, for someone hoping to create an Activity, might be worth looking at, particularly the ones in the “activity” and “bundle” subdirectories. “…/activity/registry.py” is a particularly good one.

After all that poking, I saw the classes and functions needed to list all of the Activities that Sugar currently is aware of. These are stored in Sugar’s registry (a binary database similar in use to the registry under Windows). I also saw how to remove the entry for a specific Activity from the Sugar registry.

Each entry has a name (e.g. “Sonata”), an icon, a “bundle ID” (“com.ywwg.Sonata”), an installation path (“/home/olpc/Activities/sonata.activity”), a command to launch the Activity (“sugar-activity SonataActivity.SonataActivity”), and a show-launcher indicator.

The Activities appear to be accessed and referred to by their installation paths, rather than their names or bundle IDs (which is a bit surprising to me, but using the path as the primary access key may allow both the names and IDs to be non-unique).

I’ve created a couple of handy utilities, ‘sugar-list-bundles’ and ‘sugar-forget-bundle’. Both are short Python scripts, and can be run from the Terminal Activity’s command line. They can be downloaded in a “.zip” file from here.

‘sugar-list-bundles’ doesn’t take any arguments. It just dumps out the info on all the Activities currently listed in the Sugar registry. It lists the name, ID, path, and command for each Activity. To run it from the command line (assuming you’ve unzipped the utilities into the current directory):

./sugar-list-bundles

‘sugar-forget-bundle’ takes one argument, the name of an Activity. This name must exactly match one of the names dumped out by ‘sugar-list-bundles’ for ‘sugar-forget-bundle’ to be able to use it. ‘sugar-forget-bundle’ will remove the Activity’s record from the Sugar registry. It will NOT delete the directories or files associated with the Activity. For example:

./sugar-forget-bundle Sonata

will cause Sugar to “forget” that the Sonata Activity is installed. It will NOT remove /home/olpc/Activities/sonata.activity or any of the files under it.

I’m sure there must be equivalents to these two utilities floating around (especially around the OLPC XO development team), but I haven’t stumbled across them. I hope you find them handy.