HID mouse emulation with Arduino + Usb HostShield!
- Please DO NOT use this repository for illegal activities.
- 이 레포지토리를 불법적인 활동을 하는데 사용하지 말아주세요.🥲
- before you begin, make sure you have an
Arduino Leonardo R3 ATmega32u4with aSoldered USB HostShield. - This code was designed for my Glorious Model O Mouse, so if it doesn't work with yours, you will need to modify it according to the instructions below.
- You will need Arduino IDE version 1.8.19 or higher(This code was written for version 1.8.19 and might not work correctly on later versions).
- Download and unpack the repository archive to
C:\Users\your_username\Documents\Arduino\libraries\HID-Arduino-HostShield. - Download and unpack this archive into
C:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0. - All Arduino script files are located in a folder that has the same name as the file itself.
- Inside the repository, there are two versions of the Arduino script. All of these behaviors are fully adjustable and can be changed to suit your needs(Check the update list as there may be other files in the latest version).
RandomDelay_RandomMove.ino: This script receives coordinates from a PC and performs a series of human-like movements. Instead of moving directly to the target coordinates, it intentionally introduces a random delay and first moves to a nearby location before moving to the final, specified coordinates. This staged movement is designed to mimic the unpredictable nature of human-like behavior.
RandomDelay.ino: In contrast, this version is much simpler. After receiving and moving to a set of coordinates, it only adds a random delay before receiving the next command.
- Open Arduino script what you want.
- Connect the computer, Arduino Leonardo R3, and USB host shield together.
- Set the board and port under the toos menu, then upload the Arduino script.
- If your mouse works properly after upload, you are all set.
- Change
#define ENABLE_UHS_DEBUGGING 0to#define ENABLE_UHS_DEBUGGING 1inC:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0\settings.h. - Open
Debug.inoand upload it. - Press
Ctrl + Shift + Mand set them toBoth NL & CRand9600 baud rate. - Move the mouse and check the serial monitor.
- The serial monitor will typically display something like
00 00 00 00 00 00 00 00. Observe which byte changes (and to what value, in octal or hexadecimal) when you press a specific mouse button. If your mouse's X, Y values are octal, you must change void onMouseMove(int16_t x, int16_t y, int8_t wheel) to int8_t x, int8_t y, and so on If the X buttons don't work, you'll need to change#define MOUSE_NEXTand#define MOUSE_PREVto the numbers that appear when XButton1 or XButton2 are pressed, like#define MOUSE_NEXT (number when XButton2 is pressed),#define MOUSE_PREV (number when XButton2 is pressed). If the scroll wheel doesn't work well, you may need to modifyScrollValueinside.\hidmouserptparser.cpp, but it might be easier to get help from ChatGPT or Gemini. - Once everything is working correctly, change
#define ENABLE_UHS_DEBUGGING 1back to#define ENABLE_UHS_DEBUGGING 0inC:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0\settings.h. - Upload
Debug.inoagain, and then upload the Arduino script file you want to use.
- 이건 제 글로리어스 모델 O 마우스 위주로 위주로 코딩한거라 사용자의 마우스에 따라 작동이 되지 않을 수 있으며 작동이 되지 않는다면 아래 나와있는대로 따로 코딩을 하셔야 합니다.
- 이 코드를 사용하려면
아두이노 레오나르도 R3 ATMEGA32U4,납땜한 아두이노 USB 호스트쉴드가 필요합니다 없으면 납땜 가격포함 약 2만원정도로 그렇게 안비싸니 하나 사시는걸 추천드려요 - 아두이노 IDE 버전은 1.8.19버전 이상(1.8.19버전에서 작성한거라 상위 버전에선 작동 안할수도 있음)이 필요합니다
- 파일을 다운받고 압축풀어서
C:\Users\your_username\Documents\Arduino\libraries\HID-Arduino-HostShield여기에 이렇게 저장해주세요 - 이 파일을 다운받아 압축풀고
C:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0여기에 이렇게 저장해주세요 - 모든 아두이노 스크립트 파일은 해당 파일의 이름을 가지고 있는 폴더 안에 있습니다
- 파일 안에는 두가지 버전의 아두이노 스크립트가 있습니다.
RandomDelay_RandomMove.ino는 PC로부터 좌표를 받고 움직이고 나서 다시 좌표를 받을때 일부러 무작위 딜레이를 걸며 PC에서 좌표가 보내질때 바로 그 좌표로 움직이지 않고 그 주변으로 움직인뒤에 PC에서 보낸 좌표로 움직여 사람처럼 보이게 합니다.RandomDelay.ino는 좌표를 받고 움직이고나서 다시 좌표를 받을때 무작위 딜레이만 걸며 이 모든건 다 변경이 가능합니다 최신 버전에선 다른 파일들도 있을 수 있으니 업데이트 목록을 확인하세요
- 사용하고 싶은 아두이노 스크립트 파일을 여세요
- 아두이노 레오나르도 보드, 컴퓨터, USB 호스트쉴드를 서로 연결해주세요
- 툴에 있는 보드와 포트 설정을 해주고나서 아두이노 스크립트를 업로드 해주세요
- 마우스가 잘 작동된다면 성공!
C:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0\settings.h에서#define ENABLE_UHS_DEBUGGING 0을#define ENABLE_UHS_DEBUGGING 1로 바꾸세요Debug.ino파일을 열고 업로드하세요Ctrl + Shift + M을 누르고 오른쪽 아래에 있는걸Both NL & CR,9600 보드레이트로 설정하세요- 마우스를 움직이고 버튼을 누르면서 시리얼 모니터를 확인하세요
- 자 이제부터가 중요합니다. 시리얼 모니터가
00 00 00 00 00 00 00 00과 비슷하게 뜰텐데 마우스에서 어떤 버튼을 눌렀을때 몇 번째가 어떤 숫자로 바뀌는지, 8진수인지 16진수인지를 알아내야합니다 자신의 마우스의 x, y가 8진수라면 모든void onMouseMove(int16_t x, int16_t y, int8_t wheel)에서int8_t x,int8_t y과 같이 바꾸거나 X버튼이 먹히지 않는다면#define MOUSE_NEXT (XButton2을 눌렀을때 나오는 숫자),#define MOUSE_PREV (XButton2을 눌렀을때 나오는 숫자))과 같이 해야하거나 스크롤이 잘 먹히지 않는다면.\hidmouserptparser.cpp안에있는ScrollValue값을 변경하거나 해야하지만 챗지피티나 제미나이에게 도움을 받는것이 편할수도 있습니다 - 이후에 모든것이 잘 작동한다면 다시
C:\Users\your_username\Documents\Arduino\libraries\USB_Host_Shield_2.0-1.7.0\settings.h에서#define ENABLE_UHS_DEBUGGING 1을#define ENABLE_UHS_DEBUGGING 0로 바꾸세요 - 다시 한 번 더
Debug.ino를 업로드한 뒤에 원하는 아두이노 스크립트 파일을 업로드하여 사용하시면 됩니다
- Added a new file called
Serial_InstantDragClickIt lets you imitate drag clicking with both the left and right mouse buttons. To use, upload a file and press left or right button. Serial_InstatnDragClick이란 새 파일을 추가했습니다. 마우스 좌클릭, 우클릭을 꾹 눌러 드래그 클릭을 흉내낼 수 있습니다.
- If the mouse's polling rate(hz) is very low, it may not work well
- 마우스의 폴링레이트(hz)가 낮다면 잘 작동하지 않을 수 있습니다
- If the Arduino script doesn't compile you must check that you're NOT using the Windows Store version of Arduino IDE and you are using the one from the link in the setup tutorial
- 아두이노 스크립트가 컴파일되지 않는다면 윈도우 스토어 버전 아두이노 IDE를 사용하고 있는게 아닌지 확인하세요
- If your Arduino has issues working in general, try using a different USB port and a better cable. I recommend the one that comes with the Arduino
- 아두이노가 일반적으로 작동하는데 문제가 있다면, 다른 USB 케이블을 사용해보세요(아두이노 살 때 같이 동봉되서 오는 케이블을 사용하는걸 추천합니다)
- If this doesn't work, read it all over again slowly
- 모든걸 다해봤는데도 잘 작동하지 않는다면 이걸 다시 처음부터 천천히 읽어보세요
- The Arduino receives and processes the value sent by the PC in the format of
X,Y,Click_State - 아두이노는 PC가
X,Y,클릭상태처럼 주는 값을 받아 처리합니다 - In Arduino Script(C++),
1 == 1ms == 0.001sec / random(1, 10) == 1 ~ 9, so be careful when setting delays - 아두이노 스크립트(C++)에선
1 == 1ms == 0.001sec / random(1, 10) == 1 ~ 9이니 딜레이를 설정할때 주의하세요