-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
60 lines (45 loc) · 1.8 KB
/
main.c
File metadata and controls
60 lines (45 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Include the most common headers from the C standard library
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Include the main libnx system header, for Switch development
#include <switch.h>
// Include the main cpython header
#include <Python.h>
// Main program entrypoint
int main(int argc, char* argv[])
{
// This example uses a text console, as a simple way to output text to the screen.
// If you want to write a software-rendered graphics application,
// take a look at the graphics/simplegfx example, which uses the libnx Framebuffer API instead.
// If on the other hand you want to write an OpenGL based application,
// take a look at the graphics/opengl set of examples, which uses EGL instead.
consoleInit(NULL);
Py_NoSiteFlag = 1;
Py_IgnoreEnvironmentFlag = 1;
Py_NoUserSiteDirectory = 1;
/* Look for python libraries in /lib/python3.X/ */
Py_SetPythonHome(L"/");
Py_Initialize();
printf("Python %s on %s\n", Py_GetVersion(), Py_GetPlatform());
/* Execute some python code!!! */
PyRun_SimpleString("print('Hello python world! Press + to exit.')");
Py_Finalize();
// Main loop
while (appletMainLoop())
{
// Scan all the inputs. This should be done once for each frame
hidScanInput();
// hidKeysDown returns information about which buttons have been
// just pressed in this frame compared to the previous one
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
if (kDown & KEY_PLUS)
break; // break in order to return to hbmenu
// Your code goes here
// Update the console, sending a new frame to the display
consoleUpdate(NULL);
}
// Deinitialize and clean up resources used by the console (important!)
consoleExit(NULL);
return 0;
}