PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GapiDraw 3.01 (Palm) NOTE: Any Zodiac Analog Stick Support?

Just thought I'd start a topic where people can express v3.01 related issues. With the new Palm inclusion, there's most likely going to be a few questions and bugs. Here's where to do it. :)

I've been getting GapiDraw 3.01 set up with CodeWarrior 9.3 for PalmOS.
My target audience is purely Tapwave Zodiac users (PalmOS5.2 gaming PDA with a 480x320 screen: www.tapwave.com ) and everythings been fairly smooth so far. For those who are new to GapiDraw such as me, I had to enable the following to use the correct orientation of the Zodiac's widescreen and make it use the full screen:

Code:
config.dwDisplayMode = GDDISPMODE_ROTATE90CCW;
config.bHandleScreenSizeChanged = TRUE;


Using the Virtual File System (VFS) is VERY easy, and I love the included VFS Editor tool. Just remember by default, if using the Simple sample as the base for your game, when making virtual.vfs and then splitting the files, by default it will make virtual.rcp, but its filename needs to be changed to virtualfs.rcp to work.

Also, the input for GapiDraw, to me is a little confusing. I was hoping to do something along the lines of:

Code:
switch (dwKey)
{
//keylist.vkXXXX is not a constant and will not work

case keylist.vkUp:
//do what needs to be done for pressing Up
break;
case keylist.vkDown:
//do what needs to be done for pressing Down
break;
}


But since the keylist's are variables and not constants, a switch wont work. So when I tried to find out what keylist.vkUp's value was, thinking it was a constant, I got very confused. So my question is, what would be the most effiecent way of going about input in GapiDraw? Is a switch not a good idea/feasible in this situation?

Congrats on GapiDraw 3.01, great product!

-Fraggler
Use an if-else-if statement.
Ok, pretty much what I would of done. Thanks.

While I'm at it, I am not custom to writing event based games.
I usually write very linear games, and seeing how GapiDraw is written makes me a bit confused as to writing my game. I saw a movie in the docs folder that said it's possible to write linear games by using a loop inside the ProcessNextFrame event.
Is writing a linear game within GapiDraw ok to do, or is it not recommended?
If it's ok to do, how would you write a linear game from inside the ProcessNextFrame event, if it needs to return S_OK to display the backbuffer?
Also, how would input be used inside this loop inside ProcessNextFrame be detected? I'd imagine you wouldn't use the ::KeyDown event.

Thanks! :)

P.S. Off-topic but nice work on Concentrix, mlepage. Very polished looking.
You can manually call CGapiDisplay::Flip to draw the backbuffer to the screen.

But you're right, you wouldn't receive any input.

Your best bet is to look at the sample programs and follow their structure. It would be even better if you had source code for an actual game implemented using GapiDraw.

Thanks for the compliment.
Wow, so the only way you can receive input is through the key/stylus events?
There's no way to check the status of a key/stylus pressed from within a function?
There may be, but you're really better off just following the event driven model.

Get your input asynchronously, then in ProcessFrame, process input, update your game state, draw to the backbuffer, then return which flips the backbuffer to the actual screen.
Ok, sounds simple enough.
How would you recommend taking care of input...
Since the input is event driven, there is a need to know what state the game is at during the time of the KeyDown/StylusDown so it can act appropriately.
My idea was to have a global variable such as "keyCommand" and assign it a value, right before I need to get some input. Then in the KeyDown I would use a switch for "keyCommand" so I could keep track of what the input does at different points in my game.
I just have a feeling there's a better way of going about this.
If there is, let me know.

Thanks for helping me out with this in such a timely manner. :)
Ah, just came to my senses.
Have the keyDown event set a variable to say what was pressed, then have it checked in ProcessNextFrame.
Yes that is one technique.

How do you handle input? It depends.

In Concentrix, if you move left or right on the dpad, that key event is handled in KeyDown, altering the game state immediately. This gives immediate response, even if you don't see the result drawn until the next ProcessFrame.

