==== Input devices ====
Both reMarkable 1 and reMarkable 2 have 3 distinct input devices: Wacom Digitizer (pen input), Parade Touchscreen (touch input), and GPIO (power button and left/home/right buttons on reMarkable 1). These devices are standard [[https://www.kernel.org/doc/html/latest/input/input_uapi.html|linux evdev devices]] that can be found under ''/dev/input''. The exact name of each device in that folder varies between reMarkable 1 and reMarkable 2, and may even vary from one system release to the other, so it’s recommended to query the capabilities of all the available devices to find the one you’re looking for. This can be done using the ''EVIOCGBIT'' ioctl ([[https://github.com/rmkit-dev/rmkit/blob/a99b2f70c72539bedc1d201e3899da6e19c197da/src/rmkit/input/device_id.cpy#L37|example]]). For reference, the following table lists the names of each input device.
^ Device ^ Name on rM1 < 2.9 ^ Name on rM1 ⩾ 2.9 ^ Name on rM2 ^
| Wacom Digitizer (Pen input) | ''event0'' | ''event0'' | ''event1'' |
| Multitouch (Finger input) | ''event1'' | ''event2'' | ''event2'' |
| GPIO (Buttons) | ''event2'' | ''event1'' | ''event0'' |
==== Reading raw events ====
[[https://github.com/reMarkable/linux/blob/lars/zero-gravitas_4.9/include/uapi/linux/input.h#L25|This struct]] are the binary packets emitted by input devices. All input event codes can be found [[https://github.com/reMarkable/linux/blob/lars/zero-gravitas_4.9/include/uapi/linux/input-event-codes.h|here]] (or [[https://github.com/canselcik/libremarkable/blob/master/src/input/ecodes.rs|here]] for relevant codes per device).
Toltec includes an evtest tool which might come handy during debugging. It gives you human readable output out of the evdev files. [[https://github.com/LinusCDE/rmWacomToMouse/blob/master/rmDebugWacomInput.py|Here]] is also a simple python example that reads out the data of the Wacom pen without any libraries on the rM 1 (but every major programming language has a evdev library to make it easier).
Note that many launchers may grab, inject/overflow or intercept these input events to make switching between multiple running programs possible.
Here is an example of debugging the GPIO (Buttons) device and pressing the middle button on once (on a reMarkable 1):
reMarkable: /home/root/ evtest
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0: Wacom I2C Digitizer
/dev/input/event1: cyttsp5_mt
/dev/input/event2: gpio-keys
Select the device event number [0-2]: 2
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 102 (KEY_HOME)
Event code 105 (KEY_LEFT)
Event code 106 (KEY_RIGHT)
Event code 116 (KEY_POWER)
Event code 143 (KEY_WAKEUP)
Properties:
Testing ... (interrupt to exit)
Event: time 1611410679.061331, type 1 (EV_KEY), code 102 (KEY_HOME), value 1
Event: time 1611410679.061331, -------------- EV_SYN ------------
Event: time 1611410679.191312, type 1 (EV_KEY), code 102 (KEY_HOME), value 0
Event: time 1611410679.191312, -------------- EV_SYN ------------
[[https://github.com/canselcik/libremarkable/|libremarkable]] is a library for the reMarkable in Rust that contains logic to read the inputs of both the reMarkable 1 and 2.
QT applications also support most types of input by default with the provided libraries. Though you might also want to look into Oxide's APIs for improved multitasking support / launcher integration.
=== Oxide ===
Oxide handles informing you of buttons being held in the API, but not normal button presses. Oxide never lets power button presses through ([[https://github.com/Eeems/oxide/blob/master/applications/system-service/buttonhandler.h#L91-L94|code]], so only useful for rM1).
You have triggers in the [[https://github.com/Eeems/oxide/wiki/Developing-Applications-for-Oxide#system-api|Oxide API]] for when your device wakes from sleep (deviceResuming, but make sure your app is a background(able) app).
A bug to be aware of when using Oxide: [[https://github.com/Eeems/oxide/issues/147|Launching remarkable-hacks patched xochitl with Oxide breaks L+R shortcut for Zen Mode]]
=== Draft ===
You can have a look at [[https://github.com/dixonary/button-capture-reMarkable|button-capture-reMarkable]] (don't know whether this still works).
=== Full Outputs of evtest for RM1 and RM2 ===
RM1: event0, Wacom I2C Digitizer (pre 2.9)
reMarkable: ~/ evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x56a product 0x0 version 0x36
Input device name: "Wacom I2C Digitizer"
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 code 332 (BTN_STYLUS2)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 20246
Min 0
Max 20967
Event code 1 (ABS_Y)
Value 13733
Min 0
Max 15725
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 4095
Event code 25 (ABS_DISTANCE)
Value 62
Min 0
Max 255
Event code 26 (ABS_TILT_X)
Value 0
Min -9000
Max 9000
Event code 27 (ABS_TILT_Y)
Value 0
Min -9000
Max 9000
RM1: event1, touchscreen (pre 2.9)
reMarkable: ~/ evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "cyttsp5_mt"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event type 2 (EV_REL)
Event type 3 (EV_ABS)
Event code 25 (ABS_DISTANCE)
Value 0
Min 0
Max 255
Event code 47 (ABS_MT_SLOT)
Value 0
Min 0
Max 31
Event code 48 (ABS_MT_TOUCH_MAJOR)
Value 0
Min 0
Max 255
Event code 49 (ABS_MT_TOUCH_MINOR)
Value 0
Min 0
Max 255
Event code 52 (ABS_MT_ORIENTATION)
Value 0
Min -127
Max 127
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 767
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 1023
Event code 55 (ABS_MT_TOOL_TYPE)
Value 0
Min 0
Max 1
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 65535
Event code 58 (ABS_MT_PRESSURE)
Value 0
Min 0
Max 255
RM1: event2, GPIO buttons (pre 2.9)
reMarkable: ~/ evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 102 (KEY_HOME)
Event code 105 (KEY_LEFT)
Event code 106 (KEY_RIGHT)
Event code 116 (KEY_POWER)
Event code 143 (KEY_WAKEUP)
RM2: event0, Power Button
reMarkable: ~/ evtest /dev/input/event0
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x0 product 0x0 version 0x0
Input device name: "30370000.snvs:snvs-powerkey"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 116 (KEY_POWER)
RM2: event1, Wacom I2C digitizer
reMarkable: ~/ evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x18 vendor 0x56a product 0x0 version 0x31
Input device name: "Wacom I2C Digitizer"
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 code 332 (BTN_STYLUS2)
Event type 3 (EV_ABS)
Event code 0 (ABS_X)
Value 5291
Min 0
Max 20966
Event code 1 (ABS_Y)
Value 10464
Min 0
Max 15725
Event code 24 (ABS_PRESSURE)
Value 0
Min 0
Max 4095
Event code 25 (ABS_DISTANCE)
Value 78
Min 0
Max 255
Event code 26 (ABS_TILT_X)
Value -2800
Min -9000
Max 9000
Event code 27 (ABS_TILT_Y)
Value 2900
Min -9000
Max 9000
RM2: event2, touchscreen
reMarkable: ~/ evtest /dev/input/event2
Input driver version is 1.0.1
Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0
Input device name: "pt_mt"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 59 (KEY_F1)
Event code 60 (KEY_F2)
Event code 61 (KEY_F3)
Event code 62 (KEY_F4)
Event code 63 (KEY_F5)
Event code 64 (KEY_F6)
Event code 65 (KEY_F7)
Event code 66 (KEY_F8)
Event type 2 (EV_REL)
Event type 3 (EV_ABS)
Event code 25 (ABS_DISTANCE)
Value 0
Min 0
Max 255
Event code 47 (ABS_MT_SLOT)
Value 0
Min 0
Max 31
Event code 48 (ABS_MT_TOUCH_MAJOR)
Value 0
Min 0
Max 255
Event code 49 (ABS_MT_TOUCH_MINOR)
Value 0
Min 0
Max 255
Event code 52 (ABS_MT_ORIENTATION)
Value 0
Min -127
Max 127
Event code 53 (ABS_MT_POSITION_X)
Value 0
Min 0
Max 1403
Event code 54 (ABS_MT_POSITION_Y)
Value 0
Min 0
Max 1871
Event code 55 (ABS_MT_TOOL_TYPE)
Value 0
Min 0
Max 1
Event code 57 (ABS_MT_TRACKING_ID)
Value 0
Min 0
Max 65535
Event code 58 (ABS_MT_PRESSURE)
Value 0
Min 0
Max 255