mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +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.
|
// take a look at the graphics/opengl set of examples, which uses EGL instead.
|
||||||
consoleInit(NULL);
|
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;
|
Result rc=0;
|
||||||
RingCon ring={0};
|
RingCon ring={0};
|
||||||
bool ready=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().
|
printf(CONSOLE_ESC(2;1H)"ringconCreate(): 0x%x, 0x%x", rc, ringconGetErrorFlags(&ring)); // You can also use ringconGetErrorFlag().
|
||||||
ready = R_SUCCEEDED(rc);
|
ready = R_SUCCEEDED(rc);
|
||||||
|
|
||||||
@ -35,14 +40,14 @@ int main(int argc, char **argv)
|
|||||||
// Main loop
|
// Main loop
|
||||||
while(appletMainLoop())
|
while(appletMainLoop())
|
||||||
{
|
{
|
||||||
//Scan all the inputs. This should be done once for each frame
|
// Scan the gamepad. This should be done once for each frame
|
||||||
hidScanInput();
|
padUpdate(&pad);
|
||||||
|
|
||||||
// hidKeysDown returns information about which buttons have been
|
// padGetButtonsDown returns the set of buttons that have been
|
||||||
// just pressed in this frame compared to the previous one
|
// newly pressed in this frame compared to the previous one
|
||||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
u64 kDown = padGetButtonsDown(&pad);
|
||||||
|
|
||||||
if (kDown & KEY_PLUS)
|
if (kDown & HidNpadButton_Plus)
|
||||||
break; // break in order to return to hbmenu
|
break; // break in order to return to hbmenu
|
||||||
|
|
||||||
// Get the sensor state data.
|
// Get the sensor state data.
|
||||||
|
Loading…
Reference in New Issue
Block a user