mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-20 21:12:38 +02:00
Update all non-HID examples for hid-refactor
This commit is contained in:
parent
4272e286cc
commit
1e59bd0699
@ -18,6 +18,13 @@ int main(int argc, char **argv)
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
memset(&userdata, 0, sizeof(userdata));
|
||||
memset(&profilebase, 0, sizeof(profilebase));
|
||||
|
||||
@ -68,13 +75,13 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -37,6 +37,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("alarm-notifications example\n");
|
||||
|
||||
Result rc=0, rc2=0;
|
||||
@ -75,14 +82,14 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (R_SUCCEEDED(rc) && R_SUCCEEDED(eventWait(&alarmevent, 0))) { // Some official apps don't use this. See libnx notif.h for this.
|
||||
@ -96,7 +103,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
// Setup an alarm with {current local-time} + {2 minutes}. You can use any weekday/time you want.
|
||||
// See libnx notif.h for more notifAlarmSetting*() funcs.
|
||||
|
||||
@ -121,7 +128,7 @@ int main(int argc, char* argv[])
|
||||
if (R_SUCCEEDED(rc)) printf("alarm_setting_id = 0x%x\n", alarm_setting_id);
|
||||
}
|
||||
}
|
||||
else if (kDown & KEY_B) {
|
||||
else if (kDown & HidNpadButton_B) {
|
||||
// List the Alarms.
|
||||
|
||||
total_out=0;
|
||||
@ -160,8 +167,8 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((kDown & KEY_X) && alarm_setting_id) {
|
||||
// Delete the AlarmSetting which was registered with the KEY_A block.
|
||||
else if ((kDown & HidNpadButton_X) && alarm_setting_id) {
|
||||
// Delete the AlarmSetting which was registered with the HidNpadButton_A block.
|
||||
// If wanted, you can also use this with alarm_settings[alarmi].alarm_setting_id with the output from notifListAlarmSettings.
|
||||
rc = notifDeleteAlarmSetting(alarm_setting_id);
|
||||
printf("notifDeleteAlarmSetting(): 0x%x\n", rc);
|
||||
|
@ -19,6 +19,13 @@ int main(int argc, char **argv)
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
buf = (NsApplicationControlData*)malloc(sizeof(NsApplicationControlData));
|
||||
if (buf==NULL) {
|
||||
rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
|
||||
@ -69,13 +76,13 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -20,6 +20,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("application play-stats example\n");
|
||||
|
||||
Result rc=0;
|
||||
@ -53,17 +60,17 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
// Use appletQueryApplicationPlayStatisticsByUid if you want playstats for a specific userID.
|
||||
|
||||
memset(stats, 0, sizeof(stats));
|
||||
@ -84,7 +91,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (initflag && (kDown & KEY_X)) {
|
||||
if (initflag && (kDown & HidNpadButton_X)) {
|
||||
memset(events, 0, sizeof(events));
|
||||
total_out = 0;
|
||||
|
||||
|
@ -24,6 +24,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("error example\n");
|
||||
|
||||
consoleUpdate(NULL);
|
||||
@ -34,17 +41,17 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
printf("Running errorResultRecordShow()...\n");
|
||||
consoleUpdate(NULL);
|
||||
rc = errorResultRecordShow(MAKERESULT(16, 250), time(NULL));
|
||||
|
@ -23,6 +23,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("pctlauth example\n");
|
||||
consoleUpdate(NULL);
|
||||
|
||||
@ -47,17 +54,17 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (pctlflag && (kDown & KEY_A)) {
|
||||
if (pctlflag && (kDown & HidNpadButton_A)) {
|
||||
printf("Running pctlauthShow()...\n");
|
||||
consoleUpdate(NULL);
|
||||
rc = pctlauthShow(true); // Launch the applet for validating the PIN.
|
||||
|
@ -57,6 +57,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("swkbd example\n");
|
||||
|
||||
consoleUpdate(NULL);
|
||||
@ -142,21 +149,21 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Your code goes here
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (kDown & KEY_ZR) swkbdInlineDisappear(&kbdinline); //Optional, you can have swkbd (dis)appear whenever.
|
||||
if (kDown & KEY_Y) swkbdInlineAppear(&kbdinline, &appearArg); // If you use swkbdInlineAppear again after text was submitted, you may want to use swkbdInlineSetInputText since the current-text will be the same as when it was submitted otherwise.
|
||||
if (kDown & HidNpadButton_ZR) swkbdInlineDisappear(&kbdinline); //Optional, you can have swkbd (dis)appear whenever.
|
||||
if (kDown & HidNpadButton_Y) swkbdInlineAppear(&kbdinline, &appearArg); // If you use swkbdInlineAppear again after text was submitted, you may want to use swkbdInlineSetInputText since the current-text will be the same as when it was submitted otherwise.
|
||||
|
||||
rc = swkbdInlineUpdate(&kbdinline, NULL); // Handles updating SwkbdInline state, this should be called periodically.
|
||||
if (R_FAILED(rc)) printf("swkbdInlineUpdate(): 0x%x\n", rc);
|
||||
|
@ -23,6 +23,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("web example\n");
|
||||
|
||||
consoleUpdate(NULL);
|
||||
@ -33,17 +40,17 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
WebCommonConfig config;
|
||||
WebCommonReply reply;
|
||||
WebExitReason exitReason=0;
|
||||
|
@ -18,6 +18,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("light-sensor example\n");
|
||||
printf("Press A to check light-sensor.\n");
|
||||
printf("Press + to exit.\n");
|
||||
@ -25,17 +32,17 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
Result rc = 0;
|
||||
float fLux=0;
|
||||
bool availableflag=0;
|
||||
|
@ -22,19 +22,26 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("applet exit-locking example.\n");
|
||||
|
||||
// Main loop
|
||||
while (appletMainLoop())//This loop will automatically exit when applet requests exit.
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Your code goes here
|
||||
|
@ -28,22 +28,29 @@ int main(int argc, char **argv)
|
||||
|
||||
appletInitializeGamePlayRecording();//Normally this is only recording func you need to call.
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
u32 cnt = 0;
|
||||
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_Y) {
|
||||
if (kDown & HidNpadButton_Y) {
|
||||
appletSetGamePlayRecordingState(0);//Disable recording.
|
||||
}
|
||||
else if (kDown & KEY_X) {
|
||||
else if (kDown & HidNpadButton_X) {
|
||||
appletSetGamePlayRecordingState(1);//Enable recording.
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("screenshot-overlay example\n");
|
||||
|
||||
// Setup the RGBA8 image.
|
||||
@ -56,14 +63,14 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Update the console, sending a new frame to the display
|
||||
|
@ -24,6 +24,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("VrMode example\n");
|
||||
|
||||
// Using pctl is optional.
|
||||
@ -43,18 +50,18 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (pctlinit) {
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
// Not sure what this is.
|
||||
/*rc = pctlConfirmStereoVisionPermission();
|
||||
if (R_FAILED(rc)) printf("pctlConfirmStereoVisionPermission(): 0x%x\n", rc);*/
|
||||
@ -70,7 +77,7 @@ int main(int argc, char* argv[])
|
||||
printf("appletSetVrModeEnabled(true): 0x%x\n", rc);
|
||||
}
|
||||
}
|
||||
else if (kDown & KEY_B) {
|
||||
else if (kDown & HidNpadButton_B) {
|
||||
rc = appletSetVrModeEnabled(false);
|
||||
printf("appletSetVrModeEnabled(false): 0x%x\n", rc);
|
||||
|
||||
@ -78,7 +85,7 @@ int main(int argc, char* argv[])
|
||||
/*rc = pctlResetConfirmedStereoVisionPermission();
|
||||
printf("pctlResetConfirmedStereoVisionPermission(): 0x%x\n", rc);*/
|
||||
}
|
||||
else if (kDown & KEY_X) {
|
||||
else if (kDown & HidNpadButton_X) {
|
||||
bool flag=0;
|
||||
rc = appletIsVrModeEnabled(&flag);
|
||||
printf("appletIsVrModeEnabled(): 0x%x", rc);
|
||||
|
@ -13,6 +13,13 @@ int main(void)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("Simple audren demonstration program\n");
|
||||
|
||||
static const AudioRendererConfig arConfig =
|
||||
@ -57,7 +64,7 @@ int main(void)
|
||||
audrvMemPoolAttach(&drv, mpid);
|
||||
|
||||
static const u8 sink_channels[] = { 0, 1 };
|
||||
int sink = audrvDeviceSinkAdd(&drv, AUDREN_DEFAULT_DEVICE_NAME, 2, sink_channels);
|
||||
/*int sink =*/ audrvDeviceSinkAdd(&drv, AUDREN_DEFAULT_DEVICE_NAME, 2, sink_channels);
|
||||
|
||||
res = audrvUpdate(&drv);
|
||||
printf("audrvUpdate: %" PRIx32 "\n", res);
|
||||
@ -77,16 +84,16 @@ int main(void)
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
if (initedDriver)
|
||||
{
|
||||
if (kDown & KEY_A)
|
||||
if (kDown & HidNpadButton_A)
|
||||
{
|
||||
audrvVoiceStop(&drv, 0);
|
||||
audrvVoiceAddWaveBuf(&drv, 0, &wavebuf);
|
||||
|
@ -22,6 +22,13 @@ int main(int argc, char **argv)
|
||||
// Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
AudioInBuffer audin_buf;
|
||||
AudioOutBuffer audout_buf;
|
||||
AudioInBuffer *released_in_buffer;
|
||||
@ -108,13 +115,13 @@ int main(int argc, char **argv)
|
||||
|
||||
while (appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
// Wait for audio capture and playback to finish.
|
||||
audinWaitCaptureFinish(&released_in_buffer, &released_in_count, UINT64_MAX);
|
||||
|
@ -53,6 +53,13 @@ int main(void)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("Simple hwopus-decoder example with audren\n");
|
||||
|
||||
static const AudioRendererConfig arConfig =
|
||||
@ -122,7 +129,7 @@ int main(void)
|
||||
audrvMemPoolAttach(&drv, mpid);
|
||||
|
||||
static const u8 sink_channels[] = { 0, 1 };
|
||||
int sink = audrvDeviceSinkAdd(&drv, AUDREN_DEFAULT_DEVICE_NAME, 2, sink_channels);
|
||||
/*int sink =*/ audrvDeviceSinkAdd(&drv, AUDREN_DEFAULT_DEVICE_NAME, 2, sink_channels);
|
||||
|
||||
res = audrvUpdate(&drv);
|
||||
printf("audrvUpdate: %" PRIx32 "\n", res);
|
||||
@ -163,16 +170,16 @@ int main(void)
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
if (initedDriver)
|
||||
{
|
||||
if (kDown & KEY_A)
|
||||
if (kDown & HidNpadButton_A)
|
||||
{
|
||||
//Close the opus-file if needed and (re)open it, since libopusfile doesn't support seek-to-beginning.
|
||||
if (of)
|
||||
|
@ -38,6 +38,13 @@ int main(int argc, char **argv)
|
||||
// Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
AudioOutBuffer audout_buf;
|
||||
AudioOutBuffer *audout_released_buf;
|
||||
|
||||
@ -82,57 +89,57 @@ int main(int argc, char **argv)
|
||||
|
||||
while (appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A)
|
||||
if (kDown & HidNpadButton_A)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[0]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_B)
|
||||
if (kDown & HidNpadButton_B)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[1]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_Y)
|
||||
if (kDown & HidNpadButton_Y)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[2]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_X)
|
||||
if (kDown & HidNpadButton_X)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[3]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_DLEFT)
|
||||
if (kDown & HidNpadButton_Left)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[4]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_DUP)
|
||||
if (kDown & HidNpadButton_Up)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[5]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_DRIGHT)
|
||||
if (kDown & HidNpadButton_Right)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[6]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_DDOWN)
|
||||
if (kDown & HidNpadButton_Down)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[7]);
|
||||
play_tone = true;
|
||||
@ -150,13 +157,13 @@ int main(int argc, char **argv)
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_ZL)
|
||||
if (kDown & HidNpadButton_ZL)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[10]);
|
||||
play_tone = true;
|
||||
}
|
||||
|
||||
if (kDown & KEY_ZR)
|
||||
if (kDown & HidNpadButton_ZR)
|
||||
{
|
||||
fill_audio_buffer(out_buf_data, 0, data_size, notefreq[11]);
|
||||
play_tone = true;
|
||||
|
@ -17,6 +17,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
Result rc = romfsInit();
|
||||
if (R_FAILED(rc))
|
||||
printf("romfsInit: %08X\n", rc);
|
||||
@ -41,17 +48,17 @@ int main(int argc, char *argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A)
|
||||
if (kDown & HidNpadButton_A)
|
||||
Mix_PlayMusic(audio, 1); //Play the audio file
|
||||
|
||||
// Update the console, sending a new frame to the display
|
||||
|
@ -47,6 +47,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("Triggering crash...\n");
|
||||
consoleUpdate(NULL);
|
||||
|
||||
@ -56,14 +63,14 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Your code goes here
|
||||
|
@ -32,6 +32,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
Result rc = romfsInit();
|
||||
if (R_FAILED(rc))
|
||||
printf("romfsInit: %08X\n", rc);
|
||||
@ -46,13 +53,13 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -51,6 +51,13 @@ int main(int argc, char **argv)
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
//Get the userID for save mounting. To mount common savedata, use an all-zero userID.
|
||||
|
||||
//Try to find savedata to use with get_save() first, otherwise fallback to the above hard-coded TID + the userID from accountGetPreselectedUser(). Note that you can use either method.
|
||||
@ -113,13 +120,13 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -11,6 +11,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
DIR* dir;
|
||||
struct dirent* ent;
|
||||
|
||||
@ -33,13 +40,13 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -209,12 +209,19 @@ int main(int argc, char* argv[])
|
||||
romfsInit();
|
||||
graphicsInitialize();
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
while (appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
graphicsUpdate();
|
||||
|
@ -7,6 +7,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// clear screen and home cursor
|
||||
printf( CONSOLE_ESC(2J) );
|
||||
|
||||
@ -61,15 +68,15 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ class CExample01 final : public CApplication
|
||||
static constexpr uint32_t FramebufferHeight = 720;
|
||||
static constexpr unsigned StaticCmdSize = 0x1000;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -59,6 +61,10 @@ public:
|
||||
|
||||
// Create the framebuffer resources
|
||||
createFramebufferResources();
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample01()
|
||||
@ -159,9 +165,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
render();
|
||||
|
@ -51,6 +51,8 @@ class CExample02 final : public CApplication
|
||||
static constexpr uint32_t FramebufferHeight = 720;
|
||||
static constexpr unsigned StaticCmdSize = 0x10000;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -101,6 +103,10 @@ public:
|
||||
|
||||
// Create the framebuffer resources
|
||||
createFramebufferResources();
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample02()
|
||||
@ -214,9 +220,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
render();
|
||||
|
@ -104,6 +104,8 @@ class CExample03 final : public CApplication
|
||||
static constexpr unsigned StaticCmdSize = 0x10000;
|
||||
static constexpr unsigned DynamicCmdSize = 0x10000;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -169,6 +171,10 @@ public:
|
||||
// Load the vertex buffer
|
||||
vertexBuffer = pool_data->allocate(sizeof(CubeVertexData), alignof(Vertex));
|
||||
memcpy(vertexBuffer.getCpuAddr(), CubeVertexData.data(), vertexBuffer.getSize());
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample03()
|
||||
@ -339,9 +345,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -109,6 +109,8 @@ class CExample04 final : public CApplication
|
||||
static constexpr unsigned MaxImages = 1;
|
||||
static constexpr unsigned MaxSamplers = 1;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -210,6 +212,10 @@ public:
|
||||
queue.waitIdle();
|
||||
cmdbuf.clear();
|
||||
}
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample04()
|
||||
@ -381,9 +387,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -52,6 +52,8 @@ class CExample05 final : public CApplication
|
||||
static constexpr uint32_t FramebufferHeight = 720;
|
||||
static constexpr unsigned StaticCmdSize = 0x10000;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -106,6 +108,10 @@ public:
|
||||
|
||||
// Create the framebuffer resources
|
||||
createFramebufferResources();
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample05()
|
||||
@ -236,9 +242,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
render();
|
||||
|
@ -104,6 +104,8 @@ class CExample06 final : public CApplication
|
||||
static constexpr unsigned DynamicCmdSize = 0x10000;
|
||||
static constexpr DkMsMode MultisampleMode = DkMsMode_4x;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -171,6 +173,10 @@ public:
|
||||
// Load the vertex buffer
|
||||
vertexBuffer = pool_data->allocate(sizeof(CubeVertexData), alignof(Vertex));
|
||||
memcpy(vertexBuffer.getCpuAddr(), CubeVertexData.data(), vertexBuffer.getSize());
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample06()
|
||||
@ -375,9 +381,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -74,6 +74,8 @@ class CExample07 final : public CApplication
|
||||
static constexpr unsigned DynamicCmdSize = 0x10000;
|
||||
static constexpr DkMsMode MultisampleMode = DkMsMode_4x;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -154,6 +156,10 @@ public:
|
||||
// Load the teapot mesh
|
||||
vertexBuffer = LoadFile(*pool_data, "romfs:/teapot-vtx.bin", alignof(Vertex));
|
||||
indexBuffer = LoadFile(*pool_data, "romfs:/teapot-idx.bin", alignof(u16));
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample07()
|
||||
@ -368,9 +374,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -76,6 +76,8 @@ class CExample08 final : public CApplication
|
||||
static constexpr unsigned MaxImages = 3;
|
||||
static constexpr unsigned MaxSamplers = 1;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -188,6 +190,10 @@ public:
|
||||
queue.waitIdle();
|
||||
cmdbuf.clear();
|
||||
}
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
void createFramebufferResources()
|
||||
@ -449,9 +455,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -69,6 +69,8 @@ class CExample09 final : public CApplication
|
||||
static constexpr unsigned DynamicCmdSize = 0x10000;
|
||||
static constexpr unsigned NumVertices = 256;
|
||||
|
||||
PadState pad;
|
||||
|
||||
dk::UniqueDevice device;
|
||||
dk::UniqueQueue queue;
|
||||
|
||||
@ -138,6 +140,10 @@ public:
|
||||
|
||||
// Create the framebuffer resources
|
||||
createFramebufferResources();
|
||||
|
||||
// Initialize gamepad
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
}
|
||||
|
||||
~CExample09()
|
||||
@ -291,9 +297,9 @@ public:
|
||||
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
hidScanInput();
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
return false;
|
||||
|
||||
float time = ns / 1000000000.0; // double precision division; followed by implicit cast to single precision
|
||||
|
@ -46,6 +46,8 @@ class CMainMenu final : public CApplication
|
||||
static constexpr unsigned EntriesPerScreen = 39;
|
||||
static constexpr unsigned EntryPageLength = 10;
|
||||
|
||||
PadState pad;
|
||||
|
||||
int screenPos;
|
||||
int selectPos;
|
||||
|
||||
@ -69,6 +71,10 @@ class CMainMenu final : public CApplication
|
||||
{
|
||||
consoleInit(NULL);
|
||||
renderMenu();
|
||||
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
padInitializeDefault(&pad);
|
||||
padUpdate(&pad);
|
||||
}
|
||||
|
||||
~CMainMenu()
|
||||
@ -79,23 +85,23 @@ class CMainMenu final : public CApplication
|
||||
bool onFrame(u64 ns) override
|
||||
{
|
||||
int oldPos = selectPos;
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
{
|
||||
selectPos = -1;
|
||||
return false;
|
||||
}
|
||||
if (kDown & KEY_A)
|
||||
if (kDown & HidNpadButton_A)
|
||||
return false;
|
||||
if (kDown & KEY_UP)
|
||||
if (kDown & HidNpadButton_AnyUp)
|
||||
selectPos -= 1;
|
||||
if (kDown & KEY_DOWN)
|
||||
if (kDown & HidNpadButton_AnyDown)
|
||||
selectPos += 1;
|
||||
if (kDown & KEY_LEFT)
|
||||
if (kDown & HidNpadButton_AnyLeft)
|
||||
selectPos -= EntryPageLength;
|
||||
if (kDown & KEY_RIGHT)
|
||||
if (kDown & HidNpadButton_AnyRight)
|
||||
selectPos += EntryPageLength;
|
||||
|
||||
if (selectPos < 0)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <switch.h>
|
||||
@ -430,16 +430,16 @@ static void sceneUpdate(u32 kHeld)
|
||||
float deltaTime = curTime - s_updTime;
|
||||
s_updTime = curTime;
|
||||
|
||||
if (kHeld & KEY_LEFT)
|
||||
if (kHeld & HidNpadButton_AnyLeft)
|
||||
s_cameraAngle = fract(s_cameraAngle - deltaTime/4);
|
||||
else if (kHeld & KEY_RIGHT)
|
||||
else if (kHeld & HidNpadButton_AnyRight)
|
||||
s_cameraAngle = fract(s_cameraAngle + deltaTime/4);
|
||||
if (kHeld & (KEY_UP|KEY_DOWN))
|
||||
if (kHeld & (HidNpadButton_AnyUp|HidNpadButton_AnyDown))
|
||||
{
|
||||
glm::vec3 front = deltaTime * glm::rotate(glm::vec3{0.0f, 0.0f, -1.0f}, s_cameraAngle * TAU, glm::vec3{0.0f, -1.0f, 0.0f});
|
||||
if (kHeld & KEY_UP)
|
||||
if (kHeld & HidNpadButton_AnyUp)
|
||||
s_cameraPos += front;
|
||||
else if (kHeld & KEY_DOWN)
|
||||
else if (kHeld & HidNpadButton_AnyDown)
|
||||
s_cameraPos -= front;
|
||||
}
|
||||
|
||||
@ -525,17 +525,24 @@ int main(int argc, char* argv[])
|
||||
// Initialize our scene
|
||||
sceneInit();
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Main graphics loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Get and process input
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u32 kHeld = hidKeysHeld(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
u32 kHeld = padGetButtons(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
bool shouldHalveResolution = !!(kHeld & KEY_A);
|
||||
bool shouldHalveResolution = !!(kHeld & HidNpadButton_A);
|
||||
|
||||
// Configure the resolution used to render the scene, which
|
||||
// will be different in handheld mode/docked mode.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
@ -855,13 +855,20 @@ int main(int argc, char* argv[])
|
||||
gears_init();
|
||||
gears_reshape(1280, 720);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Main graphics loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Get and process input
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
// Render stuff!
|
||||
|
@ -7,6 +7,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// clear screen and home cursor
|
||||
printf( CONSOLE_ESC(2J) );
|
||||
|
||||
@ -46,15 +53,15 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <switch.h>
|
||||
@ -414,13 +414,20 @@ int main(int argc, char* argv[])
|
||||
// Initialize our scene
|
||||
sceneInit();
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Main graphics loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Get and process input
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
// Update our scene
|
||||
|
@ -325,13 +325,20 @@ int main(int argc, char* argv[])
|
||||
// Initialize our scene
|
||||
sceneInit();
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Main graphics loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Get and process input
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
// Render stuff!
|
||||
|
@ -514,13 +514,20 @@ int main(int argc, char* argv[])
|
||||
// Initialize our scene
|
||||
sceneInit();
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Main graphics loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Get and process input
|
||||
hidScanInput();
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
// Update our scene
|
||||
|
@ -8,6 +8,13 @@ int main(int argc, char **argv)
|
||||
//Initialize console. Using NULL as the second argument tells the console library to use the internal console structure as current one.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
//Move the cursor to row 16 and column 20 and then prints "Hello World!"
|
||||
//To move the cursor you have to print "\x1b[r;cH", where r and c are respectively
|
||||
//the row and column where you want your cursor to move
|
||||
@ -15,13 +22,13 @@ int main(int argc, char **argv)
|
||||
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -7,6 +7,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// clear screen and home cursor
|
||||
printf( CONSOLE_ESC(2J) );
|
||||
|
||||
@ -61,15 +68,15 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
static u32 framebuf_width=0;
|
||||
|
||||
static PadState pad;
|
||||
|
||||
//Note that this doesn't handle any blending.
|
||||
void draw_glyph(FT_Bitmap* bitmap, u32* framebuf, u32 x, u32 y)
|
||||
{
|
||||
@ -102,8 +104,8 @@ static int error_screen(const char* fmt, ...)
|
||||
printf("Press PLUS to exit\n");
|
||||
while (appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS)
|
||||
padUpdate(&pad);
|
||||
if (padGetButtonsDown(&pad) & HidNpadButton_Plus)
|
||||
break;
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
@ -149,6 +151,12 @@ int main(int argc, char **argv)
|
||||
Result rc=0;
|
||||
FT_Error ret=0;
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
//Use this when using multiple shared-fonts.
|
||||
/*
|
||||
PlFontData fonts[PlSharedFontType_Total];
|
||||
@ -198,13 +206,13 @@ int main(int argc, char **argv)
|
||||
|
||||
while (appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
u32 stride;
|
||||
u32* framebuf = (u32*)framebufferBegin(&fb, &stride);
|
||||
|
@ -35,19 +35,26 @@ int main(int argc, char* argv[])
|
||||
u8* imageptr = (u8*)image_bin;
|
||||
#endif
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
u32 cnt = 0;
|
||||
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Retrieve the framebuffer
|
||||
|
@ -104,19 +104,26 @@ int main(int argc, char* argv[])
|
||||
u8* imageptr = (u8*)image_bin;
|
||||
#endif
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
u32 cnt = 0;
|
||||
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Retrieve the framebuffer.
|
||||
|
@ -15,13 +15,23 @@ int main(int argc, char **argv)
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
rc = jitCreate(&j, 0x100000);//Adjust size as needed.
|
||||
printf("jitCreate() returned: 0x%x\n", rc);
|
||||
printf("jit type: %d\n", j.type);
|
||||
|
||||
if (R_SUCCEEDED(rc))
|
||||
{
|
||||
jit_rwaddr = jitGetRwAddr(&j);
|
||||
jit_rxaddr = jitGetRxAddr(&j);
|
||||
printf("jitGetRwAddr(): %p\n", jit_rwaddr);
|
||||
printf("jitGetRxAddr(): %p\n", jit_rxaddr);
|
||||
|
||||
rc = jitTransitionToWritable(&j);
|
||||
printf("jitTransitionToWritable() returned: 0x%x\n", rc);
|
||||
@ -47,15 +57,15 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -35,6 +35,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
mutexInit(&g_PrintMutex);
|
||||
barrierInit(&g_Barrier, 4);
|
||||
|
||||
@ -61,11 +68,11 @@ int main(int argc, char **argv)
|
||||
|
||||
while(appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
mutexLock(&g_PrintMutex);
|
||||
|
@ -54,6 +54,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
mutexInit(&g_PrintMutex);
|
||||
ueventCreate(&g_Event, false);
|
||||
ueventCreate(&g_ExitEvent, false);
|
||||
@ -88,11 +95,11 @@ int main(int argc, char **argv)
|
||||
|
||||
while (appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
consoleUpdate(NULL);
|
||||
|
@ -50,6 +50,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
mutexInit(&g_PrintMutex);
|
||||
utimerCreate(&g_Timer, 2000000000, TimerType_Repeating); // 2s
|
||||
utimerCreate(&g_FastTimer, 1000000000, TimerType_Repeating); // 1s
|
||||
@ -93,11 +100,11 @@ int main(int argc, char **argv)
|
||||
|
||||
while(appletMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
padUpdate(&pad);
|
||||
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break;
|
||||
|
||||
consoleUpdate(NULL);
|
||||
|
@ -48,6 +48,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
socketInitializeDefault();
|
||||
|
||||
printf("curl example\n");
|
||||
@ -57,14 +64,14 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Your code goes here
|
||||
|
@ -112,6 +112,13 @@ int main(int argc, char **argv)
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Initialise sockets
|
||||
socketInitializeDefault();
|
||||
|
||||
@ -208,23 +215,23 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
if (R_SUCCEEDED(rc) && (kDown & (KEY_A|KEY_B))) {
|
||||
if (R_SUCCEEDED(rc) && (kDown & (HidNpadButton_A|HidNpadButton_B))) {
|
||||
Result rc2 = ldnGetState(&state);
|
||||
printf("ldnGetState(): 0x%x, %d\n", rc, state);
|
||||
if (R_SUCCEEDED(rc2) && state==LdnState_Initialized) {
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
rc2 = create_network(&sec_config, &user_config, &netconfig, advert, sizeof(advert));
|
||||
printf("create_network(): 0x%x\n", rc2);
|
||||
}
|
||||
if (kDown & KEY_B) {
|
||||
if (kDown & HidNpadButton_B) {
|
||||
rc2 = connect_network(&filter, &sec_config, &user_config, advert, sizeof(advert));
|
||||
printf("connect_network(): 0x%x\n", rc2);
|
||||
}
|
||||
@ -274,7 +281,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc) && (kDown & KEY_X)) {
|
||||
if (R_SUCCEEDED(rc) && (kDown & HidNpadButton_X)) {
|
||||
if (sockfd >= 0) {
|
||||
close(sockfd);
|
||||
sockfd = -1;
|
||||
@ -282,14 +289,14 @@ int main(int argc, char **argv)
|
||||
leave_network();
|
||||
}
|
||||
|
||||
if (R_SUCCEEDED(rc) && sockfd>=0 && (kDown & (KEY_DLEFT|KEY_DRIGHT|KEY_DUP|KEY_DDOWN))) {
|
||||
if (R_SUCCEEDED(rc) && sockfd>=0 && (kDown & (HidNpadButton_Left|HidNpadButton_Right|HidNpadButton_Up|HidNpadButton_Down))) {
|
||||
char tmpstr[32];
|
||||
memset(tmpstr, 0, sizeof(tmpstr));
|
||||
|
||||
if (kDown & KEY_DLEFT) strncpy(tmpstr, "Button DLEFT pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & KEY_DRIGHT) strncpy(tmpstr, "Button DRIGHT pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & KEY_DUP) strncpy(tmpstr, "Button DUP pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & KEY_DDOWN) strncpy(tmpstr, "Button DDOWN pressed.", sizeof(tmpstr)-1);
|
||||
if (kDown & HidNpadButton_Left) strncpy(tmpstr, "Button DLEFT pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & HidNpadButton_Right) strncpy(tmpstr, "Button DRIGHT pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & HidNpadButton_Up) strncpy(tmpstr, "Button DUP pressed.", sizeof(tmpstr)-1);
|
||||
else if (kDown & HidNpadButton_Down) strncpy(tmpstr, "Button DDOWN pressed.", sizeof(tmpstr)-1);
|
||||
|
||||
ssize_t ret = sendto(sockfd, tmpstr, sizeof(tmpstr), 0, (struct sockaddr*) &serv_addr, sizeof(struct sockaddr_in));
|
||||
int tmp = errno;
|
||||
|
@ -20,6 +20,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
// Initialise sockets
|
||||
socketInitializeDefault();
|
||||
|
||||
@ -44,20 +51,20 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u32 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u32 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_A) {
|
||||
if (kDown & HidNpadButton_A) {
|
||||
printf("A Pressed\n");
|
||||
}
|
||||
if (kDown & KEY_B) {
|
||||
if (kDown & HidNpadButton_B) {
|
||||
printf("B Pressed\n");
|
||||
}
|
||||
|
||||
|
@ -9,14 +9,16 @@
|
||||
|
||||
// See also libnx nfc.h.
|
||||
|
||||
static PadState pad;
|
||||
|
||||
// Indefinitely wait for an event to be signaled
|
||||
// Break when + is pressed, or if the application should quit (in this case, return value will be non-zero)
|
||||
Result eventWaitLoop(Event *event) {
|
||||
Result rc = 1;
|
||||
while (appletMainLoop()) {
|
||||
rc = eventWait(event, 0);
|
||||
hidScanInput();
|
||||
if (R_SUCCEEDED(rc) || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS))
|
||||
padUpdate(&pad);
|
||||
if (R_SUCCEEDED(rc) || (padGetButtonsDown(&pad) & HidNpadButton_Plus))
|
||||
break;
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
@ -181,6 +183,12 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("NFC example program.\n");
|
||||
printf("Scan an amiibo tag to display information about it.\n\n");
|
||||
consoleUpdate(NULL);
|
||||
@ -223,12 +231,12 @@ int main(int argc, char* argv[])
|
||||
|
||||
// Main loop
|
||||
while (appletMainLoop()) {
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) {
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
if (padGetButtonsDown(&pad) & HidNpadButton_A) {
|
||||
rc = process_amiibo(app_id);
|
||||
|
||||
// If an error happened, print it.
|
||||
@ -239,7 +247,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// If + was pressed to exit an eventWaitLoop(), we also catch it here.
|
||||
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS)
|
||||
if (padGetButtonsDown(&pad) & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Update the console, sending a new frame to the display
|
||||
|
@ -9,22 +9,30 @@ const char* const chargers[3] = {"None", "Official", "Generic"};
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
Result rc = psmInitialize();
|
||||
if (R_FAILED(rc))
|
||||
goto cleanup;
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("\x1b[16;16HPress PLUS to exit.");
|
||||
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
u32 charge;
|
||||
double rawCharge;
|
||||
|
@ -12,6 +12,13 @@ int main(int argc, char **argv)
|
||||
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
Result rc = setInitialize();
|
||||
if (R_FAILED(rc)) printf("setInitialize() failed: 0x%x.\n", rc);
|
||||
|
||||
@ -47,15 +54,15 @@ int main(int argc, char **argv)
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// Your code goes here
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
consoleUpdate(NULL);
|
||||
}
|
||||
|
@ -12,18 +12,25 @@ int main(int argc, char **argv)
|
||||
{
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("\x1b[16;16HPress PLUS to exit.");
|
||||
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS) break; // break in order to return to hbmenu
|
||||
if (kDown & HidNpadButton_Plus) break; // break in order to return to hbmenu
|
||||
|
||||
//Print current time
|
||||
time_t unixTime = time(NULL);
|
||||
|
@ -31,6 +31,13 @@ int main(int argc, char* argv[])
|
||||
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||
consoleInit(NULL);
|
||||
|
||||
// Configure our supported input layout: a single player with standard controller styles
|
||||
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
|
||||
|
||||
// Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller)
|
||||
PadState pad;
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("usbhs example\n");
|
||||
|
||||
memset(&inf_event, 0, sizeof(inf_event));
|
||||
@ -58,14 +65,14 @@ int main(int argc, char* argv[])
|
||||
// Main loop
|
||||
while (appletMainLoop())
|
||||
{
|
||||
// Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
// Scan the gamepad. This should be done once for each frame
|
||||
padUpdate(&pad);
|
||||
|
||||
// hidKeysDown returns information about which buttons have been
|
||||
// just pressed in this frame compared to the previous one
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
// padGetButtonsDown returns the set of buttons that have been
|
||||
// newly pressed in this frame compared to the previous one
|
||||
u64 kDown = padGetButtonsDown(&pad);
|
||||
|
||||
if (kDown & KEY_PLUS)
|
||||
if (kDown & HidNpadButton_Plus)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (R_SUCCEEDED(rc2)) rc = eventWait(&inf_event, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user