From bd146b465a9489c6dcfd8748f95036e80fa5d17d Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sun, 8 Jan 2023 20:09:50 +0100 Subject: [PATCH] Fix in positions of term and mouse events --- Capy64/Eventing/InputManager.cs | 4 ++-- Capy64/LuaRuntime/Libraries/Term.cs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Capy64/Eventing/InputManager.cs b/Capy64/Eventing/InputManager.cs index 1606981..5dc2d58 100644 --- a/Capy64/Eventing/InputManager.cs +++ b/Capy64/Eventing/InputManager.cs @@ -99,12 +99,12 @@ public class InputManager if (pos != mousePosition) { + mousePosition = pos + new Point(1, 1); _eventEmitter.RaiseMouseMove(new() { - Position = pos, + Position = mousePosition, PressedButtons = mouseButtonStates.Where(q => q.Value == ButtonState.Pressed).Select(q => (int)q.Key).ToArray() }); - mousePosition = pos; } int vValue = 0; diff --git a/Capy64/LuaRuntime/Libraries/Term.cs b/Capy64/LuaRuntime/Libraries/Term.cs index 396bceb..0eb22a6 100644 --- a/Capy64/LuaRuntime/Libraries/Term.cs +++ b/Capy64/LuaRuntime/Libraries/Term.cs @@ -453,8 +453,8 @@ internal class Term : IPlugin var x = (int)L.CheckNumber(1); var y = (int)L.CheckNumber(2); - L.PushInteger(x * CharWidth); - L.PushInteger(y * CharHeight); + L.PushInteger(x * CharWidth - CharWidth + 1); + L.PushInteger(y * CharHeight - CharHeight + 1); return 2; } @@ -463,11 +463,11 @@ internal class Term : IPlugin { var L = Lua.FromIntPtr(state); - var x = (int)L.CheckNumber(1); - var y = (int)L.CheckNumber(2); + var x = (int)L.CheckNumber(1) - 1; + var y = (int)L.CheckNumber(2) - 1; - L.PushInteger(x / CharWidth); - L.PushInteger(y / CharHeight); + L.PushInteger(x / CharWidth + 1); + L.PushInteger(y / CharHeight + 1); return 2; }