Split arguments to miiSelectorLaunch

This commit is contained in:
Philipp Joram 2017-08-08 21:21:30 +02:00
parent 452fddc658
commit c2c3cc8d16
2 changed files with 22 additions and 15 deletions

View File

@ -84,21 +84,13 @@ _assert_struct_size(MiiSelectorReturn, 0x84);
#undef _assert_struct_size
/**
* @brief Mii selector context
*
* Configure how to launch the applet in @ref MiiSelectorContext.config. After
* returning, the applet has written data to @ref MiiSelectorContext.ret.
*/
typedef union {
MiiSelectorConf config; ///< Configuration passed to applet
MiiSelectorReturn ret; ///< Data written by applet after return
} MiiSelectorContext;
/**
* @brief Launch the Mii selector library applet
*
* @param conf Configuration determining how the applet should behave
* @param returnbuf Data returned by the applet
*/
Result miiSelectorLaunch(MiiSelectorContext *ctx);
Result miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn* returnbuf);
/**
* @brief Verifies that the Mii data returned from the applet matches its

View File

@ -1,12 +1,27 @@
#include <3ds/types.h>
#include <3ds/result.h>
#include <3ds/services/apt.h>
#include <3ds/applets/miiselector.h>
Result miiSelectorLaunch(MiiSelectorContext *ctx)
#include <string.h> // for memcpy
Result miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn *returnbuf)
{
ctx->config.magic = MIISELECTOR_MAGIC;
return aptLaunchLibraryApplet(APPID_APPLETED, &ctx->config, sizeof(MiiSelectorConf), 0);
union {
MiiSelectorConf config;
MiiSelectorReturn ret;
} ctx;
memcpy(&ctx.config, conf, sizeof(MiiSelectorConf));
ctx.config.magic = MIISELECTOR_MAGIC;
Result ret = aptLaunchLibraryApplet(APPID_APPLETED, &ctx.config, sizeof(MiiSelectorConf), 0);
if(R_SUCCEEDED(ret) && returnbuf) {
memcpy(returnbuf, &ctx.ret, sizeof(MiiSelectorReturn));
}
return ret;
}
static u16 crc16_ccitt(void const *buf, size_t len, uint32_t starting_val)