diff --git a/src/Gamecube.c b/src/Gamecube.c index 66b6642..0b785a2 100644 --- a/src/Gamecube.c +++ b/src/Gamecube.c @@ -62,7 +62,7 @@ bool gc_origin(const uint8_t pin, Gamecube_Origin_t* origin) bool gc_read(const uint8_t pin, Gamecube_Report_t* report, const bool rumble) { - // Command to send to the gamecube, LSB is rumble + // Command to send to the gamecube controller, LSB is rumble uint8_t command[] = { 0x40, 0x03, rumble }; // Send the command and read in data @@ -74,6 +74,25 @@ bool gc_read(const uint8_t pin, Gamecube_Report_t* report, const bool rumble) } +bool gc_read_wheel(const uint8_t pin, Gamecube_Report_t* report, const int8_t force) +{ + // Command to send to the gamecube wheel, last byte is force feedback + uint8_t motor = 0x04; + if (force) { + // Enable motor if force feedback is used + motor = 0x06; + } + uint8_t command[] = { 0x30, 0x06, force }; + + // Send the command and read in data + uint8_t receivedBytes = gc_n64_send_get(pin, command, sizeof(command), (uint8_t*)report, sizeof(Gamecube_Report_t)); + + // Return status information for optional use. + // On error the report may have been modified! + return (receivedBytes == sizeof(Gamecube_Report_t)); +} + + //================================================================================ // Gamecube Console //================================================================================ diff --git a/src/Gamecube.h b/src/Gamecube.h index db2922d..4eabfb3 100644 --- a/src/Gamecube.h +++ b/src/Gamecube.h @@ -36,6 +36,7 @@ THE SOFTWARE. // You need to switch the bytes for the docs which are widely available online. // A default Gamecube controller would look like 0x0900. #define NINTENDO_DEVICE_GC_WIRED 0x0009 +#define NINTENDO_DEVICE_GC_WHEEL 0x0008 #define NINTENDO_DEVICE_GC_NONE 0x0000 @@ -131,6 +132,7 @@ extern "C" { bool gc_init(const uint8_t pin, Gamecube_Status_t* status); bool gc_origin(const uint8_t pin, Gamecube_Origin_t* origin); bool gc_read(const uint8_t pin, Gamecube_Report_t* report, const bool rumble); +bool gc_read_wheel(const uint8_t pin, Gamecube_Report_t* report, const int8_t force); uint8_t gc_write(const uint8_t pin, Gamecube_Status_t* status, Gamecube_Origin_t* origin, Gamecube_Report_t* report); #ifdef __cplusplus