Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / events / ozone / evdev / event_device_info.cc
index 9621646..858f57c 100644 (file)
@@ -14,8 +14,6 @@ namespace ui {
 namespace {
 
 bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) {
-  base::ThreadRestrictions::AssertIOAllowed();
-
   if (ioctl(fd, EVIOCGBIT(type, size), buf) < 0) {
     DLOG(ERROR) << "failed EVIOCGBIT(" << type << ", " << size << ") on fd "
                 << fd;
@@ -26,8 +24,6 @@ bool GetEventBits(int fd, unsigned int type, void* buf, unsigned int size) {
 }
 
 bool GetPropBits(int fd, void* buf, unsigned int size) {
-  base::ThreadRestrictions::AssertIOAllowed();
-
   if (ioctl(fd, EVIOCGPROP(size), buf) < 0) {
     DLOG(ERROR) << "failed EVIOCGPROP(" << size << ") on fd " << fd;
     return false;
@@ -40,6 +36,14 @@ bool BitIsSet(const unsigned long* bits, unsigned int bit) {
   return (bits[bit / EVDEV_LONG_BITS] & (1UL << (bit % EVDEV_LONG_BITS)));
 }
 
+bool GetAbsInfo(int fd, int code, struct input_absinfo* absinfo) {
+  if (ioctl(fd, EVIOCGABS(code), absinfo)) {
+    DLOG(ERROR) << "failed EVIOCGABS(" << code << ") on fd " << fd;
+    return false;
+  }
+  return true;
+}
+
 }  // namespace
 
 EventDeviceInfo::EventDeviceInfo() {
@@ -51,6 +55,7 @@ EventDeviceInfo::EventDeviceInfo() {
   memset(sw_bits_, 0, sizeof(sw_bits_));
   memset(led_bits_, 0, sizeof(led_bits_));
   memset(prop_bits_, 0, sizeof(prop_bits_));
+  memset(abs_info_, 0, sizeof(abs_info_));
 }
 
 EventDeviceInfo::~EventDeviceInfo() {}
@@ -80,6 +85,11 @@ bool EventDeviceInfo::Initialize(int fd) {
   if (!GetPropBits(fd, prop_bits_, sizeof(prop_bits_)))
     return false;
 
+  for (unsigned int i = 0; i < ABS_CNT; ++i)
+    if (HasAbsEvent(i))
+      if (!GetAbsInfo(fd, i, &abs_info_[i]))
+        return false;
+
   return true;
 }
 
@@ -131,4 +141,12 @@ bool EventDeviceInfo::HasProp(unsigned int code) const {
   return BitIsSet(prop_bits_, code);
 }
 
+int32 EventDeviceInfo::GetAbsMinimum(unsigned int code) const {
+  return abs_info_[code].minimum;
+}
+
+int32 EventDeviceInfo::GetAbsMaximum(unsigned int code) const {
+  return abs_info_[code].maximum;
+}
+
 }  // namespace ui