Coder Social home page Coder Social logo

raulppelaez / naga_keypadmapper Goto Github PK

View Code? Open in Web Editor NEW
102.0 16.0 33.0 93 KB

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/

License: Other

C++ 81.21% Shell 18.79%

naga_keypadmapper's People

Contributors

apocatarsis avatar boginw avatar brianfreytag avatar destroyer avatar haringsrob avatar jsiloto avatar khornem avatar raulppelaez avatar tapro avatar theguardianwolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

naga_keypadmapper's Issues

unintended keystrokes recorded with xev on Ubuntu 17.10

Please keep in mind that I don't have a lot of knowledge about the inner workings of Ubuntu, but I can follow instructions, if given.

Some relevant terminal outputs:

$ sudo naga
Starting naga daemon
Reading from: /dev/input/by-id/usb-Razer_Razer_Naga_Chroma-if02-event-kbd and /dev/input/by-id/usb-Razer_Razer_Naga_Chroma-event-mouse
Line : KP_1
Line : KP_2
Line : KP_3
Line : KP_4
Line : KP_5
Line : KP_6
Line : KP_7
Line : KP_8
Line : KP_9
Line : F1
Line : F2
Line : F3
^C

relevant xev output:
KeyPress event, serial 37, synthetic NO, window 0x4600001,
    root 0x1ef, subw 0x0, time 63942455, (1358,423), root:(3066,481),
    state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 38, synthetic NO, window 0x4600001,
    root 0x1ef, subw 0x0, time 63942463, (1358,423), root:(3066,481),
    state 0x11, keycode 87 (keysym 0xff9c, KP_End), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x4600001,
    root 0x1ef, subw 0x0, time 63942568, (1358,423), root:(3066,481),
    state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 38, synthetic NO, window 0x4600001,
    root 0x1ef, subw 0x0, time 63942568, (1358,423), root:(3066,481),
    state 0x10, keycode 87 (keysym 0xffb1, KP_1), same_screen YES,
    XLookupString gives 1 bytes: (31) "1"
    XFilterEvent returns: False

Autostart not only at boot time, but at plug time

I am thinking maybe we should not assume that the naga mouse is gong to be plugged in all the time (in case the mouse is unplugged, the naga exec goes mad if I remember correctly). Instead of starting the daemon at boot time we should start it/stop it according with the state of the mouse.
Starting the daemon whenever the mouse is plugged and stoping it when i'ts unplugged (to change it for another mouse or switch between docked/pluged mode).

However, as the mayority of people will just have the mouse plugged in all the time without changes this is not crucial nor urgent. Just throwing ideas.

epic chroma in ubuntu 15.10

first attempt at installing naga epic chroma in ubuntu failed, at first i thought it might be because i was using it wirelessly and i know windows recognizes the dock seperatly from the mouse so i uninstalled everything, plugged it in directly but get the same error at boot:

`error fount when loading /home/username/.profile:

terminate called after throwing an instance of 'std:;logic_error'
what(): basic_string::_M_construct null not valid
/sur/local/bin/nagastart.sh: line 19: 951 Aborted (core
dumped) naga chroma

As a result the session will not be configured correctly.
You should fix the problem as soon as feasible.`

not entirely sure what to try next; or if i should have left that last line in nagastart.sh as just naga instead of adding chroma, or something else. also major props on making this whole thing, really hoping i can get it to work because it looks sooo much simpler than any of the other daemons that have been made and since depreciated

Toggle and bash actions

Hey there, I've managed to write code for toggle and bash commands.

Would you mind testing and debugging this if you have the naga device? It should work theoretically I think.

https://github.com/TheGuardianWolf/Naga_KeypadMapper

'toggle' is the keyword for the toggle action.
'bash' is the keyword for the bash action, and runs the command bash -c "<yourcommandhere>"

Xinput not detecting naga 2014 on ubuntu 17.10

There seems to be a problem with xinput in ubuntu 17.10. I only used ubuntu for an hour and didn't try to solve the issue as hard as i should but I'm letting you know about it. There might be other devices non detected. I googled and I wasn't the only one with xinput screwing up in 17.10. Might have to add another dependency or configure something.

