Implement TOUCH
This commit is contained in:
@@ -305,9 +305,10 @@ class BuiltinFunction
|
|||||||
{
|
{
|
||||||
writeln("NOTIMPL:TOUCH MPID");
|
writeln("NOTIMPL:TOUCH MPID");
|
||||||
}
|
}
|
||||||
tm = 0;
|
auto pos = p.touchPosition;
|
||||||
tchx = 0;
|
tm = pos.tm;
|
||||||
tchy = 0;
|
tchx = pos.x;
|
||||||
|
tchy = pos.y;
|
||||||
}
|
}
|
||||||
static void XSCREEN(PetitComputer p, int mode, DefaultValue!(int, false) a, DefaultValue!(int, false) b)
|
static void XSCREEN(PetitComputer p, int mode, DefaultValue!(int, false) a, DefaultValue!(int, false) b)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -465,6 +465,28 @@ class PetitComputer
|
|||||||
protected BG[4] bg;
|
protected BG[4] bg;
|
||||||
bool quit;
|
bool quit;
|
||||||
Condition renderCondition;
|
Condition renderCondition;
|
||||||
|
struct Touch
|
||||||
|
{
|
||||||
|
int tm;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
};
|
||||||
|
Object touchSync = new Object();
|
||||||
|
Touch m_touch;
|
||||||
|
Touch touchPosition()
|
||||||
|
{
|
||||||
|
synchronized(touchSync)
|
||||||
|
{
|
||||||
|
return m_touch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void touchPosition(Touch to)
|
||||||
|
{
|
||||||
|
synchronized(touchSync)
|
||||||
|
{
|
||||||
|
m_touch = to;
|
||||||
|
}
|
||||||
|
}
|
||||||
void render()
|
void render()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -680,6 +702,19 @@ class PetitComputer
|
|||||||
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;
|
||||||
|
if (SDL_GetMouseState(&mousex, &mousey) & SDL_BUTTON_LMASK)
|
||||||
|
{
|
||||||
|
auto old = touchPosition;
|
||||||
|
touchPosition = Touch(old.tm + 1, mousex, mousey);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (touchPosition.tm)
|
||||||
|
{
|
||||||
|
touchPosition = Touch(0, mousex, mousey);
|
||||||
|
}
|
||||||
|
}
|
||||||
while (SDL_PollEvent(&event))
|
while (SDL_PollEvent(&event))
|
||||||
{
|
{
|
||||||
switch (event.type)
|
switch (event.type)
|
||||||
|
|||||||
Reference in New Issue
Block a user