by Spike » Sat Mar 29, 2014 8:17 pm
if your CSQC_InputEvent function returns true, the engine will not do anything further with the input.
a touch event will appear as:
IE_MOUSEABS+IE_KEYDOWN(mouse1)+IE_MOUSEABS+...IE_MOUSEABS+IE_KEYUP(mouse1)
vector fingers[8];
float(float evtype, float scanx, float chary, float devid) CSQC_InputEvent =
{
if (evtype == IE_MOUSEABS)
{
fingers[devid&7][0] = scanx;
fingers[devid&7][1] = chary;
}
else if (evtype == IE_MOUSEDELTA)
{
print("Oh noes! everyone panic! Its a mouse! Quick! Kill it!\n");
}
else if (evtype == IE_KEYDOWN && scanx == K_MOUSE1)
{
print(sprintf("finger %f was pressed at %f %f\n", devid, fingers[devid&7][0], fingers[devid&7][1]));
}
else if (evtype == IE_KEYUP && scanx == K_MOUSE1)
{
print(sprintf("finger %f was released at %f %f\n", devid, fingers[devid&7][0], fingers[devid&7][1]));
}
else return FALSE; //don't handle the event if we don't know what it is. note that this includes non-mouse1 keys, so binds for the volumeup/volumedown keys on various phones will still function as a standard key bind.
return TRUE; //stop the engine from doing any binds or whatever.
};
touch events are implemented using the same api as mice (really it should use K_TOUCH instead of K_MOUSE1 or something). all touch events use absolute coords.
you can track each finger separately by using the 'devid' value. from the down event to the up event, a single finger moving across the touchscreen will retain the same devid value. It will be recycled on the up event.
If you return false, the engine will carry out its default behaviour. you may still receive movement and release events while the menu or console is visible, but press events will be swallowed by whatever has priority focus over the game. Be careful with blocking keys as killing apps can be a pain on android - you might want to do your prototyping using '_windowed_mouse 0;vid_fullscreen 0' on a desktop instead, where shift+escape cannot be blocked and will always get at the console if you break your menu somehow.
on windows, you can additionally use 'in_simulatemultitouch 1; in_rawinput 1; in_restart' and that should result in one cursor for each mouse plugged into the system.
.