Last active
September 29, 2018 15:30
-
-
Save endrift/04c497b54b6b4e55856315f01957de8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#include <switch.h> | |
int main(int argc, char **argv) { | |
struct HidController controller[9]; | |
gfxInitDefault(); | |
socketInitializeDefault(); | |
nxlinkStdio(); | |
u32 handles[6]; | |
hidGetSixAxisSensorHandles(handles, 2, CONTROLLER_PLAYER_1, TYPE_JOYCON_PAIR); | |
hidGetSixAxisSensorHandles(&handles[2], 1, CONTROLLER_HANDHELD, TYPE_HANDHELD); | |
hidGetSixAxisSensorHandles(&handles[3], 1, CONTROLLER_PLAYER_1, TYPE_PROCONTROLLER); | |
hidGetSixAxisSensorHandles(&handles[4], 1, CONTROLLER_PLAYER_1, TYPE_JOYCON_LEFT); | |
hidGetSixAxisSensorHandles(&handles[5], 1, CONTROLLER_PLAYER_1, TYPE_JOYCON_RIGHT); | |
hidStartSixAxisSensor(handles[0]); | |
hidStartSixAxisSensor(handles[1]); | |
hidStartSixAxisSensor(handles[2]); | |
hidStartSixAxisSensor(handles[3]); | |
hidStartSixAxisSensor(handles[4]); | |
hidStartSixAxisSensor(handles[5]); | |
while(appletMainLoop()) { | |
hidScanInput(); | |
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); | |
if (kDown & KEY_PLUS) break; | |
HidSharedMemory* sharedMem = (HidSharedMemory*) hidGetSharedmemAddr(); | |
int c = hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1; | |
SixAxisSensorValues sixaxis; | |
hidSixAxisSensorValuesRead(&sixaxis, c, 1); | |
printf("---\n"); | |
printf("Layout: %x\n", hidGetControllerType(c)); | |
printf("Accel:\tx %f\ty %f\tz %f\n", sixaxis.accelerometer.x, sixaxis.accelerometer.y, sixaxis.accelerometer.z); | |
printf("Gyro:\tx %f\ty %f\tz %f\n", sixaxis.gyroscope.x, sixaxis.gyroscope.y, sixaxis.gyroscope.z); | |
printf("???:\tx %f\ty %f\tz %f\n", sixaxis.unk.x, sixaxis.unk.y, sixaxis.unk.z); | |
printf("Orientation:\n\t%f\t%f\t%f\n\t%f\t%f\t%f\n\t%f\t%f\t%f\n", | |
sixaxis.orientation[0].x, sixaxis.orientation[0].y, sixaxis.orientation[0].z, | |
sixaxis.orientation[1].x, sixaxis.orientation[1].y, sixaxis.orientation[1].z, | |
sixaxis.orientation[2].x, sixaxis.orientation[2].y, sixaxis.orientation[2].z); | |
gfxWaitForVsync(); | |
} | |
socketExit(); | |
gfxExit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment