Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Keyboard Input

Author
Message
reapz
15
Years of Service
User Offline
Joined: 4th Jun 2009
Location:
Posted: 11th Jun 2009 05:22
Hey,

I'm looking for a method to get keyboard input for a game without using scan codes, as the scan codes can change from keyboard to keyboard.

If this is wrong let me know, but is there a way to get the ASCII codes for key presses, more importantly for multiple keys being held down etc at the same time.

Or perhaps a way to override KEY_DOWN or do something like that?

Appreciated
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 11th Jun 2009 07:32
dbGetEntry(); returns a char* of keys pressed on the keyboard in this format: a, A, #, @,

You could possibly use that with
dbClearEntryBuffer(); which basically resets the variable that dbGetEntry(); holds back to NULL

ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 11th Jun 2009 21:32
The problem with dbEntry is that it doesn't filter out escape characters, meaning you have to do that all manually. I am actually working on a class that can be used to replace dbEntry, which fixes all of it's pitfalls. I am actually almost done it. I really just have to implement a word wrap feature and one or two more behavioral options and that's about it.

At the moment the class has 31 member functions which gives you a lot of control over the output/input behavior.

------------------------------------
Currently 1500+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.
reapz
15
Years of Service
User Offline
Joined: 4th Jun 2009
Location:
Posted: 12th Jun 2009 05:28
I did try with dbGetEntry, unfortunately I don't think it keeps adding a keychar if you hold a key down.

I solved the problem, it appears (I hope) that scan codes are in fact consistant between QWERTY keyboards so I used the dbKeyState(pass in scancode of key) function. This works well assuming that the scan codes are common, going with that for the moment.

Sounds good ABXG. Here's what I have atm, very simple but it works with multiple keypresses.

GPZ
15
Years of Service
User Offline
Joined: 20th Feb 2009
Location:
Posted: 16th Jul 2009 11:07
Reapz, excellent... This is nearly identical to the DXInput code I was using. Sounds like it will work perfectly for DarkGDK (and as you stated, it DOES work). Getting back into Dark*anything has made me forget some things as simple as separating key_up from key_down because of the list of commands that are supposed to aid in this sort of thing. Reguardless, some of the documented commands aren't even included in the DarkSDK libs - has anyone ever tried using dbCheckListQuantity()? That's off topic, but an example of one of the struggles I've had using DarkGDK (especially, struggling with glitchy input commands).
DnB
15
Years of Service
User Offline
Joined: 28th Feb 2009
Location:
Posted: 10th Aug 2009 14:47
I just use dinput



And You just replace B with whatever. Ill try to post the complete list here in a bit.
DnB
15
Years of Service
User Offline
Joined: 28th Feb 2009
Location:
Posted: 19th Aug 2009 23:21
List of dinput codes
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 20th Aug 2009 05:39
Try this just for brevity. I don't know that it would be any faster

bool Input::isKeyDown(int scanCode)
{
return (dbKeyState(scanCode) != 0)
}

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
DarkwingDuck
14
Years of Service
User Offline
Joined: 5th Oct 2009
Location:
Posted: 14th Oct 2009 22:06
I'm having problems with my keyboard commands.


for instance:
if ( dbUpKey ( ) )
dbMoveCamera ( 1 );

// move the camera backwards
if ( dbDownKey ( ) )
dbMoveCamera ( -1 );
// move camera left
if ( dbLeftKey ( ) )
dbMoveCamera ( ? );

how do i make the camera go left? if i put a 1 or a -1 where the question mark is, all it does is move forward.
DnB
15
Years of Service
User Offline
Joined: 28th Feb 2009
Location:
Posted: 15th Oct 2009 02:16
You have to use dbTurnCameraLeft & dbTurnCameraRight commands

Login to post a reply

Server time is: 2024-10-01 14:34:54
Your offset time is: 2024-10-01 14:34:54