However, it also sets a state variable saying that button is held down. ProcessFrame checks this variable, and periodically repeats the movement. So if you are still holding the button down, it will autorepeat after a while. The overall sequence is: move, pause for a long time, then repeat move with short pause in between each repeat.

Slamming (dpad down) is only ever handled in ProcessFrame, using a state variable set in the KeyDown/KeyUp functions. But that's because the desired behaviour is different. You can think of it as altering the speed at which the player's shape falls.
fraggler wrote:Ah, just came to my senses.
Have the keyDown event set a variable to say what was pressed, then have it checked in ProcessNextFrame.


Yes you are better off using flags and have your game logic check which keys/events have occurred from time to time so that they can react. I'm sure that you'll soon get a hang of this. :)

- Erick
fraggler · 30 May 2004, 19:46 UTC — Tapwave Zodiac ANalog stick problem
Ok, got the program flow down, and I can get input and react accordingly.

New problem though...
The Tapwave Zodiac uses an analog stick, and it seems keylist.vkUp/Down/Left/Right do not work.
How do you implement the directional inputs using GapiDraw 3.01 with the Zodiac's analog stick?
I'd imagine others will soon be asking the same thing. :)
Fraggler: Right now, you would have to add support for the analogue stick by yourself, using Tapwave's APIs.

We are however right now working with Tapwave to add support for both analogue input and TwGfx to GapiDraw. Personally I believe the Zodiac is one of the best mobile gaming devices in years.
It's very reassuring that you considered the Zodiac in the future of GapiDraw. :)

I'm a little confused as to how GapiDraw handles the key assignments so I wasn't able to implement the analog stick into the "keylist."
Here's my temporary solution to handling the Zodiac's analog stick...

Code:

//normal zodiac keys
//#define keyBitRockerUp 0x00010000 // 5-way rocker
//#define keyBitRockerDown 0x00020000
//#define keyBitRockerLeft 0x00040000
//#define keyBitRockerRight 0x00080000
// Reassigned the keys based on the 90CCW orientation
#define keyBitRockerRight 0x00010000 // 5-way rocker
#define keyBitRockerDown 0x00080000
#define keyBitRockerLeft 0x00020000
#define keyBitRockerUp 0x00040000
#define keyBitRockerCenter 0x00100000
#define keyBitLaunch 0x00800000
#define keyBitNavUp keyBitRockerUp
#define keyBitNavDown keyBitRockerDown
#define keyBitNavLeft keyBitRockerLeft
#define keyBitNavRight keyBitRockerRight
#define keyBitNavSelect keyBitRockerCenter
#define keyBitsNavAll 0x001F0000
#define keyBitsNavUpLeft 0x00050000
#define keyBitsNavUpRight 0x00090000
#define keyBitsNavDownLeft 0x00060000
#define keyBitsNavDownRight 0x000A0000
#define keyBitJogBack 0x00008000
#define keyBitFunction keyBitJogBack // jog wheel back button
#define keyBitTriggerA 0x04000000
#define keyBitTriggerB 0x08000000
#define keyBitActionA 0x10000000
#define keyBitActionB 0x20000000
#define keyBitActionC 0x40000000
#define keyBitActionD 0x80000000

//key pressed event
HRESULT CMyApplication::KeyDown(DWORD dwKey, GDKEYLIST& keylist)
{
//check for keys (state) being pressed
UInt32 keys = KeyCurrentState();

//a key was pressed down as the event was triggered. This checks for which key.
if ( keys & keyBitNavDown) // keyBitNavDown is the D-pad "Down" so replace as needed
{
//do what you want for when the key is pressed
}
}
While on the subject of KeyDown, how does GapiDraw handle repeated key presses when a key is held down for 'x' amount of time?

Palm's SDK has a KeyRate function, but not sure if its implemented with GapiDraw.
In my mind, that functionality belongs in CGapiApplication, but it is not present.
Ok. Yeah its something that if implemented would save some time. And thats what GapiDraw is all about, being easier and more efficient.
We'll add key repeat to the todo-list. :) Thanks for the key codes for the Zodiac, we just haven't had time yet to dig into the Zodiac SDK!