Quesillo Quesedor | 10 May 03:04 2012
Picon

Changing sensitivity ThinkPad USB Keyboard with TrackPoint

Hello 

I have this python script for changing the sensitivity of the trackpoint.

#pyusb imports
import usb.core 
import usb.util

data = [0x4, 0x6a, 0x3, 0xfc, 0x38]
dev = usb.core.find(idVendor=0x17ef, idProduct=0x6009)
dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)

It needs root to be able to open the device and on linux you need to unbind the trackpoint device from usbhid module before you run the script and then bind it back.
# echo XXX > /sys/bus/usb/drivers/usbhid/unbind
# python2 trackpoint-script.py
# echo XXX > /sys/bus/usb/drivers/usbhid/bind
I did try to use Device.attach_kernel_driver but it doesn't seems to work for the trackpoint interface.

data[3] is the value that changes the sensitivity level, I found that the windows driver use one of the following values
0x66 0x72 0x80 0x8f 0xa0 0xb3 0xc9 0xe1 0xfc

This script also works on OS X.
Yves-Alexis Perez | 10 May 07:52 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

On mer., 2012-05-09 at 18:04 -0700, Quesillo Quesedor wrote:
> Hello 
> 
> I have this python script for changing the sensitivity of the trackpoint.
> 
> #pyusb imports
> import usb.core 
> import usb.util
> 
> data = [0x4, 0x6a, 0x3, 0xfc, 0x38]
> dev = usb.core.find(idVendor=0x17ef, idProduct=0x6009)
> 
> dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)
> 
> 
> It needs root to be able to open the device and on linux you need to unbind the trackpoint device from usbhid
module before you run the script and then bind it back.
> # echo XXX > /sys/bus/usb/drivers/usbhid/unbind
> 
> # python2 trackpoint-script.py
> # echo XXX > /sys/bus/usb/drivers/usbhid/bind
> I did try to use Device.attach_kernel_driver but it doesn't seems to work for the trackpoint interface.
> 
> data[3] is the value that changes the sensitivity level, I found that the windows driver use one of the
following values
> 0x66 0x72 0x80 0x8f 0xa0 0xb3 0xc9 0xe1 0xfc
> 
I'm a bit unsure about that, but would it make sense to do that with an
in-kernel interface or something like that?

--

-- 
Yves-Alexis
Quesillo Quesedor | 11 May 02:24 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

> I'm a bit unsure about that, but would it make sense to do that with an

> in-kernel interface or something like that?

I think it would be better a Xorg driver.
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Richard Neill | 10 May 23:59 2012

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

On 10/05/12 02:04, Quesillo Quesedor wrote:
> Hello
>
> I have this python script for changing the sensitivity of the trackpoint.

Thanks - that's really useful. I've been looking for something like this 
for ages! Let me check: this is the external USB Ultranav keyboard, not 
the internal one.

I'm having some trouble with this:

1. When I run
	echo XXX > /sys/bus/usb/drivers/usbhid/unbind

I get:   bash: echo: write error: No such device.
(this happens even as root, though the file in /sys does exist).

Btw, I have more than one USB HID device attached - how do we know which 
one is being unbound?

2. My VID/HID aren't as below. Running lsusb, I get two possibilities:

Bus 002 Device 008: ID 04b3:3018 IBM Corp. UltraNav Keyboard
Bus 002 Device 009: ID 06cb:0009 Synaptics, Inc. Composite TouchPad and 
TrackPoint

Trying with either of these causes a python usb.core.USBError: 
Input/output error, but this might be because of the failure to unbind 
the USB hid device.

I think there are 2 different models of Ultranav USB keyboard.

Thanks for your help,

Best wishes,

Richard
 .

P.S. Also, can I suggest this would be really useful as an addition to 
Thinkwiki.org?

