Ubuntu Pastebin

Paste from bschaefer at Mon, 9 Nov 2015 19:57:08 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
static void
HandleTouchEvent(MirTouchEvent const* touch, int device_id, SDL_Window* sdl_window)
{
    int i, point_count;
    point_count = MIR_mir_touch_event_point_count(touch);

    for (i = 0; i < point_count; i++) {
        int id = MIR_mir_touch_event_id(touch, i);

        int width  = sdl_window->w;
        int height = sdl_window->h;

        float x = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_x);
        float y = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_y);

        float n_x = x / width;
        float n_y = y / height;

        float pressure = MIR_mir_touch_event_axis_value(touch, i, mir_touch_axis_pressure);

        AddTouchDevice(device_id);

        switch (MIR_mir_touch_event_action(touch, i)) {
            case mir_touch_action_up:
                HandleTouchPress(device_id, id, SDL_TRUE, n_x, n_y, pressure);
                break;
            case mir_touch_action_down:
                HandleTouchPress(device_id, id, SDL_FALSE, n_x, n_y, pressure);
                break;
            case mir_touch_action_change:
                HandleTouchMotion(device_id, id, n_x, n_y, pressure);
                break;
        }
    }
}
Download as text