Shop OBEX P1 Docs P2 Docs Learn Events
USB keyboard emulator — Parallax Forums

USB keyboard emulator

Michael OBannonMichael OBannon Posts: 19
edited 2007-02-19 18:54 in Propeller 1
I'd like to translate an old BS2 design to a Prop chip. The current design emulates standard keyboard keystrokes (triggered by real-world contact closures) and sends them to a PS2 port. Now it's become necessary do the same thing on newer laptop that has no dedicated keyboard port. I understand keyboard scan codes and the keyboard port from the "good old days" when things were simpler, but have no clue how to do this with USB. Could someone give me a hint where to start (hopefully without reading 600+ pages of interface standards)?

Thanks for any help!

Comments

  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 07:37
    I have written a routine in VB a couple of years back where it sits scanning a serial port waiting for input and then injects what it receives it into the keyboard buffer as if typed on the keyboard. I have used this on laptops with USB to serial adapters - I can search for it if you like ?

    So you can use this in conjunction with·your Basic stamp version - or·dig into the propellor and·with a fullduplexserial or similar object you can do the same - input via your real contact device to stamp or prop - serial out to usb to serial device attached to laptop/pc - application running on pc waiting for a com event - send received data to keyboard buffer - as if typed on the pc !



    Post Edited (QuattroRS4) : 1/26/2007 5:13:44 PM GMT
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 18:22
    Have found an old version and attached it - put parallax forums logo on it.

    The zip file contains 2 items

    an ini file - set com port no,baud rate, and whether the application should be visible.

    place the exe and ini file in same path - set the ini to your requirements - default 9600,n,8,1
    and app form visibility is 'true' - set this to 'false'. Start the app you will note an icon in the sys tray
    open anything e.g notepad.exe - make sure it is highlighted i.e active - tab is blue at the top.


    use a null modem cable between 2 pc's - on the second pc start up hyperterminal to same settings.Type in on in hyper terminal and watch what you type appear on the other screen - notepad or what ever is open !!

    The sent items will only appear in an active window - just like a normal keyboard - ....
    Similarly use stamp serout - to send the data to the pc with the app running.
    Or use the 'prop' with any of the·serial objects e.g·FullDuplexSerial

    A simple mod would be to alter this prog. to append a text file for datalogging !
    I can do that if you are badly stuck

    Note: if you chose to make the app invisible - use taskmanager to shut it down ...
    ········It was designed to run in the background ...



    Any difficulty just post it here .... enjoy
    Comments from anyone welcome !

    EDIT:
    ······ I have updated this program as requested by a few - the attached program now has supports 'BackSpace' and Arrow keys..

    Rgds,
    ······ Quattro


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 3/12/2007 5:50:59 PM GMT
  • Michael OBannonMichael OBannon Posts: 19
    edited 2007-01-26 19:12
    Quattro,

    Thanks a lot for the response! This should work out just fine. I will give it a try this weekend and let you know how it goes.

    Best regards,
    Michael
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-01-26 19:19
    Michael,
    Do let me know - It should meet your needs...
  • SlikDSlikD Posts: 4
    edited 2007-02-18 05:38
    Hmmmm, Can I do a serout of ASCII (37, 38, 39, 40) <the arrow keys> to drive my position in a 3D simulation that is the active running program. The 3D sim is already set to use arrow key input.

    2125 tilt sensor> eb500 bluetooth> hyperterminal> running 3D Simulation?

    SlikD
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-18 13:41
    Have you used the application I attached previously ? If so I don't believe I included the arrow keys scan codes - but if you are stuck I will certainly do it for you ...

    Quattro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-18 19:18
    Well if hyperterminal was used to 'send' the arrow keys it sends

    [noparse][[/noparse]D for 'left arrow'
    [noparse][[/noparse]A for 'up arrow'
    [noparse][[/noparse]C for 'Right Arrow'
    [noparse][[/noparse]B for 'Down Arrow'

    for keyboard scancodes what is required

    &H25 - 'Left Arrow'
    &H26 - 'Up Arrow'
    &H27 - 'Right Arrow'
    &H28 - 'Down Arrow'

    I just included these in the attached application for you - let me know how you go with it ..
    explanation of how to use it is posted earlier in this thread...

    Rgds,
    QuattroRS4

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • SlikDSlikD Posts: 4
    edited 2007-02-18 21:26
    I get <Component 'MSCOMM32.OCX' or one of its dependencies not correctly registered; a file is missing or invalid.> error message on my XP laptop with a USB keyboard when I run your exe. : (
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-18 21:27
    Not the application - your system needs a component

    and / or·vbruntimes

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 2/18/2007 10:15:15 PM GMT
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-18 21:33
    or just do this ....

    Unzip the attached and place the file in your c:\windows\system32 folder

    depending on your XP system it may be

    c:\winnt\system32


    then
    start,Run

    regsvr32 c:\windows\system32\mscomm32.ocx

    or if its the 'winnt' type

    regsvr32 c:\winnt\system32\mscomm32.ocx·

    and press <RETURN>

    You should get a 'Succeeded' message box






    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 3/12/2007 5:53:35 PM GMT
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-19 18:54
    In response to requests in other forums and PM's received I have made an application in VB6 whereby if it receives

    L,l,<Left Arrow> - any one of these 3 chars through the serial port it will 'inject' the scancode for <Left Arrow> into the keyboard buffer of the P.C as if it were typed/pressed on that p.c

    R,r,<Right Arrow>

    U,u,<Up Arrow>

    D,d,<Down Arrow>

    I have removed all other key scan codes from this application as requested
    I also have a .NET version created if someone would prefer that.

    so -

    Basic Stamp Example for Right:
    SEROUT 0,16468,[noparse][[/noparse]"R"]

    - sends R via PIN0 at 9600,N,8,1 to the P.C running the Application

    Propeller Example for Right:

    CON
    ·_clkmode = xtal1 + pll16x
    ·_xinfreq = 5_000_000

    OBJ
    ·ExtSerial : "FullDuplexSerial

    Pub SENDR
    ·extserial.start(-1, 0, 2, 9600) ' (transmit only)- rxpin,txpin,mode,Baud - depends on your set up
    ·extserial.str(string("R "))

    so following on from that L for left ,U for up,D for Down.



    I have attached 'Dinj.Zip'
    which contains
    Dinj.Pdf - operating instructions
    Dinj.exe - the application
    Dinj.ini - settings file

    I hope that meets the requirements ...
    enjoy !

    Quattro

    (Comments Welcome - good,bad and Ugly !)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 2/19/2007 7:15:22 PM GMT
Sign In or Register to comment.