Does the G1 have KeyEvent.KEYCODE_DPAD.* keys?

Put your problem here if it does not fit any of the other categories.

Does the G1 have KeyEvent.KEYCODE_DPAD.* keys?

Postby Sweevo » Mon Oct 20, 2008 10:37 am

I'm writing a game that uses the cursor keys for movement (think along the lines of Pac-Man).

It works on the emulator, but would it work on the G1? from what I see, it doesn't seem to have cursor keys.

Are they there, or do I need to use an alternative method, like the WASD keys or something?

iPhone versions use screen swiping or a virtual joystick, but of course these method don't work as well as real keys.
Sweevo
Developer
Developer
 
Posts: 35
Joined: Thu Oct 16, 2008 9:27 am

Top

Postby MrSnowflake » Mon Oct 20, 2008 12:18 pm

I'm not really sure. This is what the docs say on Activity.onTrackballEvent()
Code: Select all
public boolean onTrackballEvent(MotionEvent event)
Called when the trackball was moved and not handled by any of the views inside of the activity. So, for example, if the trackball moves while focus is on a button, you will receive a call here because buttons do not normally do anything with trackball events. The call here happens before trackball movements are converted to DPAD key events, which then get sent back to the view hierarchy, and will be processed at the point for things like focus navigation.

I think you should implement onTrackballEvent(MotionEvent event) so it emulates dpad presses, if that's viable for your app.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Sweevo » Mon Oct 20, 2008 12:22 pm

From this I'm getting the opposite - if I *don't* implement / handle trackball events, they might be converted into key events.
Sweevo
Developer
Developer
 
Posts: 35
Joined: Thu Oct 16, 2008 9:27 am

Postby MrSnowflake » Mon Oct 20, 2008 12:35 pm

Take a look at onKeyDown(). They explicitly say what the default implementation does, so I don't really know. Try sending your own MotionEvent and see what it does.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Sweevo » Mon Oct 20, 2008 12:53 pm

I'll play with those event handlers a little bit - but I bet the emulator doesn't behave like the G1's trackball.
Sweevo
Developer
Developer
 
Posts: 35
Joined: Thu Oct 16, 2008 9:27 am

Postby MrSnowflake » Mon Oct 20, 2008 1:11 pm

I know that's why you have to send your own motionEvent.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 24 guests