Getting input with Dreamcast keyboard.

Anything related in any way to game development as a whole is welcome here. Tell us about your game, grace us with your project, show us your new YouTube video, etc.

Moderator: PC Supremacists

Post Reply
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Getting input with Dreamcast keyboard.

Post by Falco Girgis »

Finally, after all of these months did I learn how to get input with the keyboard. It is such a great and useful peripheral on the DC. You can use all of those extra keys for debugging and secrets and all sorts of coolness.

I dug up some old KOS example, and I disected it with the help of Tvspelsfreak.

Then we had the problem where we had no clue which key was what. We looked up scancodes online and for some reason the DC's is different. After Tvspelsfreak abondened me (:lol:), I printed out the scancodes of the keys I pushed straight from t3h DC. Then, I manually converted them to hex.

Well, I could've used the integers, but I think it's easier to go with hex when you're getting keyboard input. Makes it look alot easier to understand. That's right. I actually used something from computer science club. Decimal (base 10) to hex (base 16) conversions.

Then I forgot about just doing this:

Code: Select all

printf("%x", keyboard_var);
That'll print out the hex for you! XD
Looks like the conversions are still useless . . .

In the end the Tile Demo thing now supports keyboard -- I want to say perfectly, because it does as perfectly as possible ATM.

Apparently, the keyboard, unlike the controller doesn't register holding the button down. You litterally have to push it again every single time you want to move a pixel. I'm sure there's a way around that somehow. What do you think, Tvspels?

Shooting with keyboard works perfectly, walking does (only you have to push it 20 times to move 20 pixels), jumping works sorta (It makes you jump higher based on the length of time the button is held down and the keyboard won't register more than once).

The best part is that now I can take a screenshot by pushing the "Print Screen" button how god had intended.

Man, I love the keyboard on the DC.

Anyway, this is good progress. Slowly we are pwning more and more peripherals. First it was analog stick, then VMU, and now keyboard.

I'm trying for rumble pack now. That's supposed to be a pain in the ass though...
User avatar
JS Lemming
Game Developer
Game Developer
Posts: 2383
Joined: Fri May 21, 2004 4:09 pm
Location: C:\CON\CON

Post by JS Lemming »

I can see trying to get the rumble pak to work... but why the keyboard? I bet only a few folk have a DC keyboard and PLUS, who wants to use a keyboard when you gots a controller. But if it was for the epedition of more knowledge, keeep trucking.

Awwwww..... don't tell me you HAVE to use C instead of C++ when devving the DC... say it aint so.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

JS Lemming wrote:I can see trying to get the rumble pak to work... but why the keyboard? I bet only a few folk have a DC keyboard and PLUS, who wants to use a keyboard when you gots a controller. But if it was for the epedition of more knowledge, keeep trucking.

Awwwww..... don't tell me you HAVE to use C instead of C++ when devving the DC... say it aint so.
It aint so. I've used C++ for 90% of my devving.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Getting input with Dreamcast keyboard.

Post by MarauderIIC »

GyroVorbis wrote: Apparently, the keyboard, unlike the controller doesn't register holding the button down. You litterally have to push it again every single time you want to move a pixel. I'm sure there's a way around that somehow. What do you think, Marauder?
:)

Can you tell when a key is pushed and when it is let up again? Cause if so then you can poll it to see if the key has been let up and if it hasn't then you're holding it. Might require some multithreading or something though, so you can do other stuff at the same time.

Well, maybe not. Just really really short sleep()s.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

:lol:

Didn't think you still browsed the DC dev forum.

What I'm not sure of is if you can tell when it's down and up. I was looking through the keyboard.c in the KOS files and I couldn't see anything that'd tell if it is up or down. But what it did say is this:

Code: Select all

/*

This module is an (almost) complete keyboard system. It handles key
debouncing and queueing so you don't miss any pressed keys as long
as you poll often enough. The only thing missing currently is key
repeat handling.

*/
Notice it says that it's missing "key repeat handling". I have no clue WTF that is.

If that is the ability to tell if the key is held down, maybe we aren't screwed. Perhaps the newer kos has it completed. I'd just copy and paste the source into my old kos.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

Here's my latest on the keyboard. I wanted to get so much done last night, but I fell asleep at my desk after doing just this. :oops:

I wanted to get it so that when you type letters they are displayed on the screen. The problem was that the example used the Vram to do that. That way what they had previously typed in stayed on the screen. If I tried to do that, the character that you just pushed would show up for a frame and then disappear because we use t3h PVR.

I decided to keep drawing with the bios font (not a good thing when using the PVR). What I ended up doing was having a character array that holds all the characters that I've typed thus far and reprints every frame.

The bios font working with the PVR causes trouble. I thought this was because PVR is 3D hardware bios font is 2D. Well, it ended up working, but after you get large amounts of text onscreen, it LAGS like a mother.

No big deal, I am redoing it now and this time I'm drawing the text with the PVR.
User avatar
JS Lemming
Game Developer
Game Developer
Posts: 2383
Joined: Fri May 21, 2004 4:09 pm
Location: C:\CON\CON

Post by JS Lemming »

You could always use an image font.
Small girl at the harbor wrote:Look Brandon, that crab's got ham!
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Post by Falco Girgis »

Naw, there's a great font library with the PVR.

It allows custom fonts and stuff. Oh, and Tvspels made an NES font for it a while back...

mmm...NES font....

:mrgreen:
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Post by MarauderIIC »

If you can't tell whether it's down or up, how do you tell if it's pressed? :p
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply