joycon hotfix, fixed tap to double click

This commit is contained in:
devl0rd 2020-04-24 12:28:16 -06:00
parent e47419ec8c
commit fb7056c56b
6 changed files with 520 additions and 506 deletions

View file

@ -140,8 +140,6 @@ function heldKeysBitmask(HeldKeys) {
Down: isOdd(HeldKeys >> 15)
}
}
var mouseIsDown = false;
var rightTouchTime = 0;
function handleControllerInput(hid, controllerId, playerNumber) {
var heldKeys = hid.get("HeldKeys" + playerNumber);
var LJoyX = hid.get("LJoyX" + playerNumber);
@ -243,6 +241,10 @@ function handleControllerInput(hid, controllerId, playerNumber) {
}
var touchX1old = 0;
var touchY1old = 0;
var leftClicking = false;
var rightTouchTime = 0;
var leftTouchTime = 0;
var rightClicking = false;
var scrolling = false;
hidStreamClient.on('data', function (data) {
@ -266,7 +268,7 @@ hidStreamClient.on('data', function (data) {
var touchY2 = hid.get("touchY2");
if (touchX2 && touchY2) {
rightTouchTime++;
if (rightTouchTime > 10) {
if (rightTouchTime > 5) { //Handle scrolling
if (!touchX1old) touchX1old = touchX1;
if (!touchY1old) touchY1old = touchY1;
var xDiff = touchX1old - touchX1;
@ -276,7 +278,7 @@ hidStreamClient.on('data', function (data) {
touchY1old = touchY1;
scrolling = true;
rightClicking = false;
} else {
} else { //Handle left click
rightClicking = true;
}
} else {
@ -288,20 +290,26 @@ hidStreamClient.on('data', function (data) {
rightTouchTime = 0;
}
if (!scrolling) {
leftTouchTime++;
robot.moveMouse(touchX1, touchY1);
if (!mouseIsDown) {
if (!leftClicking) {
robot.mouseToggle("down");
mouseIsDown = true;
leftClicking = true;
}
} else {
robot.mouseToggle("up");
mouseIsDown = false;
leftClicking = false;
}
} else {
if (mouseIsDown) {
if (leftClicking) { //release left click
robot.mouseToggle("up");
mouseIsDown = false;
leftClicking = false;
if (leftTouchTime < 3) {
robot.mouseClick("left", true); //double click
}
}
leftTouchTime = 0;
rightTouchTime = 0;
}
});

View file

@ -881,7 +881,7 @@
0000000000042ea0 0000000000000310 t FC_RenderLeft
00000000000431b0 00000000000001ac T FC_DrawColor
0000000000043360 0000000000000274 T audioHandlerLoop
00000000000435e0 00000000000001e8 T gamePadSend
00000000000435e0 00000000000001f0 T gamePadSend
00000000000437d0 0000000000000060 T inputHandlerLoop
0000000000043830 0000000000000104 T init
0000000000043940 000000000000003c T unInit

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

View file

@ -9,10 +9,19 @@ void gamePadSend(JoyConSocket *connection)
JoystickPosition lJoy;
JoystickPosition rJoy;
JoyPkg pkg;
HidControllerID conID;
/* Recieve switch input and generate the package */
hidScanInput();
short controllersConnected = 0;
HidControllerID player1Id;
if (hidGetHandheldMode())
{
player1Id = CONTROLLER_HANDHELD;
controllersConnected++;
}
else
{
player1Id = CONTROLLER_PLAYER_1;
}
for (short i = 0; i < 4; i++)
{
if (hidIsControllerConnected(i))
@ -21,11 +30,9 @@ void gamePadSend(JoyConSocket *connection)
}
}
pkg.controllerCount = controllersConnected;
conID = hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1;
pkg.heldKeys1 = hidKeysHeld(conID);
hidJoystickRead(&lJoy, conID, JOYSTICK_LEFT);
hidJoystickRead(&rJoy, conID, JOYSTICK_RIGHT);
pkg.heldKeys1 = hidKeysHeld(player1Id);
hidJoystickRead(&lJoy, player1Id, JOYSTICK_LEFT);
hidJoystickRead(&rJoy, player1Id, JOYSTICK_RIGHT);
pkg.lJoyX1 = lJoy.dx;
pkg.lJoyY1 = lJoy.dy;
pkg.rJoyX1 = rJoy.dx;