qzed / linux-surface-pen-button-remap

Remapper for the Bluetooth (Eraser) Button of the Surface Pen (Work in Progress).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working with SurfacePro9

cwittenberg opened this issue · comments

Great idea but cannot get it to work on my SurfacePro9

Output i keep getting:
surface-pen-button[17261]: Error: Device not found
systemd[1]: surface-pen-button.service: Main process exited, code=exited, status=1/FAILURE

Remap config used:
[device]
vendor = 0x45e
product = 0x9ae

[actions]
single = ["KEY_LEFTMETA", "KEY_S"]
double = ["KEY_LEFT"]
hold = ["KEY_LEFTCTRL", "KEY_Q"]

This is evtest output. I have used them all but the one i think i should use is 12, see below evtest output:
Available devices:
/dev/input/event0: Lid Switch
/dev/input/event1: Intel Touch Host Controller
/dev/input/event2: Intel Touch Host Controller
/dev/input/event3: Intel Touch Host Controller
/dev/input/event4: Intel Touch Host Controller Touchscreen
/dev/input/event5: Intel Touch Host Controller
/dev/input/event6: Intel Touch Host Controller
/dev/input/event7: Intel Touch Host Controller Stylus
/dev/input/event8: Intel Touch Host Controller
/dev/input/event9: gpio-keys
/dev/input/event10: gpio-keys
/dev/input/event11: Microsoft Surface POS Tablet Mode Switch
/dev/input/event12: Microsoft Surface 045E:09AE Keyboard
/dev/input/event13: Microsoft Surface 045E:09B0 Keyboard
/dev/input/event14: Microsoft Surface 045E:09B0
/dev/input/event15: Microsoft Surface 045E:09B0
/dev/input/event16: IPTS Touch
/dev/input/event17: IPTS Stylus
/dev/input/event18: Microsoft Surface 045E:09AF Mouse
/dev/input/event19: Microsoft Surface 045E:09AF Touchpad
/dev/input/event20: Microsoft Surface 045E:09AF UNKNOWN
/dev/input/event21: Microsoft Surface 045E:09AF UNKNOWN
/dev/input/event22: Video Bus
/dev/input/event23: HDA Intel PCH HDMI/DP,pcm=3
/dev/input/event24: HDA Intel PCH HDMI/DP,pcm=7
/dev/input/event25: HDA Intel PCH HDMI/DP,pcm=8
/dev/input/event26: HDA Intel PCH HDMI/DP,pcm=9
Select the device event number [0-26]: 12
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x45e product 0x9ae version 0x111
Input device name: "Microsoft Surface 045E:09AE Keyboard"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 1 (KEY_ESC)
Event code 2 (KEY_1)
Event code 3 (KEY_2)
Event code 4 (KEY_3)
Event code 5 (KEY_4)

That doesn't look like the correct device. I think 0x9AE is related to the typecover. Did you pair and connect the pen via Bluetooth?

The pen itself is just working on ubuntu with my surfacepro9 - i didn't do anything else to pair it, should I?
The device that comes closest in evtest is "IPTS Stylus" but 0xc52 gives me the same result. Any idea?

Select the device event number [0-26]: 17
Input driver version is 1.0.1
Input device ID: bus 0x6 vendor 0x45e product 0xc52 version 0x0
Input device name: "IPTS Stylus"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 320 (BTN_TOOL_PEN)
Event code 321 (BTN_TOOL_RUBBER)
Event code 330 (BTN_TOUCH)
Event code 331 (BTN_STYLUS)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 760
Min 0
Max 9600
Resolution 35
Event code 1 (ABS_Y)
Value 2390
Min 0
Max 7200
Resolution 39
Event code 24 (ABS_PRESSURE)
Value 0
Min 0

The button is essentially a separate Bluetooth device. So you need to connect/pair that before you can use it.

Got it. However, the SurfacePro 9 pen is not showing up as a pairable bluetooth device.

Thank you. Tried the same. The pen is not showing up by default in GNOME bluetooth settings. I used bluetoothctl to find the ID, paired it through command line, after a few seconds though it shows the below in dmesg and the connection gets broken.

Not sure but it might be related to the surface-linux? I am running kernel 6.4.12-surface

Dmesg output when attempting pairing:

[ 784.264373] input: Surface Slim Pen 2 Keyboard as /devices/virtual/misc/uhid/0005:045E:0C0F.000B/input/input46
[ 784.264675] input: Surface Slim Pen 2 as /devices/virtual/misc/uhid/0005:045E:0C0F.000B/input/input47
[ 784.264822] input: Surface Slim Pen 2 as /devices/virtual/misc/uhid/0005:045E:0C0F.000B/input/input48
[ 784.265129] hid-generic 0005:045E:0C0F.000B: input,hidraw6: BLUETOOTH HID v5.96 Keyboard [Surface Slim Pen 2] on 58:1c:f8:ec:37:b7
[ 784.745596] Bluetooth: hci0: Opcode 0x 401 failed: -16
[ 801.425571] Bluetooth: hci0: Hardware error 0x0c
[ 801.439607] Bluetooth: hci0: Retrieving Intel exception info failed (-16)
[ 801.760417] Bluetooth: hci0: Opcode 0x 401 failed: -16
[ 801.770448] Bluetooth: hci0: Opcode 0x 401 failed: -16
[ 801.780550] Bluetooth: hci0: Opcode 0x 401 failed: -16
[ 801.790524] Bluetooth: hci0: Opcode 0x 401 failed: -16
[ 801.800516] Bluetooth: hci0: Opcode 0x 401 failed: -16

Hmm yeah that looks like something is going wrong with the bluetooth controller or device. Unfortunately, I don't know what.