Generalize the code for other devices

The generalization is very easy!. The only thing to do is literally to tell the code how many keys the device has (and not even that with some caution during the mapping.txt reading) and relate the Code of the key with the actual key. Which is done in the Run function.

In the Naga Epic mouse the button 1 has Code=2 .... button 12 Code=13.

But I do not know about other devices.

100% CPU usage when Naga is disconnected

If you disconnect naga when the daemon is running, you gonna get 100% CPU usage.
One of the possible fixes is to close it when naga is disconnected, others would be to just wait until it's connected.

So for people who are using this on laptop e.g. here's simple fix, however definitely not the best solution surely.

rd = read (fd, ev, size * 64);
if (rd == -1)
exit(1);

Use xdotool mousedown/mouseup instead of click to handle click action

In order to simulate a mouse click it would be more convinient to send a mousedown when pressing a key and a mouseup when releasing instead of a default click duration (12 ms according to xdotool).
However click in a macro should maintain the current behavior of click (maybe with an optional second argument with the duration of the click)

TODO next version

install

  • fix "repeating installations" (writing multiple times to nagastart)
  • change owner of ~/.naga and ~/.profile to user (so they can change these without root privileges)
  • copy mapping_03.txt to ~/.naga as well

docs

  • fix uninstallation info (.profile)
  • fix formatting

executable

  • add docking station (to install script as well)
  • rename path variable in loadConf() to filename

Mouse showing up twice in xinput

Hey there,

thank you for coding such a handy piece of software! :)

I just have one problem: My mouse (Naga Chroma) is showing up twice in xinput under Xubuntu 15.10:

⎡ Virtual core pointer                id=2    [master pointer  (3)]
⎜   ↳ Razer Razer Naga Chroma       id=9    [slave  pointer  (2)]
⎜   ↳ Razer Razer Naga Chroma       id=10   [slave  pointer  (2)]
⎣ Virtual core keyboard               id=3    [master keyboard (2)]
    ↳ Razer Razer Naga Chroma     id=11   [slave  keyboard (3)]

It also appears twice in dev/input/by-id/:

lrwxrwxrwx 1 root root  9 Apr 11 21:30 usb-Razer_Razer_Naga_Chroma-event-mouse -> ../event5
lrwxrwxrwx 1 root root  9 Apr 11 21:30 usb-Razer_Razer_Naga_Chroma-if01-event-kbd -> ../event6
lrwxrwxrwx 1 root root  9 Apr 11 21:30 usb-Razer_Razer_Naga_Chroma-if02-event-kbd -> ../event7
lrwxrwxrwx 1 root root  9 Apr 11 21:30 usb-Razer_Razer_Naga_Chroma-mouse -> ../mouse0

Because of this, nagastart.sh wont work properly. This wouldn't be much of a problem, but I can't even get it to work when manually setting the xinput-button-map for both devices.

Can you tell me what I'm doing wrong?

