This week was a bit better than usual. I spent about half the time not being very productive, and the other half being about twice as productive as usual, so I guess it all averaged out. Mostly I spent a lot of time tweaking the look and feel of the Java version of Sprung (which will be changing its name again) and doing various compatability testing and locking down our target platform. I'd gone to great pains to keep it MIDP-1.0 compatible, but because it doesn't run on any MIDP-1.0 phones anyway (the few phones which will even take a 200K .JAR all spontaneously quit while the first level is loading, without any sort of error message, when I have a pretty intense error-catching framework now) today we decided to just switch to MIDP-2.0 as the base target since it lets us do some other stuff that we were not doing before.
For example, the way you access the softkeys in MIDP-1.0 is fucking retarded. The only proper, non vendor-specific way is by binding command actions to the display canvas, and since MIDP's command actions are done as a semantic toolkit thing, you can't really predict what will happen. On some phones it just binds the action which is what we wanted, but on most of them it instead binds a generic menu which then pops up and lets the user select the menu or to quit the app. Very ugly. And on Series 40, it's even worse — it binds the menu to the select key instead of the softkey! Very retarded.
MIDP-2.0 is still pretty retarded, though. MIDP doesn't specify specific keycodes for all keys so you have to use static class members which are initialized in the class initializer, which is a good way to do it, except the
GameCanvas class still doesn't specify any keys other than the number keys and the directional pad. (Which is a step up from MIDP 1's
Canvas, which only specifies the number keys, and provides a semantic equivalence mapping from which you can access the directional pad through a stupid layer of indirection which makes some things really hard to keep track of due to the lack of typed enums in Java.) Fortunately, it's easy enough to just query the semantic mapping about a key and if it says "I dunno" just assume it's a softkey; unfortunately, deciding what to map it to is difficult because you can't guarantee any range of keycode bindings since every vendor does it differently.
So what I ended up doing was just scanning keycodes from -65536 to 65535 until it finds one that the semantic layer goes "I dunno" to. Fortunately I don't foresee many phones using all 131072 keycodes in that range, but you never know... it also assumes that
getGameAction will return 0 and/or throw
IllegalArgumentException for an unknown value, when strictly-speaking a phone could return -1 or whatever. (The spec says that the phone is supposed to throw
IllegalArgumentException but Nokia phones don't.)
So anyway, next week might be interesting, or stressful, or whatever. But my wrists need a break from typing so I think I'll spend the weekend working on music or something instead. (I am loving the hell out of Logic 7. Also the controller I just bought came with a scaled-down version of Reason which I hope is still ReWire-enabled because if it is, I can use it with Logic too. I'm still not sure if I want to buy Logic Express or Logic Pro, though — Express does everything I need but Pro does a hell of a lot of stuff I want!)