Path: blob/master/RSDKv5/RSDK/Input/NX/NXInputDevice.cpp
1168 views
1// NOTE: I'm using enums & structs from the libNX homebrew lib, but they should have the same values as the official APIs23using namespace RSDK::SKU;45HidNpadIdType npadTypes[5] = { HidNpadIdType_Handheld, HidNpadIdType_No1, HidNpadIdType_No2, HidNpadIdType_No3, HidNpadIdType_No4 };6int32 nxVibrateDeviceCount = 0;78int32 lastNPadType = -1;9int activeNPadTypes[5] = { -1, -1, -1, -1, -1 };1011uint8 activeNPadCount = 8;12uint8 nPadIDs[] = { 2, 3, 4, 5, 6, 7, 8, 9 };13uint8 storedNPadIDs[] = { 0, 0, 0, 0, 0 };1415int32 RSDK::SKU::currentNXControllerType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_HANDHELD << 0);1617void UpdateInputNX(InputDeviceNX *device, u64 *buttonMasks, int32 *hDelta, int32 *vDelta)18{19int32 prevButtonMasks = device->buttonMasks;20device->buttonMasks = *buttonMasks;2122device->hDelta_L = hDelta[0] + 128.0;23device->vDelta_L = vDelta[0] + 128.0;2425float div = sqrtf((device->hDelta_L * device->hDelta_L) + (device->vDelta_L * device->vDelta_L));26device->hDelta_L = device->hDelta_L / div;27device->vDelta_L = device->vDelta_L / div;28if (div <= 15728.0) {29device->hDelta_L = 0.0;30device->vDelta_L = 0.0;31}32else {33device->hDelta_L = device->hDelta_L * ((fminf(div, 127.0) + -15728.0) / 17039.0);34device->vDelta_L = device->vDelta_L * ((fminf(div, 127.0) + -15728.0) / 17039.0);35}3637device->hDelta_R = hDelta[1] + 128.0;38device->vDelta_R = vDelta[1] + 128.0;3940div = sqrtf((device->hDelta_R * device->hDelta_R) + (device->vDelta_R * device->vDelta_R));41device->hDelta_R = device->hDelta_R / div;42device->vDelta_R = device->vDelta_R / div;43if (div <= 15728.0) {44device->hDelta_R = 0.0;45device->vDelta_R = 0.0;46}47else {48device->hDelta_R = device->hDelta_R * ((fminf(div, 127.0) + -15728.0) / 17039.0);49device->vDelta_R = device->vDelta_R * ((fminf(div, 127.0) + -15728.0) / 17039.0);50}5152int32 changedButtons = device->buttonMasks & ~prevButtonMasks;5354if (changedButtons) {55currentNXControllerType = device->gamepadType;56device->inactiveTimer[0] = 0;57}58else {59++device->inactiveTimer[0];60}6162if ((changedButtons & KEYMASK_A) || (changedButtons & KEYMASK_START))63device->inactiveTimer[1] = 0;64else65++device->inactiveTimer[1];6667device->anyPress = changedButtons;6869device->ProcessInput(CONT_ANY);70}7172void InputDeviceNXHandheld::UpdateInput()73{74int32 vDelta[2];75int32 hDelta[2];76HidNpadHandheldState state;7778hidGetNpadStatesHandheld(this->npadType, &state, 1);79hDelta[0] = -state.analog_stick_l.x;80hDelta[1] = -state.analog_stick_r.x;81vDelta[0] = -state.analog_stick_l.y;82vDelta[1] = -state.analog_stick_r.y;8384UpdateInputNX(this, &state.buttons, hDelta, vDelta);85}8687void InputDeviceNXJoyL::UpdateInput()88{89int32 vDelta[2];90int32 hDelta[2];91HidNpadHandheldState state;9293hidGetNpadStatesJoyLeft(this->npadType, &state, 1);94hDelta[0] = -state.analog_stick_l.x;95hDelta[1] = -state.analog_stick_r.x;96vDelta[0] = -state.analog_stick_l.y;97vDelta[1] = -state.analog_stick_r.y;9899u64 correctedButtonMasks = state.buttons;100101// "Rotate" the buttons102correctedButtonMasks |= (state.buttons & HidNpadButton_Down) ? HidNpadButton_A : 0;103correctedButtonMasks |= (state.buttons & HidNpadButton_Left) ? HidNpadButton_B : 0;104correctedButtonMasks |= (state.buttons & HidNpadButton_Right) ? HidNpadButton_X : 0;105correctedButtonMasks |= (state.buttons & HidNpadButton_Up) ? HidNpadButton_Y : 0;106correctedButtonMasks |= (state.buttons & HidNpadButton_StickL) ? HidNpadButton_StickL : 0;107correctedButtonMasks |= (state.buttons & HidNpadButton_Plus) ? HidNpadButton_Plus : 0;108109correctedButtonMasks &= ~HidNpadButton_L;110if (state.buttons & HidNpadButton_LeftSL)111correctedButtonMasks |= HidNpadButton_L;112113correctedButtonMasks &= ~HidNpadButton_R;114if (state.buttons & HidNpadButton_LeftSR)115correctedButtonMasks |= HidNpadButton_R;116117UpdateInputNX(this, &correctedButtonMasks, hDelta, vDelta);118if (state.buttons & HidNpadButton_L) {119// if (this->npadType >= HidNpadIdType_No4)120// OnAssertionFailure(2, "", "", "", 0);121122if (lastNPadType <= 3 && activeNPadTypes[lastNPadType] == 4)123hidMergeSingleJoyAsDualJoy((HidNpadIdType)activeNPadTypes[lastNPadType], this->npadType);124else125lastNPadType = this->npadType;126}127}128129void InputDeviceNXJoyR::UpdateInput()130{131int32 vDelta[2];132int32 hDelta[2];133HidNpadHandheldState state;134135hidGetNpadStatesJoyRight(this->npadType, &state, 1);136hDelta[0] = -state.analog_stick_l.x;137hDelta[1] = -state.analog_stick_r.x;138vDelta[0] = -state.analog_stick_l.y;139vDelta[1] = -state.analog_stick_r.y;140141u64 correctedButtonMasks = state.buttons;142143// "Rotate" the buttons144correctedButtonMasks |= (state.buttons & HidNpadButton_A) ? HidNpadButton_B : 0;145correctedButtonMasks |= (state.buttons & HidNpadButton_B) ? HidNpadButton_Y : 0;146correctedButtonMasks |= (state.buttons & HidNpadButton_X) ? HidNpadButton_A : 0;147correctedButtonMasks |= (state.buttons & HidNpadButton_Y) ? HidNpadButton_X : 0;148correctedButtonMasks |= (state.buttons & HidNpadButton_StickR) ? HidNpadButton_StickL : 0;149correctedButtonMasks |= (state.buttons & HidNpadButton_Plus) ? HidNpadButton_Plus : 0;150151correctedButtonMasks &= ~HidNpadButton_L;152if (state.buttons & HidNpadButton_RightSL)153correctedButtonMasks |= HidNpadButton_L;154155correctedButtonMasks &= ~HidNpadButton_R;156if (state.buttons & HidNpadButton_RightSR)157correctedButtonMasks |= HidNpadButton_R;158159UpdateInputNX(this, &correctedButtonMasks, hDelta, vDelta);160if (state.buttons & HidNpadButton_R) {161// if (this->npadType >= HidNpadIdType_No4)162// OnAssertionFailure(2, "", "", "", 0);163164if (lastNPadType <= 3 && activeNPadTypes[lastNPadType] == 3)165hidMergeSingleJoyAsDualJoy((HidNpadIdType)activeNPadTypes[lastNPadType], this->npadType);166else167lastNPadType = this->npadType;168}169}170171void InputDeviceNXJoyGrip::UpdateInput()172{173int32 vDelta[2];174int32 hDelta[2];175HidNpadHandheldState state;176177hidGetNpadStatesJoyDual(this->npadType, &state, 1);178hDelta[0] = -state.analog_stick_l.x;179hDelta[1] = -state.analog_stick_r.x;180vDelta[0] = -state.analog_stick_l.y;181vDelta[1] = -state.analog_stick_r.y;182183UpdateInputNX(this, &state.buttons, hDelta, vDelta);184185// if (this->npadType >= HidNpadIdType_No4)186// OnAssertionFailure(2, "", "", "", 0);187188int32 masks = (int32)state.buttons;189if ((masks & HidNpadButton_LeftSL) && (masks & HidNpadButton_LeftSR)) {190for (int32 id = HidNpadIdType_No1; id <= HidNpadIdType_No4; ++id) {191if (!hidGetNpadStyleSet((HidNpadIdType)id)) {192hidSetNpadJoyAssignmentModeSingleByDefault((HidNpadIdType)id);193return;194}195}196197hidSetNpadJoyAssignmentModeSingle(this->npadType, HidNpadJoyDeviceType_Left);198}199else if ((masks & HidNpadButton_RightSL) && (masks & HidNpadButton_RightSR)) {200for (int32 id = HidNpadIdType_No1; id <= HidNpadIdType_No4; ++id) {201if (!hidGetNpadStyleSet((HidNpadIdType)id)) {202hidSetNpadJoyAssignmentModeSingleByDefault((HidNpadIdType)id);203return;204}205}206207hidSetNpadJoyAssignmentModeSingle(this->npadType, HidNpadJoyDeviceType_Right);208}209}210211void InputDeviceNXPro::UpdateInput()212{213int32 vDelta[2];214int32 hDelta[2];215HidNpadHandheldState state;216217hidGetNpadStatesFullKey(this->npadType, &state, 1);218hDelta[0] = -state.analog_stick_l.x;219hDelta[1] = -state.analog_stick_r.x;220vDelta[0] = -state.analog_stick_l.y;221vDelta[1] = -state.analog_stick_r.y;222223UpdateInputNX(this, &state.buttons, hDelta, vDelta);224}225226void InputDeviceNX::ProcessInput(int32 controllerID)227{228int32 buttonMasks = (int32)this->buttonMasks;229230controller[controllerID].keyUp.press |= (buttonMasks & HidNpadButton_Up) != 0;231controller[controllerID].keyDown.press |= (buttonMasks & HidNpadButton_Down) != 0;232controller[controllerID].keyLeft.press |= (buttonMasks & HidNpadButton_Left) != 0;233controller[controllerID].keyRight.press |= (buttonMasks & HidNpadButton_Right) != 0;234controller[controllerID].keyA.press |= (buttonMasks & HidNpadButton_B) != 0;235controller[controllerID].keyB.press |= (buttonMasks & HidNpadButton_A) != 0;236controller[controllerID].keyX.press |= (buttonMasks & HidNpadButton_Y) != 0;237controller[controllerID].keyY.press |= (buttonMasks & HidNpadButton_X) != 0;238controller[controllerID].keyStart.press |= (buttonMasks & HidNpadButton_Plus) != 0;239controller[controllerID].keySelect.press |= (buttonMasks & HidNpadButton_Minus) != 0;240241#if RETRO_REV02242stickL[controllerID].keyStick.press |= (buttonMasks & HidNpadButton_StickL) != 0;243stickL[controllerID].hDelta = this->hDelta_L;244stickL[controllerID].vDelta = this->vDelta_L;245stickL[controllerID].keyUp.press |= this->vDelta_L > INPUT_DEADZONE;246stickL[controllerID].keyDown.press |= this->vDelta_L < -INPUT_DEADZONE;247stickL[controllerID].keyLeft.press |= this->hDelta_L < -INPUT_DEADZONE;248stickL[controllerID].keyRight.press |= this->hDelta_L > INPUT_DEADZONE;249250stickR[controllerID].keyStick.press |= (buttonMasks & HidNpadButton_StickR) != 0;251stickR[controllerID].hDelta = this->hDelta_R;252stickR[controllerID].vDelta = this->vDelta_R;253stickR[controllerID].keyUp.press |= this->vDelta_R > INPUT_DEADZONE;254stickR[controllerID].keyDown.press |= this->vDelta_R < -INPUT_DEADZONE;255stickR[controllerID].keyLeft.press |= this->hDelta_R < -INPUT_DEADZONE;256stickR[controllerID].keyRight.press |= this->hDelta_R > INPUT_DEADZONE;257258triggerL[controllerID].keyBumper.press |= (buttonMasks & HidNpadButton_L) != 0;259triggerL[controllerID].keyTrigger.press |= (buttonMasks & HidNpadButton_ZL) != 0;260triggerL[controllerID].bumperDelta = triggerL[controllerID].keyBumper.press ? 1.0 : 0.0;261triggerL[controllerID].triggerDelta = triggerL[controllerID].keyTrigger.press ? 1.0 : 0.0;262263triggerR[controllerID].keyBumper.press |= (buttonMasks & HidNpadButton_R) != 0;264triggerR[controllerID].keyTrigger.press |= (buttonMasks & HidNpadButton_ZR) != 0;265triggerR[controllerID].bumperDelta = triggerR[controllerID].keyBumper.press ? 1.0 : 0.0;266triggerR[controllerID].triggerDelta = triggerR[controllerID].keyTrigger.press ? 1.0 : 0.0;267#else268controller[controllerID].keyStickL.press |= (buttonMasks & HidNpadButton_StickL) != 0;269stickL[controllerID].hDeltaL = this->hDelta_L;270stickL[controllerID].vDeltaL = this->vDelta_L;271stickL[controllerID].keyUp.press |= this->vDelta_L > INPUT_DEADZONE;272stickL[controllerID].keyDown.press |= this->vDelta_L < -INPUT_DEADZONE;273stickL[controllerID].keyLeft.press |= this->hDelta_L < -INPUT_DEADZONE;274stickL[controllerID].keyRight.press |= this->hDelta_L > INPUT_DEADZONE;275276controller[controllerID].keyStickR.press |= (buttonMasks & HidNpadButton_StickR) != 0;277stickL[controllerID].hDeltaL = this->hDelta_R;278stickL[controllerID].vDeltaL = this->vDelta_R;279280controller[controllerID].keyBumperL.press |= (buttonMasks & HidNpadButton_L) != 0;281controller[controllerID].keyTriggerL.press |= (buttonMasks & HidNpadButton_ZL) != 0;282stickL[controllerID].triggerDeltaL = controller[controllerID].keyTriggerL.press ? 1.0 : 0.0;283284controller[controllerID].keyBumperR.press |= (buttonMasks & HidNpadButton_R) != 0;285controller[controllerID].keyTriggerR.press |= (buttonMasks & HidNpadButton_ZR) != 0;286stickL[controllerID].triggerDeltaR = controller[controllerID].keyTriggerR.press ? 1.0 : 0.0;287#endif288}289290InputDeviceNXHandheld *RSDK::SKU::InitNXHandheldInputDevice(uint32 id, HidNpadIdType type)291{292if (inputDeviceCount == INPUTDEVICE_COUNT)293return NULL;294295if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)296return NULL;297298if (inputDeviceList[inputDeviceCount])299delete inputDeviceList[inputDeviceCount];300301inputDeviceList[inputDeviceCount] = new InputDeviceNXHandheld();302303InputDeviceNXHandheld *device = (InputDeviceNXHandheld *)inputDeviceList[inputDeviceCount];304305device->gamepadType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_HANDHELD << 0);306device->disabled = false;307device->id = id;308device->active = true;309device->npadType = type;310311for (int32 i = 0; i < PLAYER_COUNT; ++i) {312if (inputSlots[i] == id) {313inputSlotDevices[i] = device;314device->isAssigned = true;315}316}317318inputDeviceCount++;319return device;320}321322InputDeviceNXJoyL *RSDK::SKU::InitNXJoyLInputDevice(uint32 id, HidNpadIdType type)323{324if (inputDeviceCount == INPUTDEVICE_COUNT)325return NULL;326327if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)328return NULL;329330if (inputDeviceList[inputDeviceCount])331delete inputDeviceList[inputDeviceCount];332333inputDeviceList[inputDeviceCount] = new InputDeviceNXJoyL();334335InputDeviceNXJoyL *device = (InputDeviceNXJoyL *)inputDeviceList[inputDeviceCount];336337device->gamepadType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_JOY_L << 0);338device->disabled = false;339device->id = id;340device->active = true;341device->npadType = type;342343for (int32 i = 0; i < PLAYER_COUNT; ++i) {344if (inputSlots[i] == id) {345inputSlotDevices[i] = device;346device->isAssigned = true;347}348}349350inputDeviceCount++;351return device;352}353InputDeviceNXJoyR *RSDK::SKU::InitNXJoyRInputDevice(uint32 id, HidNpadIdType type)354{355if (inputDeviceCount == INPUTDEVICE_COUNT)356return NULL;357358if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)359return NULL;360361if (inputDeviceList[inputDeviceCount])362delete inputDeviceList[inputDeviceCount];363364inputDeviceList[inputDeviceCount] = new InputDeviceNXJoyR();365366InputDeviceNXJoyR *device = (InputDeviceNXJoyR *)inputDeviceList[inputDeviceCount];367368device->gamepadType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_JOY_R << 0);369device->disabled = false;370device->id = id;371device->active = true;372device->npadType = type;373374for (int32 i = 0; i < PLAYER_COUNT; ++i) {375if (inputSlots[i] == id) {376inputSlotDevices[i] = device;377device->isAssigned = true;378}379}380381inputDeviceCount++;382return device;383}384InputDeviceNXJoyGrip *RSDK::SKU::InitNXJoyGripInputDevice(uint32 id, HidNpadIdType type)385{386if (inputDeviceCount == INPUTDEVICE_COUNT)387return NULL;388389if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)390return NULL;391392if (inputDeviceList[inputDeviceCount])393delete inputDeviceList[inputDeviceCount];394395inputDeviceList[inputDeviceCount] = new InputDeviceNXJoyGrip();396397InputDeviceNXJoyGrip *device = (InputDeviceNXJoyGrip *)inputDeviceList[inputDeviceCount];398399device->gamepadType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_JOY_GRIP << 0);400device->disabled = false;401device->id = id;402device->active = true;403device->npadType = type;404405for (int32 i = 0; i < PLAYER_COUNT; ++i) {406if (inputSlots[i] == id) {407inputSlotDevices[i] = device;408device->isAssigned = true;409}410}411412inputDeviceCount++;413return device;414}415InputDeviceNXPro *RSDK::SKU::InitNXProInputDevice(uint32 id, HidNpadIdType type)416{417if (inputDeviceCount == INPUTDEVICE_COUNT)418return NULL;419420if (inputDeviceList[inputDeviceCount] && inputDeviceList[inputDeviceCount]->active)421return NULL;422423if (inputDeviceList[inputDeviceCount])424delete inputDeviceList[inputDeviceCount];425426inputDeviceList[inputDeviceCount] = new InputDeviceNXPro();427428InputDeviceNXPro *device = (InputDeviceNXPro *)inputDeviceList[inputDeviceCount];429430device->gamepadType = (DEVICE_API_NONE << 16) | (DEVICE_TYPE_CONTROLLER << 8) | (DEVICE_SWITCH_PRO << 0);431device->disabled = false;432device->id = id;433device->active = true;434device->npadType = type;435436for (int32 i = 0; i < PLAYER_COUNT; ++i) {437if (inputSlots[i] == id) {438inputSlotDevices[i] = device;439device->isAssigned = true;440}441}442443inputDeviceCount++;444return device;445}446447void RSDK::SKU::InitNXInputAPI()448{449hidInitializeNpad();450hidInitializeTouchScreen();451hidSetSupportedNpadStyleSet(HidNpadStyleTag_NpadFullKey | HidNpadStyleTag_NpadHandheld | HidNpadStyleTag_NpadJoyDual | HidNpadStyleTag_NpadJoyLeft452| HidNpadStyleTag_NpadJoyRight);453hidSetSupportedNpadIdType(npadTypes, 5);454455hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);456457ProcessInput();458459// Unsure about this one, hope its right :)460HidVibrationDeviceHandle handles[8];461hidInitializeVibrationDevices(handles, 8, HidNpadIdType_No3, HidNpadStyleTag_NpadFullKey);462nxVibrateDeviceCount = 8;463}464465void RSDK::SKU::ProcessNXInputDevices()466{467lastNPadType = -1;468469// check for lost connections470for (int32 d = 4; d >= 1; --d) {471int32 type = activeNPadTypes[d];472473// if no controller (and there was one before), remove!474if (type != -1 && !hidGetNpadStyleSet(npadTypes[d])) {475int32 prevID = storedNPadIDs[d];476storedNPadIDs[d] = 0;477if (prevID)478nPadIDs[activeNPadCount++] = prevID;479480InputDevice *device = InputDeviceFromID(prevID);481if (device)482RemoveInputDevice(device);483484activeNPadTypes[d] = -1;485}486}487488// check for changed controller types489for (int32 d = 4; d >= 1; --d) {490int32 type = activeNPadTypes[d];491492// if what it is now, isn't what we "remembered", change!493if (type != -1 && !(hidGetNpadStyleSet(npadTypes[d]) & (1 << (type & 0x1F)))) {494int32 prevID = storedNPadIDs[d];495storedNPadIDs[d] = 0;496if (prevID)497nPadIDs[activeNPadCount++] = prevID;498499InputDevice *device = InputDeviceFromID(prevID);500if (device)501RemoveInputDevice(device);502503activeNPadTypes[d] = -1;504}505}506507// update input device states & etc508for (int32 c = 0; c < 5; ++c) {509uint32 styleSet = hidGetNpadStyleSet(npadTypes[c]);510511if (activeNPadTypes[c] == -1) {512InputDevice *device = NULL;513uint32 id = 0;514515if (!device && (styleSet & HidNpadStyleTag_NpadHandheld)) {516id = 0;517if (activeNPadCount) {518id = nPadIDs[--activeNPadCount];519storedNPadIDs[c] = id;520}521522device = InputDeviceFromID(id);523if (!device)524device = InitNXHandheldInputDevice(id, npadTypes[c]);525526activeNPadTypes[c] = 1;527}528529if (!device && (styleSet & HidNpadStyleTag_NpadJoyLeft)) {530id = 0;531if (activeNPadCount) {532id = nPadIDs[--activeNPadCount];533storedNPadIDs[c] = id;534}535536device = InputDeviceFromID(id);537if (!device)538device = InitNXJoyLInputDevice(id, npadTypes[c]);539540if (device) {541hidSetNpadJoyAssignmentModeSingleByDefault(npadTypes[c]);542hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);543}544545activeNPadTypes[c] = 3;546}547548if (!device && (styleSet & HidNpadStyleTag_NpadJoyRight)) {549id = 0;550if (activeNPadCount) {551id = nPadIDs[--activeNPadCount];552storedNPadIDs[c] = id;553}554555device = InputDeviceFromID(id);556if (!device)557device = InitNXJoyRInputDevice(id, npadTypes[c]);558559if (device) {560hidSetNpadJoyAssignmentModeSingleByDefault(npadTypes[c]);561hidSetNpadJoyHoldType(HidNpadJoyHoldType_Horizontal);562}563564activeNPadTypes[c] = 4;565}566567if (!device && (styleSet & HidNpadStyleTag_NpadJoyDual)) {568id = 0;569if (activeNPadCount) {570id = nPadIDs[--activeNPadCount];571storedNPadIDs[c] = id;572}573574device = InputDeviceFromID(id);575if (!device)576device = InitNXJoyGripInputDevice(id, npadTypes[c]);577578activeNPadTypes[c] = 2;579}580581if (!device && (styleSet & HidNpadStyleTag_NpadFullKey)) {582id = 0;583if (activeNPadCount) {584id = nPadIDs[--activeNPadCount];585storedNPadIDs[c] = id;586}587588device = InputDeviceFromID(id);589if (!device)590device = InitNXProInputDevice(id, npadTypes[c]);591592activeNPadTypes[c] = 0;593}594}595}596597HidTouchScreenState touchState;598hidGetTouchScreenStates(&touchState, 1);599600touchInfo.count = 0;601for (int32 f = 0; f < touchState.count; ++f) {602if (!touchState.touches[f].finger_id) {603touchInfo.down[0] = true;604touchInfo.x[0] = touchState.touches[0].x / 1280.0;605touchInfo.y[0] = touchState.touches[0].y / 720.0;606touchInfo.count++;607}608}609}610611