~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to tests/interactive/test-devices.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
} TestDevicesApp;
11
11
 
12
 
 
 
12
static const gchar *
 
13
device_type_name (ClutterInputDevice *device)
 
14
{
 
15
  ClutterInputDeviceType d_type;
 
16
 
 
17
  d_type = clutter_input_device_get_device_type (device);
 
18
  switch (d_type)
 
19
    {
 
20
    case CLUTTER_POINTER_DEVICE:
 
21
      return "Pointer";
 
22
 
 
23
    case CLUTTER_KEYBOARD_DEVICE:
 
24
      return "Keyboard";
 
25
 
 
26
    case CLUTTER_EXTENSION_DEVICE:
 
27
      return "Extension";
 
28
 
 
29
    default:
 
30
      return "Unknown";
 
31
    }
 
32
 
 
33
  g_warn_if_reached ();
 
34
 
 
35
  return NULL;
 
36
}
13
37
 
14
38
static gboolean
15
39
stage_motion_event_cb (ClutterActor *actor, 
24
48
 
25
49
  hand = g_hash_table_lookup (app->devices, device);
26
50
 
 
51
  g_print ("Device: '%s' (id:%d, type:%s)\n",
 
52
           clutter_input_device_get_device_name (device),
 
53
           clutter_input_device_get_device_id (device),
 
54
           device_type_name (device));
 
55
 
27
56
  if (hand != NULL)
28
57
    {
29
58
      gfloat event_x, event_y;
43
72
  ClutterActor *stage;
44
73
  TestDevicesApp *app;
45
74
  ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
 
75
  ClutterDeviceManager *manager;
46
76
  const GSList *stage_devices, *l;
47
77
 
48
78
  /* force enabling X11 support */
63
93
 
64
94
  clutter_actor_show_all (stage);
65
95
 
66
 
  stage_devices = clutter_x11_get_input_devices ();
 
96
  manager = clutter_device_manager_get_default ();
 
97
  stage_devices = clutter_device_manager_peek_devices (manager);
67
98
 
68
99
  if (stage_devices == NULL)
69
 
    g_error ("No extended input devices found.");
 
100
    g_error ("No input devices found.");
70
101
 
71
102
  for (l = stage_devices; l != NULL; l = l->next)
72
103
    {
74
105
      ClutterInputDeviceType device_type;
75
106
      ClutterActor *hand = NULL;
76
107
 
 
108
      g_print ("got a %s device '%s' with id %d...\n",
 
109
               device_type_name (device),
 
110
               clutter_input_device_get_device_name (device),
 
111
               clutter_input_device_get_device_id (device));
 
112
 
77
113
      device_type = clutter_input_device_get_device_type (device);
78
 
      if (device_type  == CLUTTER_POINTER_DEVICE)
 
114
      if (device_type == CLUTTER_POINTER_DEVICE ||
 
115
          device_type == CLUTTER_EXTENSION_DEVICE)
79
116
        {
80
 
          g_print ("got a pointer device with id %d...\n",
81
 
                   clutter_input_device_get_device_id (device));
82
 
 
83
 
          hand = clutter_texture_new_from_file ("redhand.png", NULL);
 
117
          hand = clutter_texture_new_from_file (TESTS_DATADIR
 
118
                                                G_DIR_SEPARATOR_S
 
119
                                                "redhand.png",
 
120
                                                NULL);
84
121
          g_hash_table_insert (app->devices, device, hand);
85
122
 
86
123
          clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);