Blame SOURCES/0007-begin-work-on-input-devices.patch

121cca
From 691ed58e2838ca3e50e899f013e259ea84f6bfe9 Mon Sep 17 00:00:00 2001
121cca
From: Lyonel Vincent <lyonel@ezix.org>
121cca
Date: Wed, 1 Apr 2020 00:43:15 +0200
121cca
Subject: [PATCH 07/65] begin work on input devices
121cca
121cca
still missing:
121cca
 * capabilities
121cca
 * properties
121cca
 * report at least as much information as /proc/bus/input/devices
121cca
---
121cca
 src/core/hw.cc    |   2 +-
121cca
 src/core/input.cc | 146 ++++++++++++++++++++++++++++++++++++++++++++++
121cca
 src/core/input.h  |   8 +++
121cca
 src/core/main.cc  |   4 ++
121cca
 5 files changed, 160 insertions(+), 2 deletions(-)
121cca
 create mode 100644 src/core/input.cc
121cca
 create mode 100644 src/core/input.h
121cca
121cca
diff --git a/src/core/hw.cc b/src/core/hw.cc
121cca
index a592730..f7da370 100644
121cca
--- a/src/core/hw.cc
121cca
+++ b/src/core/hw.cc
121cca
@@ -1083,7 +1083,7 @@ void hwNode::setLogicalName(const string & name)
121cca
       This->logicalnames.push_back("/dev/" + n);
121cca
     }
121cca
     else
121cca
-      This->logicalnames.push_back(n);
121cca
+      This->logicalnames.push_back(basename(n.c_str()));
121cca
 
121cca
     if(This->dev == "")
121cca
       This->dev = get_devid(n);
