~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/client/lttng/input_receiver_report.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
Import upstream version 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
 
17
 */
 
18
 
 
19
#include "input_receiver_report.h"
 
20
#include "mir/report/lttng/mir_tracepoint.h"
 
21
 
 
22
#include <stdexcept>
 
23
#include <boost/throw_exception.hpp>
 
24
 
 
25
#define TRACEPOINT_DEFINE
 
26
#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
 
27
#include "input_receiver_report_tp.h"
 
28
 
 
29
void mir::client::lttng::InputReceiverReport::received_event(MirEvent const& event)
 
30
{
 
31
    switch (event.type)
 
32
    {
 
33
    case mir_event_type_key:
 
34
        report(event.key);
 
35
        break;
 
36
    case mir_event_type_motion:
 
37
        report(event.motion);
 
38
        break;
 
39
    default:
 
40
        BOOST_THROW_EXCEPTION(std::runtime_error("Unexpected event type"));
 
41
    }
 
42
}
 
43
 
 
44
void mir::client::lttng::InputReceiverReport::report(MirKeyEvent const& event) const
 
45
{
 
46
    mir_tracepoint(mir_client_input_receiver, key_event, event.device_id, event.source_id,
 
47
                   static_cast<int>(event.action), static_cast<int>(event.flags), event.modifiers, event.key_code,
 
48
                   event.scan_code, event.down_time, event.event_time);
 
49
}
 
50
 
 
51
void mir::client::lttng::InputReceiverReport::report(MirMotionEvent const& event) const
 
52
{
 
53
    mir_tracepoint(mir_client_input_receiver, motion_event, event.device_id, event.source_id, event.action,
 
54
                   static_cast<int>(event.flags), event.modifiers, event.edge_flags,
 
55
                   static_cast<int>(event.button_state), event.down_time, event.event_time);
 
56
    for (unsigned int i = 0; i < event.pointer_count; i++)
 
57
    {
 
58
        mir_tracepoint(mir_client_input_receiver, motion_event_coordinate,
 
59
                       event.pointer_coordinates[i].id, event.pointer_coordinates[i].x, event.pointer_coordinates[i].y,
 
60
                       event.pointer_coordinates[i].touch_major, event.pointer_coordinates[i].touch_minor,
 
61
                       event.pointer_coordinates[i].size, event.pointer_coordinates[i].pressure,
 
62
                       event.pointer_coordinates[i].orientation);
 
63
    }
 
64
}
 
65