mumumusuc / pi-joystick

使用raspberry zero模拟nintendo switch的手柄与声卡
GNU General Public License v3.0
52 stars 10 forks source link

[Question] How do I use this? #1

Closed rinsuki closed 5 years ago

rinsuki commented 5 years ago

I obtained /dev/hidg0 using this library, but sending data there is not recognized by the Switch. How do I use this?

my environment:

my script:

import time
fp = open("/dev/hidg0", "wb")

s = bytes([
    0x30,
    0,
    8,
    0,
    0,
    0,
    0,
    0
])
print(s)
fp.write(s)
fp.flush()
time.sleep(0.1)
s = b'\0\0\x08\0\0\0\0\0'
print(s)
fp.write(s)
fp.flush()
fp.close()

Thanks!

mumumusuc commented 5 years ago

I uploaded the latest files,and using the "hori-s.h" as the default device.You can select between "Hori-s Gamepad" and "Nintendo Switch Pro" by modifying "joystick.h".

@ joystick.h

5 #include "hori-s.h"   // simulate hori device
5 #include "switch-pro.h" // simulate pro device

For "hori-s",sending {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00} to connect to Switch. For "switch-pro",following this INSTRUCTION to connect to Switch.

rinsuki commented 5 years ago

really thanks!! it work!!!! 🙏