4141 */
4242
4343/* Output Reports */
44- static const u8 JC_OUTPUT_RUMBLE_AND_SUBCMD = 0x01 ;
45- static const u8 JC_OUTPUT_FW_UPDATE_PKT = 0x03 ;
46- static const u8 JC_OUTPUT_RUMBLE_ONLY = 0x10 ;
47- static const u8 JC_OUTPUT_MCU_DATA = 0x11 ;
48- static const u8 JC_OUTPUT_USB_CMD = 0x80 ;
44+ #define JC_OUTPUT_RUMBLE_AND_SUBCMD 0x01
45+ #define JC_OUTPUT_FW_UPDATE_PKT 0x03
46+ #define JC_OUTPUT_RUMBLE_ONLY 0x10
47+ #define JC_OUTPUT_MCU_DATA 0x11
48+ #define JC_OUTPUT_USB_CMD 0x80
4949
5050/* Subcommand IDs */
51- static const u8 JC_SUBCMD_STATE /*= 0x00*/ ;
52- static const u8 JC_SUBCMD_MANUAL_BT_PAIRING = 0x01 ;
53- static const u8 JC_SUBCMD_REQ_DEV_INFO = 0x02 ;
54- static const u8 JC_SUBCMD_SET_REPORT_MODE = 0x03 ;
55- static const u8 JC_SUBCMD_TRIGGERS_ELAPSED = 0x04 ;
56- static const u8 JC_SUBCMD_GET_PAGE_LIST_STATE = 0x05 ;
57- static const u8 JC_SUBCMD_SET_HCI_STATE = 0x06 ;
58- static const u8 JC_SUBCMD_RESET_PAIRING_INFO = 0x07 ;
59- static const u8 JC_SUBCMD_LOW_POWER_MODE = 0x08 ;
60- static const u8 JC_SUBCMD_SPI_FLASH_READ = 0x10 ;
61- static const u8 JC_SUBCMD_SPI_FLASH_WRITE = 0x11 ;
62- static const u8 JC_SUBCMD_RESET_MCU = 0x20 ;
63- static const u8 JC_SUBCMD_SET_MCU_CONFIG = 0x21 ;
64- static const u8 JC_SUBCMD_SET_MCU_STATE = 0x22 ;
65- static const u8 JC_SUBCMD_SET_PLAYER_LIGHTS = 0x30 ;
66- static const u8 JC_SUBCMD_GET_PLAYER_LIGHTS = 0x31 ;
67- static const u8 JC_SUBCMD_SET_HOME_LIGHT = 0x38 ;
68- static const u8 JC_SUBCMD_ENABLE_IMU = 0x40 ;
69- static const u8 JC_SUBCMD_SET_IMU_SENSITIVITY = 0x41 ;
70- static const u8 JC_SUBCMD_WRITE_IMU_REG = 0x42 ;
71- static const u8 JC_SUBCMD_READ_IMU_REG = 0x43 ;
72- static const u8 JC_SUBCMD_ENABLE_VIBRATION = 0x48 ;
73- static const u8 JC_SUBCMD_GET_REGULATED_VOLTAGE = 0x50 ;
51+ #define JC_SUBCMD_STATE 0x00
52+ #define JC_SUBCMD_MANUAL_BT_PAIRING 0x01
53+ #define JC_SUBCMD_REQ_DEV_INFO 0x02
54+ #define JC_SUBCMD_SET_REPORT_MODE 0x03
55+ #define JC_SUBCMD_TRIGGERS_ELAPSED 0x04
56+ #define JC_SUBCMD_GET_PAGE_LIST_STATE 0x05
57+ #define JC_SUBCMD_SET_HCI_STATE 0x06
58+ #define JC_SUBCMD_RESET_PAIRING_INFO 0x07
59+ #define JC_SUBCMD_LOW_POWER_MODE 0x08
60+ #define JC_SUBCMD_SPI_FLASH_READ 0x10
61+ #define JC_SUBCMD_SPI_FLASH_WRITE 0x11
62+ #define JC_SUBCMD_RESET_MCU 0x20
63+ #define JC_SUBCMD_SET_MCU_CONFIG 0x21
64+ #define JC_SUBCMD_SET_MCU_STATE 0x22
65+ #define JC_SUBCMD_SET_PLAYER_LIGHTS 0x30
66+ #define JC_SUBCMD_GET_PLAYER_LIGHTS 0x31
67+ #define JC_SUBCMD_SET_HOME_LIGHT 0x38
68+ #define JC_SUBCMD_ENABLE_IMU 0x40
69+ #define JC_SUBCMD_SET_IMU_SENSITIVITY 0x41
70+ #define JC_SUBCMD_WRITE_IMU_REG 0x42
71+ #define JC_SUBCMD_READ_IMU_REG 0x43
72+ #define JC_SUBCMD_ENABLE_VIBRATION 0x48
73+ #define JC_SUBCMD_GET_REGULATED_VOLTAGE 0x50
7474
7575/* Input Reports */
76- static const u8 JC_INPUT_BUTTON_EVENT = 0x3F ;
77- static const u8 JC_INPUT_SUBCMD_REPLY = 0x21 ;
78- static const u8 JC_INPUT_IMU_DATA = 0x30 ;
79- static const u8 JC_INPUT_MCU_DATA = 0x31 ;
80- static const u8 JC_INPUT_USB_RESPONSE = 0x81 ;
76+ #define JC_INPUT_BUTTON_EVENT 0x3F
77+ #define JC_INPUT_SUBCMD_REPLY 0x21
78+ #define JC_INPUT_IMU_DATA 0x30
79+ #define JC_INPUT_MCU_DATA 0x31
80+ #define JC_INPUT_USB_RESPONSE 0x81
8181
8282/* Feature Reports */
83- static const u8 JC_FEATURE_LAST_SUBCMD = 0x02 ;
84- static const u8 JC_FEATURE_OTA_FW_UPGRADE = 0x70 ;
85- static const u8 JC_FEATURE_SETUP_MEM_READ = 0x71 ;
86- static const u8 JC_FEATURE_MEM_READ = 0x72 ;
87- static const u8 JC_FEATURE_ERASE_MEM_SECTOR = 0x73 ;
88- static const u8 JC_FEATURE_MEM_WRITE = 0x74 ;
89- static const u8 JC_FEATURE_LAUNCH = 0x75 ;
83+ #define JC_FEATURE_LAST_SUBCMD 0x02
84+ #define JC_FEATURE_OTA_FW_UPGRADE 0x70
85+ #define JC_FEATURE_SETUP_MEM_READ 0x71
86+ #define JC_FEATURE_MEM_READ 0x72
87+ #define JC_FEATURE_ERASE_MEM_SECTOR 0x73
88+ #define JC_FEATURE_MEM_WRITE 0x74
89+ #define JC_FEATURE_LAUNCH 0x75
9090
9191/* USB Commands */
92- static const u8 JC_USB_CMD_CONN_STATUS = 0x01 ;
93- static const u8 JC_USB_CMD_HANDSHAKE = 0x02 ;
94- static const u8 JC_USB_CMD_BAUDRATE_3M = 0x03 ;
95- static const u8 JC_USB_CMD_NO_TIMEOUT = 0x04 ;
96- static const u8 JC_USB_CMD_EN_TIMEOUT = 0x05 ;
97- static const u8 JC_USB_RESET = 0x06 ;
98- static const u8 JC_USB_PRE_HANDSHAKE = 0x91 ;
99- static const u8 JC_USB_SEND_UART = 0x92 ;
92+ #define JC_USB_CMD_CONN_STATUS 0x01
93+ #define JC_USB_CMD_HANDSHAKE 0x02
94+ #define JC_USB_CMD_BAUDRATE_3M 0x03
95+ #define JC_USB_CMD_NO_TIMEOUT 0x04
96+ #define JC_USB_CMD_EN_TIMEOUT 0x05
97+ #define JC_USB_RESET 0x06
98+ #define JC_USB_PRE_HANDSHAKE 0x91
99+ #define JC_USB_SEND_UART 0x92
100100
101101/* Magic value denoting presence of user calibration */
102- static const u16 JC_CAL_USR_MAGIC_0 = 0xB2 ;
103- static const u16 JC_CAL_USR_MAGIC_1 = 0xA1 ;
104- static const u8 JC_CAL_USR_MAGIC_SIZE = 2 ;
102+ #define JC_CAL_USR_MAGIC_0 0xB2
103+ #define JC_CAL_USR_MAGIC_1 0xA1
104+ #define JC_CAL_USR_MAGIC_SIZE 2
105105
106106/* SPI storage addresses of user calibration data */
107- static const u16 JC_CAL_USR_LEFT_MAGIC_ADDR = 0x8010 ;
108- static const u16 JC_CAL_USR_LEFT_DATA_ADDR = 0x8012 ;
109- static const u16 JC_CAL_USR_LEFT_DATA_END = 0x801A ;
110- static const u16 JC_CAL_USR_RIGHT_MAGIC_ADDR = 0x801B ;
111- static const u16 JC_CAL_USR_RIGHT_DATA_ADDR = 0x801D ;
107+ #define JC_CAL_USR_LEFT_MAGIC_ADDR 0x8010
108+ #define JC_CAL_USR_LEFT_DATA_ADDR 0x8012
109+ #define JC_CAL_USR_LEFT_DATA_END 0x801A
110+ #define JC_CAL_USR_RIGHT_MAGIC_ADDR 0x801B
111+ #define JC_CAL_USR_RIGHT_DATA_ADDR 0x801D
112112#define JC_CAL_STICK_DATA_SIZE \
113113 (JC_CAL_USR_LEFT_DATA_END - JC_CAL_USR_LEFT_DATA_ADDR + 1)
114114
115115/* SPI storage addresses of factory calibration data */
116- static const u16 JC_CAL_FCT_DATA_LEFT_ADDR = 0x603d ;
117- static const u16 JC_CAL_FCT_DATA_RIGHT_ADDR = 0x6046 ;
116+ #define JC_CAL_FCT_DATA_LEFT_ADDR 0x603d
117+ #define JC_CAL_FCT_DATA_RIGHT_ADDR 0x6046
118118
119119/* SPI storage addresses of IMU factory calibration data */
120- static const u16 JC_IMU_CAL_FCT_DATA_ADDR = 0x6020 ;
121- static const u16 JC_IMU_CAL_FCT_DATA_END = 0x6037 ;
120+ #define JC_IMU_CAL_FCT_DATA_ADDR 0x6020
121+ #define JC_IMU_CAL_FCT_DATA_END 0x6037
122122#define JC_IMU_CAL_DATA_SIZE \
123123 (JC_IMU_CAL_FCT_DATA_END - JC_IMU_CAL_FCT_DATA_ADDR + 1)
124124/* SPI storage addresses of IMU user calibration data */
125- static const u16 JC_IMU_CAL_USR_MAGIC_ADDR = 0x8026 ;
126- static const u16 JC_IMU_CAL_USR_DATA_ADDR = 0x8028 ;
125+ #define JC_IMU_CAL_USR_MAGIC_ADDR 0x8026
126+ #define JC_IMU_CAL_USR_DATA_ADDR 0x8028
127127
128128/* The raw analog joystick values will be mapped in terms of this magnitude */
129- static const u16 JC_MAX_STICK_MAG = 32767 ;
130- static const u16 JC_STICK_FUZZ = 250 ;
131- static const u16 JC_STICK_FLAT = 500 ;
129+ #define JC_MAX_STICK_MAG 32767
130+ #define JC_STICK_FUZZ 250
131+ #define JC_STICK_FLAT 500
132132
133133/* Hat values for pro controller's d-pad */
134- static const u16 JC_MAX_DPAD_MAG = 1 ;
135- static const u16 JC_DPAD_FUZZ /*= 0*/ ;
136- static const u16 JC_DPAD_FLAT /*= 0*/ ;
134+ #define JC_MAX_DPAD_MAG 1
135+ #define JC_DPAD_FUZZ 0
136+ #define JC_DPAD_FLAT 0
137137
138138/* Under most circumstances IMU reports are pushed every 15ms; use as default */
139- static const u16 JC_IMU_DFLT_AVG_DELTA_MS = 15 ;
139+ #define JC_IMU_DFLT_AVG_DELTA_MS 15
140140/* How many samples to sum before calculating average IMU report delta */
141- static const u16 JC_IMU_SAMPLES_PER_DELTA_AVG = 300 ;
141+ #define JC_IMU_SAMPLES_PER_DELTA_AVG 300
142142/* Controls how many dropped IMU packets at once trigger a warning message */
143- static const u16 JC_IMU_DROPPED_PKT_WARNING = 3 ;
143+ #define JC_IMU_DROPPED_PKT_WARNING 3
144144
145145/*
146146 * The controller's accelerometer has a sensor resolution of 16bits and is
@@ -149,10 +149,10 @@ static const u16 JC_IMU_DROPPED_PKT_WARNING = 3;
149149 * Resolution per G (rather than per millliG): 4.096 * 1000 = 4096 digits per G
150150 * Alternatively: 1/4096 = .0002441 Gs per digit
151151 */
152- static const s32 JC_IMU_MAX_ACCEL_MAG = 32767 ;
153- static const u16 JC_IMU_ACCEL_RES_PER_G = 4096 ;
154- static const u16 JC_IMU_ACCEL_FUZZ = 10 ;
155- static const u16 JC_IMU_ACCEL_FLAT /*= 0*/ ;
152+ #define JC_IMU_MAX_ACCEL_MAG 32767
153+ #define JC_IMU_ACCEL_RES_PER_G 4096
154+ #define JC_IMU_ACCEL_FUZZ 10
155+ #define JC_IMU_ACCEL_FLAT 0
156156
157157/*
158158 * The controller's gyroscope has a sensor resolution of 16bits and is
@@ -169,12 +169,12 @@ static const u16 JC_IMU_ACCEL_FLAT /*= 0*/;
169169 * Now, 14.247 truncating to 14 loses a lot of precision, so we rescale the
170170 * min/max range by 1000.
171171 */
172- static const s32 JC_IMU_PREC_RANGE_SCALE = 1000 ;
172+ #define JC_IMU_PREC_RANGE_SCALE 1000
173173/* Note: change mag and res_per_dps if prec_range_scale is ever altered */
174- static const s32 JC_IMU_MAX_GYRO_MAG = 32767000 ; /* (2^16-1)*1000 */
175- static const u16 JC_IMU_GYRO_RES_PER_DPS = 14247 ; /* (14.247*1000) */
176- static const u16 JC_IMU_GYRO_FUZZ = 10 ;
177- static const u16 JC_IMU_GYRO_FLAT /*= 0*/ ;
174+ #define JC_IMU_MAX_GYRO_MAG 32767000 /* (2^16-1)*1000 */
175+ #define JC_IMU_GYRO_RES_PER_DPS 14247 /* (14.247*1000) */
176+ #define JC_IMU_GYRO_FUZZ 10
177+ #define JC_IMU_GYRO_FLAT 0
178178
179179/* frequency/amplitude tables for rumble */
180180struct joycon_rumble_freq_data {
0 commit comments