Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build #2

Closed
jais-p opened this issue Feb 7, 2018 · 19 comments

Comments

@jais-p
Copy link

@jais-p jais-p commented Feb 7, 2018

Hello,
When I try to build the driver, I get several errors:

make
c99 -g -Wall -Wextra -pedantic   -c -o k.o k.c
k.c: In function ‘watch’:
k.c:45:25: error: storage size of ‘usetup’ isn’t known
     struct uinput_setup usetup;
                         ^
k.c:65:15: error: ‘UI_DEV_SETUP’ undeclared (first use in this function)
     ioctl(fd, UI_DEV_SETUP, &usetup);
               ^
k.c:65:15: note: each undeclared identifier is reported only once for each function it appears in
k.c:45:25: warning: unused variable ‘usetup’ [-Wunused-variable]
     struct uinput_setup usetup;
                         ^
<commande interne> : la recette pour la cible « k.o » a échouée
make: *** [k.o] Erreur 1

I have absolutely no knowledge of how make files work. Do you have an idea of what is actually going on?
Thanks in advance.

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 7, 2018

Can you post the output of the terminal command uname -a. I have built this against fairly recent kernels, so I wonder whether it needs to be backported because of some recent change in the header files.

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 7, 2018

I am able to build it on Debian 9 (stretch).

$ uname -a
Linux villanelle 4.9.0-5-amd64 #1 SMP Debian 4.9.65-3+deb9u2 (2018-01-04) x86_64 GNU/Linux

@jais-p Another question: what compiler are you using? Do something like the following and post your output:

$ c99 --version
gcc (Debian 6.3.0-18) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Final thought: Do you know whether you have the header files for the Linux kernel installed? Some distributions don't install them by default, but they should be available as a package.

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 7, 2018

Hello there,
Thanks for replying.
Here's the answer of the uname and c99:

Linux jais-ThinkPad-13-2nd-Gen 4.13.0-32-generic #35~16.04.1-Ubuntu SMP Thu Jan 25 10:13:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.6) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

As for the header I believe they are installed, yes, as there always downloaded upon updates.

@tekktonic

This comment has been minimized.

Copy link
Contributor

@tekktonic tekktonic commented Feb 8, 2018

@whereswaldon wrote this driver against uinput 0.5, released in 2015. Both @jais-p 's distro, Ubuntu 16.04, and mine, Slackware 14.2, are using uinput 0.4 before the SETUP ioctl calls were introduced. I've submitted a pull request which adds support for old-style uinput device initializadion however it requires testing because I don't have this type of computer. @jais-p if you could test my fork of the driver and give me some feedback that would be fantastic, the patch feels like it's too easy and so I'm sure that there's something wrong somewhere that needs to be ironed out. @whereswaldon the code should be literally unchanged on modern systems (I'm using conditional compilation) but it's probably worth testing on your system as well.

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 8, 2018

@tekktonic
Thanks for your work, which just needed a ";" at the end of line 77. I was able to build and run as intended.
Just have to figure out a way to run it at startup now

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 8, 2018

@jais-p I'm working on a run-at-boot solution right now, but it isn't ready. It is also (unfortunately) dependent on the init system. I want to write a udev rule that will recognize only the hidraw input device that matches the special keys and have that rule request the start of the program as a service from systemd. If you can think of a better way to automate it, let me know. The trick is providing the right input device as an argument.
The other option is to find a way for the driver itself to discover the correct hidraw device, which is appealing because we could then just "launch" the driver when/whereever and it would work. Detecting which device is which has been a bit irritating so far.

@tekktonic Thanks for your help! Why does Ubuntu 16.04 have a newer kernel than me but an older uinput module?

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 8, 2018

@whereswaldon I've figured that if I start my computer with the keyboard plugged in, it will always be hidraw1 and hidraw2. Therefore, I was able to call the driver twice with each parameters using the startup preferences.

Regarding the kernel, I would say "go figure" :)
That's the magic behind Ubuntu sometimes

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 8, 2018

@jais-p Okay, let me know if that solution gives you trouble in the future. This driver is still WIP. It needs better error handling, among other things. #1 is still around, though I think I know how to fix it. If you have requests or ideas, please let me know.

I will be trying to find a reliable way to start the driver when the keyboard is plugged in and to kill it when the keyboard is removed. I'll make sure to give you a shout if I manage it.

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 8, 2018

Thank you very much, that was really interesting!

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 8, 2018

#3 is merged now (with the semicolon fix). Thanks again to @tekktonic for resolving that.

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 9, 2018

@jais-p I've added some error handling. No better startup solution yet, but this version can handle having the keyboard unplugged while it's running. Might be worth updating your copy.

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 9, 2018

Great, thanks I will.
I have also noticed that some shortcuts are not working fine for me, I don't know if it's also the case for you guys. I mean, sometimes they work, sometimes they don't (web backward, ctrl+P).

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 9, 2018

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 21, 2018

@jais-p The master branch now contains an installation procedure that can automatically launch the driver when you plug the keyboard in. If you decide to try it, let me know how it goes.

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 22, 2018

Hi @whereswaldon thanks for the update. It does work fine in the following cases:

  1. booting with the keyboard plugged in
  2. booting without the keyboard, then plugging it in

However, if I start with the keyboard plugged in, unplug it, then plug it back in, the special keys don't work.
Tricky, I know, but it tends to appen regularly when working in an open space. :)

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Feb 26, 2018

@jais-p Hrm... I have tried that and it seems to work fine for me. Could you send me the output of systemctl status kfreestyle2d at the following times:

  1. Just after the machine starts, with the keyboard plugged in
  2. After you unplug it
  3. After you plug it back in

It should be restarted automatically, but it seems like that is failing for you. The output of that command might tell me why.

Thanks for trying it!

@jais-p

This comment has been minimized.

Copy link
Author

@jais-p jais-p commented Feb 27, 2018

Heya @whereswaldon The problem actually happened only once, I cannot reproduce it.
But shall it happen again, I will send you the output!
Thanks!

@tekktonic

This comment has been minimized.

Copy link
Contributor

@tekktonic tekktonic commented Mar 7, 2018

@whereswaldon as a heads up I believe that if you used a sysvinit script then every existing init system would be able to use it, systemd via its sysv compatibility, and every other branch by virtue of being sysvinit or having its own compatibility layer.

@whereswaldon

This comment has been minimized.

Copy link
Owner

@whereswaldon whereswaldon commented Mar 8, 2018

Interesting... @tekktonic I'll look into that at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.