I am writting a function to know wether or not the charger is plugged in my 3ds however my function keep returning false while the charger is plugged in.
I expect my function to return true if the charger is plugged in my 3ds.
Here is the function:
bool isChargerPluggedin() {
bool chargeState;
PTMU_GetAdapterState(&chargeState);
return chargeState == 1;
}
My first attempt to solve my problem was to allocate memory to the chargeState variable:
bool isChargerPluggedin() {
bool *chargeState = new bool;
PTMU_GetAdapterState(chargeState);
bool state = *chargeState == 1;
delete chargeState;
return state;
}
My second attempt was by using an global variable to chargeState instead of a local variable :
bool chargeState;
bool isChargerPluggedin() {
PTMU_GetAdapterState(&chargeState);
return chargeState == 1;
}
To fix this, you must initialize first the libraries in your main function using the function
ptmuInit
. You must deinitialize the library before your program exitHere is a example: