+ // Initialize Xi2 system
+ Display* display = static_cast< Display* >(ecore_x_display_get());
+ Ecore_X_Window rootWindow = ecore_x_window_root_first_get();
+ int opcode = 0, event = 0, error = 0;
+ int major = XI_2_Major;
+ int minor = XI_2_Minor;
+ int deviceCount = 0;
+ XIEventMask xiEventMask;
+
+ // Check if X input extension available
+ if( XQueryExtension( display, "XInputExtension", &opcode, &event, &error ) )
+ {
+ // We support version 2.0
+ if( XIQueryVersion( display, &major, &minor ) != BadRequest )
+ {
+ xiEventMask.deviceid = XIAllDevices;
+
+ // Check device id
+ bool match = false;
+ XIDeviceInfo* deviceInfo = NULL;
+ deviceInfo = XIQueryDevice( display, XIAllDevices, &deviceCount );
+
+ for( int i = 0; i < deviceCount; i++ )
+ {
+ if( !strncmp( deviceInfo[i].name, DETENT_DEVICE_NAME, strlen( DETENT_DEVICE_NAME ) ) )
+ {
+ xiEventMask.deviceid = deviceInfo[i].deviceid;
+ match = true;
+ break;
+ }
+ }
+
+ if( match )
+ {
+ mXiDeviceId = xiEventMask.deviceid;
+
+ // SelectXi2Event
+ xiEventMask.mask = (unsigned char*)(calloc( 1, XIMaskLen( XI_LASTEVENT ) ) );
+ XISetMask( xiEventMask.mask, XI_RawMotion );
+
+ xiEventMask.mask_len = sizeof( xiEventMask.mask );
+
+ int ret = XISelectEvents( display, rootWindow, &xiEventMask, 1 );
+ if( ret == 0 )
+ {
+ // Register custom wheel events
+ mEcoreEventHandler.push_back( ecore_event_handler_add( ECORE_X_EVENT_GENERIC, EcoreEventCustomWheel, handler ) );
+ }
+ else
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to Select Events\n" );
+ }
+ }
+ }
+ else
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to query XI Version\n" );
+ }
+ }
+ else
+ {
+ DALI_LOG_INFO( gImfLogging, Debug::General, "Failed to query XInputExtension\n" );
+ }
+