really annoying mouse input/joystick input takeover scripts
using System.Collections;
using System.Collections.Generic;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Users;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class MouseCursorForCurser : MonoBehaviour
{
public float MouseInputYYY = 0f;
public float MouseInputXXX = 0f;
public float XXXYYYcenter = 17f;
public float XXXXXXcenter = 0f;
public float XXXYYYcenterADD = 0f;
public float XXXXXXcenterADD = 15f;
private Camera cam;
public KeyCode MouseRight;
public bool cannot = true;
public bool A = false;
public bool B = false;
public bool C = false;
public bool D = false;
public bool E = false;
public bool F = false;
public bool G = false;
public bool H = false;
public Image[] Cursors;
public bool useXboXjoyStick = false;
public KeyCode XboxMouseClickWatcher;
public bool LeftTriggerMouseZeroDown = false;
public bool LeftTriggerMouseZeroUP = false;
void Awake()
{
//transform.position = new Vector3(200,200, 0);
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
WhereisMouse();
}
void Start()
{
cam = Camera.main;
Cursor.visible = false;
XXXYYYcenter = 17f;
XXXXXXcenter = 0f;
XXXYYYcenterADD = 0f;
XXXXXXcenterADD = 15f;
WhereisMouse();
}
public void TurbXboxController()
{
if (useXboXjoyStick == false)
{
useXboXjoyStick = true;
}
}
public void TurnOFFXboxController()
{
if (useXboXjoyStick == true)
{
useXboXjoyStick = false;
}
}
public void WhereisMouse()
{
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
mousePos.x = Input.mousePosition.x;
mousePos.y = Input.mousePosition.y;
MouseInputXXX = mousePos.x;
MouseInputYYY = mousePos.y;
MouseInputXXX = Mathf.Clamp(MouseInputXXX, 0, Screen.width);
MouseInputYYY = Mathf.Clamp(MouseInputYYY, 0, Screen.height);
transform.position = new Vector3(MouseInputXXX - XXXXXXcenter + XXXXXXcenterADD, MouseInputYYY - XXXYYYcenter + XXXYYYcenterADD, 0);
}
// Update is called once per frame
void Update()
{
if (useXboXjoyStick == false)
{
WhereisMouse();
if (B == false)
{
if (C == false)
{
if (Input.GetMouseButtonDown(0))
{
E = true;
A = true;
H = true;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
}
}
if (B == false)
{
if (C == false)
{
if (Input.GetMouseButtonUp(0))
{
E = false;
A = false;
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
H = false;
}
}
}
if (A == false)
{
if (C == false)
{
if (Input.GetKeyDown(MouseRight))
{
B = true;
//F = true;
G = true;
if (G == true)
{
if (F == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
if (F == false)
{
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
}
}
}
}
if (A == false)
{
if (C == false)
{
if (G == true)
{
if (Input.GetMouseButtonDown(0))
{
F = true;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
if (Input.GetMouseButtonUp(0))
{
F = false;
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
if (Input.GetKeyUp(MouseRight))
{
B = false;
G = false;
if (F == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (F == false)
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (C == true)
{
D = true;
if (Input.GetMouseButtonUp(0))
{
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
H = false;
}
if (Input.GetMouseButtonDown(0))
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
H = true;
}
if (Input.GetKeyUp(MouseRight))
{
D = false;
if (H == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (H == false)
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (D == false)
{
if (Input.GetKeyDown(MouseRight))
{
C = true;
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
if (Input.GetKeyUp(MouseRight))
{
if (H == true)
{
C = false;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (H == false)
{
C = false;
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (D == true)
{
if (C == true)
{
if (Input.GetKeyUp(MouseRight))
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
}
}
}
}
}
}
///XboxMouseClickWatcher is keycode for left mouse button. right mouse is left trigger
///
if (useXboXjoyStick == true)
{
WhereisMouse();
if (Input.GetAxis("XbPoneLeftTriger") > 0.25f) //&& Time.time > nextFire)
{
LeftTriggerMouseZeroDown = true;
LeftTriggerMouseZeroUP = false;
}
if (Input.GetAxis("XbPoneLeftTriger") < 0.25f)
{
LeftTriggerMouseZeroDown = false;
LeftTriggerMouseZeroUP = true;
}
if (B == false)
{
if (C == false)
{
if (Input.GetKeyDown(XboxMouseClickWatcher)) //Input.GetMouseButtonDown(0)) (Input.GetKeyDown(XboxMouseClickWatcher))
{
E = true;
A = true;
H = true;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
}
}
if (B == false)
{
if (C == false)
{
if (Input.GetKeyUp(XboxMouseClickWatcher)) //Input.GetMouseButtonUp(0)) (Input.GetKeyUp(XboxMouseClickWatcher))
{
E = false;
A = false;
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
H = false;
}
}
}
if (A == false)
{
if (C == false)
{
if (LeftTriggerMouseZeroDown == true) //(Input.GetKeyDown(MouseRight)) (LeftTriggerMouseZeroDown == true)
{
B = true;
//F = true;
G = true;
if (G == true)
{
if (F == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
if (F == false)
{
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
}
}
}
}
if (A == false)
{
if (C == false)
{
if (G == true)
{
if (Input.GetKeyDown(XboxMouseClickWatcher)) //(Input.GetMouseButtonDown(0)) (Input.GetKeyDown(XboxMouseClickWatcher))
{
F = true;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
}
if (Input.GetKeyUp(XboxMouseClickWatcher)) // (Input.GetMouseButtonUp(0)) (Input.GetKeyUp(XboxMouseClickWatcher))
{
F = false;
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
if (LeftTriggerMouseZeroUP == true) //(Input.GetKeyUp(MouseRight)) (LeftTriggerMouseZeroUP == true)
{
B = false;
G = false;
if (F == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (F == false)
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (C == true)
{
D = true;
if (Input.GetKeyUp(XboxMouseClickWatcher)) //(Input.GetMouseButtonUp(0)) (Input.GetKeyUp(XboxMouseClickWatcher))
{
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
H = false;
}
if (Input.GetKeyDown(XboxMouseClickWatcher)) //(Input.GetMouseButtonDown(0)) (Input.GetKeyDown(XboxMouseClickWatcher))
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
H = true;
}
if (LeftTriggerMouseZeroUP == true) //(Input.GetKeyUp(MouseRight)) (LeftTriggerMouseZeroUP == true)
{
D = false;
if (H == true)
{
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (H == false)
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (D == false)
{
if (LeftTriggerMouseZeroDown == true) //(Input.GetKeyDown(MouseRight)) (LeftTriggerMouseZeroDown == true)
{
C = true;
Cursors[0].enabled = false;
Cursors[1].enabled = false;
Cursors[2].enabled = true;
}
if (LeftTriggerMouseZeroUP == true) // (Input.GetKeyUp(MouseRight)) (LeftTriggerMouseZeroUP == true)
{
if (H == true)
{
C = false;
Cursors[0].enabled = false;
Cursors[1].enabled = true;
Cursors[2].enabled = false;
F = false;
}
else
if (H == false)
{
C = false;
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
F = false;
}
}
}
}
}
if (E == true)
{
if (A == true)
{
if (D == true)
{
if (C == true)
{
if (LeftTriggerMouseZeroUP == true) //(Input.GetKeyUp(MouseRight)) (LeftTriggerMouseZeroUP == true)
{
Cursors[0].enabled = true;
Cursors[1].enabled = false;
Cursors[2].enabled = false;
}
}
}
}
}
}
}
}
/////xbox 360 controller mouse click takeover.
using UnityEngine;
using System.Runtime.InteropServices;
using UnityEngine.InputSystem;
using System.Collections.Generic;
using System.Text;
public class XboxJoyMouseClick : MonoBehaviour //StandaloneInputModule
{
public bool useXboXjoyStick = false;
public KeyCode XboxMousClick;
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int X, int Y);
public void Start()
{
SetCursorPos(50, 50);
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown | MouseOperations.MouseEventFlags.LeftUp);
}
public void TurbXboxController()
{
if (useXboXjoyStick == false)
{
useXboXjoyStick = true;
}
}
public void TurnOFFXboxController()
{
if (useXboXjoyStick == true)
{
useXboXjoyStick = false;
}
}
public class MouseOperations
{
[System.Flags]
public enum MouseEventFlags
{
LeftDown = 0x00000002,
LeftUp = 0x00000004,
MiddleDown = 0x00000020,
MiddleUp = 0x00000040,
Move = 0x00000001,
Absolute = 0x00008000,
RightDown = 0x00000008,
RightUp = 0x00000010
}
[DllImport("user32.dll", EntryPoint = "SetCursorPos")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetCursorPos(out MousePoint lpMousePoint);
[DllImport("user32.dll")]
private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
public static void SetCursorPosition(int X, int Y)
{
SetCursorPos(X, Y);
}
public static void SetCursorPosition(MousePoint point)
{
SetCursorPos(point.X, point.Y);
}
public static MousePoint GetCursorPosition()
{
MousePoint currentMousePoint;
var gotPoint = GetCursorPos(out currentMousePoint);
if (!gotPoint) { currentMousePoint = new MousePoint(0, 0); }
return currentMousePoint;
}
public static void MouseEvent(MouseEventFlags value)
{
MousePoint position = GetCursorPosition();
mouse_event
((int)value,
position.X,
position.Y,
0,
0)
;
}
[StructLayout(LayoutKind.Sequential)]
public struct MousePoint
{
public int X;
public int Y;
public MousePoint(int x, int y)
{
X = x;
Y = y;
}
}
}
public void IsMouseActionDown()
{
// if (fakeClick == true)
// {
// Input.GetMouseButtonDown(0);
// fakeClick = false;
// }
}
public void IsMouseActionUP()
{
// Input.GetMouseButtonDown(0);
}
private void Awake()
{
}
void Update()
{
if (useXboXjoyStick == true)
{
if (Input.GetKeyDown(XboxMousClick))
{
MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown | MouseOperations.MouseEventFlags.LeftUp);
Debug.Log("I AM AAAAAAAAAAAAAAAAAAAAAAAA TO CLICK");
Debug.Log("I AM AAAAAAAAAAAAAAAAAAAAAAAA TO CLICK");
Debug.Log("AAAAAAAAAAAAAAAAAAAAAAAA");
}
}
}
}
Files
Get Juneifer n Spock: Pyramids Built By Beetles
Juneifer n Spock: Pyramids Built By Beetles
Juniefer and Spock ; Beetles Built The Pyramids
Leave a comment
Log in with itch.io to leave a comment.