Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Core_GamepadSupport/Gamepad/CursorEmulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static void OnUpdate()

if (EmulatingCursor())
{
Cursor.visible = false;
var rightStick = GamepadWhisperer.GetRightStick();
if (rightStick.magnitude > 0)
{
Expand All @@ -92,6 +93,10 @@ public static void OnUpdate()
if (scrollAmount != 0)
Native.mouse_event(Native.MOUSEEVENTF_WHEEL, 0, 0, scrollAmount, 0);
}
else
{
Cursor.visible = true;
}

_previousR = rPressed;
_previousL = lPressed;
Expand Down
3 changes: 3 additions & 0 deletions Core_GamepadSupport/Navigation/CanvasCharmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ private void OnGUI()

if (GamepadSupportPlugin.CanvasDebug.Value)
DrawCanvasList(currentSelectedGameObject);

if (!Cursor.visible)
CursorDrawer.DrawMousePointer(Input.mousePosition);
}

private void Update()
Expand Down
10 changes: 10 additions & 0 deletions Core_GamepadSupport/Navigation/CursorDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ namespace KK_GamepadSupport.Navigation
public class CursorDrawer
{
private Texture2D _pointer;
private Texture2D _mousePointer;

public void LoadTexture()
{
_pointer = ResourceUtils.GetEmbeddedResource("pointer.png", typeof(CursorDrawer).Assembly).LoadTexture();
_mousePointer = ResourceUtils.GetEmbeddedResource("pointer.png", typeof(CursorDrawer).Assembly).LoadTexture();

const int idealResolutionH = 1800;

Expand All @@ -19,6 +21,9 @@ public void LoadTexture()
var scaleFactor = (float)Screen.height / idealResolutionH;
TextureScale.Bilinear(_pointer, (int)(_pointer.width * scaleFactor), (int)(_pointer.height * scaleFactor));
_pointer.Apply(false);

TextureScale.Bilinear(_mousePointer, (int)(_mousePointer.width * scaleFactor), (int)(_mousePointer.height * scaleFactor));
_mousePointer.Apply(false);
}
}

Expand Down Expand Up @@ -61,6 +66,11 @@ public void Draw(Vector2 pixelPosition, bool poke)
GUI.Label(new Rect(Mathf.Max(0, pixelPosition.x - _pointer.width) + offset, pixelPosition.y - _pointer.height / 3f, _pointer.width, _pointer.height), _pointer);
}

public void DrawMousePointer(Vector3 mousePosition)
{
GUI.Label(new Rect(mousePosition.x - _mousePointer.width / 2, Screen.height - mousePosition.y - _mousePointer.height / 2, _mousePointer.width, _mousePointer.height), _mousePointer);
}

private static Rect RectTransformToScreenSpace(RectTransform transform)
{
var size = Vector2.Scale(transform.rect.size, transform.lossyScale);
Expand Down