whereswaldon / kfreestyle2d

Unofficial Kinesis Freestyle 2 Userspace Linux Driver
MIT License
76 stars 21 forks source link

Cannot build #2

Closed jais-p closed 6 years ago

jais-p commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

Thank you very much, that was really interesting!

whereswaldon commented 6 years ago

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

whereswaldon commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

I haven't actually been using those special keys much, hrm... You can use the xev utility to see what events are generated when you press those keys. Try running that and seeing whether it always produces the right keystroke. That could help identify whether the problem is hardware/firmware or software.

On Fri, Feb 9, 2018 at 8:39 AM, jais-p notifications@github.com wrote:

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).

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/whereswaldon/kfreestyle2d/issues/2#issuecomment-364436061, or mute the thread https://github.com/notifications/unsubscribe-auth/ADvYzSMlJGc5ov6PEP_oX0RNMBBt7jIPks5tTEqigaJpZM4R8vB5 .

whereswaldon commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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