diff --git a/common/include/NintendontVersion.h b/common/include/NintendontVersion.h index a0499d7a..bc949799 100644 --- a/common/include/NintendontVersion.h +++ b/common/include/NintendontVersion.h @@ -2,7 +2,7 @@ #define __NINTENDONT_VERSION_H__ #define NIN_MAJOR_VERSION 6 -#define NIN_MINOR_VERSION 489 +#define NIN_MINOR_VERSION 490 #define NIN_VERSION ((NIN_MAJOR_VERSION << 16) | NIN_MINOR_VERSION) diff --git a/controllerconfigs/controller_ini_to_array.exe b/controllerconfigs/controller_ini_to_array.exe old mode 100644 new mode 100755 index fe89fbed..f3da07e6 Binary files a/controllerconfigs/controller_ini_to_array.exe and b/controllerconfigs/controller_ini_to_array.exe differ diff --git a/controllerconfigs/controller_ini_to_array/main.c b/controllerconfigs/controller_ini_to_array/main.c index ee287f38..2b4a2b46 100644 --- a/controllerconfigs/controller_ini_to_array/main.c +++ b/controllerconfigs/controller_ini_to_array/main.c @@ -39,6 +39,7 @@ typedef struct Layout { u32 Offset; u32 Mask; + u8 Modif; } layout; typedef struct StickLayout @@ -56,9 +57,14 @@ typedef struct Controller u32 DPAD; u32 DPADMask; u32 DigitalLR; + u32 DigitalCStick; u32 MultiIn; u32 MultiInValue; + layout Mod1; + layout Mod2; + layout Mod3; + layout Power; layout A; @@ -82,6 +88,15 @@ typedef struct Controller layout DownLeft; layout UpLeft; + layout CStickUp; + layout CStickRight; + layout CStickLeft; + layout CStickDown; + layout CStickRightUp; + layout CStickDownRight; + layout CStickDownLeft; + layout CStickUpLeft; + stickLayout StickX; stickLayout StickY; stickLayout CStickX; @@ -324,61 +339,89 @@ int main(int argc, char *argv[]) continue; } + HID_CTRL->Mod1.Offset = ConfigGetValue( Data, "Mod1", 0 ); + HID_CTRL->Mod1.Mask = ConfigGetValue( Data, "Mod1", 1 ); + + HID_CTRL->Mod2.Offset = ConfigGetValue( Data, "Mod2", 0 ); + HID_CTRL->Mod2.Mask = ConfigGetValue( Data, "Mod2", 1 ); + + HID_CTRL->Mod3.Offset = ConfigGetValue( Data, "Mod3", 0 ); + HID_CTRL->Mod3.Mask = ConfigGetValue( Data, "Mod3", 1 ); + + HID_CTRL->Power.Offset = ConfigGetValue( Data, "Power", 0 ); HID_CTRL->Power.Mask = ConfigGetValue( Data, "Power", 1 ); + HID_CTRL->Power.Modif = ConfigGetValue( Data, "Power", 2 ); HID_CTRL->A.Offset = ConfigGetValue( Data, "A", 0 ); HID_CTRL->A.Mask = ConfigGetValue( Data, "A", 1 ); + HID_CTRL->A.Modif = ConfigGetValue( Data, "A", 2 ); HID_CTRL->B.Offset = ConfigGetValue( Data, "B", 0 ); HID_CTRL->B.Mask = ConfigGetValue( Data, "B", 1 ); + HID_CTRL->B.Modif = ConfigGetValue( Data, "B", 2 ); HID_CTRL->X.Offset = ConfigGetValue( Data, "X", 0 ); HID_CTRL->X.Mask = ConfigGetValue( Data, "X", 1 ); + HID_CTRL->X.Modif = ConfigGetValue( Data, "X", 2 ); HID_CTRL->Y.Offset = ConfigGetValue( Data, "Y", 0 ); HID_CTRL->Y.Mask = ConfigGetValue( Data, "Y", 1 ); + HID_CTRL->Y.Modif = ConfigGetValue( Data, "Y", 2 ); HID_CTRL->ZL.Offset = ConfigGetValue( Data, "ZL", 0 ); HID_CTRL->ZL.Mask = ConfigGetValue( Data, "ZL", 1 ); + HID_CTRL->ZL.Modif = ConfigGetValue( Data, "ZL", 2 ); HID_CTRL->Z.Offset = ConfigGetValue( Data, "Z", 0 ); HID_CTRL->Z.Mask = ConfigGetValue( Data, "Z", 1 ); + HID_CTRL->Z.Modif = ConfigGetValue( Data, "Z", 2 ); HID_CTRL->L.Offset = ConfigGetValue( Data, "L", 0 ); HID_CTRL->L.Mask = ConfigGetValue( Data, "L", 1 ); + HID_CTRL->L.Modif = ConfigGetValue( Data, "L", 2 ); HID_CTRL->R.Offset = ConfigGetValue( Data, "R", 0 ); HID_CTRL->R.Mask = ConfigGetValue( Data, "R", 1 ); + HID_CTRL->R.Modif = ConfigGetValue( Data, "R", 2 ); HID_CTRL->S.Offset = ConfigGetValue( Data, "S", 0 ); HID_CTRL->S.Mask = ConfigGetValue( Data, "S", 1 ); + HID_CTRL->S.Modif = ConfigGetValue( Data, "S", 2 ); HID_CTRL->Left.Offset = ConfigGetValue( Data, "Left", 0 ); HID_CTRL->Left.Mask = ConfigGetValue( Data, "Left", 1 ); + HID_CTRL->Left.Modif = ConfigGetValue( Data, "Left", 2 ); HID_CTRL->Down.Offset = ConfigGetValue( Data, "Down", 0 ); HID_CTRL->Down.Mask = ConfigGetValue( Data, "Down", 1 ); + HID_CTRL->Down.Modif = ConfigGetValue( Data, "Down", 2 ); HID_CTRL->Right.Offset = ConfigGetValue( Data, "Right", 0 ); HID_CTRL->Right.Mask = ConfigGetValue( Data, "Right", 1 ); + HID_CTRL->Right.Modif = ConfigGetValue( Data, "Right", 2 ); HID_CTRL->Up.Offset = ConfigGetValue( Data, "Up", 0 ); HID_CTRL->Up.Mask = ConfigGetValue( Data, "Up", 1 ); + HID_CTRL->Up.Modif = ConfigGetValue( Data, "Up", 2 ); if( HID_CTRL->DPAD ) { HID_CTRL->RightUp.Offset = ConfigGetValue( Data, "RightUp", 0 ); HID_CTRL->RightUp.Mask = ConfigGetValue( Data, "RightUp", 1 ); + HID_CTRL->RightUp.Modif = ConfigGetValue( Data, "RightUp", 2 ); HID_CTRL->DownRight.Offset = ConfigGetValue( Data, "DownRight", 0 ); HID_CTRL->DownRight.Mask = ConfigGetValue( Data, "DownRight", 1 ); + HID_CTRL->DownRight.Modif = ConfigGetValue( Data, "DownRight", 2 ); HID_CTRL->DownLeft.Offset = ConfigGetValue( Data, "DownLeft", 0 ); HID_CTRL->DownLeft.Mask = ConfigGetValue( Data, "DownLeft", 1 ); + HID_CTRL->DownLeft.Modif = ConfigGetValue( Data, "DownLeft", 2 ); HID_CTRL->UpLeft.Offset = ConfigGetValue( Data, "UpLeft", 0 ); HID_CTRL->UpLeft.Mask = ConfigGetValue( Data, "UpLeft", 1 ); + HID_CTRL->UpLeft.Modif = ConfigGetValue( Data, "UpLeft", 2 ); } if( HID_CTRL->DPAD && //DPAD == 1 and all offsets the same @@ -406,7 +449,7 @@ int main(int argc, char *argv[]) if (HID_CTRL->StickX.Radius == 0) HID_CTRL->StickX.Radius = 80; HID_CTRL->StickX.Radius = (u64)HID_CTRL->StickX.Radius * 1280 / (128 - HID_CTRL->StickX.DeadZone); //adjust for DeadZone - // printf("HID:StickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->StickX.Offset, HID_CTRL->StickX.DeadZone, HID_CTRL->StickX.Radius); + // dbgprintf("HID:StickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->StickX.Offset, HID_CTRL->StickX.DeadZone, HID_CTRL->StickX.Radius); HID_CTRL->StickY.Offset = ConfigGetValue( Data, "StickY", 0 ); HID_CTRL->StickY.DeadZone = ConfigGetValue( Data, "StickY", 1 ); @@ -414,43 +457,78 @@ int main(int argc, char *argv[]) if (HID_CTRL->StickY.Radius == 0) HID_CTRL->StickY.Radius = 80; HID_CTRL->StickY.Radius = (u64)HID_CTRL->StickY.Radius * 1280 / (128 - HID_CTRL->StickY.DeadZone); //adjust for DeadZone - // printf("HID:StickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->StickY.Offset, HID_CTRL->StickY.DeadZone, HID_CTRL->StickY.Radius); - - HID_CTRL->CStickX.Offset = ConfigGetValue( Data, "CStickX", 0 ); - HID_CTRL->CStickX.DeadZone = ConfigGetValue( Data, "CStickX", 1 ); - HID_CTRL->CStickX.Radius = ConfigGetDecValue( Data, "CStickX", 2 ); - if (HID_CTRL->CStickX.Radius == 0) - HID_CTRL->CStickX.Radius = 80; - HID_CTRL->CStickX.Radius = (u64)HID_CTRL->CStickX.Radius * 1280 / (128 - HID_CTRL->CStickX.DeadZone); //adjust for DeadZone - // printf("HID:CStickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickX.Offset, HID_CTRL->CStickX.DeadZone, HID_CTRL->CStickX.Radius); - - HID_CTRL->CStickY.Offset = ConfigGetValue( Data, "CStickY", 0 ); - HID_CTRL->CStickY.DeadZone = ConfigGetValue( Data, "CStickY", 1 ); - HID_CTRL->CStickY.Radius = ConfigGetDecValue( Data, "CStickY", 2 ); - if (HID_CTRL->CStickY.Radius == 0) - HID_CTRL->CStickY.Radius = 80; - HID_CTRL->CStickY.Radius = (u64)HID_CTRL->CStickY.Radius * 1280 / (128 - HID_CTRL->CStickY.DeadZone); //adjust for DeadZone - // printf("HID:CStickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickY.Offset, HID_CTRL->CStickY.DeadZone, HID_CTRL->CStickY.Radius); - + // dbgprintf("HID:StickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->StickY.Offset, HID_CTRL->StickY.DeadZone, HID_CTRL->StickY.Radius); + + if (HID_CTRL->DigitalCStick) { + HID_CTRL->CStickLeft.Offset = ConfigGetValue( Data, "CStickLeft", 0 ); + HID_CTRL->CStickLeft.Mask = ConfigGetValue( Data, "CStickLeft", 1 ); + HID_CTRL->CStickLeft.Modif = ConfigGetValue( Data, "CStickLeft", 2 ); + + HID_CTRL->CStickDown.Offset = ConfigGetValue( Data, "CStickDown", 0 ); + HID_CTRL->CStickDown.Mask = ConfigGetValue( Data, "CStickDown", 1 ); + HID_CTRL->CStickDown.Modif = ConfigGetValue( Data, "CStickDown", 2 ); + + HID_CTRL->CStickRight.Offset = ConfigGetValue( Data, "CStickRight", 0 ); + HID_CTRL->CStickRight.Mask = ConfigGetValue( Data, "CStickRight", 1 ); + HID_CTRL->CStickRight.Modif = ConfigGetValue( Data, "CStickRight", 2 ); + + HID_CTRL->CStickUp.Offset = ConfigGetValue( Data, "CStickUp", 0 ); + HID_CTRL->CStickUp.Mask = ConfigGetValue( Data, "CStickUp", 1 ); + HID_CTRL->CStickUp.Modif = ConfigGetValue( Data, "CStickUp", 2 ); + + } else { + HID_CTRL->CStickX.Offset = ConfigGetValue( Data, "CStickX", 0 ); + HID_CTRL->CStickX.DeadZone = ConfigGetValue( Data, "CStickX", 1 ); + HID_CTRL->CStickX.Radius = ConfigGetDecValue( Data, "CStickX", 2 ); + if (HID_CTRL->CStickX.Radius == 0) + HID_CTRL->CStickX.Radius = 80; + HID_CTRL->CStickX.Radius = (u64)HID_CTRL->CStickX.Radius * 1280 / (128 - HID_CTRL->CStickX.DeadZone); //adjust for DeadZone + // dbgprintf("HID:CStickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickX.Offset, HID_CTRL->CStickX.DeadZone, HID_CTRL->CStickX.Radius); + + HID_CTRL->CStickY.Offset = ConfigGetValue( Data, "CStickY", 0 ); + HID_CTRL->CStickY.DeadZone = ConfigGetValue( Data, "CStickY", 1 ); + HID_CTRL->CStickY.Radius = ConfigGetDecValue( Data, "CStickY", 2 ); + if (HID_CTRL->CStickY.Radius == 0) + HID_CTRL->CStickY.Radius = 80; + HID_CTRL->CStickY.Radius = (u64)HID_CTRL->CStickY.Radius * 1280 / (128 - HID_CTRL->CStickY.DeadZone); //adjust for DeadZone + // dbgprintf("HID:CStickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickY.Offset, HID_CTRL->CStickY.DeadZone, HID_CTRL->CStickY.Radius); + } HID_CTRL->LAnalog = ConfigGetValue( Data, "LAnalog", 0 ); HID_CTRL->RAnalog = ConfigGetValue( Data, "RAnalog", 0 ); FILE *array = fopen("array.txt", "a"); fprintf(array, - "\t{ 0x%04x, 0x%04x, %i, %i, 0x%x, %i, %i, %i,\n" - "\t{0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x},\n" - "\t{0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, {0x%x, 0x%x}, \n" - "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, 0x%x, 0x%x },\n", - HID_CTRL->VID, HID_CTRL->PID, HID_CTRL->Polltype, HID_CTRL->DPAD, HID_CTRL->DPADMask, HID_CTRL->DigitalLR, HID_CTRL->MultiIn, HID_CTRL->MultiInValue, - HID_CTRL->Power.Offset ,HID_CTRL->Power.Mask, HID_CTRL->A.Offset ,HID_CTRL->A.Mask, HID_CTRL->B.Offset ,HID_CTRL->B.Mask, - HID_CTRL->X.Offset ,HID_CTRL->X.Mask, HID_CTRL->Y.Offset ,HID_CTRL->Y.Mask, HID_CTRL->ZL.Offset ,HID_CTRL->ZL.Mask, - HID_CTRL->Z.Offset ,HID_CTRL->Z.Mask, HID_CTRL->L.Offset ,HID_CTRL->L.Mask, HID_CTRL->R.Offset ,HID_CTRL->R.Mask, HID_CTRL->S.Offset ,HID_CTRL->S.Mask, - HID_CTRL->Left.Offset ,HID_CTRL->Left.Mask, HID_CTRL->Down.Offset ,HID_CTRL->Down.Mask, HID_CTRL->Right.Offset ,HID_CTRL->Right.Mask, - HID_CTRL->Up.Offset ,HID_CTRL->Up.Mask, HID_CTRL->RightUp.Offset ,HID_CTRL->RightUp.Mask, HID_CTRL->DownRight.Offset ,HID_CTRL->DownRight.Mask, - HID_CTRL->DownLeft.Offset ,HID_CTRL->DownLeft.Mask, HID_CTRL->UpLeft.Offset ,HID_CTRL->UpLeft.Mask, + "\t{ 0x%04x, 0x%04x, %i, %i, 0x%x, %i, %i, %i, %i,\n" + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x},\n" // Mod1, Mod2, Mod3 + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, " // Power, A, B + "{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, " // X, Y, ZL + "{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x},\n" // Z, L, R, S + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, " // Left, Down, Right + "{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, " // Up, RightUp, DownRight + "{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, \n" // DownLeft, UpLeft + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x},\n" // CStickUp, CStickRight, CStickLeft, CStickDown + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x},\n" // CStickRightUp, CStickDownRight, CStickDownLeft, CStickUpLeft + "\t{0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, {0x%x, 0x%x, 0x%x}, 0x%x, 0x%x },\n", // StickX, StickY, CStickX, CStickY, LAnalog, RAnalog + HID_CTRL->VID, HID_CTRL->PID, HID_CTRL->Polltype, HID_CTRL->DPAD, HID_CTRL->DPADMask, HID_CTRL->DigitalLR, HID_CTRL->DigitalCStick, HID_CTRL->MultiIn, HID_CTRL->MultiInValue, + HID_CTRL->Mod1.Offset, HID_CTRL->Mod1.Mask, HID_CTRL->Mod1.Modif, HID_CTRL->Mod2.Offset, HID_CTRL->Mod2.Mask, HID_CTRL->Mod2.Modif, HID_CTRL->Mod3.Offset, HID_CTRL->Mod3.Mask, HID_CTRL->Mod3.Modif, + HID_CTRL->Power.Offset ,HID_CTRL->Power.Mask, HID_CTRL->Power.Modif, HID_CTRL->A.Offset ,HID_CTRL->A.Mask, HID_CTRL->A.Modif, HID_CTRL->B.Offset ,HID_CTRL->B.Mask, HID_CTRL->B.Modif, + HID_CTRL->X.Offset ,HID_CTRL->X.Mask, HID_CTRL->X.Modif, HID_CTRL->Y.Offset ,HID_CTRL->Y.Mask, HID_CTRL->Y.Modif, HID_CTRL->ZL.Offset ,HID_CTRL->ZL.Mask, HID_CTRL->ZL.Modif, + HID_CTRL->Z.Offset ,HID_CTRL->Z.Mask, HID_CTRL->Z.Modif, HID_CTRL->L.Offset ,HID_CTRL->L.Mask, HID_CTRL->L.Modif, HID_CTRL->R.Offset ,HID_CTRL->R.Mask, HID_CTRL->R.Modif, HID_CTRL->S.Offset ,HID_CTRL->S.Mask, HID_CTRL->S.Modif, + HID_CTRL->Left.Offset ,HID_CTRL->Left.Mask, HID_CTRL->Left.Modif, HID_CTRL->Down.Offset ,HID_CTRL->Down.Mask, HID_CTRL->Down.Modif, HID_CTRL->Right.Offset ,HID_CTRL->Right.Mask, HID_CTRL->Right.Modif, + HID_CTRL->Up.Offset ,HID_CTRL->Up.Mask, HID_CTRL->Up.Modif, HID_CTRL->RightUp.Offset ,HID_CTRL->RightUp.Mask, HID_CTRL->RightUp.Modif, HID_CTRL->DownRight.Offset ,HID_CTRL->DownRight.Mask, HID_CTRL->DownRight.Modif, + HID_CTRL->DownLeft.Offset ,HID_CTRL->DownLeft.Mask, HID_CTRL->DownLeft.Modif, HID_CTRL->UpLeft.Offset ,HID_CTRL->UpLeft.Mask, HID_CTRL->UpLeft.Modif, + HID_CTRL->CStickUp.Offset, HID_CTRL->CStickUp.Mask, HID_CTRL->CStickUp.Modif, + HID_CTRL->CStickRight.Offset, HID_CTRL->CStickRight.Mask, HID_CTRL->CStickRight.Modif, + HID_CTRL->CStickLeft.Offset, HID_CTRL->CStickLeft.Mask, HID_CTRL->CStickLeft.Modif, + HID_CTRL->CStickDown.Offset, HID_CTRL->CStickDown.Mask, HID_CTRL->CStickDown.Modif, + HID_CTRL->CStickRightUp.Offset, HID_CTRL->CStickRightUp.Mask, HID_CTRL->CStickRightUp.Modif, + HID_CTRL->CStickDownRight.Offset, HID_CTRL->CStickDownRight.Mask, HID_CTRL->CStickDownRight.Modif, + HID_CTRL->CStickDownLeft.Offset, HID_CTRL->CStickDownLeft.Mask, HID_CTRL->CStickDownLeft.Modif, + HID_CTRL->CStickUpLeft.Offset, HID_CTRL->CStickUpLeft.Mask, HID_CTRL->CStickUpLeft.Modif, HID_CTRL->StickX.Offset, HID_CTRL->StickX.DeadZone, HID_CTRL->StickX.Radius, HID_CTRL->StickY.Offset, HID_CTRL->StickY.DeadZone, HID_CTRL->StickY.Radius, HID_CTRL->CStickX.Offset, HID_CTRL->CStickX.DeadZone, HID_CTRL->CStickX.Radius, HID_CTRL->CStickY.Offset, HID_CTRL->CStickY.DeadZone, HID_CTRL->CStickY.Radius, HID_CTRL->LAnalog, HID_CTRL->RAnalog); + fclose(array); if(ConfigGetValue( Data, "Rumble", 0 )) { diff --git a/kernel/HID.c b/kernel/HID.c index 6b793e11..b5790db7 100644 --- a/kernel/HID.c +++ b/kernel/HID.c @@ -397,10 +397,11 @@ s32 HIDOpen( u32 LoaderRequest ) } else { - HID_CTRL->DPAD = ConfigGetValue( Data, "DPAD", 0 ); - HID_CTRL->DigitalLR = ConfigGetValue( Data, "DigitalLR", 0 ); - HID_CTRL->Polltype = ConfigGetValue( Data, "Polltype", 0 ); - HID_CTRL->MultiIn = ConfigGetValue( Data, "MultiIn", 0 ); + HID_CTRL->DPAD = ConfigGetValue( Data, "DPAD", 0 ); + HID_CTRL->DigitalLR = ConfigGetValue( Data, "DigitalLR", 0 ); + HID_CTRL->DigitalCStick = ConfigGetValue( Data, "DigitalCStick", 0 ); + HID_CTRL->Polltype = ConfigGetValue( Data, "Polltype", 0 ); + HID_CTRL->MultiIn = ConfigGetValue( Data, "MultiIn", 0 ); if( HID_CTRL->MultiIn ) { @@ -417,61 +418,89 @@ s32 HIDOpen( u32 LoaderRequest ) continue; } + HID_CTRL->Mod1.Offset = ConfigGetValue( Data, "Mod1", 0 ); + HID_CTRL->Mod1.Mask = ConfigGetValue( Data, "Mod1", 1 ); + + HID_CTRL->Mod2.Offset = ConfigGetValue( Data, "Mod2", 0 ); + HID_CTRL->Mod2.Mask = ConfigGetValue( Data, "Mod2", 1 ); + + HID_CTRL->Mod3.Offset = ConfigGetValue( Data, "Mod3", 0 ); + HID_CTRL->Mod3.Mask = ConfigGetValue( Data, "Mod3", 1 ); + + HID_CTRL->Power.Offset = ConfigGetValue( Data, "Power", 0 ); HID_CTRL->Power.Mask = ConfigGetValue( Data, "Power", 1 ); + HID_CTRL->Power.Modif = ConfigGetValue( Data, "Power", 2 ); HID_CTRL->A.Offset = ConfigGetValue( Data, "A", 0 ); HID_CTRL->A.Mask = ConfigGetValue( Data, "A", 1 ); + HID_CTRL->A.Modif = ConfigGetValue( Data, "A", 2 ); HID_CTRL->B.Offset = ConfigGetValue( Data, "B", 0 ); HID_CTRL->B.Mask = ConfigGetValue( Data, "B", 1 ); + HID_CTRL->B.Modif = ConfigGetValue( Data, "B", 2 ); HID_CTRL->X.Offset = ConfigGetValue( Data, "X", 0 ); HID_CTRL->X.Mask = ConfigGetValue( Data, "X", 1 ); + HID_CTRL->X.Modif = ConfigGetValue( Data, "X", 2 ); HID_CTRL->Y.Offset = ConfigGetValue( Data, "Y", 0 ); HID_CTRL->Y.Mask = ConfigGetValue( Data, "Y", 1 ); + HID_CTRL->Y.Modif = ConfigGetValue( Data, "Y", 2 ); HID_CTRL->ZL.Offset = ConfigGetValue( Data, "ZL", 0 ); HID_CTRL->ZL.Mask = ConfigGetValue( Data, "ZL", 1 ); + HID_CTRL->ZL.Modif = ConfigGetValue( Data, "ZL", 2 ); HID_CTRL->Z.Offset = ConfigGetValue( Data, "Z", 0 ); HID_CTRL->Z.Mask = ConfigGetValue( Data, "Z", 1 ); + HID_CTRL->Z.Modif = ConfigGetValue( Data, "Z", 2 ); HID_CTRL->L.Offset = ConfigGetValue( Data, "L", 0 ); HID_CTRL->L.Mask = ConfigGetValue( Data, "L", 1 ); + HID_CTRL->L.Modif = ConfigGetValue( Data, "L", 2 ); HID_CTRL->R.Offset = ConfigGetValue( Data, "R", 0 ); HID_CTRL->R.Mask = ConfigGetValue( Data, "R", 1 ); + HID_CTRL->R.Modif = ConfigGetValue( Data, "R", 2 ); HID_CTRL->S.Offset = ConfigGetValue( Data, "S", 0 ); HID_CTRL->S.Mask = ConfigGetValue( Data, "S", 1 ); + HID_CTRL->S.Modif = ConfigGetValue( Data, "S", 2 ); HID_CTRL->Left.Offset = ConfigGetValue( Data, "Left", 0 ); HID_CTRL->Left.Mask = ConfigGetValue( Data, "Left", 1 ); + HID_CTRL->Left.Modif = ConfigGetValue( Data, "Left", 2 ); HID_CTRL->Down.Offset = ConfigGetValue( Data, "Down", 0 ); HID_CTRL->Down.Mask = ConfigGetValue( Data, "Down", 1 ); + HID_CTRL->Down.Modif = ConfigGetValue( Data, "Down", 2 ); HID_CTRL->Right.Offset = ConfigGetValue( Data, "Right", 0 ); HID_CTRL->Right.Mask = ConfigGetValue( Data, "Right", 1 ); + HID_CTRL->Right.Modif = ConfigGetValue( Data, "Right", 2 ); HID_CTRL->Up.Offset = ConfigGetValue( Data, "Up", 0 ); HID_CTRL->Up.Mask = ConfigGetValue( Data, "Up", 1 ); + HID_CTRL->Up.Modif = ConfigGetValue( Data, "Up", 2 ); if( HID_CTRL->DPAD ) { HID_CTRL->RightUp.Offset = ConfigGetValue( Data, "RightUp", 0 ); HID_CTRL->RightUp.Mask = ConfigGetValue( Data, "RightUp", 1 ); + HID_CTRL->RightUp.Modif = ConfigGetValue( Data, "RightUp", 2 ); HID_CTRL->DownRight.Offset = ConfigGetValue( Data, "DownRight", 0 ); HID_CTRL->DownRight.Mask = ConfigGetValue( Data, "DownRight", 1 ); + HID_CTRL->DownRight.Modif = ConfigGetValue( Data, "DownRight", 2 ); HID_CTRL->DownLeft.Offset = ConfigGetValue( Data, "DownLeft", 0 ); HID_CTRL->DownLeft.Mask = ConfigGetValue( Data, "DownLeft", 1 ); + HID_CTRL->DownLeft.Modif = ConfigGetValue( Data, "DownLeft", 2 ); HID_CTRL->UpLeft.Offset = ConfigGetValue( Data, "UpLeft", 0 ); HID_CTRL->UpLeft.Mask = ConfigGetValue( Data, "UpLeft", 1 ); + HID_CTRL->UpLeft.Modif = ConfigGetValue( Data, "UpLeft", 2 ); } if( HID_CTRL->DPAD && //DPAD == 1 and all offsets the same @@ -509,13 +538,48 @@ s32 HIDOpen( u32 LoaderRequest ) HID_CTRL->StickY.Radius = (u64)HID_CTRL->StickY.Radius * 1280 / (128 - HID_CTRL->StickY.DeadZone); //adjust for DeadZone // dbgprintf("HID:StickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->StickY.Offset, HID_CTRL->StickY.DeadZone, HID_CTRL->StickY.Radius); + if (HID_CTRL->DigitalCStick) { + HID_CTRL->CStickLeft.Offset = ConfigGetValue( Data, "CStickLeft", 0 ); + HID_CTRL->CStickLeft.Mask = ConfigGetValue( Data, "CStickLeft", 1 ); + HID_CTRL->CStickLeft.Modif = ConfigGetValue( Data, "CStickLeft", 2 ); + + HID_CTRL->CStickDown.Offset = ConfigGetValue( Data, "CStickDown", 0 ); + HID_CTRL->CStickDown.Mask = ConfigGetValue( Data, "CStickDown", 1 ); + HID_CTRL->CStickDown.Modif = ConfigGetValue( Data, "CStickDown", 2 ); + + HID_CTRL->CStickRight.Offset = ConfigGetValue( Data, "CStickRight", 0 ); + HID_CTRL->CStickRight.Mask = ConfigGetValue( Data, "CStickRight", 1 ); + HID_CTRL->CStickRight.Modif = ConfigGetValue( Data, "CStickRight", 2 ); + + HID_CTRL->CStickUp.Offset = ConfigGetValue( Data, "CStickUp", 0 ); + HID_CTRL->CStickUp.Mask = ConfigGetValue( Data, "CStickUp", 1 ); + HID_CTRL->CStickUp.Modif = ConfigGetValue( Data, "CStickUp", 2 ); + + if( HID_CTRL->DPAD ){ // get values, however useful they are + HID_CTRL->CStickRightUp.Offset = ConfigGetValue( Data, "CStickRightUp", 0 ); + HID_CTRL->CStickRightUp.Mask = ConfigGetValue( Data, "CStickRightUp", 1 ); + HID_CTRL->CStickRightUp.Modif = ConfigGetValue( Data, "CStickRightUp", 2 ); + + HID_CTRL->CStickDownRight.Offset = ConfigGetValue( Data, "CStickDownRight", 0 ); + HID_CTRL->CStickDownRight.Mask = ConfigGetValue( Data, "CStickDownRight", 1 ); + HID_CTRL->CStickDownRight.Modif = ConfigGetValue( Data, "CStickDownRight", 2 ); + + HID_CTRL->CStickDownLeft.Offset = ConfigGetValue( Data, "CStickDownLeft", 0 ); + HID_CTRL->CStickDownLeft.Mask = ConfigGetValue( Data, "CStickDownLeft", 1 ); + HID_CTRL->CStickDownLeft.Modif = ConfigGetValue( Data, "CStickDownLeft", 2 ); + + HID_CTRL->CStickUpLeft.Offset = ConfigGetValue( Data, "CStickUpLeft", 0 ); + HID_CTRL->CStickUpLeft.Mask = ConfigGetValue( Data, "CStickUpLeft", 1 ); + HID_CTRL->CStickUpLeft.Modif = ConfigGetValue( Data, "CStickUpLeft", 2 ); + } + } HID_CTRL->CStickX.Offset = ConfigGetValue( Data, "CStickX", 0 ); HID_CTRL->CStickX.DeadZone = ConfigGetValue( Data, "CStickX", 1 ); HID_CTRL->CStickX.Radius = ConfigGetDecValue( Data, "CStickX", 2 ); if (HID_CTRL->CStickX.Radius == 0) HID_CTRL->CStickX.Radius = 80; HID_CTRL->CStickX.Radius = (u64)HID_CTRL->CStickX.Radius * 1280 / (128 - HID_CTRL->CStickX.DeadZone); //adjust for DeadZone - // dbgprintf("HID:CStickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickX.Offset, HID_CTRL->CStickX.DeadZone, HID_CTRL->CStickX.Radius); + // dbgprintf("HID:CStickX: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickX.Offset, HID_CTRL->CStickX.DeadZone, HID_CTRL->CStickX.Radius); HID_CTRL->CStickY.Offset = ConfigGetValue( Data, "CStickY", 0 ); HID_CTRL->CStickY.DeadZone = ConfigGetValue( Data, "CStickY", 1 ); @@ -523,7 +587,7 @@ s32 HIDOpen( u32 LoaderRequest ) if (HID_CTRL->CStickY.Radius == 0) HID_CTRL->CStickY.Radius = 80; HID_CTRL->CStickY.Radius = (u64)HID_CTRL->CStickY.Radius * 1280 / (128 - HID_CTRL->CStickY.DeadZone); //adjust for DeadZone - // dbgprintf("HID:CStickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickY.Offset, HID_CTRL->CStickY.DeadZone, HID_CTRL->CStickY.Radius); + // dbgprintf("HID:CStickY: Offset=%3X Deadzone=%3X Radius=%d\r\n", HID_CTRL->CStickY.Offset, HID_CTRL->CStickY.DeadZone, HID_CTRL->CStickY.Radius); HID_CTRL->LAnalog = ConfigGetValue( Data, "LAnalog", 0 ); HID_CTRL->RAnalog = ConfigGetValue( Data, "RAnalog", 0 ); diff --git a/kernel/HID.h b/kernel/HID.h index 327a5168..15d217bb 100644 --- a/kernel/HID.h +++ b/kernel/HID.h @@ -11,6 +11,7 @@ typedef struct Layout { u32 Offset; u32 Mask; + u8 Modif; } layout; typedef struct StickLayout @@ -28,9 +29,14 @@ typedef struct Controller u32 DPAD; u32 DPADMask; u32 DigitalLR; + u32 DigitalCStick; u32 MultiIn; u32 MultiInValue; + layout Mod1; + layout Mod2; + layout Mod3; + layout Power; layout A; @@ -54,6 +60,15 @@ typedef struct Controller layout DownLeft; layout UpLeft; + layout CStickUp; + layout CStickRight; + layout CStickLeft; + layout CStickDown; + layout CStickRightUp; + layout CStickDownRight; + layout CStickDownLeft; + layout CStickUpLeft; + stickLayout StickX; stickLayout StickY; stickLayout CStickX; diff --git a/kernel/HID_controllers.h b/kernel/HID_controllers.h index 67b4b57d..8a45fa82 100644 --- a/kernel/HID_controllers.h +++ b/kernel/HID_controllers.h @@ -1,127 +1,208 @@ -//This File was Generated using controller_ini_to_array - -#ifndef __HID_CONTROLLER_H__ -#define __HID_CONTROLLER_H_ - -controller DefControllers[] = { - { 0x2002, 0x9000, 1, 1, 0xf, 0, 0, 0, - {0x1, 0x10}, {0x0, 0x1}, {0x0, 0x2}, {0x0, 0x8}, {0x0, 0x10}, {0x0, 0x0}, {0x0, 0x80}, {0x1, 0x1}, {0x1, 0x2}, {0x1, 0x8}, - {0x2, 0x6}, {0x2, 0x4}, {0x2, 0x2}, {0x2, 0x0}, {0x2, 0x1}, {0x2, 0x3}, {0x2, 0x5}, {0x2, 0x7}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x10, 0x10 }, - { 0x054c, 0x05c5, 1, 1, 0xf, 0, 0, 0, - {0x7, 0x1}, {0x5, 0x20}, {0x5, 0x40}, {0x5, 0x10}, {0x5, 0x80}, {0x0, 0x0}, {0x6, 0x80}, {0x6, 0x1}, {0x6, 0x2}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x8, 0x9 }, - { 0x0079, 0x0006, 1, 1, 0xf, 1, 0, 0, - {0x6, 0x10}, {0x5, 0x40}, {0x5, 0x80}, {0x5, 0x20}, {0x5, 0x10}, {0x0, 0x0}, {0x6, 0x8}, {0x6, 0x1}, {0x6, 0x2}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x0, 0x0 }, - { 0x25f0, 0x83c1, 1, 1, 0xf, 0, 0, 0, - {0x1, 0x10}, {0x0, 0x2}, {0x0, 0x4}, {0x0, 0x8}, {0x0, 0x1}, {0x0, 0x0}, {0x0, 0x20}, {0x0, 0x40}, {0x0, 0x80}, {0x1, 0x2}, - {0x2, 0x6}, {0x2, 0x4}, {0x2, 0x2}, {0x2, 0x0}, {0x2, 0x1}, {0x2, 0x3}, {0x2, 0x5}, {0x2, 0x7}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x11, 0x12 }, - { 0x0f0d, 0x0011, 0, 0, 0xffff, 1, 0, 0, - {0x1, 0x10}, {0x0, 0x4}, {0x0, 0x2}, {0x0, 0x8}, {0x0, 0x1}, {0x0, 0x0}, {0x12, 0xff}, {0x0, 0x10}, {0x0, 0x20}, {0x1, 0x2}, - {0x8, 0xff}, {0xa, 0xff}, {0x7, 0xff}, {0x9, 0xff}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, - { 0x046d, 0xc219, 1, 1, 0xf, 1, 0, 0, - {0x6, 0x40}, {0x5, 0x20}, {0x5, 0x10}, {0x5, 0x80}, {0x5, 0x40}, {0x0, 0x0}, {0x6, 0x2}, {0x6, 0x4}, {0x6, 0x8}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x0, 0x0 }, - { 0x046d, 0xc216, 1, 1, 0xf, 0, 0, 0, - {0x5, 0x10}, {0x4, 0x20}, {0x4, 0x40}, {0x4, 0x10}, {0x4, 0x80}, {0x0, 0x0}, {0x5, 0x2}, {0x5, 0x4}, {0x5, 0x8}, {0x5, 0x20}, - {0x4, 0x6}, {0x4, 0x4}, {0x4, 0x2}, {0x4, 0x0}, {0x4, 0x1}, {0x4, 0x3}, {0x4, 0x5}, {0x4, 0x7}, - {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0xf, 0xe }, - { 0x046d, 0xc218, 1, 1, 0xf, 1, 0, 0, - {0x5, 0x10}, {0x4, 0x20}, {0x4, 0x10}, {0x4, 0x40}, {0x4, 0x80}, {0x5, 0x1}, {0x5, 0x2}, {0x5, 0x4}, {0x5, 0x8}, {0x5, 0x20}, - {0x4, 0x6}, {0x4, 0x4}, {0x4, 0x2}, {0x4, 0x0}, {0x4, 0x1}, {0x4, 0x3}, {0x4, 0x5}, {0x4, 0x7}, - {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0x0, 0x0 }, - { 0x0926, 0x2526, 1, 1, 0xf, 0, 0, 0, - {0x1, 0x62}, {0x1, 0x1}, {0x1, 0x2}, {0x1, 0x4}, {0x1, 0x8}, {0x0, 0x0}, {0x1, 0x40}, {0x1, 0x10}, {0x1, 0x20}, {0x1, 0x80}, - {0x2, 0x1}, {0x2, 0x4}, {0x2, 0x2}, {0x2, 0x8}, {0x2, 0xa}, {0x2, 0x6}, {0x2, 0x5}, {0x2, 0x9}, - {0x3, 0x0, 0x3e8}, {0x4, 0x0, 0x3e8}, {0x5, 0x0, 0x3e8}, {0x6, 0x0, 0x3e8}, 0x7, 0x7 }, - { 0x0925, 0x03e8, 1, 1, 0xf0, 2, 1, 1, - {0x2, 0x3}, {0x1, 0x2}, {0x1, 0x8}, {0x1, 0x1}, {0x1, 0x4}, {0x0, 0x0}, {0x1, 0x80}, {0x6, 0x78}, {0x7, 0xf}, {0x2, 0x2}, - {0x4, 0x60}, {0x4, 0x40}, {0x4, 0x20}, {0x4, 0x0}, {0x4, 0x10}, {0x4, 0x30}, {0x4, 0x50}, {0x4, 0x70}, - {0x3, 0x0, 0x3e8}, {0x4, 0x0, 0x3e8}, {0x5, 0x0, 0x3e8}, {0x6, 0x0, 0x3e8}, 0x6, 0x7 }, - { 0x1d79, 0x0301, 1, 1, 0xf, 1, 0, 0, - {0x6, 0x40}, {0x5, 0x20}, {0x5, 0x40}, {0x5, 0x10}, {0x5, 0x80}, {0x0, 0x0}, {0x6, 0x2}, {0x6, 0x4}, {0x6, 0x8}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, 0x20, 0x21 }, - { 0x045e, 0x001b, 1, 1, 0xf, 1, 0, 0, - {0x8, 0xf0}, {0x8, 0x1}, {0x8, 0x2}, {0x8, 0x8}, {0x8, 0x4}, {0x0, 0x0}, {0x8, 0x20}, {0x8, 0x80}, {0x8, 0x10}, {0x8, 0x40}, - {0x7, 0x6}, {0x7, 0x4}, {0x7, 0x2}, {0x7, 0x0}, {0x7, 0x1}, {0x7, 0x3}, {0x7, 0x5}, {0x7, 0x7}, - {0x1, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x21 }, - { 0x045e, 0x0038, 1, 1, 0xf0, 1, 0, 0, - {0x4, 0xf0}, {0x4, 0x1}, {0x4, 0x2}, {0x4, 0x8}, {0x4, 0x4}, {0x0, 0x0}, {0x4, 0x20}, {0x4, 0x80}, {0x4, 0x10}, {0x4, 0x40}, - {0x5, 0x60}, {0x5, 0x40}, {0x5, 0x20}, {0x5, 0x0}, {0x5, 0x10}, {0x5, 0x30}, {0x5, 0x50}, {0x5, 0x70}, - {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0x0, 0x21 }, - { 0x057e, 0x0337, 1, 1, 0xf0, 0, 3, 9, - {0x3, 0xf}, {0x2, 0x1}, {0x2, 0x2}, {0x2, 0x4}, {0x2, 0x8}, {0x0, 0x0}, {0x3, 0x2}, {0x3, 0x8}, {0x3, 0x4}, {0x3, 0x1}, - {0x2, 0x10}, {0x2, 0x40}, {0x2, 0x20}, {0x2, 0x80}, {0x2, 0xa0}, {0x2, 0x60}, {0x2, 0x50}, {0x2, 0x90}, - {0x4, 0x0, 0x3e8}, {0x5, 0x0, 0x3e8}, {0x6, 0x0, 0x3e8}, {0x7, 0x0, 0x3e8}, 0x8, 0x9 }, - { 0x0955, 0x7210, 1, 1, 0xf, 2, 1, 1, - {0x2, 0x80}, {0x1, 0x1}, {0x1, 0x4}, {0x1, 0x2}, {0x1, 0x8}, {0x0, 0x0}, {0x1, 0x20}, {0xd, 0xff}, {0xf, 0xff}, {0x2, 0x2}, - {0x3, 0x6}, {0x3, 0x4}, {0x3, 0x2}, {0x3, 0x0}, {0x3, 0x1}, {0x3, 0x3}, {0x3, 0x5}, {0x3, 0x7}, - {0x5, 0x0, 0x320}, {0x7, 0x0, 0x320}, {0x9, 0x0, 0x320}, {0xb, 0x0, 0x320}, 0xd, 0xf }, - { 0x1a34, 0x0836, 1, 1, 0xf, 1, 0, 0, - {0x6, 0x9}, {0x5, 0x2}, {0x5, 0x1}, {0x5, 0x4}, {0x5, 0x8}, {0x0, 0x0}, {0x5, 0x20}, {0x5, 0x40}, {0x5, 0x80}, {0x6, 0x2}, - {0x7, 0x6}, {0x7, 0x4}, {0x7, 0x2}, {0x7, 0x0}, {0x7, 0x1}, {0x7, 0x3}, {0x7, 0x5}, {0x7, 0x7}, - {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0x0, 0x0 }, - { 0x0810, 0x0001, 1, 1, 0xf, 1, 1, 1, - {0x6, 0x10}, {0x5, 0x20}, {0x5, 0x40}, {0x5, 0x10}, {0x5, 0x80}, {0x0, 0x0}, {0x6, 0x8}, {0x6, 0x1}, {0x6, 0x2}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x3, 0x1a, 0x4e6}, {0x4, 0x1a, 0x4e6}, {0x2, 0x1a, 0x4e6}, {0x1, 0x1a, 0x4e6}, 0x0, 0x0 }, - { 0x054c, 0x0268, 0, 0, 0xffff, 2, 0, 0, - {0x2, 0x1}, {0x3, 0x20}, {0x3, 0x40}, {0x3, 0x10}, {0x3, 0x80}, {0x0, 0x0}, {0x3, 0x8}, {0x12, 0xf0}, {0x13, 0xf0}, {0x2, 0x8}, - {0x2, 0x80}, {0x2, 0x40}, {0x2, 0x20}, {0x2, 0x10}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, - {0x6, 0x0, 0x320}, {0x7, 0x0, 0x320}, {0x8, 0x0, 0x320}, {0x9, 0x0, 0x320}, 0x12, 0x13 }, - { 0x054c, 0x05c4, 1, 1, 0xf, 2, 0, 0, - {0x6, 0x0}, {0x5, 0x40}, {0x5, 0x20}, {0x5, 0x80}, {0x5, 0x10}, {0x0, 0x0}, {0x6, 0x2}, {0x8, 0xf0}, {0x9, 0xf0}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x8, 0x9 }, - { 0x054c, 0x09cc, 1, 1, 0xf, 2, 0, 0, - {0x6, 0x0}, {0x5, 0x40}, {0x5, 0x20}, {0x5, 0x80}, {0x5, 0x10}, {0x0, 0x0}, {0x6, 0x2}, {0x8, 0xf0}, {0x9, 0xf0}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x8, 0x9 }, - { 0x044f, 0xb315, 1, 1, 0xf0, 1, 0, 0, - {0x0, 0x0}, {0x0, 0x4}, {0x0, 0x1}, {0x0, 0x8}, {0x0, 0x2}, {0x0, 0x10}, {0x0, 0x40}, {0x0, 0x20}, {0x0, 0x80}, {0x1, 0x2}, - {0x2, 0x60}, {0x2, 0x40}, {0x2, 0x20}, {0x2, 0x0}, {0x2, 0x10}, {0x2, 0x30}, {0x2, 0x50}, {0x2, 0x70}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, - { 0x044f, 0xb303, 1, 1, 0xf0, 1, 0, 0, - {0x1, 0x3}, {0x0, 0x1}, {0x0, 0x2}, {0x0, 0x4}, {0x0, 0x8}, {0x0, 0x10}, {0x0, 0x40}, {0x0, 0x20}, {0x0, 0x80}, {0x1, 0x2}, - {0x2, 0x60}, {0x2, 0x40}, {0x2, 0x20}, {0x2, 0x0}, {0x2, 0x10}, {0x2, 0x30}, {0x2, 0x50}, {0x2, 0x70}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, - { 0x044f, 0xd007, 1, 1, 0x27, 1, 0, 0, - {0x1, 0x10}, {0x0, 0x2}, {0x0, 0x1}, {0x0, 0x4}, {0x0, 0x8}, {0x0, 0x0}, {0x0, 0x20}, {0x0, 0x40}, {0x0, 0x80}, {0x1, 0x2}, - {0x2, 0x26}, {0x2, 0x24}, {0x2, 0x22}, {0x2, 0x20}, {0x2, 0x21}, {0x2, 0x23}, {0x2, 0x25}, {0x2, 0x27}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, - { 0x2006, 0x0118, 1, 1, 0xf0, 0, 0, 0, - {0x0, 0x0}, {0x1, 0x1}, {0x1, 0x2}, {0x1, 0x4}, {0x1, 0x8}, {0x0, 0x0}, {0x1, 0x40}, {0x1, 0x10}, {0x1, 0x20}, {0x2, 0x1}, - {0x2, 0x60}, {0x2, 0x40}, {0x2, 0x20}, {0x2, 0x0}, {0x2, 0x10}, {0x2, 0x30}, {0x2, 0x50}, {0x2, 0x70}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x7, 0x70 }, - { 0x0810, 0x0003, 1, 1, 0xf, 1, 0, 0, - {0x6, 0x10}, {0x5, 0x40}, {0x5, 0x80}, {0x5, 0x20}, {0x5, 0x10}, {0x0, 0x0}, {0x6, 0x8}, {0x6, 0x1}, {0x6, 0x2}, {0x6, 0x20}, - {0x5, 0x6}, {0x5, 0x4}, {0x5, 0x2}, {0x5, 0x0}, {0x5, 0x1}, {0x5, 0x3}, {0x5, 0x5}, {0x5, 0x7}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x1, 0x0, 0x320}, 0x0, 0x0 }, - { 0x7701, 0x0003, 1, 0, 0xffff, 0, 0, 0, - {0x0, 0x0}, {0x0, 0x4}, {0x0, 0x8}, {0x0, 0x2}, {0x0, 0x1}, {0x0, 0x0}, {0x0, 0x80}, {0x0, 0x10}, {0x0, 0x20}, {0x1, 0x2}, - {0x1, 0x80}, {0x1, 0x40}, {0x1, 0x20}, {0x1, 0x10}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, - {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, 0x0, 0x0 }, - { 0x0079, 0x1800, 1, 1, 0xf, 1, 1, 1, - {0x2, 0x4}, {0x1, 0x4}, {0x1, 0x1}, {0x1, 0x8}, {0x1, 0x2}, {0x0, 0x0}, {0x1, 0x20}, {0x1, 0x40}, {0x1, 0x80}, {0x2, 0x8}, - {0x7, 0x6}, {0x7, 0x4}, {0x7, 0x2}, {0x7, 0x0}, {0x7, 0x1}, {0x7, 0x3}, {0x7, 0x5}, {0x7, 0x7}, - {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, -}; - -u8 RumbleDataOn_0079_0006[14] = { 0x51, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xfa, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 }; -u8 RumbleDataOff_0079_0006[14] = { 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 }; -u8 RumbleDataOn_0810_0001[5] = { 0x01, 0x00, 0x00, 0x7f, 0x7f }; -u8 RumbleDataOff_0810_0001[5] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; - -rumble DefRumble[] = { - { 0x0079, 0x0006, 1, 14, 2, 7, RumbleDataOn_0079_0006, RumbleDataOff_0079_0006 }, - { 0x0810, 0x0001, 0, 5, 1, 5, RumbleDataOn_0810_0001, RumbleDataOff_0810_0001 }, -}; - -#endif +//This File was Generated using controller_ini_to_array + +#ifndef __HID_CONTROLLER_H__ +#define __HID_CONTROLLER_H_ + +controller DefControllers[] = { + { 0x044f, 0xd007, 1, 1, 0x27, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x10, 0x0}, {0x0, 0x2, 0x0}, {0x0, 0x1, 0x0}, {0x0, 0x4, 0x0}, {0x0, 0x8, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x20, 0x0}, {0x0, 0x40, 0x0}, {0x0, 0x80, 0x0}, {0x1, 0x2, 0x0}, + {0x2, 0x26, 0x0}, {0x2, 0x24, 0x0}, {0x2, 0x22, 0x0}, {0x2, 0x20, 0x0}, {0x2, 0x21, 0x0}, {0x2, 0x23, 0x0}, {0x2, 0x25, 0x0}, {0x2, 0x27, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, + { 0x045e, 0x001b, 1, 1, 0xf, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x8, 0xf0, 0x0}, {0x8, 0x1, 0x0}, {0x8, 0x2, 0x0}, {0x8, 0x8, 0x0}, {0x8, 0x4, 0x0}, {0x0, 0x0, 0x0}, {0x8, 0x20, 0x0}, {0x8, 0x80, 0x0}, {0x8, 0x10, 0x0}, {0x8, 0x40, 0x0}, + {0x7, 0x6, 0x0}, {0x7, 0x4, 0x0}, {0x7, 0x2, 0x0}, {0x7, 0x0, 0x0}, {0x7, 0x1, 0x0}, {0x7, 0x3, 0x0}, {0x7, 0x5, 0x0}, {0x7, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, + { 0x046d, 0xc216, 1, 1, 0xf, 0, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x5, 0x10, 0x0}, {0x4, 0x20, 0x0}, {0x4, 0x40, 0x0}, {0x4, 0x10, 0x0}, {0x4, 0x80, 0x0}, {0x0, 0x0, 0x0}, {0x5, 0x2, 0x0}, {0x5, 0x4, 0x0}, {0x5, 0x8, 0x0}, {0x5, 0x20, 0x0}, + {0x4, 0x6, 0x0}, {0x4, 0x4, 0x0}, {0x4, 0x2, 0x0}, {0x4, 0x0, 0x0}, {0x4, 0x1, 0x0}, {0x4, 0x3, 0x0}, {0x4, 0x5, 0x0}, {0x4, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0xf, 0xe }, + { 0x045e, 0x0038, 1, 1, 0xf0, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x4, 0xf0, 0x0}, {0x4, 0x1, 0x0}, {0x4, 0x2, 0x0}, {0x4, 0x8, 0x0}, {0x4, 0x4, 0x0}, {0x0, 0x0, 0x0}, {0x4, 0x20, 0x0}, {0x4, 0x80, 0x0}, {0x4, 0x10, 0x0}, {0x4, 0x40, 0x0}, + {0x5, 0x60, 0x0}, {0x5, 0x40, 0x0}, {0x5, 0x20, 0x0}, {0x5, 0x0, 0x0}, {0x5, 0x10, 0x0}, {0x5, 0x30, 0x0}, {0x5, 0x50, 0x0}, {0x5, 0x70, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0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0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, 0x0, 0x0 }, + { 0x054c, 0x09cc, 1, 1, 0xf, 2, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x6, 0x0, 0x0}, {0x5, 0x40, 0x0}, {0x5, 0x20, 0x0}, {0x5, 0x80, 0x0}, {0x5, 0x10, 0x0}, {0x0, 0x0, 0x0}, {0x6, 0x2, 0x0}, {0x8, 0xf0, 0x0}, {0x9, 0xf0, 0x0}, {0x6, 0x20, 0x0}, + {0x5, 0x6, 0x0}, {0x5, 0x4, 0x0}, {0x5, 0x2, 0x0}, {0x5, 0x0, 0x0}, {0x5, 0x1, 0x0}, {0x5, 0x3, 0x0}, {0x5, 0x5, 0x0}, {0x5, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x8, 0x9 }, + { 0x054c, 0x0268, 0, 0, 0xffff, 2, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x2, 0x1, 0x0}, {0x3, 0x20, 0x0}, {0x3, 0x40, 0x0}, {0x3, 0x10, 0x0}, {0x3, 0x80, 0x0}, {0x0, 0x0, 0x0}, {0x3, 0x8, 0x0}, {0x12, 0xf0, 0x0}, {0x13, 0xf0, 0x0}, {0x2, 0x8, 0x0}, + {0x2, 0x80, 0x0}, {0x2, 0x40, 0x0}, {0x2, 0x20, 0x0}, {0x2, 0x10, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x6, 0x0, 0x320}, {0x7, 0x0, 0x320}, {0x8, 0x0, 0x320}, {0x9, 0x0, 0x320}, 0x12, 0x13 }, + { 0x046d, 0xc219, 1, 1, 0xf, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x6, 0x40, 0x0}, {0x5, 0x20, 0x0}, {0x5, 0x10, 0x0}, {0x5, 0x80, 0x0}, {0x5, 0x40, 0x0}, {0x0, 0x0, 0x0}, {0x6, 0x2, 0x0}, {0x6, 0x4, 0x0}, {0x6, 0x8, 0x0}, {0x6, 0x20, 0x0}, + {0x5, 0x6, 0x0}, {0x5, 0x4, 0x0}, {0x5, 0x2, 0x0}, {0x5, 0x0, 0x0}, {0x5, 0x1, 0x0}, {0x5, 0x3, 0x0}, {0x5, 0x5, 0x0}, {0x5, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, 0x0, 0x0 }, + { 0x057e, 0x0337, 1, 1, 0xf0, 0, 0, 3, 9, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0,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 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x2, 0x0, 0x320}, {0x1, 0x0, 0x320}, 0x0, 0x0 }, + { 0x044f, 0xb315, 1, 1, 0xf0, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x4, 0x0}, {0x0, 0x1, 0x0}, {0x0, 0x8, 0x0}, {0x0, 0x2, 0x0}, {0x0, 0x10, 0x0}, {0x0, 0x40, 0x0}, {0x0, 0x20, 0x0}, {0x0, 0x80, 0x0}, {0x1, 0x2, 0x0}, + {0x2, 0x60, 0x0}, {0x2, 0x40, 0x0}, {0x2, 0x20, 0x0}, {0x2, 0x0, 0x0}, {0x2, 0x10, 0x0}, {0x2, 0x30, 0x0}, {0x2, 0x50, 0x0}, {0x2, 0x70, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, + { 0x054c, 0x05c4, 1, 1, 0xf, 2, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x6, 0x0, 0x0}, {0x5, 0x40, 0x0}, {0x5, 0x20, 0x0}, {0x5, 0x80, 0x0}, {0x5, 0x10, 0x0}, {0x0, 0x0, 0x0}, {0x6, 0x2, 0x0}, {0x8, 0xf0, 0x0}, {0x9, 0xf0, 0x0}, {0x6, 0x20, 0x0}, + {0x5, 0x6, 0x0}, {0x5, 0x4, 0x0}, {0x5, 0x2, 0x0}, {0x5, 0x0, 0x0}, {0x5, 0x1, 0x0}, {0x5, 0x3, 0x0}, {0x5, 0x5, 0x0}, {0x5, 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 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x7, 0x70 }, + { 0x1d79, 0x0301, 1, 1, 0xf, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x6, 0x40, 0x0}, {0x5, 0x20, 0x0}, {0x5, 0x40, 0x0}, {0x5, 0x10, 0x0}, {0x5, 0x80, 0x0}, {0x0, 0x0, 0x0}, {0x6, 0x2, 0x0}, {0x6, 0x4, 0x0}, {0x6, 0x8, 0x0}, {0x6, 0x20, 0x0}, + {0x5, 0x6, 0x0}, {0x5, 0x4, 0x0}, {0x5, 0x2, 0x0}, {0x5, 0x0, 0x0}, {0x5, 0x1, 0x0}, {0x5, 0x3, 0x0}, {0x5, 0x5, 0x0}, {0x5, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x0, 0x0, 0x320}, {0x1, 0x0, 0x320}, 0x20, 0x21 }, + { 0x0079, 0x1800, 1, 1, 0xf, 1, 0, 1, 1, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x2, 0x4, 0x0}, {0x1, 0x4, 0x0}, {0x1, 0x1, 0x0}, {0x1, 0x8, 0x0}, {0x1, 0x2, 0x0}, {0x0, 0x0, 0x0}, {0x1, 0x20, 0x0}, {0x1, 0x40, 0x0}, {0x1, 0x80, 0x0}, {0x2, 0x8, 0x0}, + {0x7, 0x6, 0x0}, {0x7, 0x4, 0x0}, {0x7, 0x2, 0x0}, {0x7, 0x0, 0x0}, {0x7, 0x1, 0x0}, {0x7, 0x3, 0x0}, {0x7, 0x5, 0x0}, {0x7, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, + { 0x044f, 0xb303, 1, 1, 0xf0, 1, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x3, 0x0}, {0x0, 0x1, 0x0}, {0x0, 0x2, 0x0}, {0x0, 0x4, 0x0}, {0x0, 0x8, 0x0}, {0x0, 0x10, 0x0}, {0x0, 0x40, 0x0}, {0x0, 0x20, 0x0}, {0x0, 0x80, 0x0}, {0x1, 0x2, 0x0}, + {0x2, 0x60, 0x0}, {0x2, 0x40, 0x0}, {0x2, 0x20, 0x0}, {0x2, 0x0, 0x0}, {0x2, 0x10, 0x0}, {0x2, 0x30, 0x0}, {0x2, 0x50, 0x0}, {0x2, 0x70, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, + { 0x7701, 0x0003, 1, 0, 0xffff, 0, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x4, 0x0}, {0x0, 0x8, 0x0}, {0x0, 0x2, 0x0}, {0x0, 0x1, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x80, 0x0}, {0x0, 0x10, 0x0}, {0x0, 0x20, 0x0}, {0x1, 0x2, 0x0}, + {0x1, 0x80, 0x0}, {0x1, 0x40, 0x0}, {0x1, 0x20, 0x0}, {0x1, 0x10, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x2, 0x0, 0x320}, {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, 0x0, 0x0 }, + { 0x25f0, 0x83c1, 1, 1, 0xf, 0, 0, 0, 0, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x1, 0x10, 0x0}, {0x0, 0x2, 0x0}, {0x0, 0x4, 0x0}, {0x0, 0x8, 0x0}, {0x0, 0x1, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x20, 0x0}, {0x0, 0x40, 0x0}, {0x0, 0x80, 0x0}, {0x1, 0x2, 0x0}, + {0x2, 0x6, 0x0}, {0x2, 0x4, 0x0}, {0x2, 0x2, 0x0}, {0x2, 0x0, 0x0}, {0x2, 0x1, 0x0}, {0x2, 0x3, 0x0}, {0x2, 0x5, 0x0}, {0x2, 0x7, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x11, 0x12 }, + { 0x0810, 0x0001, 1, 1, 0xf, 1, 0, 1, 1, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 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0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, + {0x3, 0x0, 0x320}, {0x4, 0x0, 0x320}, {0x5, 0x0, 0x320}, {0x6, 0x0, 0x320}, 0x0, 0x0 }, +}; + +u8 RumbleDataOn_0079_0006[14] = { 0x51, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xfa, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 }; +u8 RumbleDataOff_0079_0006[14] = { 0x51, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00 }; +u8 RumbleDataOn_0810_0001[5] = { 0x01, 0x00, 0x00, 0x7f, 0x7f }; +u8 RumbleDataOff_0810_0001[5] = { 0x01, 0x00, 0x00, 0x00, 0x00 }; + +rumble DefRumble[] = { + { 0x0079, 0x0006, 1, 14, 2, 7, RumbleDataOn_0079_0006, RumbleDataOff_0079_0006 }, + { 0x0810, 0x0001, 0, 5, 1, 5, RumbleDataOn_0810_0001, RumbleDataOff_0810_0001 }, +}; + +#endif diff --git a/kernel/global.h b/kernel/global.h index 9c289ad4..f66e13a2 100644 --- a/kernel/global.h +++ b/kernel/global.h @@ -24,7 +24,7 @@ //#define DEBUG_EXI 1 //#define DEBUG_SRAM 1 //#define DEBUG_FST 1 -#define DEBUG_PATCH 1 +//#define DEBUG_PATCH 1 //#define DEBUG_TIME 1 //#define DEBUG_SOCK 1 diff --git a/kernel/hidmem.h b/kernel/hidmem.h index 508bf5ab..b732bc6e 100644 --- a/kernel/hidmem.h +++ b/kernel/hidmem.h @@ -2,5 +2,5 @@ #ifndef _HIDMEM_H_ #define _HIDMEM_H_ static controller *HID_CTRL = (controller*)0x13005000; -static void *HID_Packet = (void*)0x130050F0; +static void *HID_Packet = (void*)0x130052F0; #endif diff --git a/loader/include/global.h b/loader/include/global.h index 4c4402de..4e926747 100644 --- a/loader/include/global.h +++ b/loader/include/global.h @@ -27,6 +27,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "Config.h" #include "grrlib.h" +#define DEFAULT_UDP_LOG_HOST "192.168.43.132" +#define DEFAULT_UDP_LOG_PORT 9930 +#include "udp_log.h" + #ifndef HW_RVL #define HW_RVL #endif diff --git a/loader/include/udp_log.h b/loader/include/udp_log.h new file mode 100644 index 00000000..fce121dd --- /dev/null +++ b/loader/include/udp_log.h @@ -0,0 +1,15 @@ +#include + + +#ifndef DEFAULT_UDP_LOG_PORT +#define DEFAULT_UDP_LOG_PORT 9930 +#endif +#ifndef DEFAULT_UDP_LOG_HOST +#define DEFAULT_UDP_LOG_HOST "192.168.43.132" // Address of debug server +#endif + +int udp_printf_to(const char* ipv4_addr, u16 port, const char* fmt, ...); + +#define udp_printf(fmt, ...) udp_printf_to(DEFAULT_UDP_LOG_HOST, DEFAULT_UDP_LOG_PORT, fmt, __VA_ARGS__) + + diff --git a/loader/loader.dol b/loader/loader.dol index 6177083b..6b74bc85 100644 Binary files a/loader/loader.dol and b/loader/loader.dol differ diff --git a/loader/source/ppc/PADReadGC/include/HID.h b/loader/source/ppc/PADReadGC/include/HID.h index 42e15346..d0059a40 100644 --- a/loader/source/ppc/PADReadGC/include/HID.h +++ b/loader/source/ppc/PADReadGC/include/HID.h @@ -3,10 +3,12 @@ #include "PS3Controller.h" + typedef struct Layout { u32 Offset; u32 Mask; + u8 Modif; } layout; typedef struct StickLayout @@ -24,9 +26,14 @@ typedef struct Controller u32 DPAD; u32 DPADMask; u32 DigitalLR; + u32 DigitalCStick; u32 MultiIn; u32 MultiInValue; + layout Mod1; + layout Mod2; + layout Mod3; + layout Power; layout A; @@ -50,6 +57,15 @@ typedef struct Controller layout DownLeft; layout UpLeft; + layout CStickUp; + layout CStickRight; + layout CStickLeft; + layout CStickDown; + layout CStickRightUp; + layout CStickDownRight; + layout CStickDownLeft; + layout CStickUpLeft; + stickLayout StickX; stickLayout StickY; stickLayout CStickX; diff --git a/loader/source/ppc/PADReadGC/include/hidmem.h b/loader/source/ppc/PADReadGC/include/hidmem.h index ebdd6fb3..6c2a6b51 100644 --- a/loader/source/ppc/PADReadGC/include/hidmem.h +++ b/loader/source/ppc/PADReadGC/include/hidmem.h @@ -2,5 +2,5 @@ #ifndef _HIDMEM_H_ #define _HIDMEM_H_ static volatile controller *HID_CTRL = (volatile controller*)0x93005000; -static vu8 *HID_Packet = (vu8*)0x930050F0; +static vu8 *HID_Packet = (vu8*)0x930052F0; #endif diff --git a/loader/source/ppc/PADReadGC/source/PADReadGC.c b/loader/source/ppc/PADReadGC/source/PADReadGC.c index d741f7a0..88f1c667 100644 --- a/loader/source/ppc/PADReadGC/source/PADReadGC.c +++ b/loader/source/ppc/PADReadGC/source/PADReadGC.c @@ -72,6 +72,15 @@ const s8 DEADZONE = 0x1A; else if(tmp_stick16 < -0x80) tmp_stick8 = -0x80; \ else tmp_stick8 = (s8)tmp_stick16; +// HID enable mapping with 3 modifiers +static u8 hidButtonValue(volatile layout *button); +static u8 hidIsButtonOn(volatile layout *button, u8 with_mods); +static u8 hidConsume(volatile layout *button, u8 with_mods); +static s8 hidRectifyStickValue(volatile stickLayout *stick, s8 raw_value); +static u32 used_buttons[24]; // how big is safe size? +static u8 modifiers_boolvals[4] = {1}; // no_mod + 3 modifiers, booleans + + u32 PADRead(u32 calledByGame) { // Registers r1,r13-r31 automatically restored if used. @@ -316,7 +325,7 @@ u32 PADRead(u32 calledByGame) { if(HIDMemPrep == 0) // first run { - HID_Packet = (vu8*)0x930050F0; // reset back to default offset + HID_Packet = (vu8*)0x930052F0; // reset back to default offset memInvalidate = (u32)HID_Packet; // prepare memory asm volatile("dcbi 0,%0" : : "b"(memInvalidate) : "memory"); //invalidate cache block for controllers using more than 0x10 bytes @@ -335,7 +344,6 @@ u32 PADRead(u32 calledByGame) PrevAdapterChannel3 = PrevAdapterChannel4; PrevAdapterChannel4 = HID_Packet[0] - 1; } - if (HID_CTRL->MultiIn == 3) //multiple controllers connected to a single usb port all in one message { HID_Packet = (vu8*)(0x930050F0 + (chan * HID_CTRL->MultiInValue)); //skip forward how ever many bytes in each controller @@ -385,99 +393,118 @@ u32 PADRead(u32 calledByGame) used |= (1<>chan); + /* first buttons */ u16 button = 0; - if(HID_CTRL->DPAD == 0) + s8 stickX, stickY, substickX = 0, substickY = 0; + modifiers_boolvals[1] = hidButtonValue(&(HID_CTRL->Mod1)); + modifiers_boolvals[2] = hidButtonValue(&(HID_CTRL->Mod2)); + modifiers_boolvals[3] = hidButtonValue(&(HID_CTRL->Mod3)); + for (int k=0; k<24; k++) { used_buttons[k] = 0; } // init + // HID MODIFIED BUTTONS LOOP + // first pass: process buttons with modifier (remember keys pressed) + // second pass: buttons without mods, omit the keys already processed + for (s8 with_mods=1; with_mods >= 0; with_mods--) { - if( HID_Packet[HID_CTRL->Left.Offset] & HID_CTRL->Left.Mask ) + // consume DPAD + if(hidConsume(&(HID_CTRL->Left), with_mods)) button |= PAD_BUTTON_LEFT; - - if( HID_Packet[HID_CTRL->Right.Offset] & HID_CTRL->Right.Mask ) + if(hidConsume(&(HID_CTRL->Right), with_mods)) button |= PAD_BUTTON_RIGHT; - - if( HID_Packet[HID_CTRL->Down.Offset] & HID_CTRL->Down.Mask ) + if(hidConsume(&(HID_CTRL->Down), with_mods)) button |= PAD_BUTTON_DOWN; - - if( HID_Packet[HID_CTRL->Up.Offset] & HID_CTRL->Up.Mask ) - button |= PAD_BUTTON_UP; - } - else - { - if(((HID_Packet[HID_CTRL->Up.Offset] & HID_CTRL->DPADMask) == HID_CTRL->Up.Mask) || ((HID_Packet[HID_CTRL->UpLeft.Offset] & HID_CTRL->DPADMask) == HID_CTRL->UpLeft.Mask) || ((HID_Packet[HID_CTRL->RightUp.Offset] & HID_CTRL->DPADMask) == HID_CTRL->RightUp.Mask)) + if(hidConsume(&(HID_CTRL->Up), with_mods)) button |= PAD_BUTTON_UP; - - if(((HID_Packet[HID_CTRL->Right.Offset] & HID_CTRL->DPADMask) == HID_CTRL->Right.Mask) || ((HID_Packet[HID_CTRL->DownRight.Offset] & HID_CTRL->DPADMask) == HID_CTRL->DownRight.Mask) || ((HID_Packet[HID_CTRL->RightUp.Offset] & HID_CTRL->DPADMask) == HID_CTRL->RightUp.Mask)) - button |= PAD_BUTTON_RIGHT; - - if(((HID_Packet[HID_CTRL->Down.Offset] & HID_CTRL->DPADMask) == HID_CTRL->Down.Mask) || ((HID_Packet[HID_CTRL->DownRight.Offset] & HID_CTRL->DPADMask) == HID_CTRL->DownRight.Mask) || ((HID_Packet[HID_CTRL->DownLeft.Offset] & HID_CTRL->DPADMask) == HID_CTRL->DownLeft.Mask)) - button |= PAD_BUTTON_DOWN; - - if(((HID_Packet[HID_CTRL->Left.Offset] & HID_CTRL->DPADMask) == HID_CTRL->Left.Mask) || ((HID_Packet[HID_CTRL->DownLeft.Offset] & HID_CTRL->DPADMask) == HID_CTRL->DownLeft.Mask) || ((HID_Packet[HID_CTRL->UpLeft.Offset] & HID_CTRL->DPADMask) == HID_CTRL->UpLeft.Mask)) - button |= PAD_BUTTON_LEFT; - } - if(HID_Packet[HID_CTRL->A.Offset] & HID_CTRL->A.Mask) - button |= PAD_BUTTON_A; - if(HID_Packet[HID_CTRL->B.Offset] & HID_CTRL->B.Mask) - button |= PAD_BUTTON_B; - if(HID_Packet[HID_CTRL->X.Offset] & HID_CTRL->X.Mask) - button |= PAD_BUTTON_X; - if(HID_Packet[HID_CTRL->Y.Offset] & HID_CTRL->Y.Mask) - button |= PAD_BUTTON_Y; - if(HID_Packet[HID_CTRL->Z.Offset] & HID_CTRL->Z.Mask) - button |= PAD_TRIGGER_Z; - - if( HID_CTRL->DigitalLR == 1) //digital trigger buttons only - { - if(!(HID_Packet[HID_CTRL->ZL.Offset] & HID_CTRL->ZL.Mask)) //ZL acts as shift for half pressed + if(HID_CTRL->DPAD) // HID_CTRL->DPAD not 0 { - if(HID_Packet[HID_CTRL->L.Offset] & HID_CTRL->L.Mask) - button |= PAD_TRIGGER_L; - if(HID_Packet[HID_CTRL->R.Offset] & HID_CTRL->R.Mask) - button |= PAD_TRIGGER_R; + if(hidConsume(&(HID_CTRL->UpLeft), with_mods)) + button |= PAD_BUTTON_LEFT | PAD_BUTTON_UP; + if(hidConsume(&(HID_CTRL->RightUp), with_mods)) + button |= PAD_BUTTON_RIGHT | PAD_BUTTON_UP; + if(hidConsume(&(HID_CTRL->DownLeft), with_mods)) + button |= PAD_BUTTON_DOWN | PAD_BUTTON_LEFT; + if(hidConsume(&(HID_CTRL->DownRight), with_mods)) + button |= PAD_BUTTON_DOWN | PAD_BUTTON_RIGHT; } - } - else if( HID_CTRL->DigitalLR == 2) //no digital trigger buttons compute from analog trigger values - { - if ((HID_CTRL->VID == 0x0925) && (HID_CTRL->PID == 0x03E8)) //Mayflash Classic Controller Pro Adapter + // other buttons + if(hidConsume(&(HID_CTRL->A), with_mods)) + button |= PAD_BUTTON_A; + if(hidConsume(&(HID_CTRL->B), with_mods)) + button |= PAD_BUTTON_B; + if(hidConsume(&(HID_CTRL->S), with_mods)) + button |= PAD_BUTTON_START; + if(hidConsume(&(HID_CTRL->X), with_mods)) + button |= PAD_BUTTON_X; + if(hidConsume(&(HID_CTRL->Y), with_mods)) + button |= PAD_BUTTON_Y; + if(hidConsume(&(HID_CTRL->Z), with_mods)) + button |= PAD_TRIGGER_Z; + + // LR triggers + if( HID_CTRL->DigitalLR == 2) //no digital trigger buttons compute from analog trigger values { - if((HID_Packet[HID_CTRL->L.Offset] & 0x7C) >= HID_CTRL->L.Mask) //only some bits are part of this control - button |= PAD_TRIGGER_L; - if((HID_Packet[HID_CTRL->R.Offset] & 0x0F) >= HID_CTRL->R.Mask) //only some bits are part of this control - button |= PAD_TRIGGER_R; + if ((HID_CTRL->VID == 0x0925) && (HID_CTRL->PID == 0x03E8)) //Mayflash Classic Controller Pro Adapter + { + if((HID_Packet[HID_CTRL->L.Offset] & 0x7C) >= HID_CTRL->L.Mask) //only some bits are part of this control + button |= PAD_TRIGGER_L; + if((HID_Packet[HID_CTRL->R.Offset] & 0x0F) >= HID_CTRL->R.Mask) //only some bits are part of this control + button |= PAD_TRIGGER_R; + } + else //standard no digital trigger button + { + if(HID_Packet[HID_CTRL->L.Offset] >= HID_CTRL->L.Mask) + button |= PAD_TRIGGER_L; + if(HID_Packet[HID_CTRL->R.Offset] >= HID_CTRL->R.Mask) + button |= PAD_TRIGGER_R; + } } - else //standard no digital trigger button - { - if(HID_Packet[HID_CTRL->L.Offset] >= HID_CTRL->L.Mask) + else if((HID_CTRL->DigitalLR != 1) || !(HID_Packet[HID_CTRL->ZL.Offset] & HID_CTRL->ZL.Mask)) { + // when HID_CTRL->DigitalLR == 1 : ZL acts as shift for half pressed + // otherwise standard digital left and right trigger buttons + if(hidConsume(&(HID_CTRL->L), with_mods)) button |= PAD_TRIGGER_L; - if(HID_Packet[HID_CTRL->R.Offset] >= HID_CTRL->R.Mask) + if(hidConsume(&(HID_CTRL->R), with_mods)) button |= PAD_TRIGGER_R; } - } - else //standard digital left and right trigger buttons - { - if(HID_Packet[HID_CTRL->L.Offset] & HID_CTRL->L.Mask) - button |= PAD_TRIGGER_L; - if(HID_Packet[HID_CTRL->R.Offset] & HID_CTRL->R.Mask) - button |= PAD_TRIGGER_R; - } - if (PADBarrelEnabled[chan] && PADIsBarrel[chan]) //if bongo controller - { - if(button & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_START)) //any bongo pressed - PADBarrelPress[0+chan] = 6; - else + if (PADBarrelEnabled[chan] && PADIsBarrel[chan]) //if bongo controller { - if(PADBarrelPress[0+chan] > 0) - PADBarrelPress[0+chan]--; + if(button & (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | PAD_BUTTON_START)) //any bongo pressed + PADBarrelPress[0+chan] = 6; + else + { + if(PADBarrelPress[0+chan] > 0) + PADBarrelPress[0+chan]--; + } + if ((( HID_CTRL->DigitalLR != 1) && (HID_Packet[HID_CTRL->RAnalog] > 0x30)) //shadowfield liked 40 but didnt work for multi player + ||(( HID_CTRL->DigitalLR == 1) && (HID_Packet[HID_CTRL->R.Offset] & HID_CTRL->R.Mask))) + if (PADBarrelPress[0+chan] == 0) // bongos not pressed last 6 cycles (dont pickup bongo noise as clap) + button |= PAD_TRIGGER_R; //force button presss todo: bogo should only be using analog } - if ((( HID_CTRL->DigitalLR != 1) && (HID_Packet[HID_CTRL->RAnalog] > 0x30)) //shadowfield liked 40 but didnt work for multi player - ||(( HID_CTRL->DigitalLR == 1) && (HID_Packet[HID_CTRL->R.Offset] & HID_CTRL->R.Mask))) - if (PADBarrelPress[0+chan] == 0) // bongos not pressed last 6 cycles (dont pickup bongo noise as clap) - button |= PAD_TRIGGER_R; //force button presss todo: bogo should only be using analog - } + + // Digital CStick needs to be processed here for modified buttons disambiguation + if (HID_CTRL->DigitalCStick){ + // DIGITAL CSTICK TAKES PRECEDENCE OVER ALL BUTTONS + // INTENDED USE IS Modifier+DPAD=EmulatedCStick + u8 cstickval = hidConsume(&(HID_CTRL->CStickUp), with_mods) + | ( hidConsume(&(HID_CTRL->CStickDown), with_mods) << 1 ) + | ( hidConsume(&(HID_CTRL->CStickRight), with_mods) << 2 ) + | ( hidConsume(&(HID_CTRL->CStickLeft), with_mods) << 3 ); + if(HID_CTRL->DPAD != 0){ + if( hidConsume(&(HID_CTRL->CStickRightUp), with_mods)) { cstickval |= 5; } + if( hidConsume(&(HID_CTRL->CStickDownRight), with_mods)) { cstickval |= 6; } + if( hidConsume(&(HID_CTRL->CStickUpLeft), with_mods)) { cstickval |= 9; } + if( hidConsume(&(HID_CTRL->CStickDownLeft), with_mods)) { cstickval |= 10; } + } // sorry for weird writing way, but need to save bytes :'( ... (from 093003008 down to 093003000) + + if(1 & cstickval) { substickY = 127; } + if(2 & cstickval) { substickY = -127; } + if(4 & cstickval) { substickX = 127; } + if(8 & cstickval) { substickX = -127; } + } + + } // END OF HID MODIFIED BUTTONS LOOP - if(HID_Packet[HID_CTRL->S.Offset] & HID_CTRL->S.Mask) - button |= PAD_BUTTON_START; Pad[chan].button = button; if((Pad[chan].button&0x1030) == 0x1030) //reset by pressing start, Z, R @@ -489,7 +516,6 @@ u32 PADRead(u32 calledByGame) *RESET_STATUS = 0; /* then analog sticks */ - s8 stickX, stickY, substickX, substickY; if (PADIsBarrel[chan]) { stickX = stickY = substickX = substickY = 0; //DK Jungle Beat requires all sticks = 0 in menues @@ -551,37 +577,18 @@ u32 PADRead(u32 calledByGame) { stickX = HID_Packet[HID_CTRL->StickX.Offset] - 128; stickY = 127 - HID_Packet[HID_CTRL->StickY.Offset]; - substickX = HID_Packet[HID_CTRL->CStickX.Offset] - 128; - substickY = 127 - HID_Packet[HID_CTRL->CStickY.Offset]; - } - - s8 tmp_stick = 0; - if(stickX > HID_CTRL->StickX.DeadZone && stickX > 0) - tmp_stick = (double)(stickX - HID_CTRL->StickX.DeadZone) * HID_CTRL->StickX.Radius / 1000; - else if(stickX < -HID_CTRL->StickX.DeadZone && stickX < 0) - tmp_stick = (double)(stickX + HID_CTRL->StickX.DeadZone) * HID_CTRL->StickX.Radius / 1000; - Pad[chan].stickX = tmp_stick; - - tmp_stick = 0; - if(stickY > HID_CTRL->StickY.DeadZone && stickY > 0) - tmp_stick = (double)(stickY - HID_CTRL->StickY.DeadZone) * HID_CTRL->StickY.Radius / 1000; - else if(stickY < -HID_CTRL->StickY.DeadZone && stickY < 0) - tmp_stick = (double)(stickY + HID_CTRL->StickY.DeadZone) * HID_CTRL->StickY.Radius / 1000; - Pad[chan].stickY = tmp_stick; - - tmp_stick = 0; - if(substickX > HID_CTRL->CStickX.DeadZone && substickX > 0) - tmp_stick = (double)(substickX - HID_CTRL->CStickX.DeadZone) * HID_CTRL->CStickX.Radius / 1000; - else if(substickX < -HID_CTRL->CStickX.DeadZone && substickX < 0) - tmp_stick = (double)(substickX + HID_CTRL->CStickX.DeadZone) * HID_CTRL->CStickX.Radius / 1000; - Pad[chan].substickX = tmp_stick; + if(! HID_CTRL->DigitalCStick) { // DigitalCStick has been handled previously in the buttons loop + substickX = HID_Packet[HID_CTRL->CStickX.Offset] - 128; + substickY = 127 - HID_Packet[HID_CTRL->CStickY.Offset]; + } + } - tmp_stick = 0; - if(substickY > HID_CTRL->CStickY.DeadZone && substickY > 0) - tmp_stick = (double)(substickY - HID_CTRL->CStickY.DeadZone) * HID_CTRL->CStickY.Radius / 1000; - else if(substickY < -HID_CTRL->CStickY.DeadZone && substickY < 0) - tmp_stick = (double)(substickY + HID_CTRL->CStickY.DeadZone) * HID_CTRL->CStickY.Radius / 1000; - Pad[chan].substickY = tmp_stick; + // main stick + Pad[chan].stickX = hidRectifyStickValue(&(HID_CTRL->StickX), stickX); + Pad[chan].stickY = hidRectifyStickValue(&(HID_CTRL->StickY), stickY);; + // Cstick + Pad[chan].substickX = hidRectifyStickValue(&(HID_CTRL->CStickX), substickX); + Pad[chan].substickY = hidRectifyStickValue(&(HID_CTRL->CStickY), substickY);; /* Pad[chan].stickX = stickX; Pad[chan].stickY = stickY; @@ -1420,6 +1427,56 @@ u32 PADRead(u32 calledByGame) } +/* Functions for HID */ +static u8 hidGetMod(volatile layout *button){ + // constrain button->Modif value to [0,3] + // 0 is no Modifier, else is Modifier_ID + return (button->Modif > 0) && (button->Modif < 4) ? button->Modif : 0; +} +static u8 hidButtonValue(volatile layout *button){ + // return (boolean) button is pressed + return (HID_Packet[button->Offset] & button->Mask) == button->Mask; +} +static u8 hidSpecialValue(volatile layout *button){ + // return (boolean) DPADbutton is pressed -> for special DPAD encoding + return (HID_Packet[button->Offset] & HID_CTRL->DPADMask) == button->Mask; +} +static u8 hidIsDPAD(volatile layout *button){ + return (button->Offset == HID_CTRL->Up.Offset + || button->Offset == HID_CTRL->Down.Offset + || button->Offset == HID_CTRL->Right.Offset + || button->Offset == HID_CTRL->Left.Offset + ) && (button->Mask & HID_CTRL->DPADMask) == button->Mask; +} +static u8 hidIsButtonOn(volatile layout *button, u8 with_mods){ + u8 m = hidGetMod(button); + return ((with_mods == 0) ^ (m > 0)) // [with_mods=1 && m>0] OR [with_mods=0 && m=0] + // true if [with_mods and button has a modifier] or [not with_mods and button has no modifier] + && modifiers_boolvals[m] && hidButtonValue(button) // check if modifier + button are on + // Special case if button is DPAD and special DPAD encoding -> needs testing + && ( (HID_CTRL->DPAD == 0) // DPAD is not special + || !(hidIsDPAD(button)) // button is not DPAD + || hidSpecialValue(button)) // could be Special DPAD but checks out + // check if button already used, the used_buttons can deactivate all buttons in a button group with shared bits + && !(used_buttons[button->Offset] & (button->Mask == 0 ? 0x10000 : button->Mask)) ; +} +static u8 hidTagUsedButton(volatile layout * button){ + used_buttons[button->Offset] |= (button->Mask == 0 ? 0x10000 : button->Mask); // buttons masks are actually u8 + return 1; +} +static u8 hidConsume(volatile layout *button, u8 with_mods){ + return hidIsButtonOn(button, with_mods) && hidTagUsedButton(button); +} +static s8 hidRectifyStickValue(volatile stickLayout *stick, s8 raw_value){ + // adjust value using deadzone and radius parameters + if(raw_value > stick->DeadZone && raw_value > 0) + return (double)(raw_value - stick->DeadZone) * stick->Radius / 1000; + else if(raw_value < -stick->DeadZone && raw_value < 0) + return (double)(raw_value + stick->DeadZone) * stick->Radius / 1000; + else + return 0; +} + /* Functions for PSO Keyboard */ static void kbDoSpecial(u8 *in, u8 *out) { diff --git a/loader/source/udp_log.c b/loader/source/udp_log.c new file mode 100644 index 00000000..29d61a1c --- /dev/null +++ b/loader/source/udp_log.c @@ -0,0 +1,78 @@ +#include +#include +#include +#include +#include "udp_log.h" + +static u8 __udp_log__init_network = 1; + +//--------------------------------------------------------------------------------- +int udp_printf_to(const char* ipv4_addr, u16 port, const char* fmt, ...){ +// return 0 if success +// return 1 if fail to create socket +// return 2 if fail to send bytes +// return 3 if fail to init network +//--------------------------------------------------------------------------------- + s32 sock; + struct sockaddr_in sa; + int bytes_sent; + char buffer[200]; + // assemble message + va_list argptr; + va_start(argptr, fmt); + vsnprintf(buffer, 200, fmt, argptr); + va_end(argptr); + + // network init on first time ; can take ~5 seconds + if(__udp_log__init_network == 1){ + printf("Configuring network ...\n"); + // // Configure the network interface + char localip[16] = {0}; + char gateway[16] = {0}; + char netmask[16] = {0}; + if (if_config ( localip, netmask, gateway, TRUE, 20) == 0) { + printf ("network configured, ip: %s, gw: %s, mask %s\n", localip, gateway, netmask); + __udp_log__init_network = 0; + } else { + printf ("network configuration failed!\n"); + __udp_log__init_network = 2; + } + } + + if(__udp_log__init_network == 0){ + /* create an Internet, datagram, socket using UDP */ + sock = net_socket(AF_INET, SOCK_DGRAM, IPPROTO_IP); + if (sock == -1) { + /* if socket failed to initialize, exit */ + printf("Error Creating Socket\n"); + return 1; + } + + /* Zero out socket address */ + memset(&sa, 0, sizeof sa); + + /* The address is IPv4 */ + sa.sin_family = AF_INET; + + /* IPv4 adresses is a uint32_t, convert a string representation of the octets to the appropriate value */ + sa.sin_addr.s_addr = inet_addr(ipv4_addr); + + /* sockets are unsigned shorts, htons(x) ensures x is in network byte order, set the port to 7654 */ + sa.sin_port = htons(port); + sa.sin_len = 8; + + + int ret = 0; + // printf("Sending UDP packet @ %s:%d\n",ipv4_addr, port); + bytes_sent = net_sendto(sock, buffer, strlen(buffer), 0,(struct sockaddr*)&sa, 8); + if (bytes_sent < 0) { + printf("Error sending packet: code[%d]\n", bytes_sent); + ret = 2; + } + net_close(sock); /* close the socket */ + + return ret; // 0 if all good, else 2 + } + return 3; // network init fail +} + diff --git a/mem_map.txt b/mem_map.txt index 0409dfa7..f93de480 100644 --- a/mem_map.txt +++ b/mem_map.txt @@ -50,7 +50,7 @@ MEM2 0x93004000-0x93005000=nincfg 0x93005000-0x930050E8=hid controller positions -0x930050F0-0x93005170=hid packet (may be bigger device dependent) +0x930052F0-0x93005370=hid packet (may be bigger device dependent) 0x93006000-0x93010000=IOS Interface