diff --git a/hid/ring-con/source/main.c b/hid/ring-con/source/main.c index 923d424..d346e00 100644 --- a/hid/ring-con/source/main.c +++ b/hid/ring-con/source/main.c @@ -19,14 +19,19 @@ int main(int argc, char **argv) // take a look at the graphics/opengl set of examples, which uses EGL instead. consoleInit(NULL); - printf(CONSOLE_ESC(1;1H)"Press PLUS to exit."); + // Configure our supported input layout: a single player with standard controller styles + padConfigureInput(1, HidNpadStyleSet_NpadStandard); - hidScanInput(); // This needs to be used at least once before ringconCreate() since it uses hidGetControllerType() internally. This is only called here since ringconCreate() is called before the main-loop in this example. + // Initialize the default gamepad (which reads handheld mode inputs as well as the first connected controller) + PadState pad; + padInitializeDefault(&pad); + + printf(CONSOLE_ESC(1;1H)"Press PLUS to exit."); Result rc=0; RingCon ring={0}; bool ready=0; - rc = ringconCreate(&ring, CONTROLLER_PLAYER_1); // Setup Ring-Con usage for the specified controller, if you want to use multiple controllers you can do so by calling this multiple times with multiple RingCon objects/controllers. The Ring-Con must be connected to the specified controller. + rc = ringconCreate(&ring, HidNpadIdType_No1); // Setup Ring-Con usage for the specified controller, if you want to use multiple controllers you can do so by calling this multiple times with multiple RingCon objects/controllers. The Ring-Con must be connected to the specified controller. printf(CONSOLE_ESC(2;1H)"ringconCreate(): 0x%x, 0x%x", rc, ringconGetErrorFlags(&ring)); // You can also use ringconGetErrorFlag(). ready = R_SUCCEEDED(rc); @@ -35,14 +40,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 // Get the sensor state data.