LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 03-07-2007, 04:55 AM   #1
fosnez
LQ Newbie
 
Registered: Mar 2007
Distribution: Mandriva (Official) 2007
Posts: 3

Rep: Reputation: 0
Customizing keystrokes sent from a Logitec MX518's "Scroll" buttons.


Greetings, I have had a hunt around the forums and google, but i can't find a similar request, so my appologies if this is a dupe. An example of some of the guides I have read through is this one.

Here is what I want to do:

I use Amarok as my media player on Mandriva 2007 (Official) and I want to setup the "extra" mouse button on my Logitech MX518 to send keystrokes to amarok's global hotkeys. One for next track, one for play/pause, and one to display the info about the song i am currently playing (OSD - On Screen Display).

Here are the relevant areas of xorg.conf - I have been trying to get it to work, so I will leave (but commented out) the other things I have tried.

Code:
Section "ServerFlags"
    #DontZap # disable <Crtl><Alt><BS> (server abort)
    #DontZoom # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
    AllowMouseOpenFail # allows the server to start up even if the mouse does not work
EndSection

#Section "InputDevice"
#    Identifier "Mouse1"
#    Driver "evdev"
#    Option "evBits"  "+1-2"
#    Option "keyBits" "~272-287"
#    Option "relBits" "~0-2 ~6 ~8"
#    Option "Pass"    "3"
# EndSection

Section "InputDevice"
    Identifier "Mouse1"
    Driver "mouse"
    Option "Protocol" "Auto"
    Option "Device" "/dev/mouse"
    Option "Emulate3Buttons"
    Option "Emulate3Timeout" "50"
    Option "EmulateWheel"
    Option "EmulateWheelButton" "2"
#    Option "Buttons" "6"
#    Option "ButtonMapping" "1 2 3 6 7 8"
EndSection

#Section "InputDevice"
#     Identifier  "Mouse1"
#     Driver      "evdev"
#     Option      "Device" "/dev/input/event0" # (cat /proc/bus/input/devices)
#     Option      "Name" "Logitech MX518"
#EndSection

Section "InputDevice"
    Identifier "Mouse2"
    Driver "evdev"
    Option "product" "0xc01e"
    Option "vendor" "0x046d"
EndSection

Section "ServerLayout"
    Identifier "layout1"
    InputDevice "Keyboard1" "CoreKeyboard"
#    InputDevice "Mouse1" "CorePointer"
    InputDevice "Mouse1" "SendCoreEvents"
    InputDevice "Mouse2" "CorePointer"
#    InputDevice "Mouse2" "SendCoreEvents"
    Screen "screen1"
EndSection
Mouse1 and Mouse2 were there after I installed.

Ok, so that's that done... Now for the result of evtest.c

Code:
[root@BrightBawx tmp]# ./evtest /dev/input/event0
Input driver version is 1.0.0
Input device ID: bus 0x3 vendor 0x46d product 0xc01e version 0x2200
Input device name: "Logitech USB-PS/2 Optical Mouse"
Supported events:
  Event type 0 (Sync)
  Event type 1 (Key)
    Event code 272 (LeftBtn)
    Event code 273 (RightBtn)
    Event code 274 (MiddleBtn)
    Event code 275 (SideBtn)
    Event code 276 (ExtraBtn)
    Event code 277 (ForwardBtn)
    Event code 278 (BackBtn)
    Event code 279 (TaskBtn)
  Event type 2 (Relative)
    Event code 0 (X)
    Event code 1 (Y)
    Event code 8 (Wheel)
Testing ... (interrupt to exit)
In the picture of the mouse the above event codes link the buttons below (I tested them):

