From 6b5bf35584363984387b779c246b9aaa82600078 Mon Sep 17 00:00:00 2001 From: otya128 Date: Sun, 11 Dec 2016 20:44:07 +0900 Subject: [PATCH] Fix TOUCH --- SMILEBASIC/builtinfunctions.d | 12 ++++++++++-- SMILEBASIC/petitcomputer.d | 16 ++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 09f20cf..b39048e 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -340,8 +340,16 @@ class BuiltinFunction { auto pos = p.touchPosition; tm = pos.tm; - tchx = pos.x; - tchy = pos.y; + if (p.x.mode == PetitComputer.XMode.WIIU) + { + tchx = pos.display1X; + tchy = pos.display1Y; + } + else + { + tchx = pos.x; + tchy = pos.y; + } } static void TOUCH(PetitComputer p, int id, out int tm, out int tchx, out int tchy) { diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index db8a3bc..cfb1f1b 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -754,14 +754,14 @@ class PetitComputer { auto w = currentDisplay.rect[0].w; auto h = currentDisplay.rect[0].h; - auto x3DS = cast(int)(mousex * (cast(float)w / screenWidthDisplay1)); - auto y3DS = cast(int)(mousey * (cast(float)h / screenHeightDisplay1)); - auto gamepadx = cast(int)(mousex * (cast(float)w / 854)); - auto gamepady = cast(int)(mousey * (cast(float)h / 480)); + auto x3DS = cast(int)(mousex * (screenWidthDisplay1 / cast(float)w)); + auto y3DS = cast(int)(mousey * (screenHeightDisplay1 / cast(float)h)); + auto gamepadx = cast(int)(mousex * (854 / cast(float)w)); + auto gamepady = cast(int)(mousey * (480 / cast(float)h)); touchPosition = Touch(old.tm + 1, x3DS.clamp(5, 314), y3DS.clamp(5, 234), - gamepadx.clamp(8, 854 - 8), gamepady.clamp(8, 480 - 8), - mousex, mousey); + gamepadx.clamp(8, 854 - 9), gamepady.clamp(8, 480 - 9), + mousex.clamp(8, w - 9), mousey.clamp(8, h - 9)); } else { @@ -777,8 +777,8 @@ class PetitComputer auto gamepady = cast(int)(mousey * (480 / cast(float)h)); touchPosition = Touch(old.tm + 1, x3DS.clamp(5, 314), y3DS.clamp(5, 234), - gamepadx.clamp(8, 854 - 8), gamepady.clamp(8, 480 - 8), - mousex, mousey); + gamepadx.clamp(8, 854 - 9), gamepady.clamp(8, 480 - 9), + mousex.clamp(8, w - 9), mousey.clamp(8, h - 9)); } } }