Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Gamecube wheel support #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/Gamecube.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
//================================================================================
Expand Down
2 changes: 2 additions & 0 deletions src/Gamecube.h
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down