RaulPPelaez / Naga_KeypadMapper

This little linux xorg daemon allows you to map the side keypad of the Razer Naga series mice via a configuration file called mapping.txt under $HOME/.naga/
Other
105 stars 32 forks source link

Mouse still enabled? #32

Closed SuperCuber closed 7 years ago

SuperCuber commented 7 years ago

I am using Naga 2014 in Manjaro, and after running your install script and sudo -E bash nagastart.sh, the custom actions work but the numbers still go through... Error log:

Invalid format 0 Reading from: /dev/input/by-id/usb-Razer_Razer_Naga_2014-if02-event-kbd and /dev/input/by-id/usb-Razer_Razer_Naga_2014-event-mouse Starting naga daemon

Thanks for doing this man, you are awesome!

TheGuardianWolf commented 7 years ago

What do you mean numbers still go through? You mean your keypresses trigger two actions?

apocatarsis commented 7 years ago

See 2) in USAGE in README

In order to get rid of the original bindings it disables the keypad using xinput as follows:

$ xinput set-int-prop [id] "Device Enabled" 8 0 where [id] is the id number of the keypad returned by $ xinput.

Does not that get rid of the original bindings?

Also in step 4)

4) You may have to also run

$ xinput set-button-map [id2] 1 2 3 4 5 6 7 11 10 8 9 13 14 15

where [id2] is the id number of the pointer device returned by xinput - in case of naga 2014 you also have to check which of those two has more than 7 numbers by typing xinput get-button-map [id2]. Although this seems to be unnecesary in some systems (i.e CentOS 7)

I cannot tell, but it seems naga 2014 has a special treatment. Be sure your issue is not related with this!

I am not sure where the "Invalid format 0" is coming from. It appears that the naga daemon is working normally. So it is probably coming from some of the xinput calls above naga in nagastart.sh, could you pinpoint which one? (By calling nagastart.sh with bash -x nagastart.sh i.e)

TheGuardianWolf commented 7 years ago

I've also got a modification to the code for ioctl to exclusively capture device input, since I was too lazy to do the xinput mods. This means no tweaking with device settings.

It's on my Linux install somewhere, I'll grab it when I next boot into it.

EDIT: Actually never mind, I came from your thread on reddit, the code you have here is a lot different to the source, not sure if you're still using ioctl anymore.

SuperCuber commented 7 years ago

This is the output with -x... I can't really tell what's going on tbh. http://pastebin.com/H0WM92Dc

As to what I mean, I mean that when I press 1, both the special function happens AND the program gets a "1" written into it

TheGuardianWolf commented 7 years ago

Try inserting the following before the while(1) loop in the run() function in file naga.cpp: ioctl(side_btn_fd, EVIOCGRAB, 1); ioctl(extra_btn_fd, EVIOCGRAB, 1);

Assuming this works, the application will gain exclusive control of the side key inputs until you exit it.

SuperCuber commented 7 years ago

It does work, however seems like the application also gains control of the mouse itself, as I can't move it... And the Invalid format 0 persists, too

TheGuardianWolf commented 7 years ago

Alright, drop the second ioctl, and see what happens.

I have no idea about the invalid format 0 though but it seems to be 'working'.

SuperCuber commented 7 years ago

That works! 🥇

TheGuardianWolf commented 7 years ago

Guess my mods on the original script still works on this app, I'll leave the 'Invalid format 0' to apocatarsis since I don't personally have a Naga, I use the Naga Hex v2.

apocatarsis commented 7 years ago

Hey I like the ioctl magic, thats cool!! Thanks! I'll add it to the master when I have a little time to test it. Or open a new branch and do it yourself if you want!

From the pastebin I see the complaining line is: $ xinput set-int-prop 15 16 'Device Enabled' 8 0 This is incorrect, there should be either 15 or 16, only one id. Thats why it fails.

nagastart.sh is detecting wrong the xinput id of your Naga side keyboard, it appears as it is showing twice, as grep gives back two lines. Something that I havent see in the two nagas I have been able to test this myself... Could you post the output of $xinput please?? that way ill should be able to generalize the script.

Either way, if the ioctl lines by @TheGuardianWolf work as expected some of the xinput lines in nagastart could be dropped. This is starting to look less like a cluster of hacks!! super cool! thanks guys!

Lastly, @SuperCuber, if I am not mistaken, with the ioctl line, you can just drop the lines

NAGAID1=$(xinput | grep Naga | grep keyboard | cut -d= -f2 | cut -b1-2)
xinput set-int-prop $NAGAID1 "Device Enabled" 8 0

in your nagastart.sh and it should work without complaining.

TheGuardianWolf commented 7 years ago

I've been looking to write an extension for razer-cfg for my Naga Hex V2 since it's not supported, does the Naga not have razer-cfg support or such for the side keys as well?

apocatarsis commented 7 years ago

Well I think that when I wrote this It didnt, It was more about the lights an such, not even DPI AFAIK. But I dont have much experience, I tried to install it whitout success and just gave up when I didnt see how to change the bindings.

On the other hand, the idea was so simple that I just wrote it, just look at the code, whitout boiler palte its like 10 lines of system calls to xdotool...

However I invite you to somehow merge this with razer-cfg if you feel like it.