Saturday, December 11, 2004

5way nav et al-fighting the button-o-rama

Recently, more and more licencees start to integrate the five-way navigators that were introduced with OS5. In addition, the licencees always could introduce their own hardware buttons. While users enjoy the flexibility of the extra knobs, developers have to wrestle with different keycodes that can only be obtained in the licencee's SDKs. It's the usual thing in Palmieland-the tech is here, but where is the standard/who implements it?
This article will present you with a few hints to "improve your odds" when hardware buttons are concerned!
1)Harness the switch, dude
Most developers know switch as universal solution to problems where multiple choices need to be handled. Less developers know that the break; following the end of each case statement can be omitted-the program will compile o.k. However, the switch block will not be exited. The code of the cases below will get executed until the block ends or a break; is found. Now, lets say that one licencee defines a buttons keycode as 1101, the other as 1102. The following switch(its pseudocode) would handle both the same:
switch(keycode)
{
case 1101:
case 1102:
HandleButton();
break;
//Other buttons
}
2)Let the user select the buttons
Some developers have found a really innovative solution for the problem. Since keycodes stay the same for the whole lifetime of a device, they can be stored as application preferences. When the app starts for the first time, a special form pops up requesting the user to press the hardware button he wants to assign(and a cancel button if he "runs out" of buttons). The form's event handler traps and handles the keydownevents and stores the keycodes in the preferences(see the Palm OS documentation/the datebook sample for details).
Then, when a real keydownevent is encountered, the input is compared with the stored values. However, if must be used for the comparation, as switch expects constants.

Tell me how you solve your button-related events. I am looking forward to a lively discussion!

8 Comments:

Blogger Steven Fisher said...

I know this is a bit off topic, but... this is also valid C, and is an error I keep making in my code. It compiles away to nothing:

switch (I)
{
1112:
1113:
// do something
1114:
// do something
break;
}

What's wrong? The word "case" is missing.

Anyway, back on topic...

How much of a problem are differnet button codes? After all, there are only so many vendors out there, and they've standardized going forward haven't they?

3:03 PM  
Blogger Tam Hanna said...

Hi,
mailing me about C is never ever off topic-it always helps me learn.
BTW, I think that your error is different. There must be at least one case in the switch block. The Rest of the Code is considered Goto Labels…

The button stuff can be quite a fuzz, look at McPhlings Sources for more information about how many different SDKs had to be included only for the buttons sake. While standardisation is definitely going on, it won’t help with the many devices that already exist. A ROM update would be required to change the buttons, and I don’t really believe anything like this is gonna happen soon.
Thanks for the comment..
With best regards
Tam Hanna

3:08 PM  
Blogger Steven Fisher said...

My point was just that it compiles without an error. Or even a warning. So if you're an old Pascal programmer like me, you're going to get nailed by that language difference. Looking at the code and your explanation, you're almost certainly right. And knowing that will hopefully help me remember to include the "case" keyword. I'm getting better at it, but I still remember the first time it took me over five hours to work out what was wrong with my code. I was assuming it was a logical problem, not a syntax one...

I'll check out the McPhling code. I have to admit I've been a bit lazy about button codes in the past -- I figure if it works the PalmOne-branded devices it's reaching almost all of the market. I'm trying to do better with this application, though. The market is actually getting interesting, and there seems to actually be compelling reasons to buy a non-PalmOne unit now.

3:22 PM  
Blogger Tam Hanna said...

Hi,
Well, this is one of the biggest advantages and weaknesses of C.... . It allows you to do whatever you want to-regardless of cost and risk..

The Assumption PalmONE=PalmOS is very very wrong, and needs to be broken up for the good of the Platform... . It is true that PalmOne is PalmSources main licencee, but there are others too! Sony has quite a big markt share, Tapwave is growing fast, and the rest of the pack also sell enough to keep them in business....

5:36 PM  
Blogger oakleyses said...

cheap oakley sunglasses, louis vuitton outlet, uggs on sale, michael kors outlet online, prada outlet, michael kors outlet online, ugg boots, oakley sunglasses, longchamp outlet, oakley sunglasses, oakley sunglasses wholesale, jordan shoes, michael kors outlet online, christian louboutin shoes, michael kors outlet, replica watches, gucci handbags, louis vuitton outlet, uggs outlet, polo outlet, nike free, chanel handbags, michael kors outlet online, christian louboutin outlet, oakley sunglasses, ugg boots, uggs outlet, kate spade outlet, nike air max, nike outlet, longchamp outlet, ray ban sunglasses, louis vuitton outlet, ray ban sunglasses, christian louboutin, longchamp outlet, michael kors outlet, louis vuitton, burberry handbags, nike air max, tiffany jewelry, burberry outlet, polo ralph lauren outlet online, tiffany and co, ray ban sunglasses

2:45 AM  
Blogger oakleyses said...

polo lacoste, burberry pas cher, true religion outlet, hollister uk, ray ban pas cher, replica handbags, ralph lauren uk, nike free uk, michael kors, true religion outlet, north face uk, nike roshe, sac longchamp pas cher, timberland pas cher, longchamp pas cher, coach outlet, mulberry uk, nike blazer pas cher, kate spade, nike air max, true religion jeans, true religion outlet, lululemon canada, nike free run, ray ban uk, nike roshe run uk, converse pas cher, guess pas cher, hollister pas cher, nike tn, michael kors pas cher, oakley pas cher, nike air max uk, nike air force, sac vanessa bruno, jordan pas cher, new balance, north face, coach purses, vans pas cher, nike air max uk, sac hermes, hogan outlet, louboutin pas cher, air max, michael kors, michael kors outlet, abercrombie and fitch uk, coach outlet store online, polo ralph lauren

2:46 AM  
Blogger oakleyses said...

iphone cases, ipad cases, iphone 6 plus cases, bottega veneta, chi flat iron, louboutin, iphone 6s cases, insanity workout, nike roshe run, babyliss, hollister, p90x workout, vans outlet, s6 case, lululemon, mac cosmetics, jimmy choo outlet, hollister clothing, nfl jerseys, north face outlet, nike huaraches, oakley, soccer jerseys, nike trainers uk, instyler, baseball bats, mcm handbags, mont blanc pens, herve leger, wedding dresses, ferragamo shoes, north face outlet, giuseppe zanotti outlet, timberland boots, ghd hair, ralph lauren, soccer shoes, iphone 5s cases, abercrombie and fitch, hermes belt, iphone 6s plus cases, valentino shoes, celine handbags, beats by dre, longchamp uk, new balance shoes, nike air max, reebok outlet, iphone 6 cases

2:47 AM  
Blogger oakleyses said...

wedding dresses, moncler outlet, pandora jewelry, toms shoes, converse, louis vuitton, ugg uk, ray ban, moncler, links of london, nike air max, marc jacobs, karen millen uk, moncler outlet, canada goose uk, canada goose outlet, ugg pas cher, juicy couture outlet, pandora jewelry, lancel, barbour, canada goose, hollister, swarovski, louis vuitton, hollister, doudoune moncler, canada goose outlet, louis vuitton, swarovski crystal, converse outlet, montre pas cher, moncler uk, coach outlet, thomas sabo, canada goose, canada goose, ugg,ugg australia,ugg italia, louis vuitton, vans, moncler, ugg, louis vuitton, barbour uk, moncler, pandora uk, replica watches, canada goose outlet, gucci, doke gabbana, pandora charms, supra shoes, moncler

2:49 AM  

Post a Comment

<< Home