I've managed to map all buttons and triggers from joycons using joycon-python to an emulated Xbox 360 controller using vgamepad. However, I cannot figure out how to map the joysticks. I've tried tons of different ways. In the worst cases I get no output at all, while in the best cases the emulated output goes strictly and strongly into one direction, which I can't noticeably influence by moving the sticks.
import vgamepad as vg
import time
from pyjoycon import JoyCon, get_R_id, get_L_id
right_joycon_id = get_R_id()
left_joycon_id = get_L_id()
right_joycon = JoyCon(*right_joycon_id)
left_joycon = JoyCon(*left_joycon_id)
gamepad = vg.VX360Gamepad()
while True:
right_report = right_joycon.get_status()
left_report = left_joycon.get_status()
right_stick_x = right_report['analog-sticks']['right']['horizontal']
right_stick_y = right_report['analog-sticks']['right']['vertical']
left_stick_x = left_report['analog-sticks']['left']['horizontal']
left_stick_y = left_report['analog-sticks']['left']['vertical']
mapped_right_stick_x = int((right_stick_x - 32768) * 32767 / 32768)
mapped_right_stick_y = int((right_stick_y - 32768) * 32767 / 32768)
mapped_left_stick_x = int((left_stick_x - 32768) * 32767 / 32768)
mapped_left_stick_y = int((left_stick_y - 32768) * 32767 / 32768)
gamepad.right_joystick(x_value=mapped_right_stick_x, y_value=mapped_right_stick_y)
gamepad.left_joystick(x_value=mapped_left_stick_x, y_value=mapped_left_stick_y)
gamepad.update()
time.sleep(0.005)
With this code, the output just continuously points the emulated joysticks sharply to the lower left regardless of the physical state of the sticks.
Indeed I barely know what I'm doing and am probably overlooking something obvious, but I got quite far mapping all other functions (aside from rumble), so I hope someone can explain what I'm missing