>
> #pyusb imports
> import usb.core
> import usb.util
>
> data = [0x4, 0x6a, 0x3, 0xfc, 0x38]
> dev = usb.core.find(idVendor=0x17ef, idProduct=0x6009)
> dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)
>
> It needs root to be able to open the device and on linux you need to unbind the trackpoint device from usbhid
module before you run the script and then bind it back.
> # echo XXX > /sys/bus/usb/drivers/usbhid/unbind
> # python2 trackpoint-script.py
> # echo XXX > /sys/bus/usb/drivers/usbhid/bind
> I did try to use Device.attach_kernel_driver but it doesn't seems to work for the trackpoint interface.
>
> data[3] is the value that changes the sensitivity level, I found that the windows driver use one of the
following values
> 0x66 0x72 0x80 0x8f 0xa0 0xb3 0xc9 0xe1 0xfc
>
> This script also works on OS X.

--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Richard Neill | 11 May 00:24 2012

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint


On 10/05/12 22:59, Richard Neill wrote:
>
> I'm having some trouble with this:
>
> 1. When I run
> echo XXX > /sys/bus/usb/drivers/usbhid/unbind

OK...I'm being an idiot. The XXX isn't a literal "XXX", but the relevant 
bus/path name, such as 2-1.6.4:1.1
(Is there an elegant way to discover the correct value of XXX with a 
script?).

>
> I get: bash: echo: write error: No such device.
> (this happens even as root, though the file in /sys does exist).
>
> Btw, I have more than one USB HID device attached - how do we know which
> one is being unbound?
>
>
> 2. My VID/HID aren't as below. Running lsusb, I get two possibilities:
>
> Bus 002 Device 008: ID 04b3:3018 IBM Corp. UltraNav Keyboard
> Bus 002 Device 009: ID 06cb:0009 Synaptics, Inc. Composite TouchPad and
> TrackPoint
>
> Trying with either of these causes a python usb.core.USBError:
> Input/output error, but this might be because of the failure to unbind
> the USB hid device.

Now I know it's the right device (because after unbinding, the 
trackpoint doesn't work), but I now get a USB Pipe error.

Perhaps it's a different protocol?

Richard
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Quesillo Quesedor | 11 May 01:07 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

I only have the 55Y9026 (LA spanish version of the 55Y9003) so yes it could be a different protocol. Maybe you could sniff the usb when the trackpoint utility changes the sensitivity.
Richard Neill | 11 May 03:03 2012

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint


On 11/05/12 00:07, Quesillo Quesedor wrote:
> I only have the 55Y9026 (LA spanish version of the 55Y9003) so yes it
> could be a different protocol. Maybe you could sniff the usb when the
> trackpoint utility changes the sensitivity.

I've got a: FRU: 41A5158

Unfortunately, sniffing the USB protocol under Windows isn't possible 
for me: I have no windows systems left!   I did try it a few years ago,
and here's what I found:
http://old.nabble.com/Hacking-the-UltraNav-USB-keyboard-td14971752.html
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Quesillo Quesedor | 11 May 04:50 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

That's strange I did almost the same thing but I used windows 8 cp and usbtrace, but my problem was that I was
always getting the i/o error in linux(it was the usbhid module). 

Can you use a VM? Some VMs allow to connect input devices directly to the guest os. I use vmware, enabled "Show
all input devices" in the usb option, and installed the windows drivers. You could also use usbmon to sniff
the usb port. 
# modprobe usbmon
# mount -t debugfs none_debugs /sys/kernel/debug
# cat /sys/kernel/debug/usb/usbmon/2u > usblog

This is what i got in the log when i changed the sensitivity bar and clicked on apply:

ffff8802ac75b9c0 2542376229 S Co:9:003:0 s 21 09 0304 0001 0005 5 = 046a03fc 38
ffff8802ac75b9c0 2542377180 C Co:9:003:0 0 5 >

you can see that 
21 09 0304 0001

is 
dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)

and 
046a03fc 38 
is 
data = [0x4, 0x6a, 0x3, 0xfc, 0x38]