Oh, and here are the button mappings of the two devices (they don't seem to change):

xinput get-button-map $(echo 9 | awk '{print $1}')

1 2 3 4 5 6 7 11 10 8 9 13 14 

xinput get-button-map $(echo 10 | awk '{print $1}')

1 2 3 4 5 6 7 

Sudo, $SUDO_USER and $HOME

Ideally mapping.txt goes into the home folder of some user. But if you need to run install.sh or the naga executable as root the $HOME variable is set to /root (at least in my system), so it is not ideal to read/write mapping.txt using $HOME.
The solution could be to use SUDO_USER instead of HOME. This works in my system, but I do not know if its safe.

Not executing the same key twice with delay

Hello guys!

First of all, thanks for developing this awesome tool, I'm actively using it to play Dota2.
I'm currently facing an issue, not sure if I'm implementing it wrong or if it's just a bug.
Here's the situation>

In my mapping txt file I got this configuration

1 - key=KP_Up
2 - key=KP_Home
3 - key=KP_Left
4 - key=KP_Right
5 - key=KP_Down
6 - key=KP_Prior
7 - key=KP_Page_Up
8 - key=KP_Next
9 - key=KP_Page_Down
10 - key=KP_End
11 - key=KP_Begin
12 - key=KP_Page_Up
12 - delay=100
12 - key=KP_Page_Up

I'm using a naga 2014, the key number 12 is not working well. I expect KP_Page_Up to be pressed two times with a delay of 100, but only the first KP_Page_Up is executed, not the second one.

What I'm doing wrong?
Thanks in advance!

Assigning a key to "Space" makes entire computer lag

As the title says, I have assigned in my keyMapping file "12 - key=KP_Space" on my Naga Epic Chroma. Every time I press the button on my mouse, my entire computer lags for like half a sec and it will not always insert a space where I want it. I also have my 11 key set to "Enter" in the same way and that works perfectly fine.

I also had another question, is it possible to assign the middle mouse button when you press it to the left and right? I really miss being able to go Back and Forward using it.

Thanks!

Error checking

We should add some error checking once in a while during the execution, to check if the device is still present (stopping/pausing the execution until it is back online) or has changed between the docking/plugged mode.

And we should also do error checking in every step of the initialization.

Mouse still enabled?

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!

Mapping to numpad key?

Hey I'm using your keypad mapper really well. I want to map my naga buttons with numpad numbers and symbols (ie. Keypad+). What would I have to put for those?
Thanks!

Add support for naga 2014

you can add to the docs or add comment or something, for people wondering if this software works with naga 2014 it does, just change the param in nagastart.sh

 sudo naga /dev/input/by-id/usb-Razer_Razer_Naga_2014-if02-event-kbd

Reduce CPU usage

The new version of the mapper uses more CPU than it should. It appears to be related with mouse movement, which should not affect at all.

Running nagastart.sh shows Invalid Format 0 & unable to grep

I'm running Fedora 24 and trying to run the install.sh gives me the following Error:

[zyian@localhost Naga_KeypadMapper-master] $ sudo bash install.sh
[sudo] password for zyian:
grep: /home/zyian/.profile: No such file or directory
Adding user zyian to group razer
[zyian@localhost Naga_KeypadMapper-master] $ sudo ./nagastart.sh
sudo: ./nagastart.sh: command not found
[zyian@localhost Naga_KeypadMapper-master] $ ls
install.sh mapping_02.txt naga.desktop README.md
mapping_01.txt mapping_03.txt nagastart.sh src
[zyian@localhost Naga_KeypadMapper-master] $ sudo ./nagastart.sh
Invalid format 0
./nagastart.sh: line 19: naga: command not found
[zyian@localhost Naga_KeypadMapper-master] $ cd /usr/local/bin
[zyian@localhost bin] $ ls
naga nagastart.sh
[zyian@localhost bin] $ ./nagastart.sh
Invalid format 0
No naga devices found or you don't have permission to access them.
[zyian@localhost bin] $ sudo ./nagastart.sh
Invalid format 0
./nagastart.sh: line 19: naga: command not found

buttons 13 and 14 can't detect release

if (ev2[1].type == 1 && ev2[1].value == 1) //Only extra buttons
switch (ev2[1].code) {
case 275:
case 276:
chooseAction(ev2[1].code - OFFSET, 1);
break;
// do nothing on default
}

should be

if (ev2[1].type == 1) //Only extra buttons
switch (ev2[1].code) {
case 275:
case 276:
chooseAction(ev2[1].code - OFFSET, ev2[1].value);
break;
// do nothing on default
}

The current version makes people unable to run things when releasing the 13th and 14th buttons.
I also suggest "upgrading" to my version for an easier to edit code using classes ;)

Running shortcut inside gnome-terminal

Great solution! Saves a lot of time!

If I make a key press - then in my gnome terminal I see the number I pressed (although the command binded to that key has executed successfully ) how to get rid of that trail numbers in terminal?

Syntax for Numpad

Can you please help to solve an issue?
Snippet does not work:
key=ctrl+alt+Num_1
What's the syntax for num?

