bluetooth: fix BLE/HID keyboard & mouse pairing, auto-bypass T9 on external keyboard, and show mouse cursor
This commit is contained in:
1 parent
b9e7c6847b
commit
02ce3ab1f4
67 files changed
+1073
-139
No files matched your search
+1
-1
@@ -25,7 +25,7 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
- **Bluetooth audio (`A2DP`, `HSP/HFP`), HID peripherals (keyboards, mice, gamepads), discoverability & alias settings, and active connection badges (`xnetworks`, `bananarchy-bt-obex`, `sxmo_audio.sh`, `dwm`, `libneoui.so`)**:
|
- **Bluetooth audio (`A2DP`, `HSP/HFP`), HID peripherals (keyboards, mice, gamepads), discoverability & alias settings, and active connection badges (`xnetworks`, `bananarchy-bt-obex`, `sxmo_audio.sh`, `dwm`, `libneoui.so`)**:
|
||||||
- Configured BlueZ (`/etc/bluetooth/main.conf`, `/etc/bluetooth/input.conf`) and WirePlumber (`50-bluetooth.conf`) with full **A2DP** (`a2dp_sink`, `a2dp_source` with `sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`), **HSP/HFP** (`hsp_hs`, `hsp_ag`, `hfp_hf`, `hfp_ag` with `mSBC` wideband speech and hardware volume), and **HID / BLE HOGP** (`uhid`, `hidp`, `uinput`, `rfcomm`, `bnep`, `xpad`) profile support, and added `Bluetooth` as a selectable audio output/input route in `sxmo_audio.sh`, `xdrawer`, and `dmenu` Audio menu (plus automatic PipeWire `"default"` ALSA routing in `gambatte` and `remedy` when Bluetooth audio is active).
|
- Configured BlueZ (`/etc/bluetooth/main.conf`, `/etc/bluetooth/input.conf`) and WirePlumber (`50-bluetooth.conf`) with full **A2DP** (`a2dp_sink`, `a2dp_source` with `sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`), **HSP/HFP** (`hsp_hs`, `hsp_ag`, `hfp_hf`, `hfp_ag` with `mSBC` wideband speech and hardware volume), and **HID / BLE HOGP** (`uhid`, `hidp`, `uinput`, `rfcomm`, `bnep`, `xpad`) profile support, and added `Bluetooth` as a selectable audio output/input route in `sxmo_audio.sh`, `xdrawer`, and `dmenu` Audio menu (plus automatic PipeWire `"default"` ALSA routing in `gambatte` and `remedy` when Bluetooth audio is active).
|
||||||
- Added **Discoverable** (`ON (Visible)` / `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`) and **Bluetooth Device Name** (`Name: <Alias> [Edit]` with a multi-tap modal editor persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname) rows to the `3:Bluetooth` tab of `xnetworks`, alongside active connection count headers (`Bluetooth: ON (N Active)`), pinned active device cards with live profile and battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and a **Switch Audio (A2DP / HSP-HFP)** action.
|
- Added **Discoverable** (`ON (Visible)` / `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`) and **Bluetooth Device Name** (`Name: <Alias> [Edit]` with a multi-tap modal editor persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname) rows to the `3:Bluetooth` tab of `xnetworks`, alongside active connection count headers (`Bluetooth: ON (N Active)`), pinned active device cards with live profile and battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and a **Switch Audio (A2DP / HSP-HFP)** action.
|
||||||
- Added an automatic `/dev/uinput` gamepad-to-keypad bridge (`Bananarchy BT Gamepad Bridge`) inside `/usr/bin/bananarchy-bt-obex` so Bluetooth/USB gamepads (`D-Pad` / `Left Stick` -> `Up`/`Down`/`Left`/`Right`, `South/A` -> `Enter`, `East/B` -> `8`, `West/X` -> `5`, `North/Y` -> `6`, `Start` -> `2`, `Select` -> `3`, `L1`/`R1` -> `Left`/`Right softkey`, `L2`/`R2` -> `*`/`0`, `Mode` -> `Escape`) control all NeoUI apps and games (`snake`, `tetris`, `scoundrel`, `gambatte`, `remedy`) out of the box, and added dynamic `XFixes` cursor visibility in `dwm` (and `ButtonPress` handling in `dwm` and `libneoui.so`) so connecting a Bluetooth mouse shows the cursor on movement/click and hides it automatically on keypad use.
|
- Added a persistent BlueZ `NoInputNoOutput` default pairing/authorization agent (`/org/bananarchy/bt_agent`) and D-Bus `connect`/`pair` handler inside `/usr/bin/bananarchy-bt-obex` (with a 15-second discovery scan window) for seamless BLE HOGP (`00001812`) and Classic HID (`00001124`) keyboard/mouse/gamepad SMP/SSP Just-Works bonding and auto-reconnection, an automatic `/dev/uinput` gamepad-to-keypad bridge (`Bananarchy BT Gamepad Bridge`, excluding QWERTY keyboards) so Bluetooth/USB gamepads (`D-Pad` / `Left Stick` -> `Up`/`Down`/`Left`/`Right`, `South/A` -> `Enter`, `East/B` -> `8`, `West/X` -> `5`, `North/Y` -> `6`, `Start` -> `2`, `Select` -> `3`, `L1`/`R1` -> `Left`/`Right softkey`, `L2`/`R2` -> `*`/`0`, `Mode` -> `Escape`) control all NeoUI apps and games (`snake`, `tetris`, `scoundrel`, `gambatte`, `remedy`) out of the box, automatic `[KBD]` external keyboard detection (`isExternalKeyboardActive()`) in `fcitx5-t9`, `libneoui.so`, and DWM plugins so connecting a Bluetooth/USB QWERTY keyboard automatically bypasses T9 multi-tap and preedit popups for all keys (`0-9`, `*`, `#`, `Shift+0-9`, and letters), and automatic `XFixes` cursor display in `dwm` (`dwm_has_external_mouse()`) whenever a Bluetooth/USB mouse is connected.
|
||||||
- **Universal Power button (`dmenu power`) access, lockscreen X11 grab preemption, ReMEdy `Call (green)` pause menu, JSR expansion, and 64 MB mark-and-sweep GC**:
|
- **Universal Power button (`dmenu power`) access, lockscreen X11 grab preemption, ReMEdy `Call (green)` pause menu, JSR expansion, and 64 MB mark-and-sweep GC**:
|
||||||
- Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately opens (or toggles) the system **Power menu (`dmenu power`)** while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**.
|
- Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately opens (or toggles) the system **Power menu (`dmenu power`)** while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**.
|
||||||
- Updated `locker.so` (`xlocker`) and `dwm` to preempt active X11 keyboard grabs and window stacking over any running fullscreen application or game (`webarchy`, `remedy`, `gambatte`, `scoundrel`, `snake`, `tetris`, and all NeoUI plugins) when the screen locks, cleanly restoring the previously focused application upon unlock.
|
- Updated `locker.so` (`xlocker`) and `dwm` to preempt active X11 keyboard grabs and window stacking over any running fullscreen application or game (`webarchy`, `remedy`, `gambatte`, `scoundrel`, `snake`, `tetris`, and all NeoUI plugins) when the screen locks, cleanly restoring the previously focused application upon unlock.
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/
|
|||||||
- **Three connectivity tabs (`Left`/`Right` or `1`–`3`)**:
|
- **Three connectivity tabs (`Left`/`Right` or `1`–`3`)**:
|
||||||
- **`1:Wi-Fi`**: toggle Wi-Fi radio, rescan (`*`), toggle **Wi-Fi Hotspot**, and connect to WPA2/open networks with a multi-tap password dialog (`*` toggles password visibility).
|
- **`1:Wi-Fi`**: toggle Wi-Fi radio, rescan (`*`), toggle **Wi-Fi Hotspot**, and connect to WPA2/open networks with a multi-tap password dialog (`*` toggles password visibility).
|
||||||
- **`2:Cell/APN`**: toggle **Mobile Data** (configuring the QMI `bam-dmux` `wwan0` static IPv4 bearer, default route, and DNS automatically), inspect `wwan0` IPv4 status, edit **APN Configuration**, and toggle **USB Tethering**.
|
- **`2:Cell/APN`**: toggle **Mobile Data** (configuring the QMI `bam-dmux` `wwan0` static IPv4 bearer, default route, and DNS automatically), inspect `wwan0` IPv4 status, edit **APN Configuration**, and toggle **USB Tethering**.
|
||||||
- **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`ON (Visible)` vs `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), monitor the live **OBEX File Receiver** widget (`#` opens `~/Downloads/` in `xfiles`), scan nearby devices (`*`), and manage paired/discovered devices. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Disconnect / Connect**, **Switch Audio (A2DP / HSP-HFP)**, **Trust**, and **Remove / Forget**. Supports Bluetooth **A2DP** (`sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`) and **HSP/HFP** (`mSBC` / `CVSD`) audio (routable via `xdrawer`, `dmenu Audio`, and `sxmo_audio.sh`), **HID keyboards**, **HID mice** (with automatic X11 cursor display on mouse movement/click and auto-hide on keypad input), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`).
|
- **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`ON (Visible)` vs `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), monitor the live **OBEX File Receiver** widget (`#` opens `~/Downloads/` in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Connect Device**, **Disconnect Device**, **Pair & Trust Device**, **Switch Audio (A2DP / HSP-HFP)**, and **Forget / Remove Device**. Supports Bluetooth **A2DP** (`sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`) and **HSP/HFP** (`mSBC` / `CVSD`) audio (routable via `xdrawer`, `dmenu Audio`, and `sxmo_audio.sh`), **HID keyboards** (automatically switching `fcitx5-t9` and NeoUI/plugin inputs to `[KBD]` direct QWERTY mode so `0-9`, `*`, `#`, `Shift+0-9`, and letters bypass T9 multi-tap and preedit popups), **HID mice** (automatically showing the X11 mouse cursor whenever a mouse is connected and hiding it when disconnected), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`).
|
||||||
|
|
||||||
13. **Ringtones, notification/SMS sounds, and ringer manager (`ringtones.so` / `xringtones`)**:
|
13. **Ringtones, notification/SMS sounds, and ringer manager (`ringtones.so` / `xringtones`)**:
|
||||||
- **Open**: select **Ringtones** from the System, Config, or Audio menu, select **Notification Sound** from the **Notifications (`Notifs`)** menu, or run `xringtones [--notif] [file]`.
|
- **Open**: select **Ringtones** from the System, Config, or Audio menu, select **Notification Sound** from the **Notifications (`Notifs`)** menu, or run `xringtones [--notif] [file]`.
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="keypad", ENV{ID_INPUT_KEYBOA
|
|||||||
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="gpio-keys", ENV{ID_INPUT_KEYBOARD}="1"
|
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="gpio-keys", ENV{ID_INPUT_KEYBOARD}="1"
|
||||||
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8941_resin", ENV{ID_INPUT_KEYBOARD}="1"
|
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8941_resin", ENV{ID_INPUT_KEYBOARD}="1"
|
||||||
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8xxx*vib*", SYMLINK+="input/by-path/platform-vibrator-event"
|
SUBSYSTEM=="input", KERNEL=="event*", ATTRS{name}=="pm8xxx*vib*", SYMLINK+="input/by-path/platform-vibrator-event"
|
||||||
|
KERNEL=="uinput", GROUP="input", MODE="0660"
|
||||||
Binary file not shown.
@@ -327,6 +327,7 @@ def run_gamepad_uinput_bridge(is_running):
|
|||||||
uinput_fd = None
|
uinput_fd = None
|
||||||
gamepads = {} # path -> {"fd": int, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}}
|
gamepads = {} # path -> {"fd": int, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}}
|
||||||
last_scan = 0.0
|
last_scan = 0.0
|
||||||
|
last_input_mtime = 0
|
||||||
|
|
||||||
def ensure_uinput():
|
def ensure_uinput():
|
||||||
nonlocal uinput_fd
|
nonlocal uinput_fd
|
||||||
@@ -386,6 +387,16 @@ def run_gamepad_uinput_bridge(is_running):
|
|||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
if now - last_scan >= 2.0:
|
if now - last_scan >= 2.0:
|
||||||
last_scan = now
|
last_scan = now
|
||||||
|
try:
|
||||||
|
st_in = os.stat("/dev/input")
|
||||||
|
if last_input_mtime != 0 and st_in.st_mtime_ns != last_input_mtime:
|
||||||
|
subprocess.Popen(
|
||||||
|
["sh", "-c", "DISPLAY=:0 xsetroot -name \"$(cat /tmp/sxmo_status_bar 2>/dev/null || printf 'Bananarchy')\" >/dev/null 2>&1 || sxmo_hook_statusbar.sh >/dev/null 2>&1"],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||||
|
)
|
||||||
|
last_input_mtime = st_in.st_mtime_ns
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
for entry in os.listdir("/dev/input"):
|
for entry in os.listdir("/dev/input"):
|
||||||
if not entry.startswith("event"):
|
if not entry.startswith("event"):
|
||||||
@@ -406,7 +417,8 @@ def run_gamepad_uinput_bridge(is_running):
|
|||||||
buf = bytearray(96)
|
buf = bytearray(96)
|
||||||
fcntl.ioctl(fd, eviocgbit_key, buf, True)
|
fcntl.ioctl(fd, eviocgbit_key, buf, True)
|
||||||
has_gamepad = bool((buf[0x130 // 8] >> (0x130 % 8)) & 1) or bool((buf[0x120 // 8] >> (0x120 % 8)) & 1)
|
has_gamepad = bool((buf[0x130 // 8] >> (0x130 % 8)) & 1) or bool((buf[0x120 // 8] >> (0x120 % 8)) & 1)
|
||||||
if has_gamepad:
|
has_qwerty = bool((buf[16 // 8] >> (16 % 8)) & 1) and bool((buf[30 // 8] >> (30 % 8)) & 1)
|
||||||
|
if has_gamepad and not has_qwerty:
|
||||||
ensure_uinput()
|
ensure_uinput()
|
||||||
gamepads[dev_path] = {
|
gamepads[dev_path] = {
|
||||||
"fd": fd, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}
|
"fd": fd, "hat_x": 0, "hat_y": 0, "lx": 0, "ly": 0, "ax": {}
|
||||||
@@ -522,6 +534,137 @@ def run_gamepad_uinput_bridge(is_running):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def trust_device_path(conn, dev_path):
|
||||||
|
if not isinstance(dev_path, str) or not dev_path.startswith("/org/bluez/"):
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
from jeepney import DBusAddress, new_method_call
|
||||||
|
prop_addr = DBusAddress(dev_path, bus_name="org.bluez",
|
||||||
|
interface="org.freedesktop.DBus.Properties")
|
||||||
|
conn.send(new_method_call(prop_addr, "Set", "ssv",
|
||||||
|
("org.bluez.Device1", "Trusted", ("b", True))))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def handle_agent_method_call(conn, msg, agent_path):
|
||||||
|
from jeepney import new_method_return, MessageType
|
||||||
|
if msg is None or msg.header.message_type != MessageType.method_call:
|
||||||
|
return False
|
||||||
|
path = msg.header.fields.get(1)
|
||||||
|
member = msg.header.fields.get(3)
|
||||||
|
if path != agent_path:
|
||||||
|
return False
|
||||||
|
dev_path = msg.body[0] if (msg.body and len(msg.body) > 0) else None
|
||||||
|
if member in ("RequestConfirmation", "RequestAuthorization", "AuthorizeService"):
|
||||||
|
conn.send(new_method_return(msg))
|
||||||
|
trust_device_path(conn, dev_path)
|
||||||
|
notify_networks_ui()
|
||||||
|
return True
|
||||||
|
if member == "RequestPinCode":
|
||||||
|
conn.send(new_method_return(msg, "s", ("0000",)))
|
||||||
|
trust_device_path(conn, dev_path)
|
||||||
|
notify_networks_ui()
|
||||||
|
return True
|
||||||
|
if member == "RequestPasskey":
|
||||||
|
conn.send(new_method_return(msg, "u", (0,)))
|
||||||
|
trust_device_path(conn, dev_path)
|
||||||
|
notify_networks_ui()
|
||||||
|
return True
|
||||||
|
if member in ("DisplayPinCode", "DisplayPasskey"):
|
||||||
|
conn.send(new_method_return(msg))
|
||||||
|
trust_device_path(conn, dev_path)
|
||||||
|
notify_networks_ui()
|
||||||
|
return True
|
||||||
|
if member in ("Cancel", "Release"):
|
||||||
|
conn.send(new_method_return(msg))
|
||||||
|
return True
|
||||||
|
conn.send(new_method_return(msg))
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def dbus_call_with_agent(conn, call_msg, agent_path, timeout=5.0):
|
||||||
|
from jeepney import HeaderFields, MessageType
|
||||||
|
serial = next(conn.outgoing_serial)
|
||||||
|
conn.send(call_msg, serial=serial)
|
||||||
|
deadline = time.time() + timeout
|
||||||
|
while time.time() < deadline:
|
||||||
|
rem = max(0.05, deadline - time.time())
|
||||||
|
try:
|
||||||
|
msg = conn.receive(timeout=rem)
|
||||||
|
except TimeoutError:
|
||||||
|
return None
|
||||||
|
if msg is None:
|
||||||
|
continue
|
||||||
|
if handle_agent_method_call(conn, msg, agent_path):
|
||||||
|
continue
|
||||||
|
if msg.header.message_type in (MessageType.method_return, MessageType.error):
|
||||||
|
if msg.header.fields.get(HeaderFields.reply_serial, -1) == serial:
|
||||||
|
return msg
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def register_bluez_services(conn, profile_path, agent_path):
|
||||||
|
from jeepney import DBusAddress, new_method_call
|
||||||
|
try:
|
||||||
|
aprop = DBusAddress("/org/bluez/hci0", bus_name="org.bluez",
|
||||||
|
interface="org.freedesktop.DBus.Properties")
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(aprop, "Set", "ssv",
|
||||||
|
("org.bluez.Adapter1", "PairableTimeout", ("u", 0))),
|
||||||
|
agent_path,
|
||||||
|
timeout=2.0
|
||||||
|
)
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(aprop, "Set", "ssv",
|
||||||
|
("org.bluez.Adapter1", "Pairable", ("b", True))),
|
||||||
|
agent_path,
|
||||||
|
timeout=2.0
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
am = DBusAddress("/org/bluez", bus_name="org.bluez",
|
||||||
|
interface="org.bluez.AgentManager1")
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(am, "RegisterAgent", "os",
|
||||||
|
(agent_path, "NoInputNoOutput")),
|
||||||
|
agent_path,
|
||||||
|
timeout=3.0
|
||||||
|
)
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(am, "RequestDefaultAgent", "o", (agent_path,)),
|
||||||
|
agent_path,
|
||||||
|
timeout=3.0
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
pm = DBusAddress("/org/bluez", bus_name="org.bluez",
|
||||||
|
interface="org.bluez.ProfileManager1")
|
||||||
|
opts = {
|
||||||
|
"Name": ("s", "OBEX Object Push"),
|
||||||
|
"Role": ("s", "server"),
|
||||||
|
"Channel": ("q", 9),
|
||||||
|
"RequireAuthentication": ("b", False),
|
||||||
|
"RequireAuthorization": ("b", False),
|
||||||
|
"AutoConnect": ("b", True),
|
||||||
|
}
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(pm, "RegisterProfile", "osa{sv}",
|
||||||
|
(profile_path, OPP_UUID, opts)),
|
||||||
|
agent_path,
|
||||||
|
timeout=3.0
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def run_daemon():
|
def run_daemon():
|
||||||
from jeepney import DBusAddress, new_method_call, new_method_return, MessageType
|
from jeepney import DBusAddress, new_method_call, new_method_return, MessageType
|
||||||
from jeepney.io.blocking import open_dbus_connection
|
from jeepney.io.blocking import open_dbus_connection
|
||||||
@@ -578,22 +721,22 @@ def run_daemon():
|
|||||||
gp_thread.start()
|
gp_thread.start()
|
||||||
|
|
||||||
profile_path = "/org/bananarchy/obex_opp"
|
profile_path = "/org/bananarchy/obex_opp"
|
||||||
|
agent_path = "/org/bananarchy/bt_agent"
|
||||||
conn = None
|
conn = None
|
||||||
try:
|
try:
|
||||||
conn = open_dbus_connection(bus="SYSTEM", enable_fds=True)
|
conn = open_dbus_connection(bus="SYSTEM", enable_fds=True)
|
||||||
pm = DBusAddress("/org/bluez", bus_name="org.bluez",
|
dbus_bus = DBusAddress("/org/freedesktop/DBus",
|
||||||
interface="org.bluez.ProfileManager1")
|
bus_name="org.freedesktop.DBus",
|
||||||
opts = {
|
interface="org.freedesktop.DBus")
|
||||||
"Name": ("s", "OBEX Object Push"),
|
conn.send(new_method_call(
|
||||||
"Role": ("s", "server"),
|
dbus_bus, "AddMatch", "s",
|
||||||
"Channel": ("q", 9),
|
("type='signal',sender='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.bluez'",)
|
||||||
"RequireAuthentication": ("b", False),
|
))
|
||||||
"RequireAuthorization": ("b", False),
|
conn.send(new_method_call(
|
||||||
"AutoConnect": ("b", True),
|
dbus_bus, "AddMatch", "s",
|
||||||
}
|
("type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',arg0='org.bluez.Device1'",)
|
||||||
reg_msg = new_method_call(pm, "RegisterProfile", "osa{sv}",
|
))
|
||||||
(profile_path, OPP_UUID, opts))
|
register_bluez_services(conn, profile_path, agent_path)
|
||||||
conn.send_and_get_reply(reg_msg, timeout=5.0)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -617,7 +760,10 @@ def run_daemon():
|
|||||||
msg = conn.receive(timeout=1.0)
|
msg = conn.receive(timeout=1.0)
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
msg = None
|
msg = None
|
||||||
if msg is not None and msg.header.message_type == MessageType.method_call:
|
if msg is not None:
|
||||||
|
if handle_agent_method_call(conn, msg, agent_path):
|
||||||
|
pass
|
||||||
|
elif msg.header.message_type == MessageType.method_call:
|
||||||
member = msg.header.fields.get(3) # Member name
|
member = msg.header.fields.get(3) # Member name
|
||||||
path = msg.header.fields.get(1) # Object path
|
path = msg.header.fields.get(1) # Object path
|
||||||
if path == profile_path and member == "NewConnection":
|
if path == profile_path and member == "NewConnection":
|
||||||
@@ -634,6 +780,17 @@ def run_daemon():
|
|||||||
elif path == profile_path and member in ("RequestDisconnection", "Release"):
|
elif path == profile_path and member in ("RequestDisconnection", "Release"):
|
||||||
reply = new_method_return(msg)
|
reply = new_method_return(msg)
|
||||||
conn.send(reply)
|
conn.send(reply)
|
||||||
|
elif msg.header.message_type == MessageType.signal:
|
||||||
|
member = msg.header.fields.get(3)
|
||||||
|
if member == "NameOwnerChanged" and msg.body and len(msg.body) >= 3:
|
||||||
|
name, _old_owner, new_owner = msg.body[0], msg.body[1], msg.body[2]
|
||||||
|
if name == "org.bluez" and new_owner:
|
||||||
|
register_bluez_services(conn, profile_path, agent_path)
|
||||||
|
elif member == "PropertiesChanged" and msg.body and len(msg.body) >= 2:
|
||||||
|
iface, changed = msg.body[0], msg.body[1]
|
||||||
|
if iface == "org.bluez.Device1" and isinstance(changed, dict):
|
||||||
|
if any(k in changed for k in ("Connected", "Paired", "Bonded")):
|
||||||
|
notify_networks_ui()
|
||||||
else:
|
else:
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
|
||||||
@@ -831,6 +988,275 @@ def send_file_obex(mac, filepath):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_daemon_running():
|
||||||
|
if os.path.exists(PID_FILE):
|
||||||
|
try:
|
||||||
|
with open(PID_FILE, "r", encoding="utf-8") as f:
|
||||||
|
pid = int(f.read().strip())
|
||||||
|
os.kill(pid, 0)
|
||||||
|
return
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
subprocess.Popen([sys.executable, __file__, "daemon"],
|
||||||
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||||
|
start_new_session=True)
|
||||||
|
time.sleep(0.25)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def connect_or_pair_bt_device(mac, dev_name="", do_pair=False):
|
||||||
|
from jeepney import DBusAddress, new_method_call, MessageType
|
||||||
|
from jeepney.io.blocking import open_dbus_connection
|
||||||
|
|
||||||
|
ensure_daemon_running()
|
||||||
|
mac = mac.strip().upper()
|
||||||
|
if not mac:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
dev_path = "/org/bluez/hci0/dev_" + mac.replace(":", "_")
|
||||||
|
orig_path = dev_path
|
||||||
|
cli_agent_path = f"/org/bananarchy/bt_cli_agent_{os.getpid()}"
|
||||||
|
adapter_addr = DBusAddress("/org/bluez/hci0", bus_name="org.bluez",
|
||||||
|
interface="org.bluez.Adapter1")
|
||||||
|
am_addr = DBusAddress("/org/bluez", bus_name="org.bluez",
|
||||||
|
interface="org.bluez.AgentManager1")
|
||||||
|
om_addr = DBusAddress("/", bus_name="org.bluez",
|
||||||
|
interface="org.freedesktop.DBus.ObjectManager")
|
||||||
|
|
||||||
|
conn = None
|
||||||
|
try:
|
||||||
|
conn = open_dbus_connection(bus="SYSTEM")
|
||||||
|
aprop_addr = DBusAddress("/org/bluez/hci0", bus_name="org.bluez",
|
||||||
|
interface="org.freedesktop.DBus.Properties")
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(aprop_addr, "Set", "ssv",
|
||||||
|
("org.bluez.Adapter1", "Pairable", ("b", True))),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=2.0
|
||||||
|
)
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(am_addr, "RegisterAgent", "os",
|
||||||
|
(cli_agent_path, "NoInputNoOutput")),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=2.5
|
||||||
|
)
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(am_addr, "RequestDefaultAgent", "o", (cli_agent_path,)),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=2.5
|
||||||
|
)
|
||||||
|
|
||||||
|
def pump_agent(duration):
|
||||||
|
end_t = time.time() + duration
|
||||||
|
while time.time() < end_t:
|
||||||
|
rem = max(0.05, min(0.25, end_t - time.time()))
|
||||||
|
try:
|
||||||
|
m = conn.receive(timeout=rem)
|
||||||
|
if m is not None:
|
||||||
|
handle_agent_method_call(conn, m, cli_agent_path)
|
||||||
|
except TimeoutError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_dev_props(dpath):
|
||||||
|
prop_addr = DBusAddress(dpath, bus_name="org.bluez",
|
||||||
|
interface="org.freedesktop.DBus.Properties")
|
||||||
|
rep = dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(prop_addr, "GetAll", "s", ("org.bluez.Device1",)),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=2.5
|
||||||
|
)
|
||||||
|
if rep is None or rep.header.message_type != MessageType.method_return or not rep.body:
|
||||||
|
return None
|
||||||
|
raw = rep.body[0]
|
||||||
|
if not isinstance(raw, dict):
|
||||||
|
return None
|
||||||
|
out = {}
|
||||||
|
for k, v in raw.items():
|
||||||
|
out[k] = v[1] if (isinstance(v, (tuple, list)) and len(v) == 2) else v
|
||||||
|
return out
|
||||||
|
|
||||||
|
def find_matching_device(target_name, prefer_path=None):
|
||||||
|
if not target_name:
|
||||||
|
return None
|
||||||
|
t_low = target_name.strip().lower()
|
||||||
|
rep = dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(om_addr, "GetManagedObjects"),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=3.0
|
||||||
|
)
|
||||||
|
if rep is None or rep.header.message_type != MessageType.method_return or not rep.body:
|
||||||
|
return None
|
||||||
|
objs = rep.body[0]
|
||||||
|
if not isinstance(objs, dict):
|
||||||
|
return None
|
||||||
|
candidates = []
|
||||||
|
for opath, ifaces in objs.items():
|
||||||
|
if not isinstance(opath, str) or not opath.startswith("/org/bluez/hci0/dev_"):
|
||||||
|
continue
|
||||||
|
dprops_raw = ifaces.get("org.bluez.Device1") if isinstance(ifaces, dict) else None
|
||||||
|
if not isinstance(dprops_raw, dict):
|
||||||
|
continue
|
||||||
|
dprops = {
|
||||||
|
k: (v[1] if isinstance(v, (tuple, list)) and len(v) == 2 else v)
|
||||||
|
for k, v in dprops_raw.items()
|
||||||
|
}
|
||||||
|
nm = str(dprops.get("Name") or dprops.get("Alias") or "").strip().lower()
|
||||||
|
if nm == t_low:
|
||||||
|
score = 0
|
||||||
|
if dprops.get("Connected"):
|
||||||
|
score += 100
|
||||||
|
if "RSSI" in dprops and dprops.get("RSSI") is not None:
|
||||||
|
score += 50
|
||||||
|
if opath == prefer_path:
|
||||||
|
score += 10
|
||||||
|
candidates.append((score, opath))
|
||||||
|
if not candidates:
|
||||||
|
return None
|
||||||
|
candidates.sort(key=lambda x: x[0], reverse=True)
|
||||||
|
return candidates[0][1]
|
||||||
|
|
||||||
|
def wait_for_bond_if_connected(dpath, max_wait=3.5):
|
||||||
|
deadline = time.time() + max_wait
|
||||||
|
while time.time() < deadline:
|
||||||
|
pump_agent(0.25)
|
||||||
|
p = get_dev_props(dpath)
|
||||||
|
if not p or not p.get("Connected"):
|
||||||
|
break
|
||||||
|
if p.get("Paired") or p.get("Bonded"):
|
||||||
|
return p
|
||||||
|
return get_dev_props(dpath)
|
||||||
|
|
||||||
|
def cancel_pending_connect(dpath):
|
||||||
|
dev_addr = DBusAddress(dpath, bus_name="org.bluez",
|
||||||
|
interface="org.bluez.Device1")
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn, new_method_call(dev_addr, "Disconnect"), cli_agent_path, timeout=2.0
|
||||||
|
)
|
||||||
|
|
||||||
|
def attempt_connect_path(dpath, want_pair):
|
||||||
|
trust_device_path(conn, dpath)
|
||||||
|
p = get_dev_props(dpath)
|
||||||
|
if p is None:
|
||||||
|
return False
|
||||||
|
if p.get("Connected"):
|
||||||
|
p = wait_for_bond_if_connected(dpath, 3.5) or p
|
||||||
|
if p.get("Connected") and (not want_pair or p.get("Paired") or p.get("Bonded")):
|
||||||
|
return True
|
||||||
|
|
||||||
|
dev_addr = DBusAddress(dpath, bus_name="org.bluez",
|
||||||
|
interface="org.bluez.Device1")
|
||||||
|
if want_pair and not (p.get("Paired") or p.get("Bonded")):
|
||||||
|
rep = dbus_call_with_agent(
|
||||||
|
conn, new_method_call(dev_addr, "Pair"), cli_agent_path, timeout=8.0
|
||||||
|
)
|
||||||
|
if rep is None:
|
||||||
|
cancel_pending_connect(dpath)
|
||||||
|
p = get_dev_props(dpath) or {}
|
||||||
|
|
||||||
|
if not p.get("Connected"):
|
||||||
|
rep = dbus_call_with_agent(
|
||||||
|
conn, new_method_call(dev_addr, "Connect"), cli_agent_path, timeout=8.0
|
||||||
|
)
|
||||||
|
if rep is None:
|
||||||
|
cancel_pending_connect(dpath)
|
||||||
|
p = get_dev_props(dpath) or {}
|
||||||
|
|
||||||
|
if p.get("Connected") and not (p.get("Paired") or p.get("Bonded")):
|
||||||
|
p = wait_for_bond_if_connected(dpath, 4.0) or p
|
||||||
|
|
||||||
|
if p.get("Connected"):
|
||||||
|
return True
|
||||||
|
if want_pair and (p.get("Paired") or p.get("Bonded")):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def scan_for_device(prefer_path, max_scan=15.0):
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn, new_method_call(adapter_addr, "StartDiscovery"), cli_agent_path, timeout=2.5
|
||||||
|
)
|
||||||
|
scan_start = time.time()
|
||||||
|
scan_deadline = scan_start + max_scan
|
||||||
|
discovered_path = prefer_path
|
||||||
|
while time.time() < scan_deadline:
|
||||||
|
pump_agent(0.35)
|
||||||
|
p = get_dev_props(prefer_path)
|
||||||
|
if p and (p.get("Connected") or (p.get("RSSI") is not None and (time.time() - scan_start) >= 0.8)):
|
||||||
|
discovered_path = prefer_path
|
||||||
|
break
|
||||||
|
if dev_name:
|
||||||
|
alt = find_matching_device(dev_name, prefer_path=prefer_path)
|
||||||
|
if alt:
|
||||||
|
ap = get_dev_props(alt)
|
||||||
|
if ap and (ap.get("Connected") or ap.get("RSSI") is not None):
|
||||||
|
discovered_path = alt
|
||||||
|
trust_device_path(conn, discovered_path)
|
||||||
|
if ap.get("Connected") or (time.time() - scan_start) >= 0.8:
|
||||||
|
break
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn, new_method_call(adapter_addr, "StopDiscovery"), cli_agent_path, timeout=2.0
|
||||||
|
)
|
||||||
|
pump_agent(0.15)
|
||||||
|
return discovered_path
|
||||||
|
|
||||||
|
props = get_dev_props(dev_path)
|
||||||
|
orig_unbonded = (props is None) or (not props.get("Paired") and not props.get("Bonded"))
|
||||||
|
if props and not dev_name:
|
||||||
|
dev_name = str(props.get("Name") or props.get("Alias") or "").strip()
|
||||||
|
if props is None and dev_name:
|
||||||
|
alt = find_matching_device(dev_name)
|
||||||
|
if alt:
|
||||||
|
dev_path = alt
|
||||||
|
props = get_dev_props(dev_path)
|
||||||
|
|
||||||
|
trust_device_path(conn, dev_path)
|
||||||
|
|
||||||
|
# If the device is not currently connected and has no active scan RSSI,
|
||||||
|
# run a discovery scan (up to 15s, stopping early as soon as seen) so BLE
|
||||||
|
# peripherals are in the controller cache or caught if they rotated their MAC.
|
||||||
|
if not (props and (props.get("Connected") or props.get("RSSI") is not None)):
|
||||||
|
dev_path = scan_for_device(dev_path, max_scan=15.0)
|
||||||
|
|
||||||
|
ok = attempt_connect_path(dev_path, do_pair)
|
||||||
|
|
||||||
|
if not ok:
|
||||||
|
discovered_path = scan_for_device(dev_path, max_scan=15.0)
|
||||||
|
ok = attempt_connect_path(discovered_path, do_pair)
|
||||||
|
if ok and discovered_path != orig_path and orig_unbonded:
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(adapter_addr, "RemoveDevice", "o", (orig_path,)),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=2.0
|
||||||
|
)
|
||||||
|
|
||||||
|
notify_networks_ui()
|
||||||
|
return 0 if ok else 1
|
||||||
|
except Exception:
|
||||||
|
return 1
|
||||||
|
finally:
|
||||||
|
if conn is not None:
|
||||||
|
try:
|
||||||
|
dbus_call_with_agent(
|
||||||
|
conn,
|
||||||
|
new_method_call(am_addr, "UnregisterAgent", "o", (cli_agent_path,)),
|
||||||
|
cli_agent_path,
|
||||||
|
timeout=1.5
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
conn.close()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def stop_daemon():
|
def stop_daemon():
|
||||||
if os.path.exists(PID_FILE):
|
if os.path.exists(PID_FILE):
|
||||||
try:
|
try:
|
||||||
@@ -852,21 +1278,23 @@ def main():
|
|||||||
if cmd == "daemon":
|
if cmd == "daemon":
|
||||||
run_daemon()
|
run_daemon()
|
||||||
elif cmd == "start":
|
elif cmd == "start":
|
||||||
if os.path.exists(PID_FILE):
|
ensure_daemon_running()
|
||||||
try:
|
|
||||||
with open(PID_FILE, "r", encoding="utf-8") as f:
|
|
||||||
pid = int(f.read().strip())
|
|
||||||
os.kill(pid, 0)
|
|
||||||
return 0
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
subprocess.Popen([sys.executable, __file__, "daemon"],
|
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
|
||||||
start_new_session=True)
|
|
||||||
return 0
|
return 0
|
||||||
elif cmd == "stop":
|
elif cmd == "stop":
|
||||||
stop_daemon()
|
stop_daemon()
|
||||||
return 0
|
return 0
|
||||||
|
elif cmd == "connect":
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print("Usage: bananarchy-bt-obex connect <MAC> [name]", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
nm = sys.argv[3] if len(sys.argv) >= 4 else ""
|
||||||
|
return connect_or_pair_bt_device(sys.argv[2], nm, do_pair=False)
|
||||||
|
elif cmd == "pair":
|
||||||
|
if len(sys.argv) < 3:
|
||||||
|
print("Usage: bananarchy-bt-obex pair <MAC> [name]", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
nm = sys.argv[3] if len(sys.argv) >= 4 else ""
|
||||||
|
return connect_or_pair_bt_device(sys.argv[2], nm, do_pair=True)
|
||||||
elif cmd == "send":
|
elif cmd == "send":
|
||||||
if len(sys.argv) < 4:
|
if len(sys.argv) < 4:
|
||||||
print("Usage: bananarchy-bt-obex send <MAC> <filepath>", file=sys.stderr)
|
print("Usage: bananarchy-bt-obex send <MAC> <filepath>", file=sys.stderr)
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -10,7 +10,9 @@ fi
|
|||||||
|
|
||||||
on() {
|
on() {
|
||||||
rfkill unblock bluetooth
|
rfkill unblock bluetooth
|
||||||
modprobe -q uhid hidp uinput rfcomm bnep xpad 2>/dev/null || true
|
modprobe -q uhid hidp uinput rfcomm bnep xpad af_alg algif_hash algif_skcipher algif_rng algif_aead 2>/dev/null || true
|
||||||
|
chgrp input /dev/uinput 2>/dev/null || true
|
||||||
|
chmod 0660 /dev/uinput 2>/dev/null || true
|
||||||
|
|
||||||
if [ -d /run/systemd/system ]; then
|
if [ -d /run/systemd/system ]; then
|
||||||
systemctl start bluetooth
|
systemctl start bluetooth
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -688,22 +688,6 @@ index 1962ca9..0000000
|
|||||||
-## Contact
|
-## Contact
|
||||||
-
|
-
|
||||||
-[XLibre Discussions at GitHub](https://github.com/orgs/X11Libre/discussions) | [XLibre mailing list at FreeLists](https://www.freelists.org/list/xlibre) | [@x11dev channel at Telegram](https://t.me/x11dev) | [#xlibredev space at Matrix](https://matrix.to/#/#xlibredev:matrix.org) | [XLibre security contact at GitHub](https://github.com/X11Libre/xserver/security/policy)
|
-[XLibre Discussions at GitHub](https://github.com/orgs/X11Libre/discussions) | [XLibre mailing list at FreeLists](https://www.freelists.org/list/xlibre) | [@x11dev channel at Telegram](https://t.me/x11dev) | [#xlibredev space at Matrix](https://matrix.to/#/#xlibredev:matrix.org) | [XLibre security contact at GitHub](https://github.com/X11Libre/xserver/security/policy)
|
||||||
diff --git a/Xext/xfixes/cursor.c b/Xext/xfixes/cursor.c
|
|
||||||
index d017da0..a530caa 100644
|
|
||||||
--- a/Xext/xfixes/cursor.c
|
|
||||||
+++ b/Xext/xfixes/cursor.c
|
|
||||||
@@ -122,9 +122,9 @@ typedef struct _CursorHideCountRec {
|
|
||||||
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = (func))
|
|
||||||
#define Unwrap(as,s,elt,backup) (((backup) = (s)->elt), (s)->elt = (as)->elt)
|
|
||||||
|
|
||||||
-/* The cursor doesn't show up until the first XDefineCursor() */
|
|
||||||
+/* The cursor is permanently disabled for keypad-only hardware */
|
|
||||||
Bool CursorVisible = FALSE;
|
|
||||||
-Bool EnableCursor = TRUE;
|
|
||||||
+Bool EnableCursor = FALSE;
|
|
||||||
|
|
||||||
static CursorPtr
|
|
||||||
CursorForDevice(DeviceIntPtr pDev)
|
|
||||||
diff --git a/doc/Xnamespace-protocol.md b/doc/Xnamespace-protocol.md
|
diff --git a/doc/Xnamespace-protocol.md b/doc/Xnamespace-protocol.md
|
||||||
deleted file mode 100644
|
deleted file mode 100644
|
||||||
index 673da98..0000000
|
index 673da98..0000000
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -458,7 +458,11 @@ int runContactsApp(int argc, char** argv) {
|
|||||||
|
|
||||||
const char* modeNames[4] = {"[Abc]", "[ABC]", "[abc]", "[123]"};
|
const char* modeNames[4] = {"[Abc]", "[ABC]", "[abc]", "[123]"};
|
||||||
std::string modeBadge =
|
std::string modeBadge =
|
||||||
(editField == 0) ? modeNames[static_cast<int>(caseMode)] : "[+0-9]";
|
(editField == 0)
|
||||||
|
? (isExternalKeyboardActive()
|
||||||
|
? "[KBD]"
|
||||||
|
: modeNames[static_cast<int>(caseMode)])
|
||||||
|
: "[+0-9]";
|
||||||
int mw = pangoWidth(layoutSmall, modeBadge);
|
int mw = pangoWidth(layoutSmall, modeBadge);
|
||||||
drawPango(layoutSmall, &colYellow, kWinWidth - mw - 6, 0, kHeaderH,
|
drawPango(layoutSmall, &colYellow, kWinWidth - mw - 6, 0, kHeaderH,
|
||||||
modeBadge);
|
modeBadge);
|
||||||
@@ -1208,7 +1212,7 @@ int runContactsApp(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (ev.type == KeyPress) {
|
} else if (ev.type == KeyPress) {
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
KeySym sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
|
||||||
bool isLeftSoft = (sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
bool isLeftSoft = (sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
||||||
ev.xkey.keycode == 135);
|
ev.xkey.keycode == 135);
|
||||||
bool isRightSoft = (sym == XF86XK_Back || sym == XF86XK_KbdLcdMenu2 ||
|
bool isRightSoft = (sym == XF86XK_Back || sym == XF86XK_KbdLcdMenu2 ||
|
||||||
@@ -1389,6 +1393,7 @@ int runContactsApp(int argc, char** argv) {
|
|||||||
} else if (mode == ViewMode::Edit) {
|
} else if (mode == ViewMode::Edit) {
|
||||||
char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state);
|
char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state);
|
||||||
if (editField == 0) {
|
if (editField == 0) {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
if (dialCh == '#') {
|
if (dialCh == '#') {
|
||||||
caseMode = static_cast<TextCaseMode>(
|
caseMode = static_cast<TextCaseMode>(
|
||||||
(static_cast<int>(caseMode) + 1) % 4);
|
(static_cast<int>(caseMode) + 1) % 4);
|
||||||
@@ -1407,18 +1412,10 @@ int runContactsApp(int argc, char** argv) {
|
|||||||
render();
|
render();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (sym >= XK_a && sym <= XK_z) {
|
|
||||||
char c = static_cast<char>('a' + (sym - XK_a));
|
|
||||||
if (ev.xkey.state & ShiftMask) {
|
|
||||||
c = static_cast<char>(std::toupper(static_cast<unsigned char>(c)));
|
|
||||||
}
|
}
|
||||||
editName.push_back(c);
|
if (sym >= 0x20 && sym <= 0x7e &&
|
||||||
lastTapDigit = -1;
|
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||||
render();
|
editName.push_back(static_cast<char>(sym));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (sym == XK_space) {
|
|
||||||
editName.push_back(' ');
|
|
||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
render();
|
render();
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ std::vector<BtSendTarget> queryBtSendTargets(bool scanFirst = false) {
|
|||||||
runCaptureCmd("SXMO_OS=alpine doas -n sxmo_bluetoothtoggle.sh on >/dev/null 2>&1");
|
runCaptureCmd("SXMO_OS=alpine doas -n sxmo_bluetoothtoggle.sh on >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
if (scanFirst) {
|
if (scanFirst) {
|
||||||
runCaptureCmd("timeout 5 bluetoothctl --timeout 4 scan on >/dev/null 2>&1");
|
runCaptureCmd("timeout 16 bluetoothctl --timeout 15 scan on >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
std::unordered_set<std::string> pairedMacs;
|
std::unordered_set<std::string> pairedMacs;
|
||||||
std::unordered_set<std::string> connectedMacs;
|
std::unordered_set<std::string> connectedMacs;
|
||||||
@@ -1450,7 +1450,8 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
drawPango(layoutMain, &colWhite, 28, 0, 36, inputTitle, 145);
|
drawPango(layoutMain, &colWhite, 28, 0, 36, inputTitle, 145);
|
||||||
|
|
||||||
const char* mBadge = "[abc]";
|
const char* mBadge = "[abc]";
|
||||||
if (caseMode == TextCaseMode::Title) mBadge = "[Abc]";
|
if (isExternalKeyboardActive()) mBadge = "[KBD]";
|
||||||
|
else if (caseMode == TextCaseMode::Title) mBadge = "[Abc]";
|
||||||
else if (caseMode == TextCaseMode::Upper) mBadge = "[ABC]";
|
else if (caseMode == TextCaseMode::Upper) mBadge = "[ABC]";
|
||||||
else if (caseMode == TextCaseMode::Num) mBadge = "[123]";
|
else if (caseMode == TextCaseMode::Num) mBadge = "[123]";
|
||||||
drawPango(layoutSmall, &colYellow, kWinWidth - 46, 0, 36, mBadge);
|
drawPango(layoutSmall, &colYellow, kWinWidth - 46, 0, 36, mBadge);
|
||||||
@@ -1516,7 +1517,8 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
drawPango(layoutMain, &colWhite, 25, 0, 32, titleDisp, 114);
|
drawPango(layoutMain, &colWhite, 25, 0, 32, titleDisp, 114);
|
||||||
|
|
||||||
const char* mBadge = "[abc]";
|
const char* mBadge = "[abc]";
|
||||||
if (editCaseMode == TextCaseMode::Title) mBadge = "[Abc]";
|
if (isExternalKeyboardActive()) mBadge = "[KBD]";
|
||||||
|
else if (editCaseMode == TextCaseMode::Title) mBadge = "[Abc]";
|
||||||
else if (editCaseMode == TextCaseMode::Upper) mBadge = "[ABC]";
|
else if (editCaseMode == TextCaseMode::Upper) mBadge = "[ABC]";
|
||||||
else if (editCaseMode == TextCaseMode::Num) mBadge = "[123]";
|
else if (editCaseMode == TextCaseMode::Num) mBadge = "[123]";
|
||||||
else if (editCaseMode == TextCaseMode::Sym) mBadge = "[Sym]";
|
else if (editCaseMode == TextCaseMode::Sym) mBadge = "[Sym]";
|
||||||
@@ -2405,8 +2407,8 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
} else if (mode == ViewMode::BtSendModal) {
|
} else if (mode == ViewMode::BtSendModal) {
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
if (btTargets.empty()) {
|
if (btTargets.empty()) {
|
||||||
statusBanner = "Scanning Bluetooth...";
|
statusBanner = "Scanning Bluetooth (15s)...";
|
||||||
statusBannerUntilMs = nowMs() + 2500;
|
statusBannerUntilMs = nowMs() + 16000;
|
||||||
drawUI();
|
drawUI();
|
||||||
btTargets = queryBtSendTargets(true);
|
btTargets = queryBtSendTargets(true);
|
||||||
btTargetSel = 0;
|
btTargetSel = 0;
|
||||||
@@ -2475,7 +2477,7 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
} else if (ev.type == KeyPress) {
|
} else if (ev.type == KeyPress) {
|
||||||
int64_t tNow = nowMs();
|
int64_t tNow = nowMs();
|
||||||
unsigned int kc = ev.xkey.keycode;
|
unsigned int kc = ev.xkey.keycode;
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
KeySym sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
|
||||||
|
|
||||||
bool isLeftSk =
|
bool isLeftSk =
|
||||||
(kc == 135 || sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
(kc == 135 || sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
||||||
@@ -2686,18 +2688,29 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
insertEditorNewline();
|
insertEditorNewline();
|
||||||
drawUI();
|
drawUI();
|
||||||
} else {
|
} else {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
char d = mapDialKey(sym, kc, ev.xkey.state);
|
char d = mapDialKey(sym, kc, ev.xkey.state);
|
||||||
if (d == '#') {
|
if (d == '#') {
|
||||||
editLastTapDigit = -1;
|
editLastTapDigit = -1;
|
||||||
editCaseMode = static_cast<TextCaseMode>(
|
editCaseMode = static_cast<TextCaseMode>(
|
||||||
(static_cast<int>(editCaseMode) + 1) % 5);
|
(static_cast<int>(editCaseMode) + 1) % 5);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d == '*') {
|
} else if (d == '*') {
|
||||||
commitEditorTap(10);
|
commitEditorTap(10);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d >= '0' && d <= '9') {
|
} else if (d >= '0' && d <= '9') {
|
||||||
commitEditorTap(d - '0');
|
commitEditorTap(d - '0');
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sym >= 0x20 && sym <= 0x7e &&
|
||||||
|
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||||
|
editLastTapDigit = -1;
|
||||||
|
insertEditorStr(std::string(1, static_cast<char>(sym)));
|
||||||
|
drawUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2757,18 +2770,29 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
drawUI();
|
drawUI();
|
||||||
} else {
|
} else {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
char d = mapDialKey(sym, kc, ev.xkey.state);
|
char d = mapDialKey(sym, kc, ev.xkey.state);
|
||||||
if (d == '#') {
|
if (d == '#') {
|
||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
caseMode = static_cast<TextCaseMode>(
|
caseMode = static_cast<TextCaseMode>(
|
||||||
(static_cast<int>(caseMode) + 1) % 4);
|
(static_cast<int>(caseMode) + 1) % 4);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d == '*') {
|
} else if (d == '*') {
|
||||||
commitModalTap(1);
|
commitModalTap(1);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d >= '0' && d <= '9') {
|
} else if (d >= '0' && d <= '9') {
|
||||||
commitModalTap(d - '0');
|
commitModalTap(d - '0');
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sym >= 0x20 && sym <= 0x7e &&
|
||||||
|
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||||
|
lastTapDigit = -1;
|
||||||
|
inputValue.push_back(static_cast<char>(sym));
|
||||||
|
drawUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == ViewMode::ConfirmDelete) {
|
} else if (mode == ViewMode::ConfirmDelete) {
|
||||||
@@ -2795,8 +2819,8 @@ int runFilesApp(int argc, char** argv) {
|
|||||||
drawUI();
|
drawUI();
|
||||||
}
|
}
|
||||||
} else if (d == '*') {
|
} else if (d == '*') {
|
||||||
statusBanner = "Scanning Bluetooth...";
|
statusBanner = "Scanning Bluetooth (15s)...";
|
||||||
statusBannerUntilMs = nowMs() + 2500;
|
statusBannerUntilMs = nowMs() + 16000;
|
||||||
drawUI();
|
drawUI();
|
||||||
btTargets = queryBtSendTargets(true);
|
btTargets = queryBtSendTargets(true);
|
||||||
btTargetSel = 0;
|
btTargetSel = 0;
|
||||||
|
|||||||
@@ -459,7 +459,26 @@ std::vector<BtDeviceEntry> queryBtDevices() {
|
|||||||
d.paired = (pairedMacs.count(d.mac) > 0);
|
d.paired = (pairedMacs.count(d.mac) > 0);
|
||||||
d.connected = (connectedMacs.count(d.mac) > 0);
|
d.connected = (connectedMacs.count(d.mac) > 0);
|
||||||
out.push_back(d);
|
out.push_back(d);
|
||||||
if ((d.connected || d.paired) && infoCount < 12) {
|
}
|
||||||
|
|
||||||
|
auto isRawMacName = [](const BtDeviceEntry& e) {
|
||||||
|
if (e.name == e.mac) return true;
|
||||||
|
if (e.name.size() == 17 && e.name[2] == '-' && e.name[5] == '-') return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
std::sort(out.begin(), out.end(),
|
||||||
|
[&](const BtDeviceEntry& a, const BtDeviceEntry& b) {
|
||||||
|
if (a.connected != b.connected) return a.connected > b.connected;
|
||||||
|
if (a.paired != b.paired) return a.paired > b.paired;
|
||||||
|
bool aRaw = isRawMacName(a);
|
||||||
|
bool bRaw = isRawMacName(b);
|
||||||
|
if (aRaw != bRaw) return aRaw < bRaw;
|
||||||
|
return a.name < b.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const auto& d : out) {
|
||||||
|
if (infoCount >= 12) break;
|
||||||
|
if (d.connected || d.paired || !isRawMacName(d)) {
|
||||||
infoCmd += "printf '===BTDEV %s===\\n' " + shellQuote(d.mac) +
|
infoCmd += "printf '===BTDEV %s===\\n' " + shellQuote(d.mac) +
|
||||||
"; timeout 1 bluetoothctl info " + shellQuote(d.mac) +
|
"; timeout 1 bluetoothctl info " + shellQuote(d.mac) +
|
||||||
" 2>/dev/null; ";
|
" 2>/dev/null; ";
|
||||||
@@ -571,9 +590,12 @@ std::vector<BtDeviceEntry> queryBtDevices() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::sort(out.begin(), out.end(),
|
std::sort(out.begin(), out.end(),
|
||||||
[](const BtDeviceEntry& a, const BtDeviceEntry& b) {
|
[&](const BtDeviceEntry& a, const BtDeviceEntry& b) {
|
||||||
if (a.connected != b.connected) return a.connected > b.connected;
|
if (a.connected != b.connected) return a.connected > b.connected;
|
||||||
if (a.paired != b.paired) return a.paired > b.paired;
|
if (a.paired != b.paired) return a.paired > b.paired;
|
||||||
|
bool aRaw = isRawMacName(a);
|
||||||
|
bool bRaw = isRawMacName(b);
|
||||||
|
if (aRaw != bRaw) return aRaw < bRaw;
|
||||||
return a.name < b.name;
|
return a.name < b.name;
|
||||||
});
|
});
|
||||||
return out;
|
return out;
|
||||||
@@ -757,12 +779,13 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
} else if (activeTab == NetTab::Bluetooth) {
|
} else if (activeTab == NetTab::Bluetooth) {
|
||||||
btOn = isBtEnabledFast();
|
btOn = isBtEnabledFast();
|
||||||
if (btOn) {
|
if (btOn) {
|
||||||
if (::access("/tmp/bananarchy_bt_obex.pid", F_OK) != 0) {
|
int obexPid = readIntFile("/tmp/bananarchy_bt_obex.pid");
|
||||||
|
if (obexPid <= 0 || ::kill(obexPid, 0) != 0) {
|
||||||
runAsyncCmd("/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1");
|
runAsyncCmd("/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
btRx = readBtRxStatus();
|
btRx = readBtRxStatus();
|
||||||
if (forceScan) {
|
if (forceScan) {
|
||||||
runCaptureCmd("timeout 6 bluetoothctl --timeout 5 scan on >/dev/null 2>&1");
|
runCaptureCmd("timeout 16 bluetoothctl --timeout 15 scan on >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
btList = queryBtDevices();
|
btList = queryBtDevices();
|
||||||
} else {
|
} else {
|
||||||
@@ -788,6 +811,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto textModeLabel = [&]() -> const char* {
|
auto textModeLabel = [&]() -> const char* {
|
||||||
|
if (isExternalKeyboardActive()) return "KBD";
|
||||||
switch (textMode) {
|
switch (textMode) {
|
||||||
case TextMode::Lower: return "abc";
|
case TextMode::Lower: return "abc";
|
||||||
case TextMode::Title: return "Abc";
|
case TextMode::Title: return "Abc";
|
||||||
@@ -800,6 +824,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
|
|
||||||
auto handleMultiTapKey = [&](std::string& targetStr, KeySym sym,
|
auto handleMultiTapKey = [&](std::string& targetStr, KeySym sym,
|
||||||
unsigned int kc, unsigned int state) -> bool {
|
unsigned int kc, unsigned int state) -> bool {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
char dch = mapDialKey(sym, kc, state);
|
char dch = mapDialKey(sym, kc, state);
|
||||||
if (dch == '#') {
|
if (dch == '#') {
|
||||||
textMode = static_cast<TextMode>((static_cast<int>(textMode) + 1) % 5);
|
textMode = static_cast<TextMode>((static_cast<int>(textMode) + 1) % 5);
|
||||||
@@ -838,6 +863,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
targetStr.push_back(outCh);
|
targetStr.push_back(outCh);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (sym == XK_BackSpace || sym == XK_Delete) {
|
if (sym == XK_BackSpace || sym == XK_Delete) {
|
||||||
if (!targetStr.empty()) {
|
if (!targetStr.empty()) {
|
||||||
popUtf8Char(targetStr);
|
popUtf8Char(targetStr);
|
||||||
@@ -1499,13 +1525,21 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
if (act == 0) {
|
if (act == 0) {
|
||||||
setBanner("Connecting " + targetBt.name + "...");
|
setBanner("Connecting " + targetBt.name + "...");
|
||||||
render();
|
render();
|
||||||
runCaptureCmd("timeout 8 bluetoothctl connect " + shellQuote(targetBt.mac) +
|
runCaptureCmd("/usr/bin/bananarchy-bt-obex connect " +
|
||||||
" >/dev/null 2>&1", &rc);
|
shellQuote(targetBt.mac) + " " +
|
||||||
|
shellQuote(targetBt.name) + " >/dev/null 2>&1", &rc);
|
||||||
refreshCurrentTab(false);
|
refreshCurrentTab(false);
|
||||||
if (rc == 0 && targetBt.kind == BtDevKind::Audio) {
|
bool isConn = (rc == 0);
|
||||||
|
for (const auto& d : btList) {
|
||||||
|
if ((d.mac == targetBt.mac || d.name == targetBt.name) && d.connected) {
|
||||||
|
isConn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isConn && targetBt.kind == BtDevKind::Audio) {
|
||||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||||
}
|
}
|
||||||
setBanner(rc == 0 ? ("Connected: " + targetBt.name) : "Connect failed");
|
setBanner(isConn ? ("Connected: " + targetBt.name) : "Connect failed");
|
||||||
} else if (act == 1) {
|
} else if (act == 1) {
|
||||||
setBanner("Disconnecting " + targetBt.name + "...");
|
setBanner("Disconnecting " + targetBt.name + "...");
|
||||||
render();
|
render();
|
||||||
@@ -1516,14 +1550,23 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
} else if (act == 2) {
|
} else if (act == 2) {
|
||||||
setBanner("Pairing " + targetBt.name + "...");
|
setBanner("Pairing " + targetBt.name + "...");
|
||||||
render();
|
render();
|
||||||
runCaptureCmd("timeout 10 bluetoothctl --timeout 8 pair " +
|
runCaptureCmd("/usr/bin/bananarchy-bt-obex pair " +
|
||||||
shellQuote(targetBt.mac) +
|
shellQuote(targetBt.mac) + " " +
|
||||||
" >/dev/null 2>&1; timeout 2 bluetoothctl trust " +
|
shellQuote(targetBt.name) + " >/dev/null 2>&1", &rc);
|
||||||
shellQuote(targetBt.mac) + " >/dev/null 2>&1; "
|
|
||||||
"timeout 6 bluetoothctl connect " + shellQuote(targetBt.mac) +
|
|
||||||
" >/dev/null 2>&1", &rc);
|
|
||||||
refreshCurrentTab(false);
|
refreshCurrentTab(false);
|
||||||
setBanner("Paired & trusted " + targetBt.name);
|
bool isPairedOrConn = (rc == 0);
|
||||||
|
for (const auto& d : btList) {
|
||||||
|
if ((d.mac == targetBt.mac || d.name == targetBt.name) &&
|
||||||
|
(d.connected || d.paired)) {
|
||||||
|
isPairedOrConn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isPairedOrConn && targetBt.kind == BtDevKind::Audio) {
|
||||||
|
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||||
|
}
|
||||||
|
setBanner(isPairedOrConn ? ("Paired & connected: " + targetBt.name)
|
||||||
|
: ("Pairing failed: " + targetBt.name));
|
||||||
} else if (act == 3) {
|
} else if (act == 3) {
|
||||||
std::string macU = targetBt.mac;
|
std::string macU = targetBt.mac;
|
||||||
for (char& c : macU) {
|
for (char& c : macU) {
|
||||||
@@ -1678,7 +1721,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
modal = NetModal::BtNameEditor;
|
modal = NetModal::BtNameEditor;
|
||||||
} else if (btRowSel == 3 && btOn) {
|
} else if (btRowSel == 3 && btOn) {
|
||||||
setBanner("Scanning Bluetooth devices (5s)...");
|
setBanner("Scanning Bluetooth devices (15s)...", 16000);
|
||||||
render();
|
render();
|
||||||
refreshCurrentTab(true);
|
refreshCurrentTab(true);
|
||||||
setBanner("Found " + std::to_string(btList.size()) + " device(s)");
|
setBanner("Found " + std::to_string(btList.size()) + " device(s)");
|
||||||
@@ -1728,7 +1771,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
runCaptureCmd("SXMO_OS=alpine doas -n sxmo_bluetoothtoggle.sh on >/dev/null 2>&1");
|
runCaptureCmd("SXMO_OS=alpine doas -n sxmo_bluetoothtoggle.sh on >/dev/null 2>&1");
|
||||||
refreshCurrentTab(false);
|
refreshCurrentTab(false);
|
||||||
} else {
|
} else {
|
||||||
setBanner("Scanning Bluetooth (5s)...");
|
setBanner("Scanning Bluetooth (15s)...", 16000);
|
||||||
render();
|
render();
|
||||||
refreshCurrentTab(true);
|
refreshCurrentTab(true);
|
||||||
setBanner("Found " + std::to_string(btList.size()) + " device(s)");
|
setBanner("Found " + std::to_string(btList.size()) + " device(s)");
|
||||||
@@ -1772,7 +1815,7 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
int64_t now = nowMs();
|
int64_t now = nowMs();
|
||||||
if (now < startupIgnoreUntilMs) continue;
|
if (now < startupIgnoreUntilMs) continue;
|
||||||
|
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
KeySym sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
|
||||||
unsigned int kc = ev.xkey.keycode;
|
unsigned int kc = ev.xkey.keycode;
|
||||||
|
|
||||||
bool isLSK = (kc == 135 || sym == XK_F1 || sym == XK_Menu ||
|
bool isLSK = (kc == 135 || sym == XK_F1 || sym == XK_Menu ||
|
||||||
@@ -1999,6 +2042,9 @@ int runNetworksApp(int argc, char** argv) {
|
|||||||
if (visible) render();
|
if (visible) render();
|
||||||
} else if (cmd == "REFRESH_BT") {
|
} else if (cmd == "REFRESH_BT") {
|
||||||
btRx = readBtRxStatus();
|
btRx = readBtRxStatus();
|
||||||
|
if (visible && activeTab == NetTab::Bluetooth) {
|
||||||
|
refreshCurrentTab(false);
|
||||||
|
}
|
||||||
if (visible) render();
|
if (visible) render();
|
||||||
} else if (cmd == "TOGGLE") {
|
} else if (cmd == "TOGGLE") {
|
||||||
if (visible) hideWindow();
|
if (visible) hideWindow();
|
||||||
|
|||||||
@@ -469,8 +469,61 @@ inline void runAsyncArgv(const char* prog,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool isExternalKeyboardActive() {
|
||||||
|
static time_t lastDirSec = -1;
|
||||||
|
static long lastDirNsec = -1;
|
||||||
|
static bool cachedActive = false;
|
||||||
|
|
||||||
|
struct stat st {};
|
||||||
|
if (::stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == lastDirSec && st.st_mtim.tv_nsec == lastDirNsec) {
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
lastDirSec = st.st_mtim.tv_sec;
|
||||||
|
lastDirNsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = std::fopen("/proc/bus/input/devices", "r");
|
||||||
|
if (!fp) {
|
||||||
|
cachedActive = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool extBus = false;
|
||||||
|
bool found = false;
|
||||||
|
char line[512];
|
||||||
|
while (std::fgets(line, sizeof(line), fp)) {
|
||||||
|
if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') {
|
||||||
|
extBus = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (std::strncmp(line, "I: Bus=0005", 11) == 0 ||
|
||||||
|
std::strncmp(line, "I: Bus=0003", 11) == 0) {
|
||||||
|
extBus = true;
|
||||||
|
} else if (extBus && std::strncmp(line, "B: KEY=", 7) == 0) {
|
||||||
|
const char* p = line + 7;
|
||||||
|
const char* lastToken = nullptr;
|
||||||
|
while (*p) {
|
||||||
|
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') ++p;
|
||||||
|
if (!*p) break;
|
||||||
|
lastToken = p;
|
||||||
|
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') ++p;
|
||||||
|
}
|
||||||
|
if (lastToken) {
|
||||||
|
unsigned long long mask = std::strtoull(lastToken, nullptr, 16);
|
||||||
|
if ((mask & 0x03ff0000ULL) == 0x03ff0000ULL) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::fclose(fp);
|
||||||
|
cachedActive = found;
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
|
||||||
inline char mapDialKey(KeySym sym, unsigned int keycode, unsigned int state) {
|
inline char mapDialKey(KeySym sym, unsigned int keycode, unsigned int state) {
|
||||||
if (state & (ControlMask | Mod1Mask | Mod4Mask)) {
|
if (state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)) {
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
// Keypad star (*)
|
// Keypad star (*)
|
||||||
|
|||||||
@@ -470,6 +470,7 @@ int privacy_run_main(int argc, char** argv) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto textModeBadge = [&]() -> const char* {
|
auto textModeBadge = [&]() -> const char* {
|
||||||
|
if (isExternalKeyboardActive()) return "[KBD]";
|
||||||
switch (textMode) {
|
switch (textMode) {
|
||||||
case TextMode::Lower: return "[abc]";
|
case TextMode::Lower: return "[abc]";
|
||||||
case TextMode::Title: return "[Abc]";
|
case TextMode::Title: return "[Abc]";
|
||||||
@@ -508,6 +509,7 @@ int privacy_run_main(int argc, char** argv) {
|
|||||||
|
|
||||||
auto handleMultiTapKey = [&](std::string& targetStr, KeySym sym,
|
auto handleMultiTapKey = [&](std::string& targetStr, KeySym sym,
|
||||||
unsigned int kc, unsigned int state) -> bool {
|
unsigned int kc, unsigned int state) -> bool {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
char dch = mapDialKey(sym, kc, state);
|
char dch = mapDialKey(sym, kc, state);
|
||||||
if (dch == '#') {
|
if (dch == '#') {
|
||||||
textMode = static_cast<TextMode>((static_cast<int>(textMode) + 1) % 5);
|
textMode = static_cast<TextMode>((static_cast<int>(textMode) + 1) % 5);
|
||||||
@@ -553,6 +555,7 @@ int privacy_run_main(int argc, char** argv) {
|
|||||||
targetStr.push_back(outCh);
|
targetStr.push_back(outCh);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (sym == XK_BackSpace || sym == XK_Delete) {
|
if (sym == XK_BackSpace || sym == XK_Delete) {
|
||||||
if (!targetStr.empty()) {
|
if (!targetStr.empty()) {
|
||||||
popUtf8Char(targetStr);
|
popUtf8Char(targetStr);
|
||||||
@@ -1147,7 +1150,7 @@ int privacy_run_main(int argc, char** argv) {
|
|||||||
if (!visible) continue;
|
if (!visible) continue;
|
||||||
unsigned int kc = ev.xkey.keycode;
|
unsigned int kc = ev.xkey.keycode;
|
||||||
unsigned int st = ev.xkey.state;
|
unsigned int st = ev.xkey.state;
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
KeySym sym = XLookupKeysym(&ev.xkey, (st & ShiftMask) ? 1 : 0);
|
||||||
|
|
||||||
if (querySoftkeysDown(dpy) == 3) {
|
if (querySoftkeysDown(dpy) == 3) {
|
||||||
writeSoftkeySuppress(nowMs() + 400);
|
writeSoftkeySuppress(nowMs() + 400);
|
||||||
|
|||||||
@@ -706,6 +706,8 @@ int runSmsApp(int argc, char** argv) {
|
|||||||
const char* modeBadge = "[Abc]";
|
const char* modeBadge = "[Abc]";
|
||||||
if (composeField == 0) {
|
if (composeField == 0) {
|
||||||
modeBadge = "[123]";
|
modeBadge = "[123]";
|
||||||
|
} else if (isExternalKeyboardActive()) {
|
||||||
|
modeBadge = "[KBD]";
|
||||||
} else if (caseMode == TextCaseMode::Upper) {
|
} else if (caseMode == TextCaseMode::Upper) {
|
||||||
modeBadge = "[ABC]";
|
modeBadge = "[ABC]";
|
||||||
} else if (caseMode == TextCaseMode::Lower) {
|
} else if (caseMode == TextCaseMode::Lower) {
|
||||||
@@ -1393,7 +1395,7 @@ int runSmsApp(int argc, char** argv) {
|
|||||||
} else if (ev.type == KeyPress) {
|
} else if (ev.type == KeyPress) {
|
||||||
int64_t tNow = nowMs();
|
int64_t tNow = nowMs();
|
||||||
unsigned int kc = ev.xkey.keycode;
|
unsigned int kc = ev.xkey.keycode;
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
KeySym sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
|
||||||
|
|
||||||
bool isLeftSk =
|
bool isLeftSk =
|
||||||
(kc == 135 || sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
(kc == 135 || sym == XK_Menu || sym == XF86XK_KbdLcdMenu1 ||
|
||||||
@@ -1576,19 +1578,26 @@ int runSmsApp(int argc, char** argv) {
|
|||||||
drawUI();
|
drawUI();
|
||||||
}
|
}
|
||||||
} else if (composeField == 1) {
|
} else if (composeField == 1) {
|
||||||
|
if (!isExternalKeyboardActive()) {
|
||||||
if (d == '#') {
|
if (d == '#') {
|
||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
caseMode = static_cast<TextCaseMode>(
|
caseMode = static_cast<TextCaseMode>(
|
||||||
(static_cast<int>(caseMode) + 1) % 4);
|
(static_cast<int>(caseMode) + 1) % 4);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d == '*') {
|
} else if (d == '*') {
|
||||||
commitMultiTapChar(1);
|
commitMultiTapChar(1);
|
||||||
drawUI();
|
drawUI();
|
||||||
|
continue;
|
||||||
} else if (d >= '0' && d <= '9') {
|
} else if (d >= '0' && d <= '9') {
|
||||||
commitMultiTapChar(d - '0');
|
commitMultiTapChar(d - '0');
|
||||||
drawUI();
|
drawUI();
|
||||||
} else if (sym == XK_space) {
|
continue;
|
||||||
composeText.push_back(' ');
|
}
|
||||||
|
}
|
||||||
|
if (sym >= 0x20 && sym <= 0x7e &&
|
||||||
|
!(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||||
|
composeText.push_back(static_cast<char>(sym));
|
||||||
lastTapDigit = -1;
|
lastTapDigit = -1;
|
||||||
drawUI();
|
drawUI();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,9 +195,64 @@ bool charToCtrlKey(char ch, fcitx::KeySym* symOut, uint32_t* xkbCodeOut) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isExternalKeyboardActive() {
|
||||||
|
static time_t lastDirSec = -1;
|
||||||
|
static long lastDirNsec = -1;
|
||||||
|
static bool cachedActive = false;
|
||||||
|
|
||||||
|
struct stat st {};
|
||||||
|
if (::stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == lastDirSec && st.st_mtim.tv_nsec == lastDirNsec) {
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
lastDirSec = st.st_mtim.tv_sec;
|
||||||
|
lastDirNsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = std::fopen("/proc/bus/input/devices", "r");
|
||||||
|
if (!fp) {
|
||||||
|
cachedActive = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool extBus = false;
|
||||||
|
bool found = false;
|
||||||
|
char line[512];
|
||||||
|
while (std::fgets(line, sizeof(line), fp)) {
|
||||||
|
if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') {
|
||||||
|
extBus = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( std::strncmp(line, "I: Bus=0005", 11) == 0 ||
|
||||||
|
std::strncmp(line, "I: Bus=0003", 11) == 0 ) {
|
||||||
|
extBus = true;
|
||||||
|
} else if (extBus && std::strncmp(line, "B: KEY=", 7) == 0) {
|
||||||
|
const char* p = line + 7;
|
||||||
|
const char* lastToken = nullptr;
|
||||||
|
while (*p) {
|
||||||
|
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') ++p;
|
||||||
|
if (!*p) break;
|
||||||
|
lastToken = p;
|
||||||
|
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') ++p;
|
||||||
|
}
|
||||||
|
if (lastToken) {
|
||||||
|
unsigned long long mask = std::strtoull(lastToken, nullptr, 16);
|
||||||
|
// Evdev KEY_Q..KEY_P (16..25): bits 16..25 = 0x03ff0000
|
||||||
|
if ((mask & 0x03ff0000ULL) == 0x03ff0000ULL) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::fclose(fp);
|
||||||
|
cachedActive = found;
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
|
||||||
int mapHardwareKey(const fcitx::Key& key) {
|
int mapHardwareKey(const fcitx::Key& key) {
|
||||||
if (key.states().testAny(fcitx::KeyState::Ctrl_Alt) ||
|
if (key.states().testAny(fcitx::KeyState::Ctrl_Alt) ||
|
||||||
key.states().test(fcitx::KeyState::Super)) {
|
key.states().test(fcitx::KeyState::Super) ||
|
||||||
|
key.states().test(fcitx::KeyState::Shift)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
uint32_t code = key.code();
|
uint32_t code = key.code();
|
||||||
@@ -336,10 +391,10 @@ T9Engine::T9Engine(fcitx::Instance* instance)
|
|||||||
FCITX_UNUSED(event);
|
FCITX_UNUSED(event);
|
||||||
if (sharedMode == T9Mode::Ctrl) {
|
if (sharedMode == T9Mode::Ctrl) {
|
||||||
sharedMode = T9Mode::Lower;
|
sharedMode = T9Mode::Lower;
|
||||||
writeStatusIndicator("[abc]");
|
writeStatusIndicator(isExternalKeyboardActive() ? "[KBD]" : "[abc]");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
writeStatusIndicator("[abc]");
|
writeStatusIndicator(isExternalKeyboardActive() ? "[KBD]" : "[abc]");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<fcitx::InputMethodEntry> T9Engine::listInputMethods() {
|
std::vector<fcitx::InputMethodEntry> T9Engine::listInputMethods() {
|
||||||
@@ -391,6 +446,10 @@ void T9Engine::reset(const fcitx::InputMethodEntry& entry,
|
|||||||
FCITX_ADDON_FACTORY(T9EngineFactory);
|
FCITX_ADDON_FACTORY(T9EngineFactory);
|
||||||
|
|
||||||
void T9State::updateStatusBar() const {
|
void T9State::updateStatusBar() const {
|
||||||
|
if (isExternalKeyboardActive()) {
|
||||||
|
writeStatusIndicator("[KBD]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
writeStatusIndicator("[" + modePrefix() + "]");
|
writeStatusIndicator("[" + modePrefix() + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,6 +721,15 @@ void T9State::stepCandidate(int delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool T9State::handleKeyEvent(fcitx::KeyEvent& keyEvent) {
|
bool T9State::handleKeyEvent(fcitx::KeyEvent& keyEvent) {
|
||||||
|
if (isExternalKeyboardActive()) {
|
||||||
|
if (!activeItems.empty() || commitTimer || releaseTimer || longPressTimer ||
|
||||||
|
bannerTimer) {
|
||||||
|
reset();
|
||||||
|
} else {
|
||||||
|
updateStatusBar();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
mode = engine->sharedMode;
|
mode = engine->sharedMode;
|
||||||
fcitx::Key key = keyEvent.key();
|
fcitx::Key key = keyEvent.key();
|
||||||
uint32_t code = key.code();
|
uint32_t code = key.code();
|
||||||
|
|||||||
+88
-5
@@ -232,6 +232,59 @@ bool isExternalOverlayOrLockActive(const std::string& appName) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isExternalKeyboardActive() {
|
||||||
|
static time_t lastDirSec = -1;
|
||||||
|
static long lastDirNsec = -1;
|
||||||
|
static bool cachedActive = false;
|
||||||
|
|
||||||
|
struct stat st {};
|
||||||
|
if (::stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == lastDirSec && st.st_mtim.tv_nsec == lastDirNsec) {
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
lastDirSec = st.st_mtim.tv_sec;
|
||||||
|
lastDirNsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE* fp = std::fopen("/proc/bus/input/devices", "r");
|
||||||
|
if (!fp) {
|
||||||
|
cachedActive = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool extBus = false;
|
||||||
|
bool found = false;
|
||||||
|
char line[512];
|
||||||
|
while (std::fgets(line, sizeof(line), fp)) {
|
||||||
|
if (line[0] == '\n' || line[0] == '\r' || line[0] == '\0') {
|
||||||
|
extBus = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (std::strncmp(line, "I: Bus=0005", 11) == 0 ||
|
||||||
|
std::strncmp(line, "I: Bus=0003", 11) == 0) {
|
||||||
|
extBus = true;
|
||||||
|
} else if (extBus && std::strncmp(line, "B: KEY=", 7) == 0) {
|
||||||
|
const char* p = line + 7;
|
||||||
|
const char* lastToken = nullptr;
|
||||||
|
while (*p) {
|
||||||
|
while (*p == ' ' || *p == '\t' || *p == '\n' || *p == '\r') ++p;
|
||||||
|
if (!*p) break;
|
||||||
|
lastToken = p;
|
||||||
|
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') ++p;
|
||||||
|
}
|
||||||
|
if (lastToken) {
|
||||||
|
unsigned long long mask = std::strtoull(lastToken, nullptr, 16);
|
||||||
|
if ((mask & 0x03ff0000ULL) == 0x03ff0000ULL) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::fclose(fp);
|
||||||
|
cachedActive = found;
|
||||||
|
return cachedActive;
|
||||||
|
}
|
||||||
|
|
||||||
int mapHardwareKey(KeySym sym, unsigned int keycode, unsigned int state) {
|
int mapHardwareKey(KeySym sym, unsigned int keycode, unsigned int state) {
|
||||||
if (keycode == 135 || sym == XK_Super_L || sym == XK_Menu ||
|
if (keycode == 135 || sym == XK_Super_L || sym == XK_Menu ||
|
||||||
static_cast<uint32_t>(sym) == _EVDEVK(0x8b)) {
|
static_cast<uint32_t>(sym) == _EVDEVK(0x8b)) {
|
||||||
@@ -260,7 +313,7 @@ int mapHardwareKey(KeySym sym, unsigned int keycode, unsigned int state) {
|
|||||||
sym == XK_F4 || static_cast<uint32_t>(sym) == _EVDEVK(0x6b)) {
|
sym == XK_F4 || static_cast<uint32_t>(sym) == _EVDEVK(0x6b)) {
|
||||||
return NEO_KEY_END;
|
return NEO_KEY_END;
|
||||||
}
|
}
|
||||||
if (!(state & (ControlMask | Mod1Mask | Mod4Mask))) {
|
if (!(state & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask))) {
|
||||||
if (keycode == 63 || keycode == 530 || sym == XK_asterisk ||
|
if (keycode == 63 || keycode == 530 || sym == XK_asterisk ||
|
||||||
sym == XK_KP_Multiply || static_cast<uint32_t>(sym) == 0x1008ffaa) {
|
sym == XK_KP_Multiply || static_cast<uint32_t>(sym) == 0x1008ffaa) {
|
||||||
return NEO_KEY_STAR;
|
return NEO_KEY_STAR;
|
||||||
@@ -2932,7 +2985,12 @@ int neoui_poll_event(int timeout_ms) {
|
|||||||
ctx->grabYielded = true;
|
ctx->grabYielded = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
KeySym sym = XLookupKeysym(&ev.xkey, 0);
|
char strBuf[8] = {};
|
||||||
|
KeySym sym = NoSymbol;
|
||||||
|
XLookupString(&ev.xkey, strBuf, sizeof(strBuf) - 1, &sym, nullptr);
|
||||||
|
if (sym == NoSymbol) {
|
||||||
|
sym = XLookupKeysym(&ev.xkey, (ev.xkey.state & ShiftMask) ? 1 : 0);
|
||||||
|
}
|
||||||
unsigned int kc = ev.xkey.keycode;
|
unsigned int kc = ev.xkey.keycode;
|
||||||
int nkey = bananarchy::mapHardwareKey(sym, kc, ev.xkey.state);
|
int nkey = bananarchy::mapHardwareKey(sym, kc, ev.xkey.state);
|
||||||
ctx->lastEventKey = nkey;
|
ctx->lastEventKey = nkey;
|
||||||
@@ -3153,6 +3211,9 @@ int neoui_input_cycle_mode(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* neoui_input_mode_badge(void) {
|
const char* neoui_input_mode_badge(void) {
|
||||||
|
if (bananarchy::isExternalKeyboardActive()) {
|
||||||
|
return "[KBD]";
|
||||||
|
}
|
||||||
int mode = gCtx ? gCtx->inputMode : NEO_INPUT_ABC_TITLE;
|
int mode = gCtx ? gCtx->inputMode : NEO_INPUT_ABC_TITLE;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case NEO_INPUT_ABC_TITLE: return "[Abc]";
|
case NEO_INPUT_ABC_TITLE: return "[Abc]";
|
||||||
@@ -3201,16 +3262,38 @@ int neoui_input_feed_key(int neo_key) {
|
|||||||
ctx->tapCycleIdx = 0;
|
ctx->tapCycleIdx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (neo_key == NEO_KEY_BACK) {
|
||||||
|
return neoui_input_backspace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bananarchy::isExternalKeyboardActive()) {
|
||||||
|
ctx->tapActive = false;
|
||||||
|
ctx->lastTapKey = -1;
|
||||||
|
if (ctx->lastEventKeysym >= 0x20 && ctx->lastEventKeysym <= 0x7e) {
|
||||||
|
ctx->inputText.push_back(static_cast<char>(ctx->lastEventKeysym));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (neo_key >= 0x20 && neo_key <= 0x7e) {
|
||||||
|
ctx->inputText.push_back(static_cast<char>(neo_key));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (neo_key == NEO_KEY_HASH) {
|
if (neo_key == NEO_KEY_HASH) {
|
||||||
neoui_input_cycle_mode();
|
neoui_input_cycle_mode();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (neo_key == NEO_KEY_BACK) {
|
|
||||||
return neoui_input_backspace();
|
|
||||||
}
|
|
||||||
if (neo_key == NEO_KEY_RIGHT && ctx->tapActive) {
|
if (neo_key == NEO_KEY_RIGHT && ctx->tapActive) {
|
||||||
return neoui_input_commit_tap();
|
return neoui_input_commit_tap();
|
||||||
}
|
}
|
||||||
|
if (neo_key == NEO_KEY_NONE &&
|
||||||
|
ctx->lastEventKeysym >= 0x20 && ctx->lastEventKeysym <= 0x7e) {
|
||||||
|
ctx->tapActive = false;
|
||||||
|
ctx->lastTapKey = -1;
|
||||||
|
ctx->inputText.push_back(static_cast<char>(ctx->lastEventKeysym));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (ctx->inputMode == NEO_INPUT_123) {
|
if (ctx->inputMode == NEO_INPUT_123) {
|
||||||
if ((neo_key >= '0' && neo_key <= '9') || neo_key == '*' ||
|
if ((neo_key >= '0' && neo_key <= '9') || neo_key == '*' ||
|
||||||
|
|||||||
+66
-1
@@ -250,9 +250,74 @@ add_menu_item(const char *label, const char *action, int loop)
|
|||||||
items[items_count].right = NULL;
|
items[items_count].right = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dmenu_has_external_keyboard(void)
|
||||||
|
{
|
||||||
|
static time_t last_dev_sec = 0;
|
||||||
|
static long last_dev_nsec = 0;
|
||||||
|
static int cached = 0;
|
||||||
|
struct stat st;
|
||||||
|
if (stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == last_dev_sec &&
|
||||||
|
st.st_mtim.tv_nsec == last_dev_nsec) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
last_dev_sec = st.st_mtim.tv_sec;
|
||||||
|
last_dev_nsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
FILE *fp = fopen("/proc/bus/input/devices", "r");
|
||||||
|
if (!fp) {
|
||||||
|
cached = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
char line[512];
|
||||||
|
int is_ext_bus = 0;
|
||||||
|
int has_kbd = 0;
|
||||||
|
int has_qwerty = 0;
|
||||||
|
int found = 0;
|
||||||
|
while (fgets(line, sizeof(line), fp)) {
|
||||||
|
if (line[0] == '\n' || line[0] == '\r') {
|
||||||
|
if (is_ext_bus && has_kbd && has_qwerty) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
is_ext_bus = 0;
|
||||||
|
has_kbd = 0;
|
||||||
|
has_qwerty = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strncmp(line, "I: ", 3) == 0) {
|
||||||
|
if (strstr(line, "Bus=0005") || strstr(line, "Bus=0003"))
|
||||||
|
is_ext_bus = 1;
|
||||||
|
} else if (is_ext_bus && strncmp(line, "H: Handlers=", 12) == 0) {
|
||||||
|
if (strstr(line + 12, "kbd"))
|
||||||
|
has_kbd = 1;
|
||||||
|
} else if (is_ext_bus && strncmp(line, "B: KEY=", 7) == 0) {
|
||||||
|
const char *p = line + 7;
|
||||||
|
const char *last_tok = p;
|
||||||
|
while (*p) {
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
if (!*p || *p == '\n' || *p == '\r') break;
|
||||||
|
last_tok = p;
|
||||||
|
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') p++;
|
||||||
|
}
|
||||||
|
unsigned long long mask = strtoull(last_tok, NULL, 16);
|
||||||
|
if ((mask & 0x3ffc0000ULL) == 0x3ffc0000ULL)
|
||||||
|
has_qwerty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found && is_ext_bus && has_kbd && has_qwerty)
|
||||||
|
found = 1;
|
||||||
|
fclose(fp);
|
||||||
|
cached = found;
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
t9_mode_badge(int mode)
|
t9_mode_badge(int mode)
|
||||||
{
|
{
|
||||||
|
if (dmenu_has_external_keyboard())
|
||||||
|
return "[KBD]";
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case T9_SHIFT: return "[Abc]";
|
case T9_SHIFT: return "[Abc]";
|
||||||
case T9_UPPER: return "[ABC]";
|
case T9_UPPER: return "[ABC]";
|
||||||
@@ -1580,7 +1645,7 @@ keypress(XKeyEvent *ev)
|
|||||||
KeySym ksym;
|
KeySym ksym;
|
||||||
Status status;
|
Status status;
|
||||||
|
|
||||||
if (!engage_ime) {
|
if (!engage_ime && !dmenu_has_external_keyboard()) {
|
||||||
int t9k = map_t9_key(ev);
|
int t9k = map_t9_key(ev);
|
||||||
if (t9k >= 0) {
|
if (t9k >= 0) {
|
||||||
handle_t9_keypress(t9k);
|
handle_t9_keypress(t9k);
|
||||||
|
|||||||
+28
-1
@@ -585,11 +585,38 @@ Cur *
|
|||||||
drw_cur_create(Drw *drw, int shape)
|
drw_cur_create(Drw *drw, int shape)
|
||||||
{
|
{
|
||||||
Cur *cur;
|
Cur *cur;
|
||||||
|
Pixmap src, msk;
|
||||||
|
XColor fg, bg;
|
||||||
|
static const char src_bits[32] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00,
|
||||||
|
0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x7e, 0x00,
|
||||||
|
0xfe, 0x00, 0x3e, 0x00, 0x36, 0x00, 0x62, 0x00,
|
||||||
|
0x60, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
static const char msk_bits[32] = {
|
||||||
|
0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00,
|
||||||
|
0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00,
|
||||||
|
0xff, 0x01, 0xff, 0x03, 0x7f, 0x00, 0xf7, 0x00,
|
||||||
|
0xf3, 0x00, 0xe1, 0x01, 0xe0, 0x01, 0xc0, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
(void)shape;
|
||||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
memset(&fg, 0, sizeof(fg));
|
||||||
|
fg.red = 65535;
|
||||||
|
fg.green = 65535;
|
||||||
|
fg.blue = 65535;
|
||||||
|
fg.flags = DoRed | DoGreen | DoBlue;
|
||||||
|
memset(&bg, 0, sizeof(bg));
|
||||||
|
bg.flags = DoRed | DoGreen | DoBlue;
|
||||||
|
|
||||||
|
src = XCreateBitmapFromData(drw->dpy, drw->root, src_bits, 16, 16);
|
||||||
|
msk = XCreateBitmapFromData(drw->dpy, drw->root, msk_bits, 16, 16);
|
||||||
|
cur->cursor = XCreatePixmapCursor(drw->dpy, src, msk, &fg, &bg, 0, 0);
|
||||||
|
XFreePixmap(drw->dpy, src);
|
||||||
|
XFreePixmap(drw->dpy, msk);
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|||||||
+27
-7
@@ -271,18 +271,38 @@ Cur *
|
|||||||
drw_cur_create(Drw *drw, int shape)
|
drw_cur_create(Drw *drw, int shape)
|
||||||
{
|
{
|
||||||
Cur *cur;
|
Cur *cur;
|
||||||
Pixmap blank;
|
Pixmap src, msk;
|
||||||
XColor dummy;
|
XColor fg, bg;
|
||||||
static const char data[1] = {0};
|
static const char src_bits[32] = {
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00,
|
||||||
|
0x0e, 0x00, 0x1e, 0x00, 0x3e, 0x00, 0x7e, 0x00,
|
||||||
|
0xfe, 0x00, 0x3e, 0x00, 0x36, 0x00, 0x62, 0x00,
|
||||||
|
0x60, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
static const char msk_bits[32] = {
|
||||||
|
0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00,
|
||||||
|
0x1f, 0x00, 0x3f, 0x00, 0x7f, 0x00, 0xff, 0x00,
|
||||||
|
0xff, 0x01, 0xff, 0x03, 0x7f, 0x00, 0xf7, 0x00,
|
||||||
|
0xf3, 0x00, 0xe1, 0x01, 0xe0, 0x01, 0xc0, 0x00
|
||||||
|
};
|
||||||
|
|
||||||
(void)shape;
|
(void)shape;
|
||||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memset(&dummy, 0, sizeof(dummy));
|
memset(&fg, 0, sizeof(fg));
|
||||||
blank = XCreateBitmapFromData(drw->dpy, drw->root, data, 1, 1);
|
fg.red = 65535;
|
||||||
cur->cursor = XCreatePixmapCursor(drw->dpy, blank, blank, &dummy, &dummy, 0, 0);
|
fg.green = 65535;
|
||||||
XFreePixmap(drw->dpy, blank);
|
fg.blue = 65535;
|
||||||
|
fg.flags = DoRed | DoGreen | DoBlue;
|
||||||
|
memset(&bg, 0, sizeof(bg));
|
||||||
|
bg.flags = DoRed | DoGreen | DoBlue;
|
||||||
|
|
||||||
|
src = XCreateBitmapFromData(drw->dpy, drw->root, src_bits, 16, 16);
|
||||||
|
msk = XCreateBitmapFromData(drw->dpy, drw->root, msk_bits, 16, 16);
|
||||||
|
cur->cursor = XCreatePixmapCursor(drw->dpy, src, msk, &fg, &bg, 0, 0);
|
||||||
|
XFreePixmap(drw->dpy, src);
|
||||||
|
XFreePixmap(drw->dpy, msk);
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|||||||
+157
-19
@@ -330,7 +330,7 @@ static xcb_connection_t *xcon;
|
|||||||
|
|
||||||
static struct HoldKey *holdkeyroot = NULL;
|
static struct HoldKey *holdkeyroot = NULL;
|
||||||
|
|
||||||
#define MAX_INPUT_FDS 8
|
#define MAX_INPUT_FDS 16
|
||||||
static int input_fds[MAX_INPUT_FDS];
|
static int input_fds[MAX_INPUT_FDS];
|
||||||
static int num_input_fds = 0;
|
static int num_input_fds = 0;
|
||||||
static long long last_wake_ms = 0;
|
static long long last_wake_ms = 0;
|
||||||
@@ -2089,6 +2089,115 @@ flush_pending_softkey(void)
|
|||||||
|
|
||||||
static long long last_mouse_ms = 0;
|
static long long last_mouse_ms = 0;
|
||||||
static int cursor_hidden = 0;
|
static int cursor_hidden = 0;
|
||||||
|
static int prev_ext_mouse = 0;
|
||||||
|
static time_t last_mouse_dev_sec = 0;
|
||||||
|
static long last_mouse_dev_nsec = 0;
|
||||||
|
|
||||||
|
static void
|
||||||
|
dwm_rescan_input_fds(int force)
|
||||||
|
{
|
||||||
|
static time_t last_scan_sec = 0;
|
||||||
|
static long last_scan_nsec = 0;
|
||||||
|
struct stat st;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!force && stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == last_scan_sec &&
|
||||||
|
st.st_mtim.tv_nsec == last_scan_nsec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
last_scan_sec = st.st_mtim.tv_sec;
|
||||||
|
last_scan_nsec = st.st_mtim.tv_nsec;
|
||||||
|
} else if (stat("/dev/input", &st) == 0) {
|
||||||
|
last_scan_sec = st.st_mtim.tv_sec;
|
||||||
|
last_scan_nsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
if (force) {
|
||||||
|
last_mouse_dev_sec = 0;
|
||||||
|
last_mouse_dev_nsec = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < num_input_fds; i++) {
|
||||||
|
if (input_fds[i] >= 0)
|
||||||
|
close(input_fds[i]);
|
||||||
|
}
|
||||||
|
num_input_fds = 0;
|
||||||
|
for (i = 0; i < MAX_INPUT_FDS; i++) {
|
||||||
|
char evpath[64], evname[128] = "";
|
||||||
|
int evfd;
|
||||||
|
snprintf(evpath, sizeof(evpath), "/dev/input/event%d", i);
|
||||||
|
evfd = open(evpath, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
||||||
|
if (evfd < 0)
|
||||||
|
continue;
|
||||||
|
if (ioctl(evfd, EVIOCGNAME(sizeof(evname)), evname) >= 0 &&
|
||||||
|
strstr(evname, "Jack") != NULL) {
|
||||||
|
close(evfd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
input_fds[num_input_fds++] = evfd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
dwm_has_external_mouse(void)
|
||||||
|
{
|
||||||
|
static int cached = 0;
|
||||||
|
struct stat st;
|
||||||
|
if (stat("/dev/input", &st) == 0) {
|
||||||
|
if (st.st_mtim.tv_sec == last_mouse_dev_sec &&
|
||||||
|
st.st_mtim.tv_nsec == last_mouse_dev_nsec) {
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
last_mouse_dev_sec = st.st_mtim.tv_sec;
|
||||||
|
last_mouse_dev_nsec = st.st_mtim.tv_nsec;
|
||||||
|
}
|
||||||
|
FILE *fp = fopen("/proc/bus/input/devices", "r");
|
||||||
|
if (!fp) {
|
||||||
|
cached = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
char line[512];
|
||||||
|
int is_ext_bus = 0;
|
||||||
|
int has_mouse_handler = 0;
|
||||||
|
int has_rel_xy = 0;
|
||||||
|
int found = 0;
|
||||||
|
while (fgets(line, sizeof(line), fp)) {
|
||||||
|
if (line[0] == '\n' || line[0] == '\r') {
|
||||||
|
if (is_ext_bus && (has_mouse_handler || has_rel_xy)) {
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
is_ext_bus = 0;
|
||||||
|
has_mouse_handler = 0;
|
||||||
|
has_rel_xy = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strncmp(line, "I: ", 3) == 0) {
|
||||||
|
if (strstr(line, "Bus=0005") || strstr(line, "Bus=0003"))
|
||||||
|
is_ext_bus = 1;
|
||||||
|
} else if (is_ext_bus && strncmp(line, "H: Handlers=", 12) == 0) {
|
||||||
|
if (strstr(line + 12, "mouse"))
|
||||||
|
has_mouse_handler = 1;
|
||||||
|
} else if (is_ext_bus && strncmp(line, "B: REL=", 7) == 0) {
|
||||||
|
const char *p = line + 7;
|
||||||
|
const char *last_tok = p;
|
||||||
|
while (*p) {
|
||||||
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
|
if (!*p || *p == '\n' || *p == '\r') break;
|
||||||
|
last_tok = p;
|
||||||
|
while (*p && *p != ' ' && *p != '\t' && *p != '\n' && *p != '\r') p++;
|
||||||
|
}
|
||||||
|
unsigned long long mask = strtoull(last_tok, NULL, 16);
|
||||||
|
if ((mask & 0x3ULL) == 0x3ULL)
|
||||||
|
has_rel_xy = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found && is_ext_bus && (has_mouse_handler || has_rel_xy))
|
||||||
|
found = 1;
|
||||||
|
fclose(fp);
|
||||||
|
cached = found;
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dwm_cursor_set_visible(int show)
|
dwm_cursor_set_visible(int show)
|
||||||
@@ -2113,8 +2222,10 @@ dwm_cursor_set_visible(int show)
|
|||||||
if (cursor_hidden && fn_show) {
|
if (cursor_hidden && fn_show) {
|
||||||
fn_show(dpy, root);
|
fn_show(dpy, root);
|
||||||
cursor_hidden = 0;
|
cursor_hidden = 0;
|
||||||
XFlush(dpy);
|
|
||||||
}
|
}
|
||||||
|
if (cursor[CurNormal])
|
||||||
|
XDefineCursor(dpy, root, cursor[CurNormal]->cursor);
|
||||||
|
XFlush(dpy);
|
||||||
} else {
|
} else {
|
||||||
if (!cursor_hidden && fn_hide) {
|
if (!cursor_hidden && fn_hide) {
|
||||||
fn_hide(dpy, root);
|
fn_hide(dpy, root);
|
||||||
@@ -2124,6 +2235,22 @@ dwm_cursor_set_visible(int show)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dwm_sync_mouse_cursor(void)
|
||||||
|
{
|
||||||
|
int ext_mouse = dwm_has_external_mouse();
|
||||||
|
if (ext_mouse) {
|
||||||
|
if (!prev_ext_mouse && dpy && root) {
|
||||||
|
XWarpPointer(dpy, None, root, 0, 0, 0, 0, sw / 2, sh / 2);
|
||||||
|
}
|
||||||
|
prev_ext_mouse = 1;
|
||||||
|
dwm_cursor_set_visible(1);
|
||||||
|
} else if (prev_ext_mouse) {
|
||||||
|
prev_ext_mouse = 0;
|
||||||
|
dwm_cursor_set_visible(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dwm_handle_softbar_click(int x)
|
dwm_handle_softbar_click(int x)
|
||||||
{
|
{
|
||||||
@@ -2241,7 +2368,8 @@ keypress(XEvent *e)
|
|||||||
|
|
||||||
ev = &e->xkey;
|
ev = &e->xkey;
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
if (cursor_hidden == 0 && (dwm_now_ms() - last_mouse_ms) > 4000)
|
dwm_sync_mouse_cursor();
|
||||||
|
if (!dwm_has_external_mouse() && cursor_hidden == 0 && (dwm_now_ms() - last_mouse_ms) > 4000)
|
||||||
dwm_cursor_set_visible(0);
|
dwm_cursor_set_visible(0);
|
||||||
|
|
||||||
if (is_screen_off()) {
|
if (is_screen_off()) {
|
||||||
@@ -2386,7 +2514,8 @@ keyrelease(XEvent *e)
|
|||||||
|
|
||||||
ev = &e->xkey;
|
ev = &e->xkey;
|
||||||
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0);
|
||||||
if (cursor_hidden == 0 && (dwm_now_ms() - last_mouse_ms) > 4000)
|
dwm_sync_mouse_cursor();
|
||||||
|
if (!dwm_has_external_mouse() && cursor_hidden == 0 && (dwm_now_ms() - last_mouse_ms) > 4000)
|
||||||
dwm_cursor_set_visible(0);
|
dwm_cursor_set_visible(0);
|
||||||
|
|
||||||
markreleased(keysym);
|
markreleased(keysym);
|
||||||
@@ -2642,6 +2771,7 @@ propertynotify(XEvent *e)
|
|||||||
XPropertyEvent *ev = &e->xproperty;
|
XPropertyEvent *ev = &e->xproperty;
|
||||||
|
|
||||||
if (ev->window == root) {
|
if (ev->window == root) {
|
||||||
|
dwm_sync_mouse_cursor();
|
||||||
if (ev->atom == XA_WM_NAME)
|
if (ev->atom == XA_WM_NAME)
|
||||||
updatestatus();
|
updatestatus();
|
||||||
else if (ev->atom == XA_RESOURCE_MANAGER)
|
else if (ev->atom == XA_RESOURCE_MANAGER)
|
||||||
@@ -2835,6 +2965,8 @@ run(void)
|
|||||||
}
|
}
|
||||||
if (!running)
|
if (!running)
|
||||||
break;
|
break;
|
||||||
|
dwm_rescan_input_fds(0);
|
||||||
|
dwm_sync_mouse_cursor();
|
||||||
fds[0].fd = xfd;
|
fds[0].fd = xfd;
|
||||||
fds[0].events = POLLIN;
|
fds[0].events = POLLIN;
|
||||||
fds[0].revents = 0;
|
fds[0].revents = 0;
|
||||||
@@ -2882,14 +3014,22 @@ run(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_input_fds; i++) {
|
for (i = 0; i < num_input_fds; i++) {
|
||||||
|
if (fds[1 + i].revents & (POLLHUP | POLLERR | POLLNVAL)) {
|
||||||
|
dwm_rescan_input_fds(1);
|
||||||
|
dwm_sync_mouse_cursor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (fds[1 + i].revents & POLLIN) {
|
if (fds[1 + i].revents & POLLIN) {
|
||||||
while (read(input_fds[i], &ie, sizeof(ie)) == (ssize_t)sizeof(ie)) {
|
ssize_t nread;
|
||||||
|
while ((nread = read(input_fds[i], &ie, sizeof(ie))) == (ssize_t)sizeof(ie)) {
|
||||||
if (ie.type == EV_SW && ie.code == SW_LID) {
|
if (ie.type == EV_SW && ie.code == SW_LID) {
|
||||||
if (ie.value == 1) {
|
if (ie.value == 1) {
|
||||||
lock_phone_screenoff();
|
lock_phone_screenoff();
|
||||||
} else if (ie.value == 0) {
|
} else if (ie.value == 0) {
|
||||||
wake_phone();
|
wake_phone();
|
||||||
}
|
}
|
||||||
|
} else if (ie.type == EV_REL && ie.value != 0) {
|
||||||
|
dwm_cursor_set_visible(1);
|
||||||
} else if (ie.type == EV_KEY) {
|
} else if (ie.type == EV_KEY) {
|
||||||
if (ie.code == 522 || ie.code == 55)
|
if (ie.code == 522 || ie.code == 55)
|
||||||
star_down = (ie.value != 0);
|
star_down = (ie.value != 0);
|
||||||
@@ -2912,6 +3052,11 @@ run(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nread < 0 && errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) {
|
||||||
|
dwm_rescan_input_fds(1);
|
||||||
|
dwm_sync_mouse_cursor();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fds[0].revents & (POLLIN | POLLHUP | POLLERR)) {
|
if (fds[0].revents & (POLLIN | POLLHUP | POLLERR)) {
|
||||||
@@ -3147,20 +3292,7 @@ setup(void)
|
|||||||
|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask|KeyPressMask|KeyReleaseMask;
|
|LeaveWindowMask|StructureNotifyMask|PropertyChangeMask|KeyPressMask|KeyReleaseMask;
|
||||||
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
|
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
|
||||||
XSelectInput(dpy, root, wa.event_mask);
|
XSelectInput(dpy, root, wa.event_mask);
|
||||||
num_input_fds = 0;
|
dwm_rescan_input_fds(1);
|
||||||
for (i = 0; i < MAX_INPUT_FDS; i++) {
|
|
||||||
char evpath[64], evname[128] = "";
|
|
||||||
int evfd;
|
|
||||||
snprintf(evpath, sizeof(evpath), "/dev/input/event%d", i);
|
|
||||||
evfd = open(evpath, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
|
|
||||||
if (evfd < 0)
|
|
||||||
continue;
|
|
||||||
if (ioctl(evfd, EVIOCGNAME(sizeof(evname)), evname) >= 0 && strstr(evname, "Jack") != NULL) {
|
|
||||||
close(evfd);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
input_fds[num_input_fds++] = evfd;
|
|
||||||
}
|
|
||||||
unlink("/tmp/sxmo_softkey_suppress");
|
unlink("/tmp/sxmo_softkey_suppress");
|
||||||
unlink("/tmp/sxmo_softkey_state");
|
unlink("/tmp/sxmo_softkey_state");
|
||||||
{
|
{
|
||||||
@@ -3173,7 +3305,13 @@ setup(void)
|
|||||||
load_plugins();
|
load_plugins();
|
||||||
grabkeys();
|
grabkeys();
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
|
if (dwm_has_external_mouse()) {
|
||||||
|
prev_ext_mouse = 1;
|
||||||
|
XWarpPointer(dpy, None, root, 0, 0, 0, 0, sw / 2, sh / 2);
|
||||||
|
dwm_cursor_set_visible(1);
|
||||||
|
} else {
|
||||||
dwm_cursor_set_visible(0);
|
dwm_cursor_set_visible(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1158,10 +1158,8 @@ void
|
|||||||
xinit(int cols, int rows)
|
xinit(int cols, int rows)
|
||||||
{
|
{
|
||||||
XGCValues gcvalues;
|
XGCValues gcvalues;
|
||||||
Cursor cursor;
|
|
||||||
Window parent;
|
Window parent;
|
||||||
pid_t thispid = getpid();
|
pid_t thispid = getpid();
|
||||||
XColor xmousefg, xmousebg;
|
|
||||||
|
|
||||||
xw.scr = XDefaultScreen(xw.dpy);
|
xw.scr = XDefaultScreen(xw.dpy);
|
||||||
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
xw.vis = XDefaultVisual(xw.dpy, xw.scr);
|
||||||
@@ -1222,18 +1220,6 @@ xinit(int cols, int rows)
|
|||||||
ximinstantiate, NULL);
|
ximinstantiate, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invisible 1x1 cursor for keypad-only hardware */
|
|
||||||
{
|
|
||||||
Pixmap blank;
|
|
||||||
static const char blankdata[1] = {0};
|
|
||||||
memset(&xmousefg, 0, sizeof(xmousefg));
|
|
||||||
memset(&xmousebg, 0, sizeof(xmousebg));
|
|
||||||
blank = XCreateBitmapFromData(xw.dpy, xw.win, blankdata, 1, 1);
|
|
||||||
cursor = XCreatePixmapCursor(xw.dpy, blank, blank, &xmousefg, &xmousebg, 0, 0);
|
|
||||||
XFreePixmap(xw.dpy, blank);
|
|
||||||
XDefineCursor(xw.dpy, xw.win, cursor);
|
|
||||||
}
|
|
||||||
|
|
||||||
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
|
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
|
||||||
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
|
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
|
||||||
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
|
xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
|
||||||
|
|||||||
Reference in new issue
Block a user