Once more, keystrokes... - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Once more, keystrokes...

This is the first time I'm looking for help in a message list, and I'm surprised that it really works and there are people who really wanna help.

So, this is the problem:

For those who know'the game, I'm developing a Dance Dance Revolution Pad for home use. I'm using the epsxe emulator, that emulates with perfection the 3rd edition.
But for do it, I've developed a pad (obvious) and a soft, that should return keystrokes to windows, simulating the keyboard action i would do (epsxe does not use the plug-in system for input).
I'm using the parallel port to communicate with the pad, and its working fine. Now I must turn the data chance on the port in KeyDown and KeyUp events to the proper key, so the emulator can catch it (hope it don't use a low level input handler).
Resuming: how i force a keystroke back to windows, so any other appication (such notepad, word, or the emulator) can catch it?
I've head about VKD_Force_Keys and VKD_API_Force_key functions, but it only can be used in a VxD, and I'm don't know how to make one (and it seems to hard).
I can code anything for DOS, but for windows...

That's all that's missing to finish it. Plz, any help wold be of great value.

At time, forgive my bad english. I'm brasilian and it's not my country language.

Comments

  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : This is the first time I'm looking for help in a message list, and I'm surprised that it really works and there are people who really wanna help.
    :
    : So, this is the problem:
    :
    : For those who know'the game, I'm developing a Dance Dance Revolution Pad for home use. I'm using the epsxe emulator, that emulates with perfection the 3rd edition.
    : But for do it, I've developed a pad (obvious) and a soft, that should return keystrokes to windows, simulating the keyboard action i would do (epsxe does not use the plug-in system for input).
    : I'm using the parallel port to communicate with the pad, and its working fine. Now I must turn the data chance on the port in KeyDown and KeyUp events to the proper key, so the emulator can catch it (hope it don't use a low level input handler).
    : Resuming: how i force a keystroke back to windows, so any other appication (such notepad, word, or the emulator) can catch it?
    : I've head about VKD_Force_Keys and VKD_API_Force_key functions, but it only can be used in a VxD, and I'm don't know how to make one (and it seems to hard).
    : I can code anything for DOS, but for windows...
    :
    : That's all that's missing to finish it. Plz, any help wold be of great value.
    :
    : At time, forgive my bad english. I'm brasilian and it's not my country language.
    :

    Before I start lookin up the wrong thing, are the commands that your pad send to the parallel port regular commands, like those from a keyboard? If not, the first step would be to translate your pad input to standard keyboard input. Once it is in that form, I think I have something that will help you, but I am researching it to be sure before I send you down the wrong track!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]


  • Will_SantanaWill_Santana Posts: 20Member
    : Before I start lookin up the wrong thing, are the commands that your pad send to the parallel port regular commands, like those from a keyboard? If not, the first step would be to translate your pad input to standard keyboard input. Once it is in that form, I think I have something that will help you, but I am researching it to be sure before I send you down the wrong track!
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]
    :
    :

    God bless you man ! hehehehe
    I've been working on the pad several weeks.
    The signals I got from LPT is a single byte, and the keys will be sent by checking it's bits. The user will choose wich key he wants to be sent when a switch is pressed by a window I've already made. Eacj byte of the LPT data port means a switch press (a double dance pad has exactly 8 switchs - 4 for each player).
    So, once a bit goes down (I'm using LPT PS/2 mode, in wich the port data pins goes to tri-estate and if you reads it, it's high), means the switch X is pressed, then I must send a KeyDown event with the key value the user set on the edit box. once this pin goes up again (the switch was released), I must send the KeyUp event for the same key. The KeyPress event isn't good because simultanious press are allowed (most people have 2 feet - heheheheh)
    As I said, this events should be thrown to the whole windows environment, so ANY program can catch it.
    Hope this is what is missing to you find the answer.
    Thanks for the pacience too !

    Will Santana

  • Sephiroth2Sephiroth2 Posts: 423Member
    Use the keybd_event function to fake keypresses.

  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    Yeah my counterpart took the words right out of my mouth. I suggest keybd_event as well. Here is the info right out of my help file:

    The keybd_event function synthesizes a keystroke. The system can use such a synthesized keystroke to generate a WM_KEYUP or WM_KEYDOWN message. The keyboard driver's interrupt handler calls the keybd_event function.

    VOID keybd_event(

    BYTE bVk, // virtual-key code
    BYTE bScan, // hardware scan code
    DWORD dwFlags, // flags specifying various function options
    DWORD dwExtraInfo // additional data associated with keystroke
    );


    Parameters

    bVk

    Specifies a virtual-key code. The code must be a value in the range 1 to 254.

    bScan

    Specifies a hardware scan code for the key.

    dwFlags

    A set of flag bits that specify various aspects of function operation. An application can use any combination of the following predefined constant values to set the flags:
    [code]
    Value Meaning
    KEYEVENTF_EXTENDEDKEY If specified, the scan code was preceded by a prefix byte having the value 0xE0 (224).
    KEYEVENTF_KEYUP If specified, the key is being released. If not specified, the key is being depressed.


    dwExtraInfo

    Specifies an additional 32-bit value associated with the key stroke.



    Return Values

    This function has no return value.
    [/code]

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]


  • Will_SantanaWill_Santana Posts: 20Member
    DAMN ! IT FINALLY WORKS !

    Thank you all !

    Thank Sephiroth (are Sephiroth 2 you too?) !

    I'm now just fine tunnig the prg to post it to the site and make it availble for everybody (and the mechanical schematics too)!

    It all should be done on this Sunday.

    Thank you very much !

    Will Santana


  • SephirothSephiroth Fayetteville, NC, USAPosts: 1,035Member
    : DAMN ! IT FINALLY WORKS !
    :
    : Thank you all !
    :
    : Thank Sephiroth (are Sephiroth 2 you too?) !
    :
    : I'm now just fine tunnig the prg to post it to the site and make it availble for everybody (and the mechanical schematics too)!
    :
    : It all should be done on this Sunday.
    :
    : Thank you very much !
    :
    : Will Santana
    :
    :

    No problem Will, glad I could help. And Sephiroth2 is a different person, one who has helped me quite a few times, so you can generally take his word on stuff.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red]


Sign In or Register to comment.