mod_multi example

I've had some multitouch sample code lying around for quite some time. I believe some of you might find it useful:
/**
 * Android test
 * Joseba GarcĂ­a Etxebarria - (C) 2012
 * Use as you wish
 */

import "mod_video"
import "mod_text"
import "mod_mouse"
import "mod_sound"
import "mod_wm"
import "mod_map"
import "mod_draw"
import "mod_say"
import "mod_file"
import "mod_text"
import "mod_multi"

GLOBAL
// Set to your device's native resolution
width  = SET ME;
height = SET ME;

Process Main()
Private
int song=0, num_fingers=0, i=0;

Begin
    set_mode(width, height, 32, MODE_FULLSCREEN|MODE_FRAMELESS);
   
    write(0, 0, 0, 0, "Width: "+width+" Height:"+height);
   
    graph = map_new(width, height, 16);
    x = width/2; y = height/2;

    write_var(0, 0, height, 6, num_fingers);
    drawing_map(0, graph);
    drawing_color(rgb(0, 255, 255));

    while(num_fingers != 5)
        // Store the total amount of fingers touching the screen
        num_fingers = multi_numpointers();
       
        for(i=0; i<10; i++)
            if(multi_info(i, "ACTIVE") > 0.0)
                draw_fcircle(multi_info(i, "Y"),
                             multi_info(i, "X"), 5);
                say_fast("Drawing fcircle for pointer "+i+" @ "+
                             multi_info(i, "Y")+
                         "x"+multi_info(i, "X")+
                         " active:"+multi_info(i, "ACTIVE"));
            end;
        end;

        frame;
    End;

    unload_map(0, graph);

    say("Quitting");
End;
As you can see, what this code does is paint a circle at the same position as you place your fingers.
t also writes the total number of screens as detected on the screen. IT'll qut when you place all the five fingers in your device's screen.

0 komentar:

Post a Comment

Blog Archive