Skip to content

Commit

Permalink
Remove dependency on python-uinput
Browse files Browse the repository at this point in the history
  • Loading branch information
ehfd committed Jan 5, 2024
1 parent dbce56e commit 364e52b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ This table specifies the currently supported display interfaces and how each plu

| Plugin | Device Selector | Display Interfaces | Input Interfaces | Operating Systems | Main Dependencies | Notes |
|---|---|---|---|---|---|---|
| [`ximagesrc`](https://gstreamer.freedesktop.org/documentation/ximagesrc/index.html) | `DISPLAY` environment | X.Org / X11 | [`Xlib`](https://github.com/python-xlib/python-xlib) w/ [`pynput`](https://github.com/moses-palmer/pynput), `uinput` | Linux | Various | N/A |
| [`ximagesrc`](https://gstreamer.freedesktop.org/documentation/ximagesrc/index.html) | `DISPLAY` environment | X.Org / X11 | [`Xlib`](https://github.com/python-xlib/python-xlib) w/ [`pynput`](https://github.com/moses-palmer/pynput) | Linux | Various | N/A |

This table specifies the currently implemented audio encoders and their corresponding codecs. Opus is currently the only adequate media codec supported in web browsers by specification.

Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ install_requires =
psutil
watchdog
Pillow
python-uinput @ git+https://github.com/selkies-project/python-uinput.git@0.11.3
python-xlib

[options.packages.find]
Expand Down
22 changes: 14 additions & 8 deletions src/selkies_gstreamer/webrtc_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import base64
import pynput
import io
import uinput
import msgpack
import re
import os
Expand Down Expand Up @@ -54,18 +53,25 @@
MOUSE_BUTTON_MIDDLE = 42
MOUSE_BUTTON_RIGHT = 43

UINPUT_BTN_LEFT = (0x01, 0x110)
UINPUT_BTN_MIDDLE = (0x01, 0x112)
UINPUT_BTN_RIGHT = (0x01, 0x111)
UINPUT_REL_X = (0x02, 0x00)
UINPUT_REL_Y = (0x02, 0x01)
UINPUT_REL_WHEEL = (0x02, 0x08)

# Local map for uinput and pynput buttons
MOUSE_BUTTON_MAP = {
MOUSE_BUTTON_LEFT: {
"uinput": uinput.BTN_LEFT,
"uinput": UINPUT_BTN_LEFT,
"pynput": pynput.mouse.Button.left,
},
MOUSE_BUTTON_MIDDLE: {
"uinput": uinput.BTN_MIDDLE,
"uinput": UINPUT_BTN_MIDDLE,
"pynput": pynput.mouse.Button.middle,
},
MOUSE_BUTTON_RIGHT: {
"uinput": uinput.BTN_RIGHT,
"uinput": UINPUT_BTN_RIGHT,
"pynput": pynput.mouse.Button.right,
},
}
Expand Down Expand Up @@ -267,8 +273,8 @@ def send_mouse(self, action, data):
if self.uinput_mouse_socket_path:
# Send relative motion to uinput device.
# syn=False delays the sync until the second command.
self.__mouse_emit(uinput.REL_X, x, syn=False)
self.__mouse_emit(uinput.REL_Y, y)
self.__mouse_emit(UINPUT_REL_X, x, syn=False)
self.__mouse_emit(UINPUT_REL_Y, y)
else:
# NOTE: the pynput mouse.move method moves the mouse relative to the current position using its internal tracked position.
# this does not work for relative motion where the input should just be a delta value.
Expand All @@ -278,13 +284,13 @@ def send_mouse(self, action, data):
elif action == MOUSE_SCROLL_UP:
# Scroll up
if self.uinput_mouse_socket_path:
self.__mouse_emit(uinput.REL_WHEEL, 1)
self.__mouse_emit(UINPUT_REL_WHEEL, 1)
else:
self.mouse.scroll(0, -1)
elif action == MOUSE_SCROLL_DOWN:
# Scroll down
if self.uinput_mouse_socket_path:
self.__mouse_emit(uinput.REL_WHEEL, -1)
self.__mouse_emit(UINPUT_REL_WHEEL, -1)
else:
self.mouse.scroll(0, 1)
elif action == MOUSE_BUTTON:
Expand Down

0 comments on commit 364e52b

Please sign in to comment.