JOYCON_CTLR_TYPE_JCL = 0x01,
JOYCON_CTLR_TYPE_JCR = 0x02,
JOYCON_CTLR_TYPE_PRO = 0x03,
+ JOYCON_CTLR_TYPE_LIC_PRO = 0x06,
JOYCON_CTLR_TYPE_NESL = 0x09,
JOYCON_CTLR_TYPE_NESR = 0x0A,
JOYCON_CTLR_TYPE_SNES = 0x0B,
{ /* sentinel */ },
};
+/* Licensed Pro Controllers (e.g. HORI) swap X/Y bits in the report */
+static const struct joycon_ctlr_button_mapping lic_procon_button_mappings[] = {
+ { BTN_EAST, JC_BTN_A, },
+ { BTN_SOUTH, JC_BTN_B, },
+ { BTN_NORTH, JC_BTN_Y, },
+ { BTN_WEST, JC_BTN_X, },
+ { BTN_TL, JC_BTN_L, },
+ { BTN_TR, JC_BTN_R, },
+ { BTN_TL2, JC_BTN_ZL, },
+ { BTN_TR2, JC_BTN_ZR, },
+ { BTN_SELECT, JC_BTN_MINUS, },
+ { BTN_START, JC_BTN_PLUS, },
+ { BTN_THUMBL, JC_BTN_LSTICK, },
+ { BTN_THUMBR, JC_BTN_RSTICK, },
+ { BTN_MODE, JC_BTN_HOME, },
+ { BTN_Z, JC_BTN_CAP, },
+ { /* sentinel */ },
+};
+
static const struct joycon_ctlr_button_mapping nescon_button_mappings[] = {
{ BTN_SOUTH, JC_BTN_A, },
{ BTN_EAST, JC_BTN_B, },
static inline bool joycon_type_is_procon(struct joycon_ctlr *ctlr)
{
- return ctlr->ctlr_type == JOYCON_CTLR_TYPE_PRO;
+ return ctlr->ctlr_type == JOYCON_CTLR_TYPE_PRO ||
+ ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO;
}
static inline bool joycon_type_is_snescon(struct joycon_ctlr *ctlr)
joycon_report_left_stick(ctlr, rep);
joycon_report_right_stick(ctlr, rep);
joycon_report_dpad(ctlr, rep);
- joycon_report_buttons(ctlr, rep, procon_button_mappings);
+ if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO)
+ joycon_report_buttons(ctlr, rep, lic_procon_button_mappings);
+ else
+ joycon_report_buttons(ctlr, rep, procon_button_mappings);
} else if (joycon_type_is_any_nescon(ctlr)) {
joycon_report_dpad(ctlr, rep);
joycon_report_buttons(ctlr, rep, nescon_button_mappings);
joycon_config_left_stick(ctlr->input);
joycon_config_right_stick(ctlr->input);
joycon_config_dpad(ctlr->input);
- joycon_config_buttons(ctlr->input, procon_button_mappings);
+ if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO)
+ joycon_config_buttons(ctlr->input, lic_procon_button_mappings);
+ else
+ joycon_config_buttons(ctlr->input, procon_button_mappings);
} else if (joycon_type_is_any_nescon(ctlr)) {
joycon_config_dpad(ctlr->input);
joycon_config_buttons(ctlr->input, nescon_button_mappings);
if (joycon_has_joysticks(ctlr)) {
/* get controller calibration data, and parse it */
- ret = joycon_request_calibration(ctlr);
- if (ret) {
+ if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO) {
/*
- * We can function with default calibration, but it may be
- * inaccurate. Provide a warning, and continue on.
+ * Licensed controllers may have incompatible SPI flash
+ * layouts. Use default calibration values.
*/
- hid_warn(hdev, "Analog stick positions may be inaccurate\n");
+ hid_info(hdev, "using default cal for licensed controller\n");
+ joycon_use_default_calibration(hdev,
+ &ctlr->left_stick_cal_x,
+ &ctlr->left_stick_cal_y,
+ "left", 0);
+ joycon_use_default_calibration(hdev,
+ &ctlr->right_stick_cal_x,
+ &ctlr->right_stick_cal_y,
+ "right", 0);
+ } else {
+ ret = joycon_request_calibration(ctlr);
+ if (ret) {
+ /*
+ * We can function with default calibration, but
+ * it may be inaccurate. Provide a warning, and
+ * continue on.
+ */
+ hid_warn(hdev, "Analog stick positions may be inaccurate\n");
+ }
}
}
/* Enable the IMU */
ret = joycon_enable_imu(ctlr);
if (ret) {
- hid_err(hdev, "Failed to enable the IMU; ret=%d\n", ret);
- goto out_unlock;
+ if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO) {
+ hid_dbg(hdev, "IMU enable failed for licensed controller, continuing\n");
+ ret = 0;
+ } else {
+ hid_err(hdev, "Failed to enable the IMU; ret=%d\n", ret);
+ goto out_unlock;
+ }
}
}
/* Enable rumble */
ret = joycon_enable_rumble(ctlr);
if (ret) {
- hid_err(hdev, "Failed to enable rumble; ret=%d\n", ret);
- goto out_unlock;
+ if (ctlr->ctlr_type == JOYCON_CTLR_TYPE_LIC_PRO) {
+ hid_dbg(hdev, "rumble enable failed for licensed controller, continuing\n");
+ ret = 0;
+ } else {
+ hid_err(hdev, "Failed to enable rumble; ret=%d\n", ret);
+ goto out_unlock;
+ }
}
}
USB_DEVICE_ID_NINTENDO_GENCON) },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO,
USB_DEVICE_ID_NINTENDO_N64CON) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_HORI,
+ USB_DEVICE_ID_HORI_WIRELESS_SWITCH_PAD) },
{ }
};
MODULE_DEVICE_TABLE(hid, nintendo_hid_devices);