Anyone want to try this code it might be bad but its a app to make the LED light do a lot more like change colors with the volume slider, flash and dim with the screen brightness ,flash when a game cart is inserted, flash when a app is launched, etc. If a real app dev is interested could try to look into it and finish for me I would appreciate it.
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include "guibase.h"
#include "guitheme.h"
#define PATCH_PATH "sdmc:/3ds/light_patch.bin"
#define PATCH_FILE "light_patch.bin"
#define PATCH_SIZE 0x1000
// Global variables
static bool isPatched = false;
static u8 patchData[PATCH_SIZE];
// Function prototypes
static int patchDevice(u8* patchData, size_t patchSize);
static int unpatchDevice(void);
// GUI callbacks
static void onPatchButton(uiButton* button, void* data);
static void onUnpatchButton(uiButton* button, void* data);
// Patch the device with the provided code
static int patchDevice(u8* patchData, size_t patchSize) {
// Open the patch file
FILE* patchFile = fopen(PATCH_FILE, "wb");
if (!patchFile) return -1;
// Write the patch data to the file
if (fwrite(patchData, patchSize, 1, patchFile) != 1) {
fclose(patchFile);
return -1;
}
fclose(patchFile);
// Write the patch file to the device
int ret = 0;
FILE* fp = fopen(PATCH_PATH, "wb");
if (fp) {
ret = fwrite(patchData, patchSize, 1, fp);
fclose(fp);
}
// Set the patch flag
isPatched = true;
return ret;
}
// Unpatch the device
static int unpatchDevice(void) {
// Remove the patch file
if (remove(PATCH_PATH) != 0) return -1;
// Clear the patch flag
isPatched = false;
return 0;
}
// Callback for the Patch button
static void onPatchButton(uiButton* button, void* data) {
// Read the patch data from the file
FILE* patchFile = fopen(PATCH_FILE, "rb");
if (!patchFile) {
printf("Error: Could not open patch file.\n");
return;
}
size_t patchSize = fread(patchData, 1, PATCH_SIZE, patchFile);
fclose(patchFile);
// Patch the device
if (patchDevice(patchData, patchSize) < 0) {
printf("Error: Failed to patch the device.\n");
} else {
printf("Success: Device patched.\n");
}
}
// Callback for the Unpatch button
static void onUnpatchButton(uiButton* button, void* data) {
// Unpatch the device
if (unpatchDevice() < 0) {
printf("Error: Failed to unpatch the device.\n");
} else {
printf("Success: Device unpatched.\n");
}
}
// Initialize the GUI
static int guiInit(void) {
// Initialize the Newlib GUI library
guiInit();
// Initialize the GUI theme
guiThemeInit();
// Set the GUI background color
C3D_FVB barrier;
C3D_FVUnmap(&barrier, GFX_TOP);
C3D_FVColor3f(1.0f, 1.0f, 1.0f);
C3D_FVFill(&barrier, 0.0f, 0.0f, 1.0f, 1.0f);
C3D_FVMap(&barrier, GFX_TOP);
// Create the GUI buttons
uiButton* patchButton = uiButton
I'm not a big app maker but I can code but if its broke i couldn't test it my pc is dumb and won't compile or build.
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <3ds.h>
#include <citro2d.h>
#include <citro3d.h>
#include "guibase.h"
#include "guitheme.h"
#define PATCH_PATH "sdmc:/3ds/light_patch.bin"
#define PATCH_FILE "light_patch.bin"
#define PATCH_SIZE 0x1000
// Global variables
static bool isPatched = false;
static u8 patchData[PATCH_SIZE];
// Function prototypes
static int patchDevice(u8* patchData, size_t patchSize);
static int unpatchDevice(void);
// GUI callbacks
static void onPatchButton(uiButton* button, void* data);
static void onUnpatchButton(uiButton* button, void* data);
// Patch the device with the provided code
static int patchDevice(u8* patchData, size_t patchSize) {
// Open the patch file
FILE* patchFile = fopen(PATCH_FILE, "wb");
if (!patchFile) return -1;
// Write the patch data to the file
if (fwrite(patchData, patchSize, 1, patchFile) != 1) {
fclose(patchFile);
return -1;
}
fclose(patchFile);
// Write the patch file to the device
int ret = 0;
FILE* fp = fopen(PATCH_PATH, "wb");
if (fp) {
ret = fwrite(patchData, patchSize, 1, fp);
fclose(fp);
}
// Set the patch flag
isPatched = true;
return ret;
}
// Unpatch the device
static int unpatchDevice(void) {
// Remove the patch file
if (remove(PATCH_PATH) != 0) return -1;
// Clear the patch flag
isPatched = false;
return 0;
}
// Callback for the Patch button
static void onPatchButton(uiButton* button, void* data) {
// Read the patch data from the file
FILE* patchFile = fopen(PATCH_FILE, "rb");
if (!patchFile) {
printf("Error: Could not open patch file.\n");
return;
}
size_t patchSize = fread(patchData, 1, PATCH_SIZE, patchFile);
fclose(patchFile);
// Patch the device
if (patchDevice(patchData, patchSize) < 0) {
printf("Error: Failed to patch the device.\n");
} else {
printf("Success: Device patched.\n");
}
}
// Callback for the Unpatch button
static void onUnpatchButton(uiButton* button, void* data) {
// Unpatch the device
if (unpatchDevice() < 0) {
printf("Error: Failed to unpatch the device.\n");
} else {
printf("Success: Device unpatched.\n");
}
}
// Initialize the GUI
static int guiInit(void) {
// Initialize the Newlib GUI library
guiInit();
// Initialize the GUI theme
guiThemeInit();
// Set the GUI background color
C3D_FVB barrier;
C3D_FVUnmap(&barrier, GFX_TOP);
C3D_FVColor3f(1.0f, 1.0f, 1.0f);
C3D_FVFill(&barrier, 0.0f, 0.0f, 1.0f, 1.0f);
C3D_FVMap(&barrier, GFX_TOP);
// Create the GUI buttons
uiButton* patchButton = uiButton
Post automatically merged:
I'm not a big app maker but I can code but if its broke i couldn't test it my pc is dumb and won't compile or build.