121cca
diff --git a/src/core/input.cc b/src/core/input.cc
121cca
new file mode 100644
121cca
index 0000000..1f14fa9
121cca
--- /dev/null
121cca
+++ b/src/core/input.cc
121cca
@@ -0,0 +1,146 @@
121cca
+#include "version.h"
121cca
+#include "hw.h"
121cca
+#include "sysfs.h"
121cca
+#include "osutils.h"
121cca
+#include "input.h"
121cca
+#include "disk.h"
121cca
+#include "heuristics.h"
121cca
+
121cca
+#include <vector>
121cca
+#include <iostream>
121cca
+
121cca
+__ID("@(#) $Id$");
121cca
+
121cca
+#define BUS_PCI                 0x01
121cca
+#define BUS_ISAPNP              0x02
121cca
+#define BUS_USB                 0x03
121cca
+#define BUS_HIL                 0x04
121cca
+#define BUS_BLUETOOTH           0x05
121cca
+#define BUS_VIRTUAL             0x06
121cca
+
121cca
+#define BUS_ISA                 0x10
121cca
+#define BUS_I8042               0x11
121cca
+#define BUS_XTKBD               0x12
121cca
+#define BUS_RS232               0x13
121cca
+#define BUS_GAMEPORT            0x14
121cca
+#define BUS_PARPORT             0x15
121cca
+#define BUS_AMIGA               0x16
121cca
+#define BUS_ADB                 0x17
121cca
+#define BUS_I2C                 0x18
121cca
+#define BUS_HOST                0x19
121cca
+#define BUS_GSC                 0x1A
121cca
+#define BUS_ATARI               0x1B
121cca
+#define BUS_SPI                 0x1C
121cca
+#define BUS_RMI                 0x1D
121cca
+#define BUS_CEC                 0x1E
121cca
+#define BUS_INTEL_ISHTP         0x1F
121cca
+
121cca
+using namespace std;
121cca
+
121cca
+bool scan_input(hwNode & n)
121cca
+{
121cca
+  vector < sysfs::entry > entries = sysfs::entries_by_class("input");
121cca
+
121cca
+  if (entries.empty())
121cca
+    return false;
121cca
+
121cca
+  for (vector < sysfs::entry >::iterator it = entries.begin();
121cca
+      it != entries.end(); ++it)
121cca
+  {
121cca
+    const sysfs::entry & e = *it;
121cca
+
121cca
+    if(!e.hassubdir("id")) continue;
121cca
+
121cca
+    hwNode *device = n.findChildByBusInfo(e.leaf().businfo());
121cca
+    if(!device)
121cca
+      device = n.addChild(hwNode("input", hw::input));
121cca
+    else
121cca
+    {
121cca
+      if(device->getClass() == hw::generic)
121cca
+        device->setClass(hw::input);
121cca
+    }
121cca
+    device->claim();
121cca
+    device->setLogicalName("input/"+e.name());
121cca
+    device->setProduct(e.string_attr("name"));
121cca
+    device->setModalias(e.modalias());
121cca
+    switch(e.hex_attr("id/bustype"))
121cca
+    {
121cca
+      case BUS_PCI:
121cca
+	      device->addCapability("pci", "PCI");
121cca
+	      break;
121cca
+      case BUS_ISAPNP:
121cca
+	      device->addCapability("isa", "ISA");
121cca
+	      device->addCapability("pnp", "PnP");
121cca
+	      break;
121cca
+      case BUS_USB:
121cca
+	      device->addCapability("usb", "USB");
121cca
+	      break;
121cca
+      case BUS_HIL:
121cca
+	      device->addCapability("hil", "HP-HIL");
121cca
+	      break;
121cca
+      case BUS_BLUETOOTH:
121cca
+	      device->addCapability("bt", "Bluetooth");
121cca
+	      break;
121cca
+      case BUS_VIRTUAL:
121cca
+	      device->addCapability("virtual");
121cca
+	      break;
121cca
+      case BUS_ISA:
121cca
+	      device->addCapability("isa", "ISA bus");
121cca
+	      break;
121cca
+      case BUS_I8042:
121cca
+	      device->addCapability("i8042", "i8042 PC AT keyboard controller");
121cca
+	      break;
121cca
+      case BUS_XTKBD:
121cca
+	      device->addCapability("xtkbd", "XT keyboard controller");
121cca
+	      break;
121cca
+      case BUS_RS232:
121cca
+	      device->addCapability("rs232", "RS-232 serial");
121cca
+	      break;
121cca
+      case BUS_GAMEPORT:
121cca
+	      device->addCapability("gameport", "game port");
121cca
+	      break;
121cca
+      case BUS_PARPORT:
121cca
+	      device->addCapability("parport", "parallel port");
121cca
+	      break;
121cca
+      case BUS_AMIGA:
121cca
+	      device->addCapability("amiga", "Amiga bus");
121cca
+	      break;
121cca
+      case BUS_ADB:
121cca
+	      device->addCapability("adb", "Apple Desktop Bus");
121cca
+	      break;
121cca
+      case BUS_I2C:
121cca
+	      device->addCapability("i2c", "I²C bus");
121cca
+	      break;
121cca
+      case BUS_HOST:
121cca
+	      device->addCapability("host");
121cca
+	      break;
121cca
+      case BUS_GSC:
121cca
+	      device->addCapability("gsc", "GSC bus");
121cca
+	      break;
121cca
+      case BUS_ATARI:
121cca
+	      device->addCapability("atari", "Atari bus");
121cca
+	      break;
121cca
+      case BUS_SPI:
121cca
+	      device->addCapability("spi", "SPI");
121cca
+	      break;
121cca
+      case BUS_RMI:
121cca
+	      device->addCapability("rmi", "RMI");
121cca
+	      break;
121cca
+      case BUS_CEC:
121cca
+	      device->addCapability("cec", "CEC");
121cca
+	      break;
121cca
+      case BUS_INTEL_ISHTP:
121cca
+	      device->addCapability("intelishtp", "Intel Integrated Sensor Hub");
121cca
+	      break;
121cca
+    }
121cca
+
121cca
+    vector < sysfs::entry > events = e.devices();
121cca
+    for(vector < sysfs::entry >::iterator i = events.begin(); i != events.end(); ++i)
121cca
+    {
121cca
+      const sysfs::entry & d = *i;
121cca
+      device->setLogicalName("input/"+d.name());
121cca
+    }
121cca
+  }
121cca
+
121cca
+  return true;
121cca
+}
121cca
diff --git a/src/core/input.h b/src/core/input.h
121cca
new file mode 100644
121cca
index 0000000..1bf2383
121cca
--- /dev/null
121cca
+++ b/src/core/input.h
121cca
@@ -0,0 +1,8 @@
121cca
+#ifndef _INPUT_H_
121cca
+#define _INPUT_H_
121cca
+
121cca
+#include "hw.h"
121cca
+
121cca
+bool scan_input(hwNode &);
121cca
+
121cca
+#endif
121cca
diff --git a/src/core/main.cc b/src/core/main.cc
121cca
index d0d7f10..ad0e586 100644
121cca
--- a/src/core/main.cc
121cca
+++ b/src/core/main.cc
121cca
@@ -45,6 +45,7 @@
121cca
 #include "vio.h"
121cca
 #include "nvme.h"
121cca
 #include "mmc.h"
121cca
+#include "input.h"
121cca
 #include "smp.h"
121cca
 #include "abi.h"
121cca
 #include "s390.h"
121cca
@@ -140,6 +141,9 @@ bool scan_system(hwNode & system)
121cca
     status("MMC");
121cca
     if (enabled("mmc"))
121cca
       scan_mmc(computer);
121cca
+    status("input");
121cca
+    if (enabled("input"))
121cca
+      scan_input(computer);
121cca
     status("S/390 devices");
121cca
     if (enabled("s390"))
121cca
       scan_s390_devices(computer);
121cca
-- 
121cca
2.33.1
121cca