You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Implemented native Gamecube controller support and corresponding emulator hint in ROM header (#505)
* Implemented native Gamecube controller support and corresponding emulator hint in ROM header * Added X and Y buttons to VALID_BUTTONS in sm64.h * Added workaround in controller type detection for mupen bug * read GC controllers from port 2 * L to Z logic for GC controller uses a threshold * Changed threshold for L trig to around 33% Changed threshold based on feedback * Added gGamecubeControllerPort * fixed wrong check * Bugfix: Game crashes when less than 2 controllers are connected * Suppress compiler warnings * Bugfix: button swapping still takes place on non-GC controllers * Wrap port 2 stuff in console check aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa * GC console check * Funny emulator crash moment * block comment moment * Added centering for the gamecube controller, support reset command (#511) * Added centering for the gamecube controller, support reset command * Use struct 'ControllerCenters' for 'gGamecubeControllerCenters' * Store gamecube controller centers per controller * Clamp GC controller stick values to s8 * the formatting changes Co-authored-by: Mr-Wiseguy <mrwiseguyromhacking@gmail.com> Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Denis Kopyrin <aglab3@gmail.com>
This commit is contained in:
@@ -63,6 +63,18 @@ typedef struct {
|
||||
u8 error;
|
||||
} OSContPad;
|
||||
|
||||
// Custom extended controller pad struct that contains fields for gamecube controllers
|
||||
typedef struct {
|
||||
u16 button;
|
||||
s8 stick_x; /* -80 <= stick_x <= 80 */
|
||||
s8 stick_y; /* -80 <= stick_y <= 80 */
|
||||
s8 c_stick_x;
|
||||
s8 c_stick_y;
|
||||
u8 l_trig;
|
||||
u8 r_trig;
|
||||
u8 errno;
|
||||
} OSContPadEx;
|
||||
|
||||
typedef struct {
|
||||
void *address; /* Ram pad Address: 11 bits */
|
||||
u8 databuffer[32]; /* address of the data buffer */
|
||||
@@ -103,6 +115,7 @@ typedef struct {
|
||||
#define CONT_ABSOLUTE 0x0001
|
||||
#define CONT_RELATIVE 0x0002
|
||||
#define CONT_JOYPORT 0x0004
|
||||
#define CONT_GCN 0x0008
|
||||
#define CONT_EEPROM 0x8000
|
||||
#define CONT_EEP16K 0x4000
|
||||
#define CONT_TYPE_MASK 0x1f07
|
||||
@@ -150,6 +163,25 @@ typedef struct {
|
||||
#define L_CBUTTONS CONT_C
|
||||
#define R_CBUTTONS CONT_F
|
||||
#define D_CBUTTONS CONT_D
|
||||
#define GCN_X_BUTTON 0x0040
|
||||
#define GCN_Y_BUTTON 0x0080
|
||||
|
||||
/* Gamecube controller buttons */
|
||||
|
||||
#define CONT_GCN_GET_ORIGIN 0x2000
|
||||
#define CONT_GCN_START 0x1000
|
||||
#define CONT_GCN_Y 0x0800
|
||||
#define CONT_GCN_X 0x0400
|
||||
#define CONT_GCN_B 0x0200
|
||||
#define CONT_GCN_A 0x0100
|
||||
#define CONT_GCN_USE_ORIGIN 0x0080
|
||||
#define CONT_GCN_L 0x0040
|
||||
#define CONT_GCN_R 0x0020
|
||||
#define CONT_GCN_Z 0x0010
|
||||
#define CONT_GCN_UP 0x0008
|
||||
#define CONT_GCN_DOWN 0x0004
|
||||
#define CONT_GCN_RIGHT 0x0002
|
||||
#define CONT_GCN_LEFT 0x0001
|
||||
|
||||
/* Controller error number */
|
||||
|
||||
@@ -162,6 +194,9 @@ typedef struct {
|
||||
#define CONT_ERR_VOICE_WORD 14
|
||||
#define CONT_ERR_VOICE_NO_RESPONSE 15
|
||||
|
||||
#define CONT_TYPE_N64 0
|
||||
#define CONT_TYPE_GCN 1
|
||||
|
||||
|
||||
#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
|
||||
|
||||
@@ -178,6 +213,7 @@ typedef struct {
|
||||
*
|
||||
*/
|
||||
|
||||
extern u8 __osControllerTypes[MAXCONTROLLERS];
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
@@ -191,11 +227,13 @@ extern s32 osContInit( OSMesgQueue *mq, u8 *bitpattern, OSContStatus *s
|
||||
extern s32 osContReset( OSMesgQueue *mq, OSContStatus *status);
|
||||
extern s32 osContStartQuery( OSMesgQueue *mq);
|
||||
extern s32 osContStartReadData(OSMesgQueue *mq);
|
||||
extern s32 osContStartReadDataEx(OSMesgQueue *mq);
|
||||
#ifndef _HW_VERSION_1
|
||||
extern s32 osContSetCh(u8 ch);
|
||||
#endif
|
||||
extern void osContGetQuery(OSContStatus *status);
|
||||
extern void osContGetReadData(OSContPad *pad);
|
||||
extern void osContGetReadDataEx(OSContPadEx *pad);
|
||||
|
||||
|
||||
#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */
|
||||
|
||||
@@ -62,12 +62,14 @@ extern "C" {
|
||||
/* Rumble PAK interface */
|
||||
|
||||
extern s32 osMotorInit(OSMesgQueue *mq, OSPfs *pfs, int controller_no);
|
||||
extern s32 osMotorInitEx(OSMesgQueue *mq, OSPfs *pfs, int controller_no);
|
||||
#if 1
|
||||
#define MOTOR_START 1
|
||||
#define MOTOR_STOP 0
|
||||
#define osMotorStart(x) __osMotorAccess((x), MOTOR_START)
|
||||
#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP)
|
||||
#define osMotorStart(x) __osMotorAccessEx((x), MOTOR_START)
|
||||
#define osMotorStop(x) __osMotorAccessEx((x), MOTOR_STOP)
|
||||
extern s32 __osMotorAccess(OSPfs *pfs, s32 flag);
|
||||
extern s32 __osMotorAccessEx(OSPfs *pfs, s32 flag);
|
||||
#else
|
||||
extern s32 osMotorStop( OSPfs *pfs);
|
||||
extern s32 osMotorStart(OSPfs *pfs);
|
||||
|
||||
Reference in New Issue
Block a user