----- Mensaje original -----
De: Richard Neill <rn214 <at> richardneill.org>
Para: linux-thinkpad <at> linux-thinkpad.org
CC: Quesillo Quesedor <quesilloquesedor <at> yahoo.com.ar>
Enviado: jueves, 10 de mayo de 2012 22:03
Asunto: Re: [ltp] Changing sensitivity ThinkPad USB Keyboard with TrackPoint

On 11/05/12 00:07, Quesillo Quesedor wrote:
> I only have the 55Y9026 (LA spanish version of the 55Y9003) so yes it
> could be a different protocol. Maybe you could sniff the usb when the
> trackpoint utility changes the sensitivity.

I've got a: FRU: 41A5158

Unfortunately, sniffing the USB protocol under Windows isn't possible for me: I have no windows systems
left!   I did try it a few years ago,
and here's what I found:
http://old.nabble.com/Hacking-the-UltraNav-USB-keyboard-td14971752.html
-- The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Bjørn Mork | 11 May 12:10 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

Richard Neill <rn214 <at> richardneill.org> writes:
> On 10/05/12 22:59, Richard Neill wrote:
>>
>> I'm having some trouble with this:
>>
>> 1. When I run
>> echo XXX > /sys/bus/usb/drivers/usbhid/unbind
>
> OK...I'm being an idiot. The XXX isn't a literal "XXX", but the
> relevant bus/path name, such as 2-1.6.4:1.1
> (Is there an elegant way to discover the correct value of XXX with a
> script?).

