From 9f211fddabbd7e35693ae22af4626a4d525dfd0f Mon Sep 17 00:00:00 2001 From: Skirlez Date: Tue, 26 Oct 2021 20:53:40 +0300 Subject: [PATCH 1/2] Equally divide joystick into 8 directions stickAngle gets the angle of the stick with point_direction() check stickAngle and determine if it is within what would be considered that direction --- scripts/check_keys.gml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/check_keys.gml b/scripts/check_keys.gml index c6c15359..ef4097b7 100644 --- a/scripts/check_keys.gml +++ b/scripts/check_keys.gml @@ -160,19 +160,24 @@ if (gamepad_is_supported()) { xjoyy = gamepad_axis_value(global.gamepadIndex, gp_axislv); if (is_walkzone(xjoyx, xjoyy, 1)) walk_zone = 1; if (is_past_deadzone(xjoyx, xjoyy, 1)) { - if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx < -(global.opxjoydz / 200))) { + + stickAngle = point_direction(0, 0, xjoyx, xjoyy) + if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx < -(global.opxjoydz / 200))) && stickAngle > 112.5 && stickAngle < 247.5 { ctrl_Left = -xjoyx; global.controltype = 2; } - if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx > (global.opxjoydz / 200))) { + + if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx > (global.opxjoydz / 200))) && (stickAngle <= 67.5 || stickAngle >= 292.5) { ctrl_Right = xjoyx; global.controltype = 2; } - if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy < -(global.opxjoydz / 200))) { + + if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy < -(global.opxjoydz / 200))) && stickAngle <= 157.5 && stickAngle >= 22.5 { ctrl_Up = 1; global.controltype = 2; } - if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy > (global.opxjoydz / 200))) { + + if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy > (global.opxjoydz / 200))) && stickAngle > 202.5 && stickAngle < 337.5 { ctrl_Down = 1; global.controltype = 2; } From e591c5c018407827567a60090fefc88b028306e9 Mon Sep 17 00:00:00 2001 From: Skirlez Date: Tue, 26 Oct 2021 20:57:57 +0300 Subject: [PATCH 2/2] correct (?) code formatting --- scripts/check_keys.gml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/check_keys.gml b/scripts/check_keys.gml index ef4097b7..107f0356 100644 --- a/scripts/check_keys.gml +++ b/scripts/check_keys.gml @@ -161,8 +161,9 @@ if (gamepad_is_supported()) { if (is_walkzone(xjoyx, xjoyy, 1)) walk_zone = 1; if (is_past_deadzone(xjoyx, xjoyy, 1)) { - stickAngle = point_direction(0, 0, xjoyx, xjoyy) - if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx < -(global.opxjoydz / 200))) && stickAngle > 112.5 && stickAngle < 247.5 { + stickAngle = point_direction(0, 0, xjoyx, xjoyy); + + if ((ctrl_Left == 0) && (ctrl_Right == 0) && (xjoyx < -(global.opxjoydz / 200))) && (stickAngle > 112.5 && stickAngle < 247.5) { ctrl_Left = -xjoyx; global.controltype = 2; } @@ -172,12 +173,12 @@ if (gamepad_is_supported()) { global.controltype = 2; } - if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy < -(global.opxjoydz / 200))) && stickAngle <= 157.5 && stickAngle >= 22.5 { + if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy < -(global.opxjoydz / 200))) && (stickAngle <= 157.5 && stickAngle >= 22.5) { ctrl_Up = 1; global.controltype = 2; } - if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy > (global.opxjoydz / 200))) && stickAngle > 202.5 && stickAngle < 337.5 { + if ((ctrl_Up == 0) && (ctrl_Down == 0) && (xjoyy > (global.opxjoydz / 200))) && (stickAngle > 202.5 && stickAngle < 337.5) { ctrl_Down = 1; global.controltype = 2; }