You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/app-misc/ckb/files/ckb-0.4.0-modprobe.patch

73 lines
3.0 KiB

---
src/daemon/input_linux.c | 21 ++++++++++++++-------
src/gui/mainwindow.cpp | 14 ++++++++------
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/src/daemon/input_linux.c b/src/daemon/input_linux.c
index 0391243e..8489f5b5 100644
--- a/src/daemon/input_linux.c
+++ b/src/daemon/input_linux.c
@@ -55,13 +55,20 @@ int uinputopen(struct uinput_user_dev* indev, int mouse){
///
/// Some tips on using [uinput_user_dev in](http://thiemonge.org/getting-started-with-uinput)
int os_inputopen(usbdevice* kb){
- /// First check whether the uinput module is loaded by the kernel.
- ///
- // Load the uinput module (if it's not loaded already)
- if(system("modprobe uinput") != 0) {
- ckb_fatal("Failed to load uinput module\n");
- return 1;
+ /// Let's see if uinput is already available
+ int fd = open("/dev/uinput", O_RDWR);
+ if(fd < 0){
+ fd = open("/dev/input/uinput", O_RDWR);
+ }
+
+ // If not available, load the module
+ if(fd < 0){
+ if(system("modprobe uinput") != 0) {
+ ckb_fatal("Failed to load uinput module\n");
+ return 1;
+ }
}
+ close(fd);
if(IS_SINGLE_EP(kb)) {
kb->uinput_kb = 0;
@@ -79,7 +86,7 @@ int os_inputopen(usbdevice* kb){
indev.id.product = kb->product;
indev.id.version = kb->fwversion;
// Open keyboard
- int fd = uinputopen(&indev, 0);
+ fd = uinputopen(&indev, 0);
kb->uinput_kb = fd;
if(fd <= 0)
return 0;
diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp
index 968764e7..1eb95bda 100644
--- a/src/gui/mainwindow.cpp
+++ b/src/gui/mainwindow.cpp
@@ -282,14 +282,16 @@ void MainWindow::updateVersion(){
if(kextstatOut.isEmpty())
daemonWarning.append(tr("<br /><b>Warning:</b> System Extension by \"Fumihiko Takayama\" is not allowed in Security & Privacy. Please allow it and then unplug and replug your devices."));
#elif defined(Q_OS_LINUX)
- QProcess modprobe;
- modprobe.start("modprobe", QStringList("uinput"));
+ if(!(QFileInfo("/dev/uinput").exists() || QFileInfo("/dev/input/uinput").exists())){
+ QProcess modprobe;
+ modprobe.start("modprobe", QStringList("uinput"));
- if(!modprobe.waitForFinished())
- qDebug() << "Modprobe error";
+ if(!modprobe.waitForFinished())
+ qDebug() << "Modprobe error";
- if(modprobe.exitCode())
- daemonWarning.append(tr("<br /><b>Warning:</b> The uinput module could not be loaded. If this issue persists after rebooting, compile a kernel with CONFIG_INPUT_UINPUT=y."));
+ if(modprobe.exitCode())
+ daemonWarning.append(tr("<br /><b>Warning:</b> The uinput module could not be loaded. If this issue persists after rebooting, compile a kernel with CONFIG_INPUT_UINPUT=y."));
+ }
#endif
settingsWidget->setStatus(tr("No devices connected") + daemonWarning);
}