Add a profile selector

It is very easy to manage different mappings.txt and assign some button to change between them.
Just a run parameter that kills the current naga process, changes the mapping.txt and relaunches it should do. Or even better, add code to naga.cpp to support this option.

Perhaps a simple GUI that lets you choose and create the mapping (which you would have to run as super user)

Ownership of .naga

Hello

I'm getting an error with chown when I try to install from master. Something like chown: invalid group: «username:username». The change that trigger the error was introduced in d65b795#diff-3fbb47e318cd8802bd325e7da9aaabe8.

I think the solution could be to replace +chown -R ${SUDO_USER}:${SUDO_USER} "$HOME"/.naga/ with +chown -R ${SUDO_USER} "$HOME"/.naga/. I'm not too sure to make a pull request but that works for me.

Linux Mint 17.2 Rafaela Version

Heya there,

i know you normally shouldnt create issues for saying thanks, but i have the feeling you dont get enough recognition for this ^^

i just wanted to tell you one thing: "THANKS!"
This helped me out quite a bit, because my awesome little Razer Naga Molten Edition mouse was a deal breaker for using linux.

I had to tweak it all a bit, because i have a naga molten edition, but all in all it works c:
Im happy now 😁

Code Lacks a Licence

The closest thing to a licence this has is the header at the top of naga.cpp:

/*
 * Apocatarsis 2016
 * Released with absolutely no warranty, use with your own responsibility.
 * 
 * This version is still in development
 */

You can choose a licence at https://choosealicense.com/, however you'll need to get the permission of all of the people who contributed to Naga_KeypadMapper.

Without a licence, it is technically illegal for others to use or modify your software.

Modifier keys (shift/ctrl/alt/...) for extra functionality?

Would it be possible to add modifier key shortcuts to the mappings? Not modifiers on the mouse, but holding down keyboard modifiers while hitting mouse buttons.

Something like:
1 - workspace_r=1
S1 - workspace_r=-1
C1 - workspace=0
CS1 - workspace=2

Using .bash_profile for start at login

I believe the naga.desktop thing only works in Ubuntu, and it has always been a little unpredictable. Using .bash_profile should be better and work wherever bash is used, but adding a line to .bash_profile could be a problem if someone tries, for example, to install several times.

The current master uses .bash_profile

Keys Numpad and normal keys

This is the mapping I'm using:

1 - key=KP_1
2 - key=KP_2
3 - key=KP_3
4 - key=KP_4
5 - key=KP_5
6 - key=KP_6
7 - key=KP_7
8 - key=KP_8
9 - key=KP_9
10 - key=KP_0
11 - key=KP_Subtract
12 - key=KP_Add

I'm trying to actually use 2 and KP_2 as 2 different options in Dota 2; it seems that KP_2 also does the function as 2 so I can't have 2 options with this configuration, do anybody think this could be fixed and related to Naga mapper or there's no way to avoid this from linux kernel detecting the numpad and key as the same? I did verify this idea with xev, xev denotes KP_2 and 2 as actually 2 different keys.

run= runs 2x the same thing somehow

I'm able to fix it for my usages but it's an additional patch on my things for almost nothing lol. Naga service isn't running 2x so that can't be the problem. Maybe it's because my mouse shows 4 times in xinput ?? pls help.
screenshot from 2018-04-03 11-03-26

Get a grip on sensibility

Synapse lets you assign a button to change the sensibility of the mouse. This would be neat!!
But I do not know the first thing about it

Naga Chroma can't map 2 top buttons (back and forward)

On the new naga chroma the 2 top buttons are set to the sensitivity settings from 1 to 5
which I don't want I just want normal back and forward functionality so I set in the settings file 13 - click=8 and 14 - click=9 but they don't change

Mapping.txt questions

First off, I seem to have got this working on a naga 2012. Second, what conventions are used for th mapping.txt file? I can't seem to map a button to the escape key.

Change keymap and get keymap with terminal command?

I'd like to be able to change the keymap (rotate or exact) and get the current keymap number from terminal.

