Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/wii2usb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Core
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-10 17:41:13 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-10-10 17:41:13 +0300
commita4a6e7865cf48f2a63971781c6a43faa17f6ae77 (patch)
tree701a5076d7938b54bb01f4e71c036b29a98d0c10 /Core
parentfb1a19cac417e7020e9de1b8af26e78fb7ca1077 (diff)
Nintenso Switch compatibility
Diffstat (limited to 'Core')
-rw-r--r--Core/Inc/main.h44
-rw-r--r--Core/Inc/stm32f1xx_hal_conf.h14
-rw-r--r--Core/Inc/stm32f1xx_it.h2
-rw-r--r--Core/Src/main.c56
-rw-r--r--Core/Src/stm32f1xx_hal_msp.c2
-rw-r--r--Core/Src/stm32f1xx_it.c1
6 files changed, 68 insertions, 51 deletions
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 3bda995..b5c18ec 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -39,14 +39,40 @@ extern "C" {
/* USER CODE BEGIN ET */
typedef struct __attribute__((packed))
{
- int8_t x;
- int8_t y;
- int8_t z;
- int8_t rx;
- int8_t ry;
- int8_t rz;
- uint8_t hat_switch;
- uint16_t buttons;
+ // 0
+ unsigned int Y : 1;
+ unsigned int B : 1;
+ unsigned int A : 1;
+ unsigned int X : 1;
+ unsigned int L : 1;
+ unsigned int R : 1;
+ unsigned int ZL : 1;
+ unsigned int ZR : 1;
+ // 1
+ unsigned int minus : 1;
+ unsigned int plus : 1;
+ unsigned int lclick : 1;
+ unsigned int rclick : 1;
+ unsigned int home : 1;
+ unsigned int capture : 1;
+ unsigned int : 2; // unused bits
+ // 2
+ unsigned int hat_switch : 4;
+ unsigned int : 4; // unused bits
+ // 3
+ uint8_t LX : 8;
+ // 4
+ uint8_t LY : 8;
+ // 5
+ uint8_t RX : 8;
+ // 6
+ uint8_t RY : 8;
+ // 7
+ unsigned int : 8; // unknown
+ // 8
+ //uint8_t ExtraX : 8; // for nunchuck
+ // 9
+ //uint8_t ExtraY : 8; // for nunchuck
} USB_JoystickReport_Data_t;
/* USER CODE END ET */
@@ -83,5 +109,3 @@ void Error_Handler(void);
#endif
#endif /* __MAIN_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Core/Inc/stm32f1xx_hal_conf.h b/Core/Inc/stm32f1xx_hal_conf.h
index b3a4f0d..ffdeb3b 100644
--- a/Core/Inc/stm32f1xx_hal_conf.h
+++ b/Core/Inc/stm32f1xx_hal_conf.h
@@ -1,3 +1,4 @@
+/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f1xx_hal_conf.h
@@ -5,16 +6,16 @@
******************************************************************************
* @attention
*
- * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
- * All rights reserved.</center></h2>
+ * Copyright (c) 2017 STMicroelectronics.
+ * All rights reserved.
*
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
+/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F1xx_HAL_CONF_H
@@ -388,4 +389,3 @@ void assert_failed(uint8_t* file, uint32_t line);
#endif /* __STM32F1xx_HAL_CONF_H */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Core/Inc/stm32f1xx_it.h b/Core/Inc/stm32f1xx_it.h
index df49c30..a603caf 100644
--- a/Core/Inc/stm32f1xx_it.h
+++ b/Core/Inc/stm32f1xx_it.h
@@ -66,5 +66,3 @@ void USB_LP_CAN1_RX0_IRQHandler(void);
#endif
#endif /* __STM32F1xx_IT_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 142754d..8ed9b03 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -136,40 +136,39 @@ int main(void)
wii_accessory_data.button_r, wii_accessory_data.button_zl,
wii_accessory_data.button_zr, wii_accessory_data.wtf);
#endif
-
- joystick_data.x = wii_accessory_data.jx;
- joystick_data.y = wii_accessory_data.jy;
- if (wii_accessory_data.data_format == 0) // Nunchuck
+ memset(&joystick_data, 0, sizeof(joystick_data));
+ joystick_data.LX = 0x80 + wii_accessory_data.jx;
+ joystick_data.LY = 0x80 + wii_accessory_data.jy;
+ if (wii_accessory_data.data_format == 0)
{
- // Accelerometer
- joystick_data.rx = wii_accessory_data.acc_x;
- joystick_data.ry = wii_accessory_data.acc_y;
- joystick_data.rz = wii_accessory_data.acc_z;
+ // Nunchuck
+ // Accelerometers
+ joystick_data.RX = 0x80 + wii_accessory_data.acc_x;
+ joystick_data.RY = 0x80 + wii_accessory_data.acc_y;
+ //joystick_data.ExtraX = 0x80 + wii_accessory_data.acc_z;
} else {
- joystick_data.z = wii_accessory_data.rx;
- joystick_data.rx = wii_accessory_data.ry;
+ joystick_data.RX = 0x80 + wii_accessory_data.rx;
+ joystick_data.RY = 0x80 + wii_accessory_data.ry;
// Unsigned for trigger analog buttons
- joystick_data.ry = wii_accessory_data.tl - 128;
- joystick_data.rz = wii_accessory_data.tr - 128;
+ //joystick_data.ExtraX = wii_accessory_data.tl;
+ //joystick_data.ExtraY = wii_accessory_data.tr;
}
- joystick_data.buttons = (wii_accessory_data.button_a << 0)
- | (wii_accessory_data.button_b << 1)
- | (wii_accessory_data.button_x << 2)
- | (wii_accessory_data.button_y << 3)
- | (wii_accessory_data.button_select << 4)
- | (wii_accessory_data.button_start << 5)
- | (wii_accessory_data.button_home << 6)
- | (wii_accessory_data.button_l << 7)
- | (wii_accessory_data.button_r << 8)
- | (wii_accessory_data.button_zl << 9)
- | (wii_accessory_data.button_zr << 10);
+ joystick_data.A = wii_accessory_data.button_a;
+ joystick_data.B = wii_accessory_data.button_b;
+ joystick_data.X = wii_accessory_data.button_x;
+ joystick_data.Y = wii_accessory_data.button_y;
+ joystick_data.L = wii_accessory_data.button_l;
+ joystick_data.R = wii_accessory_data.button_r;
+ joystick_data.ZL = wii_accessory_data.button_zl;
+ joystick_data.ZR = wii_accessory_data.button_zr;
+ joystick_data.minus = wii_accessory_data.button_select;
+ joystick_data.plus = wii_accessory_data.button_start;
+
if (wii_accessory_data.dpad_up && wii_accessory_data.dpad_right)
joystick_data.hat_switch = 1;
- else if (wii_accessory_data.dpad_right
- && wii_accessory_data.dpad_down)
+ else if (wii_accessory_data.dpad_right && wii_accessory_data.dpad_down)
joystick_data.hat_switch = 3;
- else if (wii_accessory_data.dpad_down
- && wii_accessory_data.dpad_left)
+ else if (wii_accessory_data.dpad_down && wii_accessory_data.dpad_left)
joystick_data.hat_switch = 5;
else if (wii_accessory_data.dpad_left && wii_accessory_data.dpad_up)
joystick_data.hat_switch = 7;
@@ -249,6 +248,7 @@ void SystemClock_Config(void)
{
Error_Handler();
}
+
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
@@ -368,5 +368,3 @@ void assert_failed(uint8_t *file, uint32_t line)
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Core/Src/stm32f1xx_hal_msp.c b/Core/Src/stm32f1xx_hal_msp.c
index 8815c3b..2cf6142 100644
--- a/Core/Src/stm32f1xx_hal_msp.c
+++ b/Core/Src/stm32f1xx_hal_msp.c
@@ -149,5 +149,3 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c
index 4ee9689..a11b485 100644
--- a/Core/Src/stm32f1xx_it.c
+++ b/Core/Src/stm32f1xx_it.c
@@ -214,4 +214,3 @@ void USB_LP_CAN1_RX0_IRQHandler(void)
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/