Shop OBEX P1 Docs P2 Docs Learn Events
Can a Propeller Emulate a USB Keyboard? — Parallax Forums

Can a Propeller Emulate a USB Keyboard?

coryco2coryco2 Posts: 107
edited 2011-12-09 17:13 in Propeller 1
Hello,

I would like to be able to generate keyboard character codes with a Propeller and send them over USB to a PC--essentially have the Propeller be functionally "typing" on the PC. In principle, this seems possible, as the Parallax Serial Terminal running on a PC receives and displays characters from the Propeller through its USB programming connection, but I am guessing there would need to be some additional driver code in order for the data stream from the Propeller to actually interact with the PC OS?

Any comments or suggestions would be greatly appreciated!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-12-06 22:14
    Keep in mind that the USB programming connection and a USB keyboard device are very different. Although the connector and the basic electrical signaling are the same, the Propeller's programming adapter identifies itself to the PC as a virtual serial port using a particular protocol used to emulate a serial port. A USB keyboard identifies itself to the PC as an HID (human interface device) which includes mice, trackpads, joysticks, etc. The protocol is completely different. A Propeller can emulate an HID therefore a keyboard, but the code is complex and not "plug and play". It's also not really supported. In the case of the Propeller's programming interface, the FTDI chip handles all the details and appears to the Propeller as a serial port. If you want to emulate a USB keyboard, you have to provide everything.
  • SRLMSRLM Posts: 5,045
    edited 2011-12-06 23:41
    Depending on your programming skills, you could (probably on windows, for sure on linux) create a virtual keyboard, and then have your software read the serial port and pass that data to the virtual keyboard. In this way it would appear to any programs as if was typed on a keyboard.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2011-12-07 08:17
    To translate what Mike Green is saying..... "Yes it can be done, but it is a lot more complex that using the older keyboard interface."

    If you have a choice, keep it simple. In some cases, you can get a dongle that converts a traditional keyboard output to a USB and it seems that the computer will then recognize the old DIN serial code via the adapter. That might be the easiest way to feed into a USB as a virtual keyboard.

    But you still have quite a bit of a learning curve. The keyboard serial protocol is unique - in one direction it totals 12 bits and in the other it totals 13 bits, and it includes parity calculation and a variety of byte codes that is quite extensive.
  • Duane C. JohnsonDuane C. Johnson Posts: 955
    edited 2011-12-07 09:03
    I may be a bit dated here because we used to do something similar when using DOS based computers, even the windows that operated above DOS.

    Escentially, DOS initially assumed the input "Console" commands came from a keyboard and output was sent to the display..
    However, one could change the console input so it came from a serial port. It was a simple DOS command string usually in the autoexec.bat file.
    BTW, this did not disable the keyboard so both the keyboard and serial input could operate the computer.

    Does anyone know if non DOS based windows machines can have alternate console inputs? If so one would simply enable the serial console and just use the prop dongle without any changes.

    As I recall, and as Mike Green said, the keyboard input is quite complex. But the output from the keyboard console program to DOS and subsequently Windows is simply the characters one types. The same as with the serial console which is simply characters.

    Does anyone know if I/O is still "Console" based and how to use it?

    If this is still true it would be simple for the Propeller to do it.

    Duane
  • TubularTubular Posts: 4,708
    edited 2011-12-07 10:25
    You can also buy black boxes called "keyboard encoders". These accept a serial stream (eg from the Prop), and convert them to 'keypresses' for the PC under test.

    This is a hardware solution so it doesn't depend on drivers, operating systems, and can "test" any software that can be keyboard driven.

    I believe there are also mouse versions but haven't used them. Control characters are supported to be simulate "Key chords" such as Ctrl-Alt-T, etc
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2011-12-07 10:58
    Seems a shame that we couldn't find a way to push the current USB stuff (Mike linked to) to becoming a way to upload to the Propeller's RAM. It would require a special program in the EEPROM for sure, and of course a special program on the PC side, but could open the door to programmable Propeller boards that didn't require FTDI chips. (Providing the EEPROM was provided pre-programmed)

    OBC
  • coryco2coryco2 Posts: 107
    edited 2011-12-09 17:13
    Thanks to all for the comments; I found the info very useful! :smile:
Sign In or Register to comment.