mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-20 21:12:38 +02:00
hid/ring-con: Updated for hid-refactor.
This commit is contained in:
parent
2b0d5062a5
commit
5a42b4766b
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user