Fix touch
This commit is contained in:
@@ -741,51 +741,33 @@ class PetitComputer
|
|||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
auto renderticks = (SDL_GetTicks() - profile);
|
||||||
auto renderticks = (SDL_GetTicks() - profile);
|
if(renderprofile) writeln(renderticks);
|
||||||
if(renderprofile) writeln(renderticks);
|
int mousex, mousey;
|
||||||
int mousex, mousey;
|
if (SDL_GetMouseState(&mousex, &mousey) & SDL_BUTTON_LMASK)
|
||||||
if (SDL_GetMouseState(&mousex, &mousey) & SDL_BUTTON_LMASK)
|
|
||||||
{
|
|
||||||
mousex = cast(int)(mousex / scaleX);
|
|
||||||
mousey = cast(int)(mousey / scaleY);
|
|
||||||
import std.algorithm.comparison : clamp;
|
|
||||||
auto old = touchPosition;
|
|
||||||
if (x.mode != XMode.WIIU)
|
|
||||||
{
|
{
|
||||||
if (mousey >= screenHeight)
|
mousex = cast(int)(mousex / scaleX);
|
||||||
|
mousey = cast(int)(mousey / scaleY);
|
||||||
|
import std.algorithm.comparison : clamp;
|
||||||
|
auto old = touchPosition;
|
||||||
|
if (x.mode != XMode.WIIU)
|
||||||
{
|
{
|
||||||
mousey -= screenHeight;
|
if (mousey >= screenHeight)
|
||||||
mousex -= (screenWidth - screenWidthDisplay1) / 2;
|
{
|
||||||
}
|
mousey -= screenHeight;
|
||||||
mousex = mousex.clamp(5, 314);
|
mousex -= (screenWidth - screenWidthDisplay1) / 2;
|
||||||
mousey = mousey.clamp(5, 234);
|
}
|
||||||
touchPosition = Touch(old.tm + 1, mousex, mousey);
|
mousex = mousex.clamp(5, 314);
|
||||||
}
|
mousey = mousey.clamp(5, 234);
|
||||||
else
|
touchPosition = Touch(old.tm + 1, mousex, mousey);
|
||||||
{
|
|
||||||
//!!WiiU
|
|
||||||
if (xscreenmode == 3)//XSCREEN 5
|
|
||||||
{
|
|
||||||
auto w = currentDisplay.rect[0].w;
|
|
||||||
auto h = currentDisplay.rect[0].h;
|
|
||||||
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 - 9), gamepady.clamp(8, 480 - 9),
|
|
||||||
mousex.clamp(8, w - 13), mousey.clamp(8, h - 9));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto w = currentDisplay.rect[1].w;
|
//!!WiiU
|
||||||
auto h = currentDisplay.rect[1].h;
|
if (xscreenmode == 3)//XSCREEN 5
|
||||||
mousex -= currentDisplay.rect[1].x;
|
|
||||||
mousey -= currentDisplay.rect[1].y;
|
|
||||||
if (mousex >= 0 && mousey >= 0)
|
|
||||||
{
|
{
|
||||||
|
auto w = currentDisplay.rect[0].w;
|
||||||
|
auto h = currentDisplay.rect[0].h;
|
||||||
auto x3DS = cast(int)(mousex * (screenWidthDisplay1 / cast(float)w));
|
auto x3DS = cast(int)(mousex * (screenWidthDisplay1 / cast(float)w));
|
||||||
auto y3DS = cast(int)(mousey * (screenHeightDisplay1 / cast(float)h));
|
auto y3DS = cast(int)(mousey * (screenHeightDisplay1 / cast(float)h));
|
||||||
auto gamepadx = cast(int)(mousex * (854 / cast(float)w));
|
auto gamepadx = cast(int)(mousex * (854 / cast(float)w));
|
||||||
@@ -793,16 +775,34 @@ class PetitComputer
|
|||||||
touchPosition = Touch(old.tm + 1,
|
touchPosition = Touch(old.tm + 1,
|
||||||
x3DS.clamp(5, 314), y3DS.clamp(5, 234),
|
x3DS.clamp(5, 314), y3DS.clamp(5, 234),
|
||||||
gamepadx.clamp(8, 854 - 9), gamepady.clamp(8, 480 - 9),
|
gamepadx.clamp(8, 854 - 9), gamepady.clamp(8, 480 - 9),
|
||||||
mousex.clamp(12, w - 13), mousey.clamp(8, h - 9));
|
mousex.clamp(8, w - 13), mousey.clamp(8, h - 9));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto w = currentDisplay.rect[1].w;
|
||||||
|
auto h = currentDisplay.rect[1].h;
|
||||||
|
mousex -= currentDisplay.rect[1].x;
|
||||||
|
mousey -= currentDisplay.rect[1].y;
|
||||||
|
if (mousex >= 0 && mousey >= 0)
|
||||||
|
{
|
||||||
|
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 - 9), gamepady.clamp(8, 480 - 9),
|
||||||
|
mousex.clamp(12, w - 13), mousey.clamp(8, h - 9));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
if (touchPosition.tm)
|
|
||||||
{
|
{
|
||||||
touchPosition = Touch(0, mousex, mousey);
|
if (touchPosition.tm)
|
||||||
|
{
|
||||||
|
touchPosition = Touch(0, mousex, mousey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
|
|||||||
Reference in New Issue
Block a user