5

I'd like to build a RaspberryPi-based device that can communicate with my Linux laptop over USB (don't think it matters, but I'll be using a custom made USB dongle that has an FTDI chip on it, and my laptop will have the FTDI drivers installed on it).

I'd like to rig my device with a simple control stick and a simple keyboard, and what I'd like to do is control my laptop's mouse and keyboard through this device. So:

  • Mouse Example:
    • I move the controller connected to the RPi
    • RPi converts this into some kind of command/input event
    • RPi sends this command/input event to the USB/FTDI dongle plugged into my laptop
    • USB/FTDI dongle sends command/input to FTDI device drivers
    • Somehow (???) the mouse (correctly) moves on my laptops screen
  • Keyboard Example
    • I type a key on the keyboard connected to the RPi
    • RPi converts this into some kind of command/input event
    • RPi sends this command/input event to the USB/FTDI dongle plugged into my laptop
    • USB/FTDI dongle sends command/input to FTDI device drivers
    • Somehow (???) the OS receives this command/input and handles it appropriately; for example if an app is open on the screen and a particular textfield has focus, the key will show up inside of it, etc.

I can handle everything up to the FTDI drivers receiving the command/input, but where I'm lost is how I can get those drivers to "talk" to whatever part of Linux that is responsible for moving the mouse or handling keystrokes. Any ideas?


I assume I need to write some native C code that will:

  1. Read from the serial port (where commands/inputs from the RPi will be sent)
  2. Translate the data on that port into a structured command (MOVE_MOUSE_10_PIXELS_LEFT, KEYSTROKE_A, KEYSTROKE_H, etc.)
  3. Somehow communicate to the Linux OS and tell it to handle such a command. In the case of a MOVE_MOUSE_* command, this means telling Linux to actually move the mouse coordinates on the screen. In the case of a KEY_* command, this means telling Linux to act as if a user had typed that key right there on the laptop's keyboard.

I'm simply unsure of how to accomplish Step #3 above.

smeeb
  • 4,950
  • 10
  • 33
  • 52

1 Answers1

1

I have such a setup with Altera DE2 FPGA with C and assembly code writing to uart0 and I use minicom in Linux Ubuntu on another computer to read the data from the FPGA. You have to figure out how interrupts work with you system and how serial communication is done. I did it in C and assembly, but you can check how it is donoe in python