I've got one of the 2014 Naga's, so I don't want to use one of my 12 buttons to change the keymap. Also, it'd be easier to set the keymap directly for whatever task I was doing than to rotate through and test until I figured out I was on the right one.

Naga Chroma Top Buttons and Tilt Wheel

The side buttons Razer Naga Chroma works just fine in Ubuntu 16.04 with this utility, however the top buttons and tilt wheel are completely unchangeable.

The tilt wheel defaults to scroll up (xev: button 4 to the right) and scroll down (xev: button 5 to the left) and the top buttons default to modifying the DPI up or down.

I'm seeing a pretty crazy issue here with the top buttons that I'm going to have to look into deeper. xev does not register anything with those DPI buttons.

I'm putting this issue in here so we can collaborate on getting this thing working right.

Eliminate the need for sudo

The naga executable needs sudo privileges in order to work. It will be nice if it didn't for security reasons.

Support on Wayland ?

Hi,

Do you have in you're road map the wayland / libinput integration ?

Actually, only libinput list the device Naga. Xinput is not usable with wayland in the newer version of fedora.
I use Fedora 29 and Wayland.

Maybe there is a way to bind libinput to xinput ? but Idon't think so.

Best regards ! 👍

You guys are gods

Thanks for this simple to install yet complete button configurator. This work is great. Keep up the good work i finally stop writing - trying to pause/play my music. Can make any macro/script execute. I feel so powerful now. I can do anything with my 14 naga buttons thanks to you dev guys. Well done. I can now use my naga to start a full wifi attack in computer class.

Middle mouse on a key

How do you bind middle mouse to a key correctly?

My mappings have 1 - click=2 but the usage seems a little buggy, pressing will start the scroll and with middle mouse pressing it again will stop the scroll but the key will just restart the scroll. Also it will 'bug out' the middle mouse making it 'locked on' causing tabs to be closed when clicking them instead of opening, fixes by using the regular middle mouse.

Hold keys (continued activation)

First off, great work! I appreciate being able to rebind my keys on my naga 2014.

I have rebound my keys on my pad and everything works great. But I use mumble for voice chat and i like to activate it via one of the keys that I have rebound on the pad (1 - key=grave) but the activation is instant and it stops. It's not registering that I am continuing to hold the key down. I can verify this by opening a text editor or a search field in a web browser and when I press and hold key 1 on the pad, I get a single ' (grave). Am I missing a setting, or is there a way for the program to register that I am keeping the button held down? TIA.

This is not a issue

This is a big thank for debugging this razor shit mouse and making it work. Thanks

Can't get model rz01-0104 configured correctly (Naga 2014)

I've gone through the guide a few times, and checked over other open issues and can't seem to figure this out.

I've customized the ~/.naga/mapping_01.txt but the key bindings still seem to be doing other things.

My mapping_01.txt looks like this..

1 - key=ctrl+shift+q
2 - key=ctrl+shift+q
3 - key=ctrl+shift+q
4 - key=ctrl+shift+q
5 - key=ctrl+shift+q
6 - key=ctrl+shift+q
7 - key=ctrl+shift+q
8 - key=ctrl+shift+q
9 - key=ctrl+shift+q
10 - key=ctrl+shift+q
11 - key=ctrl+shift+q
12 - key=ctrl+shift+q
13 - key=ctrl+shift+q
14 - key=ctrl+shift+q

just as a test. But when I type it still types out the number, and does weird random other stuff. Pressing 2 will type out "2" but then it will also close whatever active window I have selected. My ctrl+shift+q on the keyboard opens up terminal...

Would anyone mind helping me troubleshoot this?

Buttons on the top of the naga

How about them? Can you keybind them? I mean xfce can't see them but xev can, this program doesn't configure them, do you use something else to make them work or you don't have those keybinded?

Support for Razer Naga 2009?

Hi! This daemon seems to be very useful, and I would like to use it for Razer Naga 2009 (the oldest Naga version) on Linux Mint 18.3. Would that be possible to achieve? :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.