mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +02:00
Updated irsensor example.
This commit is contained in:
parent
3693998cbc
commit
8cbf348876
@ -1,22 +1,42 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
//TODO: Implement image-transfer in libnx and in this example.
|
//TODO: Implement image-transfer in libnx and in this example.
|
||||||
|
|
||||||
|
u8 *ir_buffer = NULL;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
u32 irhandle=0;
|
u32 irhandle=0;
|
||||||
|
irsImageTransferProcessorConfig config;
|
||||||
|
irsImageTransferProcessorState state;
|
||||||
|
size_t ir_buffer_size = 0x100000;
|
||||||
|
|
||||||
gfxInitDefault();
|
gfxInitDefault();
|
||||||
|
|
||||||
//Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
//Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
||||||
consoleInit(NULL);
|
consoleInit(NULL);
|
||||||
|
|
||||||
|
ir_buffer = (u8*)malloc(ir_buffer_size);
|
||||||
|
if (ir_buffer==NULL)
|
||||||
|
{
|
||||||
|
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||||
|
printf("Failed to allocate memory for ir_buffer.\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(ir_buffer, 0, ir_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
{
|
||||||
rc = irsInitialize();
|
rc = irsInitialize();
|
||||||
printf("irsInitialize() returned 0x%x\n", rc);
|
printf("irsInitialize() returned 0x%x\n", rc);
|
||||||
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
@ -30,6 +50,20 @@ int main(int argc, char **argv)
|
|||||||
printf("irsGetIrCameraHandle() returned 0x%x\n", rc);
|
printf("irsGetIrCameraHandle() returned 0x%x\n", rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
{
|
||||||
|
irsGetDefaultImageTransferProcessorConfig(&config);
|
||||||
|
rc = irsRunImageTransferProcessor(irhandle, &config, 0x100000);
|
||||||
|
printf("irsRunImageTransferProcessor() returned 0x%x\n", rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
{
|
||||||
|
//TODO: Why does this fail?
|
||||||
|
rc = irsGetImageTransferProcessorState(irhandle, ir_buffer, ir_buffer_size, &state);
|
||||||
|
printf("irsGetImageTransferProcessorState() returned 0x%x\n", rc);
|
||||||
|
}
|
||||||
|
|
||||||
while(appletMainLoop())
|
while(appletMainLoop())
|
||||||
{
|
{
|
||||||
//Scan all the inputs. This should be done once for each frame
|
//Scan all the inputs. This should be done once for each frame
|
||||||
@ -45,8 +79,11 @@ int main(int argc, char **argv)
|
|||||||
gfxWaitForVsync();
|
gfxWaitForVsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irsStopImageProcessor(irhandle);
|
||||||
irsExit();
|
irsExit();
|
||||||
|
|
||||||
|
free(ir_buffer);
|
||||||
|
|
||||||
gfxExit();
|
gfxExit();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user