Skip to content

Commit bc5bc43

Browse files
committed
libsi: move gc specific si commands to gc_controller
1 parent ec4d98f commit bc5bc43

3 files changed

Lines changed: 28 additions & 38 deletions

File tree

firmware/libsi/include/si/device/gc_controller.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,31 @@
77
#include <stdbool.h>
88
#include <stdint.h>
99

10+
// GameCube controller commands
11+
#define SI_CMD_GC_SHORT_POLL 0x40
12+
#define SI_CMD_GC_SHORT_POLL_LEN 3
13+
#define SI_CMD_GC_SHORT_POLL_RESP 8
14+
15+
#define SI_CMD_GC_READ_ORIGIN 0x41
16+
#define SI_CMD_GC_READ_ORIGIN_LEN 1
17+
#define SI_CMD_GC_READ_ORIGIN_RESP 10
18+
19+
#define SI_CMD_GC_CALIBRATE 0x42
20+
#define SI_CMD_GC_CALIBRATE_LEN 3
21+
#define SI_CMD_GC_CALIBRATE_RESP 10
22+
23+
#define SI_CMD_GC_LONG_POLL 0x43
24+
#define SI_CMD_GC_LONG_POLL_LEN 3
25+
#define SI_CMD_GC_LONG_POLL_RESP 10
26+
27+
#define SI_CMD_GC_PROBE_DEVICE 0x4D
28+
#define SI_CMD_GC_PROBE_DEVICE_LEN 3
29+
#define SI_CMD_GC_PROBE_DEVICE_RESP 8
30+
31+
#define SI_CMD_GC_FIX_DEVICE 0x4E
32+
#define SI_CMD_GC_FIX_DEVICE_LEN 3
33+
#define SI_CMD_GC_FIX_DEVICE_RESP 3
34+
1035
/**
1136
* Rumble motor states.
1237
*/
@@ -88,7 +113,6 @@ struct si_device_gc_controller {
88113
*
89114
* @param device the device to initialize
90115
* @param type the device type flags
91-
* @param input_state pointer to an input state buffer
92116
*/
93117
void si_device_gc_init(struct si_device_gc_controller *device, uint8_t type);
94118

firmware/libsi/include/si/si.h

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,6 @@
5757
#define SI_CMD_INFO_LEN 1
5858
#define SI_CMD_INFO_RESP 3
5959

60-
// GameCube controller commands
61-
#define SI_CMD_GC_SHORT_POLL 0x40
62-
#define SI_CMD_GC_SHORT_POLL_LEN 3
63-
#define SI_CMD_GC_SHORT_POLL_RESP 8
64-
65-
#define SI_CMD_GC_READ_ORIGIN 0x41
66-
#define SI_CMD_GC_READ_ORIGIN_LEN 1
67-
#define SI_CMD_GC_READ_ORIGIN_RESP 10
68-
69-
#define SI_CMD_GC_CALIBRATE 0x42
70-
#define SI_CMD_GC_CALIBRATE_LEN 3
71-
#define SI_CMD_GC_CALIBRATE_RESP 10
72-
73-
#define SI_CMD_GC_LONG_POLL 0x43
74-
#define SI_CMD_GC_LONG_POLL_LEN 3
75-
#define SI_CMD_GC_LONG_POLL_RESP 10
76-
77-
#define SI_CMD_GC_PROBE_DEVICE 0x4D
78-
#define SI_CMD_GC_PROBE_DEVICE_LEN 3
79-
#define SI_CMD_GC_PROBE_DEVICE_RESP 8
80-
81-
#define SI_CMD_GC_FIX_DEVICE 0x4E
82-
#define SI_CMD_GC_FIX_DEVICE_LEN 3
83-
#define SI_CMD_GC_FIX_DEVICE_RESP 3
84-
8560
// SI device info flags
8661
// On wireless controllers 0x00C0FF is reserved for the controller ID
8762

@@ -131,9 +106,9 @@ typedef bool (*si_byte_cb_t)(uint8_t byte, uint8_t byte_index);
131106
/**
132107
* Function type for transfer completion callbacks.
133108
*
134-
* @param result 0 on success, negative error code on failure
109+
* @param result positive number of bytes read on success, negative error code on failure
135110
*/
136-
typedef void (*si_complete_cb_t)(int result_or_bytes_read);
111+
typedef void (*si_complete_cb_t)(int result);
137112

138113
/**
139114
* Initialize the SI bus.
@@ -165,15 +140,6 @@ void si_write_bytes(const uint8_t *data, uint8_t length, si_complete_cb_t callba
165140
*/
166141
void si_read_bytes(uint8_t *buffer, uint8_t max_length, si_byte_cb_t byte_callback, si_complete_cb_t complete_callback);
167142

168-
/**
169-
* Read a single command from the SI bus.
170-
*
171-
* @param buffer the buffer to read into
172-
* @param max_length the maximum buffer size
173-
* @param callback function to call when the command has been read
174-
*/
175-
void si_read_command(uint8_t *buffer, uint8_t max_length, si_complete_cb_t callback);
176-
177143
/**
178144
* Wait for the SI bus to be idle.
179145
*

firmware/libsi/src/device/gc_controller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,11 @@ void si_device_gc_init(struct si_device_gc_controller *device, uint8_t type)
302302

303303
// Register the SI commands handled by GameCube controllers
304304
si_command_register(SI_CMD_INFO, SI_CMD_INFO_LEN, handle_info, device);
305+
si_command_register(SI_CMD_RESET, SI_CMD_RESET_LEN, handle_reset, device);
305306
si_command_register(SI_CMD_GC_SHORT_POLL, SI_CMD_GC_SHORT_POLL_LEN, handle_short_poll, device);
306307
si_command_register(SI_CMD_GC_READ_ORIGIN, SI_CMD_GC_READ_ORIGIN_LEN, handle_read_origin, device);
307308
si_command_register(SI_CMD_GC_CALIBRATE, SI_CMD_GC_CALIBRATE_LEN, handle_calibrate, device);
308309
si_command_register(SI_CMD_GC_LONG_POLL, SI_CMD_GC_LONG_POLL_LEN, handle_long_poll, device);
309-
si_command_register(SI_CMD_RESET, SI_CMD_RESET_LEN, handle_reset, device);
310310

311311
// Register additional commands handled by WaveBird receivers
312312
if (type & SI_GC_WIRELESS) {

0 commit comments

Comments
 (0)