You could look at the 

  /sys/bus/usb/drivers/usbhid/*/../{idProduct,idVendor}

files and match them against the wanted pid/vid, and then parse out
whatever the * matched.

Bjørn
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Quesillo Quesedor | 11 May 20:57 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

This is strange my device is 17ef:6009 but yours is 06cb:0009 so the script shouldnt work for you.
You could try changing this part

dev = usb .core.find(idVendor=0x06cb, idProduct=0x0009)

or maybe using this http://www.jan-steinhoff.de/linux/stick2mouse.html

----- Mensaje original -----
De: Richard Neill <rn214 <at> richardneill.org>
Para: linux-thinkpad <at> linux-thinkpad.org
CC: 
Enviado: jueves, 10 de mayo de 2012 19:24
Asunto: Re: [ltp] Changing sensitivity ThinkPad USB Keyboard with TrackPoint

On 10/05/12 22:59, Richard Neill wrote:
>
> I'm having some trouble with this:
>
> 1. When I run
> echo XXX > /sys/bus/usb/drivers/usbhid/unbind

OK...I'm being an idiot. The XXX isn't a literal "XXX", but the relevant 
bus/path name, such as 2-1.6.4:1.1
(Is there an elegant way to discover the correct value of XXX with a 
script?).

>
> I get: bash: echo: write error: No such device.
> (this happens even as root, though the file in /sys does exist).
>
> Btw, I have more than one USB HID device attached - how do we know which
> one is being unbound?
>
>
> 2. My VID/HID aren't as below. Running lsusb, I get two possibilities:
>
> Bus 002 Device 008: ID 04b3:3018 IBM Corp. UltraNav Keyboard
> Bus 002 Device 009: ID 06cb:0009 Synaptics, Inc. Composite TouchPad and
> TrackPoint
>
> Trying with either of these causes a python usb.core.USBError:
> Input/output error, but this might be because of the failure to unbind
> the USB hid device.

Now I know it's the right device (because after unbinding, the 
trackpoint doesn't work), but I now get a USB Pipe error.

Perhaps it's a different protocol?

Richard
-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Bjørn Mork | 11 May 13:15 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

Quesillo Quesedor <quesilloquesedor <at> yahoo.com.ar> writes:

> I have this python script for changing the sensitivity of the trackpoint.
>
> #pyusb imports
> import usb.core 
> import usb.util
>
> data = [0x4, 0x6a, 0x3, 0xfc, 0x38]
> dev = usb.core.find(idVendor=0x17ef, idProduct=0x6009)
>
> dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)

Just for anyone not immediately recognizing the usb_control_msg()
parameters: 

 0x21  == USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE
 0x9   == HID_REQ_SET_REPORT (assuming the interface class is HID)
 0x304 == report_type + 1 << 8 | report_id
 0x1   == interface number

So I believe this is a "set report" request for report_type 2
(HID_FEATURE_REPORT) with report_id 4, sent as a control request
referencing interface 1 on the device.  But I don't really know much
about HID so I may have gotten something wrong here.

Note that Bernhard Seibold created a simple driver for reading/setting
precisely this value via sysfs a year ago: 
 http://www.spinics.net/lists/linux-input/msg15423.html

Don't know why that hasn't been merged yet.  CCing Bernhard to ensure
that he is aware of this discussion.

Bjørn
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Bernhard Seibold | 11 May 16:15 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

Hi!

On 11.05.2012 13:15, Bjørn Mork wrote:

> Note that Bernhard Seibold created a simple driver for reading/setting
> precisely this value via sysfs a year ago: 
>  http://www.spinics.net/lists/linux-input/msg15423.html
> 
> Don't know why that hasn't been merged yet.  CCing Bernhard to ensure
> that he is aware of this discussion.

I don't really know the context here, but regarding that patch, I posted
it at least twice on the linux-input mailing list, and I asked the HID
maintainer (Jiri Kosina) at least twice about it, but I always got
ignored. I don't know why.

So I basically gave up on trying to get it merged, but if you wanna try
yourself, be my guest.

However since it looked useful to me I published an updated version of
the patch and a userspace tool with reduced functionality on github:

https://github.com/bseibold/linux/compare/master...tpkbd-unstable
https://github.com/bseibold/tpkbdctl
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Bjørn Mork | 11 May 20:24 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

Bernhard Seibold <mail <at> bernhard-seibold.de> writes:
> On 11.05.2012 13:15, Bjørn Mork wrote:
>
>> Note that Bernhard Seibold created a simple driver for reading/setting
>> precisely this value via sysfs a year ago: 
>>  http://www.spinics.net/lists/linux-input/msg15423.html
>> 
>> Don't know why that hasn't been merged yet.  CCing Bernhard to ensure
>> that he is aware of this discussion.
>
> I don't really know the context here,

Right. Sorry about that.  And I didn't even think about the problem that
posting to the mailing list is restricted to subscribers only...

You can read the discussion in the linux-thinkpad mailing list archive
if you are interested:
http://mailman.linux-thinkpad.org/pipermail/linux-thinkpad/2012-May/thread.html#50727

> but regarding that patch, I posted
> it at least twice on the linux-input mailing list, and I asked the HID
> maintainer (Jiri Kosina) at least twice about it, but I always got
> ignored. I don't know why.
>
> So I basically gave up on trying to get it merged, but if you wanna try
> yourself, be my guest.

Sorry to hear that, and thanks for the offer.  I could give it a try,
but I believe it would be better if one of those actually owning the
hardware would do that.  Anyone here wanting to push this?

I see that the USB HID DRIVERS use linux-usb as mailinglist (and not
linux-input as the rest of the HID stuff).  That could make it easier.
Nothing is ever ignored on that list, and new drivers are usually very
welcome.  At least that's the impression I've got.

> However since it looked useful to me I published an updated version of
> the patch and a userspace tool with reduced functionality on github:
>
> https://github.com/bseibold/linux/compare/master...tpkbd-unstable
> https://github.com/bseibold/tpkbdctl

Given the fact that this issue came up, I assume these tools are of
interest to a lot of pepole here.  Thanks for the pointers.

And thanks for your quick answer.

Bjørn
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Richard Neill | 16 May 05:29 2012

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint


On 11/05/12 15:15, Bernhard Seibold wrote:
> However since it looked useful to me I published an updated version of
> the patch and a userspace tool with reduced functionality on github:
>
> https://github.com/bseibold/linux/compare/master...tpkbd-unstable
> https://github.com/bseibold/tpkbdctl

Thanks. I actually have 2 different versions of this keyboard.

The newer one is identified in lsusb as:
	17ef:6009 Lenovo ThinkPad Keyboard with TrackPoint
I believe this one has been on sale for about 2 years.
and works excellently with this program. Turning up the sensitivity is a 
huge benefit: I've been wanting something like this for 5 years!

The older one (of which I have 3 on different machines) is a larger 
device, including a touchpad, numeric keypad, and 2-port USB hub. It has 
been on sale for about 10 years, and identifies as 2 devices:

   04b3:3018 IBM Corp. UltraNav Keyboard
   06cb:0009 Synaptics, Inc. Composite TouchPad and TrackPoint

I tried tweaking your program to use the VID/PID pairs, but this is 
unsuccessful. If you have any suggestions for what might work, I'd be 
delighted to try to help implement the similar functions for the other 
keyboard. (Or, if you are interested, I can post one to you: 
left-mouse-button switch is worn out, but OK for testing; no monetary 
value, and no need to return it; contact me off-list)

Best wishes, and thanks,

Richard
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

On 2012-05-16 05:29, Richard Neill wrote:
> [...]
> The older one (of which I have 3 on different machines) is a larger device,
> including a touchpad, numeric keypad, and 2-port USB hub. It has been on sale
> for about 10 years, and identifies as 2 devices:
>
> 04b3:3018 IBM Corp. UltraNav Keyboard
> 06cb:0009 Synaptics, Inc. Composite TouchPad and TrackPoint
>
Just to make sure: You did try to configure it using xinput, right?
e.g.

$ xinput list
  Virtual core pointer
      ...
      TPPS/2 IBM TrackPoint

$ xinput list-props 'TPPS/2 IBM TrackPoint'
  [lots of interesting stuff to tweak]

hth,
-- 
Infineon Technologies IT-Services GmbH   Martin.Schuster1 <at> infineon.com
Lakeside B05, 9020 Klagenfurt, Austria   Martin Schuster
          FB: LG Klagenfurt, FN 246787y   +43 5 1777 3517
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Richard Neill | 16 May 13:58 2012

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint


>>
> Just to make sure: You did try to configure it using xinput, right?
> e.g.
>
> $ xinput list
> Virtual core pointer
> ...
> TPPS/2 IBM TrackPoint
>
> $ xinput list-props 'TPPS/2 IBM TrackPoint'
> [lots of interesting stuff to tweak]
>

Yes, I did. Xinput allows for the X-server to tweak things once the 
signal reaches it. This allows for middle-button as emulate-wheel, and 
horizontal scrolling. But the trackpoint "pre-amp" gain is actually 
controlled in the hardware itself, and requires writing commands back to 
the keyboard.

For a Thinkpad, this is:
	echo -n 255 > /sys/devices/platform/i8042/serio1/sensitivity

For the older USB keyboards, there is no way to do it (as yet)

For the new USB keyboard, the tpkbdctl program works.

[It's possible to fake it slightly using mouse-speed and acceleration, 
but this reduces fine-control. Turning up the analog gain is better]

Richard
--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

Stefan Monnier | 21 May 04:58 2012
Picon

Re: Changing sensitivity ThinkPad USB Keyboard with TrackPoint

> The older one (of which I have 3 on different machines) is a larger device,
> including a touchpad, numeric keypad, and 2-port USB hub.  It has been on

As you may know, the support for the touchpad part of this keyboard has
just been incorporated into Linux-3.4.  The author of that driver also
has/had a tentative driver for the trackpoint part, making it appear as
a joystick.  I've used his touchpad driver for many years, but have
never tried his trackpoint driver, but you may want to contact him to
see if it might provide the features you need.

        Stefan

--

-- 
The linux-thinkpad mailing list home page is at:
http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad


Gmane