Multitouch for Windows Phone
Monkey Targets Forums/XNA/Multitouch for Windows Phone| 
 | ||
| I've managed to implement multitouch for Windows Phone. You need to do the following: In program.cs (targets\xna\MonkeyGame\MonkeyGame) add the following: using Microsoft.Xna.Framework.Input.Touch; You will also need to add a reference to Microsoft.Xna.Framework.Input.Touch In mojo.xna.cs (modules\mojo\native) add the following: Line 841: public TouchCollection touchState; Line 851: public int[] touches=new int[32]; public float[] touchX=new float[32]; public float[] touchY=new float[32]; Line 965: 
//Update touch
touchState = TouchPanel.GetState();
for (int i = 0; i < 32; ++i)
{
    touches[i] = -1;
    touchX[i] = (i == 0 ? mouseState.X : 0);
    touchY[i] = (i == 0 ? mouseState.Y : 0);
    keyStates[KEY_TOUCH0 + i] = 0;
    if (i <= touchState.Count - 1)
    {
        TouchLocation tl = touchState[i];
        if ((tl.State == TouchLocationState.Pressed) || (tl.State == TouchLocationState.Moved))
        {
            touches[i] = tl.Id;
            touchX[i] = tl.Position.X;
            touchY[i] = tl.Position.Y;
            keyStates[KEY_TOUCH0 + i] = 0x101;
        }
    }
}
Line 1118(Replace the following): 
public virtual float TouchX( int index ){
	return touchX[index];
	//return mouseState.X;
}
public virtual float TouchY( int index ){
	return touchY[index];
	//return mouseState.Y;
}
At this stage the touches array probably isn't used - was trying to code what I thought based on some other modules. Also probably missed something somewhere! You can test it out with the following (edited TouchDown function example from the on-line help): 
Import mojo
Class MyApp Extends App
Field touching
Method OnCreate()
        SetUpdateRate 30
    End
Method OnUpdate()
        touching=0
        For Local i=0 Until 32
            If TouchDown( i ) touching+=1
        Next
    End
Method OnRender()
        Cls
        DrawText touching,0,0
		
		For Local i=0 Until 32
			If (TouchDown(i)) Then
				DrawCircle(TouchX(i),TouchY(i),30)
					
			EndIf
		
		Next
		
    End
End
Function Main()
    New MyApp
End
 |