Git Product home page Git Product logo

rasp_vusb's Introduction

What is it?

This repo explains how to turn your Raspberry Pi Zero into USB Keyboard and Mouse. Also provides sample code and binaries to control them.

Steps - Installation

  1. Flash your SD card with NOOBS (download: https://www.raspberrypi.org/downloads/noobs/) or use your installed Raspbian.

  2. Make /share directory on your raspberry pi.

    $ sudo mkdir -m 1777 /share
    
  3. Run /script/deploy_with_pscp.bat on your PC to deploy files to Raspberry PI Zero. (download pscp.exe from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

    c:\...\script> deploy_with_pscp.bat [your_raspberrypi_ip]
    
    For example, if the address of your raspberry pi is 192.168.0.100
    
    c:\...\script> deploy_with_pscp.bat 192.168.0.100
    
  4. On your raspberry pi, make /share/install_usb.sh and /share/rasp_vusb_server.out runnable.

    $ sudo chmod +x /share/install_usb.sh
    $ sudo chmod +x /share/rasp_vusb_server.out
    
  5. Run install_usb.sh

    $ sudo /share/install_usb.sh
    
  6. That's all, all of the changes will be applied after reboot.

    $ sudo reboot
    
  7. Finally, connect your Raspberry PI zero to your Computer. Go to your "Control panel" / "Device Manager", you can find 3 new devices.

    Human Interface Devices
        * USB Input Device
    
    Keyboards
        * HID Keyboard Device
    
    Mice and other pointing devices
        * HID-compliant mouse  (Absolute position + buttons)
        * HID-compliant mouse  (Relative position + wheel)
    

    You can get the report descriptors at /report_descriptors.txt

How to Test

Now, you can run "InputController.exe (from /bin/v1_0_0_2/InputController.zip)" on your Windows PC. As soon as run, it will find "usb_server" program which is run in Raspberry PI and connect it automatically.

At first, InputController parse input as mouse data. So you can move to specific position as whatever you want but need to calculate for your circumstances. If you move to x = 50, y = 100 and your monitor's resolution is 1920 * 1080, your input has to be like this,

x = 50 * 32767 / 1920 = 853
y = 100 * 32767 / 1080 = 3033

then type it,

853 3033

you can find your mouse position is moved to (50, 100) on windows.

Also, you can move your mouse relatively. For this, type '+' or '-' prefix to number.

+50 -10

And control wheel on the mouse with 'w' prefix to offset value.

w10

It acts as scrolling down, or type "w-50" to scroll up with offset 50.

For testing input as keyboard, change the mode by typing "--mode" command,

--mode

(If you type "--mode" again, it will change to mouse input mode)

Now you can type any text and just hit ENTER,

test is good

then, your PC will accept "test is good" key inputs. Of course, you can send any special inputs of these,

Left Window key: <window>
IME toggle key: <ime>
Enter Key: <return>
Control Down: <ctrl_down>
Control Up: <ctrl_up>
Shift Down: <shift_down>
Shift Up: <shift_up>
Alt Down: <alt_down>
Alt Up: <alt_up>
CapsLock: <capslock>
ESC: <esc>
Backspace: <backspace>
Tab: <tab>
Insert: <insert>
Home: <home>
Page Up: <pageup>
Page Down: <pagedown>
Delete: <del>
End: <end>
Left Arrow key: <left>
Right Arrow key: <right>
Up Arrow key: <up>
Down Arrow Key: <down>
F1 ~ F12: <f1> ~ <f12>

If you type like this,

test is good<backspace>d <shift_down>wow<shift_up>

you will see this text input,

test is good WOW

Steps - Uninstallation

  1. Just run uninstall_usb.sh.
$ sudo /share/uninstall_usb.sh
  1. Reboot.
$ sudo reboot

Change Log

1.0.0.2 - Dec 20, 2017

  • apply ssl socket

1.0.0.1 - Oct 13, 2017

  • Add "--shutdown" command to shutdown raspberry pi.

1.0.0.0 - Oct 12, 2017

  • Initial checked-in

How to build

If you want to modify InputController.exe and rasp_vusb_server.out, just load rasp_usb.sln in Visual Studio 2017, and build it.

It needs connection info to Raspberry Pi for compiling C++ source codes to ARM machine codes.

Requests or Contributing to Repository

Any help and advices for this repo are welcome.

License

Apache License V2.0 (Refer to LICENSE.txt)

rasp_vusb's People

Contributors

stjeong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rasp_vusb's Issues

Increase hold of left click

Hello, thank you for making this project open source. I ran succefully in a raspberry pi zero w. However, I need to hold the left click for around 3-4 seconds. Could you please give a general instruction on how I can achieve this?

I was trying to add a sleep at the end of MouseDevice::SendRelative function inside the rasp_vusb_server but I'm having some trouble building this project. Could you please inform If I'm in the right path.

ABS mouse movements do not work

After changing to version 0 which works, under Linux, only keyboard and relative mouse movements work. I cannot pinpoint a reason for this in the code. There are no code changes between version 0 and 2 which relate to the mouse/keyboard control thus I believe this to still be broken.
Client: Arch Linux, Mono V.6.4.0
Server: Raspberry pi 0 w 1.1
Host: Fedora Linux

Compatible with Raspberry Pi Zero 2

Hi,

Is the triple-usb-device script is compatible with Zero 2 model?

I've just ran throught all the steps but I can't get to display device in Windows machine.

I have a Zero (1) and it works perfect there, so I'm suspecting a compatibility issue with Zero 2.

I hope you can guide me through.

Thank you.

Mouse movement not working with Linux Systems

Hello!

A represent a team of engineers that are enjoying using your application to automate mouse and keyboard on Windows computers. We've discovered that the device doesn't behave similarly when connected to a Linux device (Mouse inputs aren't working). Would you be able to point us in your code where we can begin looking to try to solve this issue on our own? Thanks and take care!

[Question] Why send always a 1 in the Modifier Key byte

https://github.com/stjeong/rasp_vusb/blob/master/rasp_vusb_server/KeyboardDevice.cpp#L32

@stjeong Is there a special reason that you need to send a 1 in the modifier key byte?

I am capturing USB "packets" with Wireshark and I see my regular keyboard sends a packet without the number 1 at the begining.

Of course If I remove the 1 from the code, recompile and run, the RaspberryPi keyboard stops working.

I was trying to understand this project following this structure but it looks like I am missing something.

https://wiki.osdev.org/USB_Human_Interface_Devices "USB keyboard" section

Would you mind sharing the reason behind this?

How to do a mouse click?

move and scroll is working without any problem.
but i can't find the way to command mouse click.

Overall working flow

Hello, I'm very surprised to find a project which seems to emulate both mouse and keyboard at the same time.
Anyway, I think it would be very useful to add to the readme file an overall working flow to describe how basically works your project.

get bus error

I get this error

Capture1

and if you make an image of your raspberry, can you share it, please?

pi@raspberrypi:/share $ ./rasp_vusb_server.out 1 1
starting...
module path: /share
init_openssl
completed: init_openssl
Bus error

the error goes when I remove the line _emulator.Run();
can you help me to figure out the problem?

API docs/C++ DLL

I'm going to go dig on that C# code. I've not written C#, so I just have to go figure out what it's doing. It would be cool to even have "api" docs. I see the TCP socket connect. Do I have to use ssl? Even if it was just a sudo code simplified common language document that is just like:

1: tcp connect to ip
2: send bytes

Just so I don't have to poke and prod so much. I wanted to try this: https://github.com/3F/DllExport

It looks like you apply some "decorators" (this is what it's called in python) and it can allow you to call methods from c++. This requires sln files though. I guess cs proj is "old"? I just don't know enough.

I'll contribute something if I put anything coherent together.

Fail in "Create Mouse/Keyboard USB gadgets"

Hey,
I really liked the project and it is definitely what I was searching for. But when I try to test it, Mouse and Keyboard don't work. I followed all steps in README. I'm also testing it on Windows. I think it has to do with a fail in creating the gadgets : "loaded failed failed Create Mouse/Keyboard USB gadgets" (as it shows in the following picture)

Screenshot_2

Is there a documentation for these errors where I can check?
Thanks in advance :)

Run by Pi

Hello, Im currently trying to setup this project.
My problem is, that i dont unterstand, how to give the Pi the parameters to move the Mouse.
Is there any way, to controle the windowsmachine only by using scripts on the pi?
Sry my C-Language knowledge isnt that good.

I think the commands for the USB output is written into /dev/hidg0
But i cant get the project run for reverse engineering what this file needs to function

I guess something like 0x07...

Job for usb_server.service failed because the control process exited with error code

I was trying this on a rp4 and in the installation I found this error. I checked systemctl status usb_server.service
and the results are:

● usb_server.service - Service for Mouse/Keyboard USB gadgets
     Loaded: loaded (/etc/systemd/system/usb_server.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2023-02-10 15:51:05 EST; 26s ago
        CPU: 5ms

Feb 01 15:51:01 rp4 systemd[1]: Starting Service for Mouse/Keyboard USB gadgets...
Feb 01 15:51:01 rp4 rasp_vusb_server.out[1123]: /share/rasp_vusb_server.out: error while loading shared libraries: libwiringPi.so: cannot open shared object file: No such file or directory
Feb 01 15:51:01 rp4 systemd[1]: usb_server.service: Control process exited, code=exited, status=127/n/a
Feb 01 15:51:01 rp4 systemd[1]: usb_server.service: Failed with result 'exit-code'.
Feb 01 15:51:01 rp4 systemd[1]: Failed to start Service for Mouse/Keyboard USB gadgets.

So I guess that I am missing libwiringPi.so? or there is any other thing to fix this?
thanks

INCLUDE Directories

Hi,
I want to ask you about the direction directory of these folders or give me the way to build the
Capture

Mouse proxy

Are there any plans to make a mouse proxy? By proxy I mean to read movement values and button presses of a mouse connected to Raspberry Pi Zero for example via Bluetooth and passing it to the USB port of Raspberry Pi Zero in gadget mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.