2 * Copyright (C) 2013 Canonical Ltd
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 * Ricardo Salveti de Araujo <ricardo.salveti@canonical.com>
25 #include <hybris/input/input_stack_compatibility_layer.h>
29 void signal_handler(int sig
)
34 void on_new_event(struct Event
* event
, void* context
)
36 printf("%s", __PRETTY_FUNCTION__
);
38 printf("\tEventType: %d \n", event
->type
);
39 printf("\tdevice_id: %d \n", event
->device_id
);
40 printf("\tsource_id: %d \n", event
->source_id
);
41 printf("\taction: %d \n", event
->action
);
42 printf("\tflags: %d \n", event
->flags
);
43 printf("\tmeta_state: %d \n", event
->meta_state
);
45 switch (event
->type
) {
46 case MOTION_EVENT_TYPE
:
47 printf("\tdetails.motion.event_time: %lld\n",
48 event
->details
.motion
.event_time
);
49 printf("\tdetails.motion.pointer_coords.x: %f\n",
50 event
->details
.motion
.pointer_coordinates
[0].x
);
51 printf("\tdetails.motion.pointer_coords.y: %f\n",
52 event
->details
.motion
.pointer_coordinates
[0].y
);
59 int main(int argc
, char** argv
)
62 signal(SIGINT
, signal_handler
);
64 struct AndroidEventListener listener
;
65 listener
.on_new_event
= on_new_event
;
66 listener
.context
= NULL
;
68 struct InputStackConfiguration config
= {
69 enable_touch_point_visualization
: true,
70 default_layer_for_touch_point_visualization
: 10000,
71 input_area_width
: 1024,
72 input_area_height
: 1024
75 android_input_stack_initialize(&listener
, &config
);
76 android_input_stack_start_waiting_for_flag(&g_stop
);
78 android_input_stack_stop();
79 android_input_stack_shutdown();