Button "A" = LeftBtn (Event Code 272)
Button "B" = RightBtn (Event Code 273)
Button "C" = MiddleBtn (Event Code 274)
Button "D" = SideBtn (Event Code 275)
Button "E" = ExtraBtn (Event Code 276)
Button "F" = ForwardBtn (Event Code 277)
Buttons "G" are not used (they are mouse hardware for changing the DPI of the mouse on the fly and work fine, they also don't produce an event in evtest)

Ok, now with this setup Button F sends a keystroke of ALT+LEFT, and Amarok can "see" that keystroke. The scroll buttons work in webpages (Button "E" goes foward a page, Button "D" goes back) but this seems to be at a level that Amarok cannot see.

I have got xbindkeys and xmodmap installed (Yay for URPMI !! ) but they do not help. Here are their current configs anyway:

.xbindkeysrc (I can't find where i read this... but i'm sure i didn't just make it up ;-)
Code:
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
   b:6
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Right]""
   b:7
"/usr/X11R6/bin/xvkbd -xsendevent -text "\[Alt_L]\[Up]""
   b:8
.Xmapmod (as advised here)
Code:
pointer = 1 2 3 6 7
Any ideas what is amiss?

Last edited by fosnez; 03-07-2007 at 04:59 AM.
 
Old 03-10-2007, 10:33 PM   #2
fosnez
LQ Newbie
 
Registered: Mar 2007
Distribution: Mandriva (Official) 2007
Posts: 3

Original Poster
Rep: Reputation: 0
Smile Solved!

Ok, after much caffine and frustration it has been solved. Here is what I did:

The below settings in xorg.conf made the two button on the left hand side of the mouse send ALT+LEFT and ALT+RIGHT but the top middle mouse button did a "normal" left mouse button click. So it required a hack! FYI this hack will add an action to the top mouse button - NOT REPLACE THE CURRENT ONE - so if it does something funky (like minimise the current window) it will do that and whatever you tell it to.

Here is xorg.conf
Code:
Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "Auto"
Option "Device" "/dev/input/mouse0" 
Option "Name" "Logitech MX518"
EndSection

Section "ServerLayout"
    Identifier "layout1"
    InputDevice "Keyboard1" "CoreKeyboard"
    InputDevice "Mouse1" "CorePointer"
    Screen "screen1"
EndSection
Download evrouter. The info below means to take keystroke 227 (Top button) from /dev/input/event0 (yours may be different) and assign ALT+UP to it. Put this in your .evrouterrc file, in your home directory:
Code:
"Logitech USB-PS/2 Optical Mouse" "/dev/input/event0" none key/277 "XKey/Alt_L+Up"
Ok, now is where it get fun! What we are going to do it intercept the signals from the mouse at a device level, however to do this you usually have to be root. I am sure there is another way to do it, but on this thread I found a nice C program to open the event up to all users. You do have to do some hacking of your system though, and it does make it less secure (only slightly though).

Code:
/*---event0_cracker.c---*/
#include 
#include 
#include 

int main(int argc,char *argv[])
{
chmod("/dev/input/event0",S_IREAD|S_IWRITE|S_IRGRP|S_IROTH);
return 0;
}
Ok, now goto a shell and compile it and move it somewhere nice:
Code:
gcc ./event0_cracker.c -o event0_cracker
cp ./event0_cracker /usr/bin/
ok, so now you have to make it as if root is runing this program, but allow anyone to run it (Lets do evrouter the same just for shits and giggles):
Code:
su
chown root:root /usr/bin/event0_cracker
chmod u+s /usr/bin_event0_cracker
chmod g+s /usr/bin/evrouter
One last step! Add event0_cracker and evrouter startup to your bashrc file and your sorted!

Code:
/usr/bin/event0_cracker
evrouter -c .evrouterrc /dev/input/event0

Last edited by fosnez; 03-11-2007 at 10:03 AM.
 
  


Reply

Tags
hardware, logitech, mouse, xmodmap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Back" and "Forward" side-buttons of my mouse Unforgiven79 Linux - Hardware 1 10-31-2006 01:10 AM
Disabling hardware detection of "reboot" and "power" buttons Sabinou Linux - General 3 08-21-2006 08:03 PM
Suggestion: for "subscribed threads" & "top of page" buttons Old_Fogie LQ Suggestions & Feedback 7 07-10-2006 06:10 PM
Having problems customizing the "Synaptics" driver options for my touchpad??? Southpaw76 Linux - Hardware 1 12-12-2005 10:19 AM
Customizing a more "secure" Bash gearoid Linux - Security 5 11-18-2003 07:12 PM


All times are GMT -5. The time now is 01:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration