Qbasicnews.com

Full Version: keyboard problem...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
For every keyboard handler I've tried, it does the same thing: There's some key combinations that don't work together?? For instance, only two of the keys in the combination H, K and J will work together, for example, if you have H and K pressed, J will not work. Or W, D and K do the same thing. U, I, O, P all work together. There doesn't seem to be a max of keys that can be pressed, because I found some combinations that allow, say, 8 keys to work together, but certain combinations won't all work together, even if its only three keys. This makes it hard to write good two player video games, because I have to find 2 sets of combinations that work together at opposite ends of the keyboard. Is it perhaps my keyboard? Is it one of the many QBasic limitations? But if so, why the weird combinations? Try programming a simple key tester using a kb handler (Cosmox's or Rellib's), and test for the H, K, and J combinations together just to see. You can get the scancodes for those letters in the QB help. Let me know if I'm dillusional, or if it's only my kb. Thanks
It has to do with your keyboard. Every keyboard has its own "non allowed key combination". It is just a mechanical retriction. You can't do anything to solve it, although there are odd turnarounds having to do with fast reading ports. I remember an ol' C program that readed up to 15 keys in my keyboard, but I have no idea where it is ...
That's what I thought, it's my keyboard. I have a pretty old keyboard, so are the newer model better for that? I'll have to program the second player to use a joystick and find a good combination for the keyboard.

Nathan said:
I remember an ol' C program that readed up to 15 keys in my keyboard, but I have no idea where it is ...

Does anyone else know anything about this or how to program this?
Hmm... well, using DirectX's DirectInput stuff, I can read any key on my keyboard at any time, but with conventional Win32 code or QBasic code I can only read a few at a time... they seem to be in banks, like you said, where only a few can be pressed at a time. My keyboard is about 8-9 years old, so that probably explains it. Cry
The year doesn't matters, my keyboard is the same Packard Bell keyb that came with my first PC. And it still beats a lot of newer crap, for three simple reasons:

- Not made 100% in plastic.
- The key matrix uses an original layout, allowing very odd key combinations, and up to 10 keys at a time (this keyb is insuperable for playing FPS)
- The key matrix doesn't uses the standard plastic sheets for checking key presses, instead it uses a rubber base and a big PCB (very similar to the PSX controller)

Now you ask, WTF is a key matrix?

[Image: keyboard-matrix.jpg]

That's a key matrix.

So, in the end, we have good keyboards and bad keyboards. Simple as that.

Oh, and another thing: keyboards weren't made for playing games. Keep in mind that. :wink:
What should I do for a two player game then. I need at least 4 keys for directional movement, and 4 more action buttons. A gamepad works fine, so I searched for gamepad routines, but if you want to add a second one, you can only use 2 action buttons. Well, since your telling me that some keyboards have differant matrixes, if I program a game with certain buttons accosiated with differant actions, some people who try my game might run into some problems when wanting to move up and left at the same time and fire, because the combination might not work for some people. This problem really sucks. What should I do. Can I use DirectX's keyboard routines in QB like DRv mentioned?
heh - That's what I thought when I had SFA3 running in my Final Burn emulator. You simply couldn't play a two players game 'cause each player needed 12 keys, and you couldn't press many of them together (it was a pain trying to cover while the other guy was doing a-do-kens). I had two sollutions:

1.- Play alone.
2.- Buy a control pad.

I'm a lucky guy, and FinalBurn had that kaillera support to play thru' the LAN, so now I can kick my flat pals' asses....

heh - I went off-topic.

There is no easy sollution. You may have to try to decrease the number of used keys or add control pad/joystick support. Or use DSOCK and make your game playable thru' TCP/IP...
The game port allows up to 12 simultaneous inputs (AFAIK), used as:

- Joystick 1 X axis
- Y axis
- Button 1
- Button 2
- Joystick 2 X axis
- Y axis
- Button 1
- Button 2

In a gamepad, the dpad uses absolute values for the X and Y axes. Button 1 and button 2 corresponds to the same buttons. 3 and 4 however are B1 and B2 of the player 2, and if the gamepad uses 8 buttons, then 5, 6, 7 and 8 are the axes of the player 2. That's why you can connect two joysticks, but only one gamepad into the port.

For a two players game, one player uses the joystick/gamepad and the other uses keyboard. Simple as that. If no joystick is available, the two players should have the option of using the keyboard, but with "no warranties". [Image: biglaugh.gif]

I honestly doubt that DirectX can handle more keys than the keyboard CPU. You know, that's hardware limitation. And, even if DX is capable of these "odd turnarounds having to do with fast reading ports" as Nathe mentioned, the sole idea of needing a windows slave to read DirectInput gives me the creeps.
Quote:I remember an ol' C program that readed up to 15 keys in my keyboard, but I have no idea where it is ...

Does anyone else know anything about this or how to program this?
Ive got code that locks onto the keyboard interrupt. it's as accurate as youll get.


And heres a solution no one else mentioned: Ive youve got a few usb keyboards plug em in, the comp will think its one keyboard and boom, double the amount of keys you can press --- someone tested it and it worked, im not sure if this is in dos two..
(basically, plug in several keyboards to your computer)
I may have found a good combination for my game. I'll use a gravis gamepad for one player and the following keys for the other. They all work together on my keyboard but might not on someone else's. Try them out and tell me what you think. (This is for my real-time tank game I'm writing. Engine->80% :bounce: )

Directional keys:

Pinkey->A->Left
Ring->S->Down
Middle->E->Up
Index->F->Right
Or use the ring for A(left), Index for F(right) and use the middle for both E(Up) and S(Down).

Action keys:
Index->H->Fire
Middle->I->Cannon rotate left
Ring->O->Cannon rotate right
Pinky->;->Stabilizer(stabilizes the cannon when turning)

I hope this combination is generic for everybody, if not, then oh well
Pages: 1 2