mirror of
https://github.com/DevL0rd/SkyNX
synced 2024-11-29 22:40:17 +00:00
joycon hotfix, fixed tap to double click
This commit is contained in:
parent
e47419ec8c
commit
fb7056c56b
6 changed files with 520 additions and 506 deletions
|
@ -140,8 +140,6 @@ function heldKeysBitmask(HeldKeys) {
|
||||||
Down: isOdd(HeldKeys >> 15)
|
Down: isOdd(HeldKeys >> 15)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var mouseIsDown = false;
|
|
||||||
var rightTouchTime = 0;
|
|
||||||
function handleControllerInput(hid, controllerId, playerNumber) {
|
function handleControllerInput(hid, controllerId, playerNumber) {
|
||||||
var heldKeys = hid.get("HeldKeys" + playerNumber);
|
var heldKeys = hid.get("HeldKeys" + playerNumber);
|
||||||
var LJoyX = hid.get("LJoyX" + playerNumber);
|
var LJoyX = hid.get("LJoyX" + playerNumber);
|
||||||
|
@ -243,6 +241,10 @@ function handleControllerInput(hid, controllerId, playerNumber) {
|
||||||
}
|
}
|
||||||
var touchX1old = 0;
|
var touchX1old = 0;
|
||||||
var touchY1old = 0;
|
var touchY1old = 0;
|
||||||
|
|
||||||
|
var leftClicking = false;
|
||||||
|
var rightTouchTime = 0;
|
||||||
|
var leftTouchTime = 0;
|
||||||
var rightClicking = false;
|
var rightClicking = false;
|
||||||
var scrolling = false;
|
var scrolling = false;
|
||||||
hidStreamClient.on('data', function (data) {
|
hidStreamClient.on('data', function (data) {
|
||||||
|
@ -266,7 +268,7 @@ hidStreamClient.on('data', function (data) {
|
||||||
var touchY2 = hid.get("touchY2");
|
var touchY2 = hid.get("touchY2");
|
||||||
if (touchX2 && touchY2) {
|
if (touchX2 && touchY2) {
|
||||||
rightTouchTime++;
|
rightTouchTime++;
|
||||||
if (rightTouchTime > 10) {
|
if (rightTouchTime > 5) { //Handle scrolling
|
||||||
if (!touchX1old) touchX1old = touchX1;
|
if (!touchX1old) touchX1old = touchX1;
|
||||||
if (!touchY1old) touchY1old = touchY1;
|
if (!touchY1old) touchY1old = touchY1;
|
||||||
var xDiff = touchX1old - touchX1;
|
var xDiff = touchX1old - touchX1;
|
||||||
|
@ -276,7 +278,7 @@ hidStreamClient.on('data', function (data) {
|
||||||
touchY1old = touchY1;
|
touchY1old = touchY1;
|
||||||
scrolling = true;
|
scrolling = true;
|
||||||
rightClicking = false;
|
rightClicking = false;
|
||||||
} else {
|
} else { //Handle left click
|
||||||
rightClicking = true;
|
rightClicking = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -288,21 +290,27 @@ hidStreamClient.on('data', function (data) {
|
||||||
rightTouchTime = 0;
|
rightTouchTime = 0;
|
||||||
}
|
}
|
||||||
if (!scrolling) {
|
if (!scrolling) {
|
||||||
|
leftTouchTime++;
|
||||||
robot.moveMouse(touchX1, touchY1);
|
robot.moveMouse(touchX1, touchY1);
|
||||||
if (!mouseIsDown) {
|
if (!leftClicking) {
|
||||||
robot.mouseToggle("down");
|
robot.mouseToggle("down");
|
||||||
mouseIsDown = true;
|
leftClicking = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
robot.mouseToggle("up");
|
robot.mouseToggle("up");
|
||||||
mouseIsDown = false;
|
leftClicking = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mouseIsDown) {
|
if (leftClicking) { //release left click
|
||||||
robot.mouseToggle("up");
|
robot.mouseToggle("up");
|
||||||
mouseIsDown = false;
|
leftClicking = false;
|
||||||
|
if (leftTouchTime < 3) {
|
||||||
|
robot.mouseClick("left", true); //double click
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
leftTouchTime = 0;
|
||||||
|
rightTouchTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
hidStreamClient.on('end', function () {
|
hidStreamClient.on('end', function () {
|
||||||
|
|
|
@ -881,7 +881,7 @@
|
||||||
0000000000042ea0 0000000000000310 t FC_RenderLeft
|
0000000000042ea0 0000000000000310 t FC_RenderLeft
|
||||||
00000000000431b0 00000000000001ac T FC_DrawColor
|
00000000000431b0 00000000000001ac T FC_DrawColor
|
||||||
0000000000043360 0000000000000274 T audioHandlerLoop
|
0000000000043360 0000000000000274 T audioHandlerLoop
|
||||||
00000000000435e0 00000000000001e8 T gamePadSend
|
00000000000435e0 00000000000001f0 T gamePadSend
|
||||||
00000000000437d0 0000000000000060 T inputHandlerLoop
|
00000000000437d0 0000000000000060 T inputHandlerLoop
|
||||||
0000000000043830 0000000000000104 T init
|
0000000000043830 0000000000000104 T init
|
||||||
0000000000043940 000000000000003c T unInit
|
0000000000043940 000000000000003c T unInit
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
|
@ -9,10 +9,19 @@ void gamePadSend(JoyConSocket *connection)
|
||||||
JoystickPosition lJoy;
|
JoystickPosition lJoy;
|
||||||
JoystickPosition rJoy;
|
JoystickPosition rJoy;
|
||||||
JoyPkg pkg;
|
JoyPkg pkg;
|
||||||
HidControllerID conID;
|
|
||||||
/* Recieve switch input and generate the package */
|
/* Recieve switch input and generate the package */
|
||||||
hidScanInput();
|
hidScanInput();
|
||||||
short controllersConnected = 0;
|
short controllersConnected = 0;
|
||||||
|
HidControllerID player1Id;
|
||||||
|
if (hidGetHandheldMode())
|
||||||
|
{
|
||||||
|
player1Id = CONTROLLER_HANDHELD;
|
||||||
|
controllersConnected++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player1Id = CONTROLLER_PLAYER_1;
|
||||||
|
}
|
||||||
for (short i = 0; i < 4; i++)
|
for (short i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (hidIsControllerConnected(i))
|
if (hidIsControllerConnected(i))
|
||||||
|
@ -21,11 +30,9 @@ void gamePadSend(JoyConSocket *connection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pkg.controllerCount = controllersConnected;
|
pkg.controllerCount = controllersConnected;
|
||||||
|
pkg.heldKeys1 = hidKeysHeld(player1Id);
|
||||||
conID = hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1;
|
hidJoystickRead(&lJoy, player1Id, JOYSTICK_LEFT);
|
||||||
pkg.heldKeys1 = hidKeysHeld(conID);
|
hidJoystickRead(&rJoy, player1Id, JOYSTICK_RIGHT);
|
||||||
hidJoystickRead(&lJoy, conID, JOYSTICK_LEFT);
|
|
||||||
hidJoystickRead(&rJoy, conID, JOYSTICK_RIGHT);
|
|
||||||
pkg.lJoyX1 = lJoy.dx;
|
pkg.lJoyX1 = lJoy.dx;
|
||||||
pkg.lJoyY1 = lJoy.dy;
|
pkg.lJoyY1 = lJoy.dy;
|
||||||
pkg.rJoyX1 = rJoy.dx;
|
pkg.rJoyX1 = rJoy.dx;
|
||||||
|
|
Loading…
Reference in a new issue