Fix global Power menu key handling, SIP G.711 audio routing, Webarchy audio playback, and ReMEdy Call menu key

This commit is contained in:
Luxferre committed 2026-10-31 19:39:28 +02:00
1 parent d7335b5ebe
commit 0af39d9fa0
76 files changed
+506 -104

No files matched your search

+3 -1
View File
@@ -13,7 +13,7 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
### New features and improvements ### New features and improvements
- **Native NeoUI communication and internet suite (`xsip`, `xemail`, `xirc`, `xtox`, `xkopher`, `webarchy`)**: - **Native NeoUI communication and internet suite (`xsip`, `xemail`, `xirc`, `xtox`, `xkopher`, `webarchy`)**:
- **SIP VoIP client (`sip.so` / `xsip`)**: implemented an RFC 3261 SIP softphone (`Dialer`, `Accounts`, `History` tabs) supporting both account-registered calling (with alphanumeric username/password multi-tap entry, Digest MD5 authentication, and background standby `REGISTER` keepalive) and direct accountless P2P/federated SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`) with RFC 3263 DNS `SRV` (`_sip._udp.<domain>`) proxy discovery, RFC 3261 Timer A `INVITE` retransmission with multi-`A` proxy failover, `Record-Route`/`Contact` dialog routing, RFC 6189 **ZRTP** media-path key agreement (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman, `H0..H3` SHA-256 hash chain, Castagnoli CRC-32C framing, `a=zrtp-hash` SDP signaling, and 4-character Base32 `SAS` verification code) with RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media, incoming `INVITE` standby wakeup and call handling integrated with `xcallscreen` (`[SIP/<codec>]` / `[SIP/<codec>:<sas>]`), wideband and narrowband multi-codec RTP/SRTP audio (`Opus` 16 kHz / 48 kHz RTP clock with in-band FEC, `ITU-T G.722` 16 kHz wideband SB-ADPCM, `G.711 PCMU`/`PCMA` 8 kHz, `GSM 06.10` Full Rate 8 kHz, `ITU-T G.726-32` 8 kHz ADPCM, `IMA ADPCM DVI4` 8/16 kHz, and `L16` uncompressed 16-bit PCM 8/16 kHz) with per-account and direct-mode codec preference selection, and RFC 2833 / RFC 4733 DTMF tones. - **SIP VoIP client (`sip.so` / `xsip`)**: implemented an RFC 3261 SIP softphone (`Dialer`, `Accounts`, `History` tabs) supporting both account-registered calling (with alphanumeric username/password multi-tap entry, Digest MD5 authentication, and background standby `REGISTER` keepalive) and direct accountless P2P/federated SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`) with RFC 3263 DNS `SRV` (`_sip._udp.<domain>`) proxy discovery, RFC 3261 Timer A `INVITE` retransmission with multi-`A` proxy failover, `Record-Route`/`Contact` dialog routing, RFC 6189 **ZRTP** media-path key agreement (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman, `H0..H3` SHA-256 hash chain, Castagnoli CRC-32C framing, `a=zrtp-hash` SDP signaling, and 4-character Base32 `SAS` verification code) with RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media, incoming `INVITE` standby wakeup and call handling integrated with `xcallscreen` (`[SIP/<codec>]` / `[SIP/<codec>:<sas>]`), wideband and narrowband multi-codec RTP/SRTP audio (`G.711 PCMU`/`PCMA` 8 kHz prioritized by default in `AUTO` mode, `GSM 06.10` Full Rate 8 kHz, `Opus` 16 kHz / 48 kHz RTP clock with in-band FEC, `ITU-T G.722` 16 kHz wideband SB-ADPCM, `ITU-T G.726-32` 8 kHz ADPCM, `IMA ADPCM DVI4` 8/16 kHz, and `L16` uncompressed 16-bit PCM 8/16 kHz) with per-account and direct-mode codec preference selection, seamless early-media (`183 Session Progress` -> `200 OK`) `arecord`/`aplay` stream continuity, and RFC 2833 / RFC 4733 DTMF tones.
- **Email client (`email.so` / `xemail` / `xmail`)**: implemented a multi-account `IMAP4rev1`, `POP3`, and `SMTP` client (`Inbox`, `Compose`, `Accounts` tabs) supporting implicit TLS (`993`/`995`/`465`), `STARTTLS` (`143`/`110`/`587`), and plain TCP, SASL `PLAIN`/`LOGIN` authentication, RFC 2047 encoded-word header decoding, Base64/Quoted-Printable MIME body decoding, HTML tag stripping, offline inbox cache (`~/.local/share/sxmo/email/`), full-screen reader, and message composer/reply. - **Email client (`email.so` / `xemail` / `xmail`)**: implemented a multi-account `IMAP4rev1`, `POP3`, and `SMTP` client (`Inbox`, `Compose`, `Accounts` tabs) supporting implicit TLS (`993`/`995`/`465`), `STARTTLS` (`143`/`110`/`587`), and plain TCP, SASL `PLAIN`/`LOGIN` authentication, RFC 2047 encoded-word header decoding, Base64/Quoted-Printable MIME body decoding, HTML tag stripping, offline inbox cache (`~/.local/share/sxmo/email/`), full-screen reader, and message composer/reply.
- **IRCv3 client (`irc.so` / `xirc`)**: implemented a multi-server IRC client (`Chat`, `Buffers`, `Servers` tabs) with OpenSSL TLS, IRCv3 capability negotiation (`CAP LS 302`: `sasl`, `server-time`, `message-tags`, `multi-prefix`, `away-notify`, `account-notify`, `chghost`, `cap-notify`), `SASL PLAIN` authentication, `433` nick-in-use fallback and `470` channel forwarding tracking, slash commands (`/join`, `/part`, `/close`, `/msg`, `/nick`, `/me`, `/clear`, `/raw`, `/quit`), targeted buffer closing (`Menu -> Close Buffer` or `BackSpace` in `Buffers`), and a resident background mode (`BG Mode`) that keeps sockets connected when the window is closed and triggers notification hooks on nick highlights or private messages. - **IRCv3 client (`irc.so` / `xirc`)**: implemented a multi-server IRC client (`Chat`, `Buffers`, `Servers` tabs) with OpenSSL TLS, IRCv3 capability negotiation (`CAP LS 302`: `sasl`, `server-time`, `message-tags`, `multi-prefix`, `away-notify`, `account-notify`, `chghost`, `cap-notify`), `SASL PLAIN` authentication, `433` nick-in-use fallback and `470` channel forwarding tracking, slash commands (`/join`, `/part`, `/close`, `/msg`, `/nick`, `/me`, `/clear`, `/raw`, `/quit`), targeted buffer closing (`Menu -> Close Buffer` or `BackSpace` in `Buffers`), and a resident background mode (`BG Mode`) that keeps sockets connected when the window is closed and triggers notification hooks on nick highlights or private messages.
- **Tox / Trifa P2P messenger and audio call client (`tox.so` / `xtox`)**: built an encrypted P2P messenger and voice call client (`Friends`, `Chat`, `My Tox ID` tabs) on `c-toxcore` (`libtoxcore.so.2`), featuring persistent profile storage (`~/.local/share/sxmo/tox/profile.tox`), non-blocking IPv4 DHT + TCP relay bootstrap, friend request handling, persistent chat logs, and standby incoming `ToxAV` 48 kHz Opus voice calls integrated with `xcallscreen` (`[TOX]`). - **Tox / Trifa P2P messenger and audio call client (`tox.so` / `xtox`)**: built an encrypted P2P messenger and voice call client (`Friends`, `Chat`, `My Tox ID` tabs) on `c-toxcore` (`libtoxcore.so.2`), featuring persistent profile storage (`~/.local/share/sxmo/tox/profile.tox`), non-blocking IPv4 DHT + TCP relay bootstrap, friend request handling, persistent chat logs, and standby incoming `ToxAV` 48 kHz Opus voice calls integrated with `xcallscreen` (`[TOX]`).
@@ -59,6 +59,8 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
- Added VM writeback (`dirty_writeback_centisecs=6000`), `printk` throttling, `sched_autogroup_enabled=0`, `nmi_watchdog=0`, `schedutil` governor rate-limit tuning (`rate_limit_us=2000`, fixing the 6.44s default caused by `qcom-cpufreq` `UINT_MAX` transition latency so cores downclock to `200 MHz` within `2 ms`), Wi-Fi powersave (`iw dev wlan0 set power_save on`), USB/platform runtime PM (`power/control = auto`), and automatic unbinding of the `7864900.sdhci` microSD host controller when no card is inserted (along with `bias-pull-up` on `sdc2-cd-off-state` and unified Adreno 304 GPU / IOMMU device-tree nodes across all 5 device `.dts`/`.dtb` files). - Added VM writeback (`dirty_writeback_centisecs=6000`), `printk` throttling, `sched_autogroup_enabled=0`, `nmi_watchdog=0`, `schedutil` governor rate-limit tuning (`rate_limit_us=2000`, fixing the 6.44s default caused by `qcom-cpufreq` `UINT_MAX` transition latency so cores downclock to `200 MHz` within `2 ms`), Wi-Fi powersave (`iw dev wlan0 set power_save on`), USB/platform runtime PM (`power/control = auto`), and automatic unbinding of the `7864900.sdhci` microSD host controller when no card is inserted (along with `bias-pull-up` on `sdc2-cd-off-state` and unified Adreno 304 GPU / IOMMU device-tree nodes across all 5 device `.dts`/`.dtb` files).
- Replaced the 120ms busy-wait loop in `gps.so` (`OsmTileCache::workerLoop`) with `std::condition_variable`, cached Dual-SIM status in `/tmp/sxmo_dsds_active` to avoid repeated `qmicli` wakes on single-SIM setups, increased the DSDS idle `select()` timeout to `300s`, and set display framebuffer `bl_power = 4` (`FB_BLANK_POWERDOWN`) whenever the screen is blanked. - Replaced the 120ms busy-wait loop in `gps.so` (`OsmTileCache::workerLoop`) with `std::condition_variable`, cached Dual-SIM status in `/tmp/sxmo_dsds_active` to avoid repeated `qmicli` wakes on single-SIM setups, increased the DSDS idle `select()` timeout to `300s`, and set display framebuffer `bl_power = 4` (`FB_BLANK_POWERDOWN`) whenever the screen is blanked.
- Increased `conky` desktop clock refresh interval to `15.0s` and froze `conky` (`SIGSTOP`/`SIGCONT`) whenever the screen is off or locked, replaced polling in `sxmo_modemmonitor.sh` with event-driven `dbus-monitor`, skipped redundant `sxmo_hook_statusbar.sh` updates while `screenoff` or locked, and drained queued X11 `UnmapNotify` events in `neoui_hide()` so all resident DWM plugins sleep at `0%` CPU when hidden. - Increased `conky` desktop clock refresh interval to `15.0s` and froze `conky` (`SIGSTOP`/`SIGCONT`) whenever the screen is off or locked, replaced polling in `sxmo_modemmonitor.sh` with event-driven `dbus-monitor`, skipped redundant `sxmo_hook_statusbar.sh` updates while `screenoff` or locked, and drained queued X11 `UnmapNotify` events in `neoui_hide()` so all resident DWM plugins sleep at `0%` CPU when hidden.
- **Universal Power button (`dmenu power`) access and ReMEdy `Call (green)` 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**.
--- ---
+2 -2
View File
@@ -233,7 +233,7 @@ All twenty-four phone applications are compiled as shared-object plugins (`/usr/
- **`1:Dialer`**: enter a SIP URI (`user@host[:port]` or `sip:user@host[:port]`) or account extension (`1001`) using multi-tap alphanumeric input (`*` or `#` cycles `[abc]` / `[ABC]` / `[123]` / `[Sym]` / `[Abc]`) or select a recent peer with `Up`/`Down`, and press **Call (green)** or **Center `OK`** to place an outgoing SIP call. Outbound calls work both with a registered SIP account and directly without any configured account (`Direct URI` mode, selectable via `Menu -> Switch Account` when accounts are also present). - **`1:Dialer`**: enter a SIP URI (`user@host[:port]` or `sip:user@host[:port]`) or account extension (`1001`) using multi-tap alphanumeric input (`*` or `#` cycles `[abc]` / `[ABC]` / `[123]` / `[Sym]` / `[Abc]`) or select a recent peer with `Up`/`Down`, and press **Call (green)** or **Center `OK`** to place an outgoing SIP call. Outbound calls work both with a registered SIP account and directly without any configured account (`Direct URI` mode, selectable via `Menu -> Switch Account` when accounts are also present).
- **`2:Accounts`**: add or edit SIP accounts (`~/.config/sxmo/sip_accounts.tsv`: Label, alphanumeric Username, Password, Domain, Port, UDP/TCP/TLS transport, ZRTP toggle, Preferred Codec, Enabled). Enabled accounts maintain RFC 3261 `REGISTER` keepalives with Digest MD5 authentication in the background even when `xsip` is closed. - **`2:Accounts`**: add or edit SIP accounts (`~/.config/sxmo/sip_accounts.tsv`: Label, alphanumeric Username, Password, Domain, Port, UDP/TCP/TLS transport, ZRTP toggle, Preferred Codec, Enabled). Enabled accounts maintain RFC 3261 `REGISTER` keepalives with Digest MD5 authentication in the background even when `xsip` is closed.
- **`3:History`**: browse incoming, outgoing, and missed SIP calls (`~/.local/share/sxmo/sip_history.tsv`) and press **Call (green)** or **Center `OK`** to redial. - **`3:History`**: browse incoming, outgoing, and missed SIP calls (`~/.local/share/sxmo/sip_history.tsv`) and press **Call (green)** or **Center `OK`** to redial.
- **Audio codecs (`AUTO`, `OPUS`, `G722`, `PCMU`, `PCMA`, `GSM`, `G726-32`, `DVI4`, `L16`)**: supports full SDP `m=audio` / `a=rtpmap` / `a=fmtp` negotiation across 10 wideband (`16 kHz`) and narrowband (`8 kHz`) RTP/SRTP audio profiles: **Opus** (`opus/48000/2`, RFC 7587, 16 kHz wideband VoIP with in-band FEC), **ITU-T G.722** (`G722/8000`, 16 kHz wideband 64 kbps SB-ADPCM), **ITU-T G.711** `PCMU` (`PT 0`) and `PCMA` (`PT 8`, 8 kHz 64 kbps), **GSM 06.10 Full Rate** (`GSM/8000`, `PT 3`, 8 kHz 13 kbps RPE-LTP), **ITU-T G.726-32** (`G726-32/8000`, 8 kHz 32 kbps ADPCM), **IMA ADPCM** (`DVI4/8000` `PT 5` and `DVI4/16000` `PT 6`), and **uncompressed 16-bit PCM** (`L16/8000` and `L16/16000`), plus **RFC 2833 / RFC 4733 `telephone-event/8000`** DTMF. Preferred codec priority is configurable per account (`Codec` field in the Account Editor) or for direct accountless calls (`Menu -> Cycle Direct Codec`). - **Audio codecs (`AUTO`, `PCMU`, `PCMA`, `GSM`, `OPUS`, `G722`, `G726-32`, `DVI4`, `L16`)**: supports full SDP `m=audio` / `a=rtpmap` / `a=fmtp` negotiation across 10 narrowband (`8 kHz`) and wideband (`16 kHz`) RTP/SRTP audio profiles, prioritizing **ITU-T G.711** `PCMU` (`PT 0`) and `PCMA` (`PT 8`, 8 kHz 64 kbps) first in `AUTO` mode, followed by **GSM 06.10 Full Rate** (`GSM/8000`, `PT 3`, 8 kHz 13 kbps RPE-LTP), **Opus** (`opus/48000/2`, RFC 7587, 16 kHz wideband VoIP with in-band FEC), **ITU-T G.722** (`G722/8000`, 16 kHz wideband 64 kbps SB-ADPCM), **ITU-T G.726-32** (`G726-32/8000`, 8 kHz 32 kbps ADPCM), **IMA ADPCM** (`DVI4/8000` `PT 5` and `DVI4/16000` `PT 6`), and **uncompressed 16-bit PCM** (`L16/8000` and `L16/16000`), plus **RFC 2833 / RFC 4733 `telephone-event/8000`** DTMF. Preferred codec priority is configurable per account (`Codec` field in the Account Editor) or for direct accountless calls (`Menu -> Cycle Direct Codec`).
- **ZRTP / SRTP encryption and CallScreen (`xcallscreen`) integration**: supports RFC 6189 **ZRTP** (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman key agreement with `a=zrtp-hash` SDP signaling and persistent 96-bit `ZID`) and RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media (`ON` by default per account and for direct accountless calls via `Menu -> Toggle Direct ZRTP`). Incoming `INVITE` requests wake the phone, trigger the ringtone/vibrator, and open `xcallscreen` with a `[SIP/<codec>]` badge; once ZRTP completes its handshake, the active codec and 4-character Short Authentication String (`SAS`) are displayed in both `xsip` (`<codec> | ZRTP SAS:<sas>`) and `xcallscreen` (`[SIP/<codec>:<sas>]`). - **ZRTP / SRTP encryption and CallScreen (`xcallscreen`) integration**: supports RFC 6189 **ZRTP** (`DH3k` 3072-bit / `DH2k` 2048-bit Diffie-Hellman key agreement with `a=zrtp-hash` SDP signaling and persistent 96-bit `ZID`) and RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`/`32`) encrypted voice media (`ON` by default per account and for direct accountless calls via `Menu -> Toggle Direct ZRTP`). Incoming `INVITE` requests wake the phone, trigger the ringtone/vibrator, and open `xcallscreen` with a `[SIP/<codec>]` badge; once ZRTP completes its handshake, the active codec and 4-character Short Authentication String (`SAS`) are displayed in both `xsip` (`<codec> | ZRTP SAS:<sas>`) and `xcallscreen` (`[SIP/<codec>:<sas>]`).
17. **Email client (`email.so` / `xemail` / `xmail`)**: 17. **Email client (`email.so` / `xemail` / `xmail`)**:
@@ -321,7 +321,7 @@ Three native X11 games (`/usr/bin/snake`, `/usr/bin/tetris`, and `/usr/bin/scoun
- **Launch**: open **ReMEdy (J2ME)** from **System menu -> Applications** or **System menu -> Games**, open any `.jar` or `.jad` file from **Files (`xfiles`)**, or run `remedy [app.jar|app.jad]`. When launched without a file argument, opens the NeoUI-themed **ReMEdy J2ME** browser scanning `/usr/share/games/j2me`, `~/Games`, `~/J2ME`, `~/Downloads`, and user directories, displaying the selected MIDlet's `MIDlet-Name`, `MIDlet-Vendor`, `MIDlet-Version`, main class, and RMS save status. - **Launch**: open **ReMEdy (J2ME)** from **System menu -> Applications** or **System menu -> Games**, open any `.jar` or `.jad` file from **Files (`xfiles`)**, or run `remedy [app.jar|app.jad]`. When launched without a file argument, opens the NeoUI-themed **ReMEdy J2ME** browser scanning `/usr/share/games/j2me`, `~/Games`, `~/J2ME`, `~/Downloads`, and user directories, displaying the selected MIDlet's `MIDlet-Name`, `MIDlet-Vendor`, `MIDlet-Version`, main class, and RMS save status.
- **Full-screen `240x320` resolution and NeoUI-themed LCDUI**: runs in a full-screen `240x320` window (`X=0, Y=0, W=240, H=320`) and declares native `240x320` dimensions (`getWidth() == 240`, `getHeight() == 320`) to J2ME applications. Full-screen `Canvas` and `GameCanvas` games get the entire `240x320` display, while high-level LCDUI screens (`Form`, `List`, `TextBox`, `Alert`, `ChoiceGroup`, `Gauge`, `TextField`, `StringItem`, and `Command` bars/menus) render with `libneoui.so` (`PluginTheme`) and adapt automatically to the active `.Xresources` / `~/.xthemes/*.xth` system theme. - **Full-screen `240x320` resolution and NeoUI-themed LCDUI**: runs in a full-screen `240x320` window (`X=0, Y=0, W=240, H=320`) and declares native `240x320` dimensions (`getWidth() == 240`, `getHeight() == 320`) to J2ME applications. Full-screen `Canvas` and `GameCanvas` games get the entire `240x320` display, while high-level LCDUI screens (`Form`, `List`, `TextBox`, `Alert`, `ChoiceGroup`, `Gauge`, `TextField`, `StringItem`, and `Command` bars/menus) render with `libneoui.so` (`PluginTheme`) and adapt automatically to the active `.Xresources` / `~/.xthemes/*.xth` system theme.
- **Hardware-accelerated 3D (JSR-184 M3G), networking, RMS, and audio**: accelerates JSR-184 (`javax.microedition.m3g.*`) 3D scenes on the Adreno 304 (`FD304`) GPU via EGL + OpenGL ES 2.0 (with depth-buffered software fallback), supports HTTP/HTTPS and raw TCP/UDP socket connections (`javax.microedition.io.Connector`, `HttpConnection`, `SocketConnection`, `FileConnection` JSR-75), Nokia UI API (`com.nokia.mid.ui.*`), persistent `RecordStore` (RMS) storage (`~/.local/share/sxmo/remedy/rms/`), and MMAPI (`javax.microedition.media.Manager`) tone and WAV/MIDI audio over ALSA (`hw:0,0`). Audio follows the system speaker volume and mute state (the xdrawer **Speaker** slider) live, at the same loudness as other apps. - **Hardware-accelerated 3D (JSR-184 M3G), networking, RMS, and audio**: accelerates JSR-184 (`javax.microedition.m3g.*`) 3D scenes on the Adreno 304 (`FD304`) GPU via EGL + OpenGL ES 2.0 (with depth-buffered software fallback), supports HTTP/HTTPS and raw TCP/UDP socket connections (`javax.microedition.io.Connector`, `HttpConnection`, `SocketConnection`, `FileConnection` JSR-75), Nokia UI API (`com.nokia.mid.ui.*`), persistent `RecordStore` (RMS) storage (`~/.local/share/sxmo/remedy/rms/`), and MMAPI (`javax.microedition.media.Manager`) tone and WAV/MIDI audio over ALSA (`hw:0,0`). Audio follows the system speaker volume and mute state (the xdrawer **Speaker** slider) live, at the same loudness as other apps.
- **Keypad controls and pause menu**: maps D-Pad (`Up`/`Down`/`Left`/`Right`), `Center OK` (`FIRE`), `0`–`9`, `*`, `#`, **Left softkey** (`-6`), and **Right softkey** (`-7`) directly to MIDP 2.0 / Nokia key codes, with customizable D-Pad (`D-Pad + 2/4/6/8`, `D-Pad Only`, `2/4/6/8 Only`) and softkey modes persisted in `~/.config/sxmo/remedy.cfg`. Press **End / Power (red)** (`Escape`) during execution to open the **ReMEdy Pause Menu** (Resume, Send Left/Right Softkey Command, Screen Scaling, 3D Renderer toggle, Audio (`Left`/`Right` change the system speaker volume, `OK` toggles ReMEdy sound), Keypad Controls remapping, Reset RMS Save Data, Load Another MIDlet, or Quit). Preinstalled MIDlets in `/usr/share/games/j2me/` and `~/Games/` include `g2048.jar`, `ReMEdy3DArena.jar` (JSR-184 3D benchmark), `AstroBlaster240.jar` (`GameCanvas` space shooter), and `NetToolJ2ME.jar` (LCDUI + HTTP/TCP socket test suite). - **Keypad controls and pause menu**: maps D-Pad (`Up`/`Down`/`Left`/`Right`), `Center OK` (`FIRE`), `0`–`9`, `*`, `#`, **Left softkey** (`-6`), and **Right softkey** (`-7`) directly to MIDP 2.0 / Nokia key codes, with customizable key bindings persisted in `~/.config/sxmo/remedy.conf`. Press **Call (green)** (or hold **Right softkey** for `500 ms`) during execution to open the **ReMEdy Pause Menu** (Resume, MIDlet Commands, 3D Engine toggle, Softkey Bar mode, FPS Cap/Overlay, Audio (`Left`/`Right` change the system speaker volume, `OK` toggles ReMEdy sound), Keypad Controls remapping, Restart MIDlet, Clear MIDlet RMS Data, Load JAR/JAD, or Quit). Preinstalled MIDlets in `/usr/share/games/j2me/` and `~/Games/` include `g2048.jar`, `ReMEdy3DArena.jar` (JSR-184 3D benchmark), `AstroBlaster240.jar` (`GameCanvas` space shooter), and `NetToolJ2ME.jar` (LCDUI + HTTP/TCP socket test suite).
### 3.2 Multi-mode `fcitx5-t9` keypad reference ### 3.2 Multi-mode `fcitx5-t9` keypad reference
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5
View File
@@ -40,8 +40,13 @@ fi
printf '%s\n' "$counter" > "$count_file" printf '%s\n' "$counter" > "$count_file"
if [ "$counter" -ge "$#" ]; then
rm -f "$count_file"
exit
fi
shift "$counter" shift "$counter"
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
rm -f "$count_file"
exit exit
fi fi
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.
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.
+6
View File
@@ -818,6 +818,12 @@ int calllog_run_main(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, ev.xkey.keycode)) {
hideWindow(false);
openPowerMenuFromPlugin(dpy);
continue;
}
if (mode == ViewMode::AddBlock) { if (mode == ViewMode::AddBlock) {
char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state); char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state);
if (dialCh == '#') { if (dialCh == '#') {
+28 -6
View File
@@ -506,7 +506,8 @@ int callscreen_run_main(int argc, char** argv) {
}; };
auto isVoipCallId = [&](const std::string& cid) -> bool { auto isVoipCallId = [&](const std::string& cid) -> bool {
return cid.rfind("sip:", 0) == 0 || cid.rfind("tox:", 0) == 0; return cid.rfind("sip:", 0) == 0 || cid.rfind("tox:", 0) == 0 ||
activeSimSlot == 3 || activeSimSlot == 4;
}; };
auto setSpeakerRoute = [&](bool toSpeaker) { auto setSpeakerRoute = [&](bool toSpeaker) {
@@ -572,8 +573,15 @@ int callscreen_run_main(int argc, char** argv) {
setOutDevFile("Earpiece"); setOutDevFile("Earpiece");
statusNotice = "Audio routed to Earpiece"; statusNotice = "Audio routed to Earpiece";
} }
runAsyncCmd("PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" " if (voip) {
"sxmo_hook_statusbar.sh volume >/dev/null 2>&1"); runAsyncCmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1; "
"wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1; "
"PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" "
"sxmo_hook_statusbar.sh volume >/dev/null 2>&1");
} else {
runAsyncCmd("PATH=\"$HOME/.config/sxmo/hooks:/usr/share/sxmo/default_hooks:$PATH\" "
"sxmo_hook_statusbar.sh volume >/dev/null 2>&1");
}
statusNoticeUntilMs = nowMs() + 2000; statusNoticeUntilMs = nowMs() + 2000;
}; };
@@ -1305,14 +1313,28 @@ int callscreen_run_main(int argc, char** argv) {
alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false); alsa.setBoolean("PRI_MI2S_RX Voice Mixer VoiceMMode1", false);
alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false); alsa.setBoolean("VoiceMMode1 Capture Mixer TERT_MI2S_TX", false);
alsa.setEnum("EAR_S", 0); alsa.setEnum("EAR_S", 0);
alsa.setEnum("RX1 MIX1 INP1", 0);
alsa.setInteger("RX1 Digital Volume", 0);
alsa.setEnum("RX3 MIX1 INP1", 3); alsa.setEnum("RX3 MIX1 INP1", 3);
alsa.setBoolean("SPK DAC Switch", true); alsa.setBoolean("SPK DAC Switch", true);
int spkPct = readIntFile(getHomeDirPath() + "/.config/sxmo/speaker_vol", 85);
alsa.setInteger("RX3 Digital Volume", pctToHwVol(spkPct, true, false));
{
bool jackPlugged = (readIntFile("/tmp/sxmo_jack_plugged", 0) == 1);
std::ofstream out("/tmp/sxmo_audio_out_device", std::ios::trunc);
if (out.is_open()) out << (jackPlugged ? "Headphones" : "Speaker") << "\n";
}
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; " runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; " "pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; " "pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; " "pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; " "pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1"); "sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1; "
"if [ \"$(cat /tmp/sxmo_jack_plugged 2>/dev/null)\" = \"1\" ]; then "
" sxmo_audio.sh out set Headphones >/dev/null 2>&1; "
"else "
" sxmo_audio.sh out set Speaker >/dev/null 2>&1; "
"fi");
render(); render();
}; };
@@ -1320,9 +1342,9 @@ int callscreen_run_main(int argc, char** argv) {
std::string cid = resolveActiveModemCallId(); std::string cid = resolveActiveModemCallId();
bool wasIncoming = (callState == CallState::Incoming); bool wasIncoming = (callState == CallState::Incoming);
stopRingingJobs(); stopRingingJobs();
if (cid.rfind("sip:", 0) == 0) { if (cid.rfind("sip:", 0) == 0 || activeSimSlot == 3) {
sendPluginCommand("sip", "CALL_HANGUP " + cid); sendPluginCommand("sip", "CALL_HANGUP " + cid);
} else if (cid.rfind("tox:", 0) == 0) { } else if (cid.rfind("tox:", 0) == 0 || activeSimSlot == 4) {
sendPluginCommand("tox", "CALL_HANGUP " + cid); sendPluginCommand("tox", "CALL_HANGUP " + cid);
} else if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") { } else if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str()); runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str());
+7 -1
View File
@@ -800,7 +800,13 @@ int runCameraApp(int argc, char** argv) {
continue; continue;
} }
if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape) {
hideWindow(); hideWindow();
continue; continue;
} }
+6
View File
@@ -1234,6 +1234,12 @@ int runContactsApp(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, ev.xkey.keycode)) {
hideWindow(false);
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape) { if (sym == XK_Escape) {
if (mode == ViewMode::List) { if (mode == ViewMode::List) {
writeSoftkeySuppress(nowMs() + 300); writeSoftkeySuppress(nowMs() + 300);
+6
View File
@@ -747,6 +747,12 @@ int dialer_run_main(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, ev.xkey.keycode)) {
hideWindow(false);
openPowerMenuFromPlugin(dpy);
continue;
}
char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state); char dialCh = mapDialKey(sym, ev.xkey.keycode, ev.xkey.state);
if (modal == DialerModal::SelectSim) { if (modal == DialerModal::SelectSim) {
+7 -1
View File
@@ -311,8 +311,14 @@ int engmenu_run_main(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, kc)) {
closeWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (isRightSoftkey(sym, kc) || sym == XK_Escape || if (isRightSoftkey(sym, kc) || sym == XK_Escape ||
sym == XK_BackSpace || kc == 124 || sym == XF86XK_HangupPhone || sym == XK_BackSpace || sym == XF86XK_HangupPhone ||
sym == XK_Cancel) { sym == XK_Cancel) {
writeSoftkeySuppress(nowMs() + 300); writeSoftkeySuppress(nowMs() + 300);
closeWindow(); closeWindow();
+7 -1
View File
@@ -2506,7 +2506,13 @@ int runFilesApp(int argc, char** argv) {
continue; continue;
} }
if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape) {
hideWindow(); hideWindow();
continue; continue;
} }
+6
View File
@@ -1895,6 +1895,12 @@ int runModemApp(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
hideWindow(); hideWindow();
continue; continue;
+7 -2
View File
@@ -1298,8 +1298,13 @@ int runMusicApp(int argc, char** argv) {
continue; continue;
} }
if (sym == XF86XK_HangupPhone || sym == XK_Cancel || kc == 124 || if (isPowerKey(sym, kc)) {
sym == XF86XK_PowerOff) { hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
hideWindow(); hideWindow();
continue; continue;
} }
+6
View File
@@ -1365,6 +1365,12 @@ int runNetworksApp(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
hideWindow(); hideWindow();
continue; continue;
+7 -1
View File
@@ -628,7 +628,13 @@ int passcode_run_main(int argc, char** argv) {
continue; continue;
} }
if (sym == XK_Escape || kc == 124 || sym == XF86XK_HangupPhone || if (isPowerKey(sym, kc)) {
closeWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape || sym == XF86XK_HangupPhone ||
sym == XK_Cancel) { sym == XK_Cancel) {
writeSoftkeySuppress(nowMs() + 300); writeSoftkeySuppress(nowMs() + 300);
closeWindow(); closeWindow();
+23
View File
@@ -1949,6 +1949,29 @@ inline void grabPluginKeyboard(Display* dpy, Window win) {
XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, win, RevertToPointerRoot, CurrentTime);
} }
inline bool isPowerKey(KeySym sym, unsigned int kc) {
return sym == XF86XK_PowerOff || kc == 124;
}
inline void openPowerMenuFromPlugin(Display* dpy) {
if (dpy) {
XUngrabKeyboard(dpy, CurrentTime);
XFlush(dpy);
}
if (isCallActiveOrRingingFast()) {
if (!sendPluginCommand("callscreen", "HANGUP")) {
runAsyncArgv("xcallscreen", "hangup");
}
return;
}
if (::access("/tmp/bananarchy_screen_locked", F_OK) == 0) {
return;
}
if (!sendPluginCommand("dmenu", "OPEN power")) {
runAsyncArgv("dmenu", "power");
}
}
inline void broadcastThemeReload(const char* selfPluginName = nullptr) { inline void broadcastThemeReload(const char* selfPluginName = nullptr) {
static const char* kPlugins[] = { static const char* kPlugins[] = {
"dmenu", "dmenu",
+6
View File
@@ -1073,6 +1073,12 @@ int runRingtonesApp(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
hideWindow(); hideWindow();
continue; continue;
+189 -67
View File
@@ -137,7 +137,7 @@ std::string normalizePreferredCodec(const std::string& raw) {
std::string cyclePreferredCodec(const std::string& cur) { std::string cyclePreferredCodec(const std::string& cur) {
static const char* kList[] = { static const char* kList[] = {
"AUTO", "OPUS", "G722", "PCMU", "PCMA", "GSM", "G726-32", "DVI4", "L16" "AUTO", "PCMU", "PCMA", "GSM", "OPUS", "G722", "G726-32", "DVI4", "L16"
}; };
std::string norm = normalizePreferredCodec(cur); std::string norm = normalizePreferredCodec(cur);
for (size_t i = 0; i < sizeof(kList) / sizeof(kList[0]); ++i) { for (size_t i = 0; i < sizeof(kList) / sizeof(kList[0]); ++i) {
@@ -152,14 +152,15 @@ std::string cyclePreferredCodec(const std::string& cur) {
uint8_t linearToUlaw(int16_t pcmVal) { uint8_t linearToUlaw(int16_t pcmVal) {
constexpr int kBias = 0x84; constexpr int kBias = 0x84;
constexpr int kClip = 32635; constexpr int kClip = 32635;
int mask = (pcmVal < 0) ? 0x7f : 0xff; int pcm = pcmVal;
if (pcmVal < 0) pcmVal = static_cast<int16_t>(-pcmVal); int mask = (pcm < 0) ? 0x7f : 0xff;
if (pcmVal > kClip) pcmVal = kClip; if (pcm < 0) pcm = -pcm;
pcmVal = static_cast<int16_t>(pcmVal + kBias); if (pcm > kClip) pcm = kClip;
pcm += kBias;
int seg = 0; int seg = 0;
for (int thr = 0xFF; seg < 7 && pcmVal > thr; ++seg, thr = (thr << 1) | 1) { for (int thr = 0xFF; seg < 7 && pcm > thr; ++seg, thr = (thr << 1) | 1) {
} }
uint8_t uval = static_cast<uint8_t>((seg << 4) | ((pcmVal >> (seg + 3)) & 0x0f)); uint8_t uval = static_cast<uint8_t>((seg << 4) | ((pcm >> (seg + 3)) & 0x0f));
return static_cast<uint8_t>(uval ^ mask); return static_cast<uint8_t>(uval ^ mask);
} }
@@ -170,18 +171,20 @@ int16_t ulawToLinear(uint8_t uval) {
} }
uint8_t linearToAlaw(int16_t pcmVal) { uint8_t linearToAlaw(int16_t pcmVal) {
int pcm = pcmVal;
int mask = 0x55; int mask = 0x55;
if (pcmVal >= 0) { if (pcm >= 0) {
mask |= 0x80; mask |= 0x80;
} else { } else {
pcmVal = static_cast<int16_t>(-pcmVal - 1); pcm = -pcm - 1;
} }
if (pcm > 32767) pcm = 32767;
int seg = 0; int seg = 0;
for (int thr = 0xFF; seg < 7 && pcmVal > thr; ++seg, thr = (thr << 1) | 1) { for (int thr = 0xFF; seg < 7 && pcm > thr; ++seg, thr = (thr << 1) | 1) {
} }
uint8_t aval = (seg == 0) uint8_t aval = (seg == 0)
? static_cast<uint8_t>((pcmVal >> 4) & 0x0f) ? static_cast<uint8_t>((pcm >> 4) & 0x0f)
: static_cast<uint8_t>((seg << 4) | ((pcmVal >> (seg + 3)) & 0x0f)); : static_cast<uint8_t>((seg << 4) | ((pcm >> (seg + 3)) & 0x0f));
return static_cast<uint8_t>(aval ^ mask); return static_cast<uint8_t>(aval ^ mask);
} }
@@ -424,7 +427,6 @@ class G722State {
int il = (el < 0) ? kMisn[mila] : kMisp[mila]; int il = (el < 0) ? kMisn[mila] : kMisp[mila];
int ril = il >> 2; int ril = il >> 2;
int dlt = (band_[0].det * kQ6m4[ril]) >> 15; int dlt = (band_[0].det * kQ6m4[ril]) >> 15;
if (il < 32) dlt = -dlt;
updateBand(0, dlt, ril, true); updateBand(0, dlt, ril, true);
// Higher sub-band (2-bit quantizer) // Higher sub-band (2-bit quantizer)
@@ -451,8 +453,7 @@ class G722State {
int ril = il >> 2; int ril = il >> 2;
int dlt = (band_[0].det * kQ6b[il]) >> 15; int dlt = (band_[0].det * kQ6b[il]) >> 15;
int rlow = std::clamp(band_[0].s + dlt, -16384, 16383); int rlow = std::clamp(band_[0].s + dlt, -16384, 16383);
updateBand(0, (band_[0].det * ((il < 32) ? -kQ6m4[ril] : kQ6m4[ril])) >> 15, updateBand(0, (band_[0].det * kQ6m4[ril]) >> 15, ril, true);
ril, true);
// Higher sub-band reconstruction (2-bit) // Higher sub-band reconstruction (2-bit)
int dhy = (band_[1].det * kQm2[ih]) >> 15; int dhy = (band_[1].det * kQm2[ih]) >> 15;
@@ -573,18 +574,18 @@ class G722State {
41, 40, 39, 38, 37, 36, 35, 34, 33, 32 41, 40, 39, 38, 37, 36, 35, 34, 33, 32
}; };
static constexpr int kQ6m4[16] = { static constexpr int kQ6m4[16] = {
0, 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0, -20456, -12896, -8968, -6288, -4240, -2584, -1200,
20456, 12896, 8968, 6288, 4240, 2584, 1200, 296 20456, 12896, 8968, 6288, 4240, 2584, 1200, 0
}; };
static constexpr int kQ6b[64] = { static constexpr int kQ6b[64] = {
-152, -28000, -21984, -18256, -15800, -13864, -12240, -10840, -136, -136, -136, -136, -24808, -21904, -19008, -16704,
-9608, -8512, -7528, -6624, -5792, -5032, -4328, -3664, -14984, -13512, -12280, -11192, -10232, -9360, -8576, -7856,
-3056, -2480, -1936, -1424, -936, -464, -152, -152, -7192, -6576, -6000, -5456, -4944, -4464, -4008, -3576,
-26400, -20912, -17600, -15288, -13448, -11880, -10520, -9320, -3168, -2776, -2400, -2032, -1688, -1360, -1040, -728,
28000, 21984, 18256, 15800, 13864, 12240, 10840, 9608, 24808, 21904, 19008, 16704, 14984, 13512, 12280, 11192,
8512, 7528, 6624, 5792, 5032, 4328, 3664, 3056, 10232, 9360, 8576, 7856, 7192, 6576, 6000, 5456,
2480, 1936, 1424, 936, 464, 152, 26400, 20912, 4944, 4464, 4008, 3576, 3168, 2776, 2400, 2032,
17600, 15288, 13448, 11880, 10520, 9320, -8232, 8232 1688, 1360, 1040, 728, 432, 136, -432, -136
}; };
static constexpr int kQm2[4] = { -7408, -1616, 7408, 1616 }; static constexpr int kQm2[4] = { -7408, -1616, 7408, 1616 };
static constexpr int kWl[16] = { static constexpr int kWl[16] = {
@@ -1403,16 +1404,16 @@ bool codecMatchesPreference(SipCodecId id, const std::string& pref) {
std::vector<SipCodecId> orderedCodecsForPreference(const std::string& pref) { std::vector<SipCodecId> orderedCodecsForPreference(const std::string& pref) {
static const SipCodecId kDefaultOrder[] = { static const SipCodecId kDefaultOrder[] = {
SipCodecId::Opus,
SipCodecId::G722,
SipCodecId::Pcmu, SipCodecId::Pcmu,
SipCodecId::Pcma, SipCodecId::Pcma,
SipCodecId::Gsm, SipCodecId::Gsm,
SipCodecId::Opus,
SipCodecId::G722,
SipCodecId::G726_32, SipCodecId::G726_32,
SipCodecId::Dvi4_16k,
SipCodecId::Dvi4_8k, SipCodecId::Dvi4_8k,
SipCodecId::L16_16k, SipCodecId::Dvi4_16k,
SipCodecId::L16_8k SipCodecId::L16_8k,
SipCodecId::L16_16k
}; };
std::vector<SipCodecId> out; std::vector<SipCodecId> out;
for (SipCodecId c : kDefaultOrder) { for (SipCodecId c : kDefaultOrder) {
@@ -1434,7 +1435,9 @@ std::string codecRtpmapLine(int pt, SipCodecId id) {
switch (id) { switch (id) {
case SipCodecId::Opus: case SipCodecId::Opus:
oss << "opus/48000/2\r\n" oss << "opus/48000/2\r\n"
<< "a=fmtp:" << pt << " minptime=10;useinbandfec=1;maxaveragebitrate=24000\r\n"; << "a=fmtp:" << pt
<< " minptime=10;useinbandfec=1;maxaveragebitrate=24000;"
"maxplaybackrate=16000;sprop-maxcapturerate=16000;stereo=0;sprop-stereo=0\r\n";
break; break;
case SipCodecId::G722: case SipCodecId::G722:
oss << "G722/8000\r\n"; oss << "G722/8000\r\n";
@@ -1579,7 +1582,20 @@ void parseSdpMedia(const std::string& msg, const std::string& preferredCodec,
} }
} }
// 2. Otherwise pick the first mutually supported codec in peer's m=audio line // 2. In AUTO mode, prefer our ordered priority list (G.711 PCMU/PCMA first)
// among all codecs offered by the peer.
for (SipCodecId prefId : orderedCodecsForPreference("AUTO")) {
for (int pt : offeredPts) {
auto it = outPtMap.find(pt);
if (it != outPtMap.end() && it->second == prefId) {
outCodec = it->second;
outPayloadType = pt;
return;
}
}
}
// 3. Otherwise pick the first mutually supported codec in peer's m=audio line
for (int pt : offeredPts) { for (int pt : offeredPts) {
auto it = outPtMap.find(pt); auto it = outPtMap.find(pt);
if (it != outPtMap.end()) { if (it != outPtMap.end()) {
@@ -1619,8 +1635,17 @@ class RtpAudioSession {
SipCodecId codec, int payloadType, int dtmfPt, SipCodecId codec, int payloadType, int dtmfPt,
const std::map<int, SipCodecId>& ptMap, bool enableZrtp, const std::map<int, SipCodecId>& ptMap, bool enableZrtp,
bool peerHasZrtpSdp = false) { bool peerHasZrtpSdp = false) {
if (remoteIp.empty() || remotePort <= 0) {
stop();
return false;
}
if (running_.load() && sock_ >= 0 && remoteIp == activeRemoteIp_ &&
remotePort == activeRemotePort_ && codec == codec_ &&
payloadType == payloadType_) {
dtmfPt_ = (dtmfPt > 0 && dtmfPt <= 127) ? dtmfPt : 101;
return true;
}
stop(); stop();
if (remoteIp.empty() || remotePort <= 0) return false;
int sock = ::socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0); int sock = ::socket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
if (sock < 0) return false; if (sock < 0) return false;
@@ -1667,6 +1692,8 @@ class RtpAudioSession {
sock_ = sock; sock_ = sock;
remAddr_ = remAddr; remAddr_ = remAddr;
activeRemoteIp_ = remoteIp;
activeRemotePort_ = remotePort;
codec_ = codec; codec_ = codec;
payloadType_ = payloadType; payloadType_ = payloadType;
dtmfPt_ = (dtmfPt > 0 && dtmfPt <= 127) ? dtmfPt : 101; dtmfPt_ = (dtmfPt > 0 && dtmfPt <= 127) ? dtmfPt : 101;
@@ -1679,6 +1706,10 @@ class RtpAudioSession {
void stop() { void stop() {
running_.store(false); running_.store(false);
pid_t cp = capPid_.load();
if (cp > 1) ::kill(cp, SIGTERM);
pid_t pp = playPid_.load();
if (pp > 1) ::kill(pp, SIGTERM);
if (worker_.joinable()) { if (worker_.joinable()) {
worker_.join(); worker_.join();
} }
@@ -1686,6 +1717,8 @@ class RtpAudioSession {
::close(sock_); ::close(sock_);
sock_ = -1; sock_ = -1;
} }
activeRemoteIp_.clear();
activeRemotePort_ = 0;
std::lock_guard<std::mutex> lk(zrtpMtx_); std::lock_guard<std::mutex> lk(zrtpMtx_);
localHelloMsg_.clear(); localHelloMsg_.clear();
srtpActive_.store(false); srtpActive_.store(false);
@@ -2319,18 +2352,69 @@ class RtpAudioSession {
"amixer -c 0 cset \"name='MultiMedia2 Mixer TERT_MI2S_TX'\" 1 >/dev/null 2>&1"); "amixer -c 0 cset \"name='MultiMedia2 Mixer TERT_MI2S_TX'\" 1 >/dev/null 2>&1");
int audioRate = codecAudioSampleRate(codec_); int audioRate = codecAudioSampleRate(codec_);
size_t frameSamples = static_cast<size_t>(audioRate / 50); // 160 @ 8k, 320 @ 16k size_t frameSamples = static_cast<size_t>(audioRate / 50); // 160 @ 8k, 320 @ 16k
std::string capCmd = "arecord -q -D plughw:0,1 --buffer-time=80000 --period-time=20000 " size_t frameBytes = frameSamples * sizeof(int16_t);
"-f S16_LE -r " + std::to_string(audioRate) + std::string rateStr = std::to_string(audioRate);
" -c 1 -t raw 2>/dev/null";
std::string playCmd = "aplay -q --buffer-time=80000 --period-time=20000 " int capPipe[2] = {-1, -1};
"-f S16_LE -r " + std::to_string(audioRate) + int capFd = -1;
" -c 1 -t raw 2>/dev/null"; pid_t capPid = -1;
FILE* capFp = ::popen(capCmd.c_str(), "r"); if (::pipe(capPipe) == 0) {
FILE* playFp = ::popen(playCmd.c_str(), "w"); capPid = ::fork();
int capFd = capFp ? ::fileno(capFp) : -1; if (capPid == 0) {
if (capFd >= 0) { ::close(capPipe[0]);
int fl = ::fcntl(capFd, F_GETFL, 0); ::dup2(capPipe[1], STDOUT_FILENO);
::fcntl(capFd, F_SETFL, fl | O_NONBLOCK); ::close(capPipe[1]);
int nullFd = ::open("/dev/null", O_RDWR);
if (nullFd >= 0) {
::dup2(nullFd, STDIN_FILENO);
::dup2(nullFd, STDERR_FILENO);
if (nullFd > 2) ::close(nullFd);
}
::execlp("arecord", "arecord", "-q", "--buffer-time=160000",
"--period-time=20000", "-f", "S16_LE", "-r", rateStr.c_str(),
"-c", "1", "-t", "raw", static_cast<char*>(nullptr));
::_exit(1);
} else if (capPid > 0) {
::close(capPipe[1]);
capFd = capPipe[0];
int fl = ::fcntl(capFd, F_GETFL, 0);
::fcntl(capFd, F_SETFL, fl | O_NONBLOCK);
capPid_.store(capPid);
} else {
::close(capPipe[0]);
::close(capPipe[1]);
}
}
int playPipe[2] = {-1, -1};
int playFd = -1;
pid_t playPid = -1;
if (::pipe(playPipe) == 0) {
playPid = ::fork();
if (playPid == 0) {
::close(playPipe[1]);
::dup2(playPipe[0], STDIN_FILENO);
::close(playPipe[0]);
int nullFd = ::open("/dev/null", O_RDWR);
if (nullFd >= 0) {
::dup2(nullFd, STDOUT_FILENO);
::dup2(nullFd, STDERR_FILENO);
if (nullFd > 2) ::close(nullFd);
}
::execlp("aplay", "aplay", "-q", "--buffer-time=200000",
"--period-time=20000", "-f", "S16_LE", "-r", rateStr.c_str(),
"-c", "1", "-t", "raw", static_cast<char*>(nullptr));
::_exit(1);
} else if (playPid > 0) {
::close(playPipe[0]);
playFd = playPipe[1];
int fl = ::fcntl(playFd, F_GETFL, 0);
::fcntl(playFd, F_SETFL, fl | O_NONBLOCK);
playPid_.store(playPid);
} else {
::close(playPipe[0]);
::close(playPipe[1]);
}
} }
int opusErr = OPUS_OK; int opusErr = OPUS_OK;
@@ -2356,8 +2440,19 @@ class RtpAudioSession {
uint32_t ts = static_cast<uint32_t>(nowMs() * 8); uint32_t ts = static_cast<uint32_t>(nowMs() * 8);
uint32_t ssrc = 0x51504241u ^ static_cast<uint32_t>(::getpid()); uint32_t ssrc = 0x51504241u ^ static_cast<uint32_t>(::getpid());
int64_t nextTxMs = nowMs() + 20; int64_t nextTxMs = nowMs() + 20;
bool playPrimed = false;
uint8_t capRing[2560];
size_t capAvail = 0;
while (running_.load()) { while (running_.load()) {
// Drain available microphone capture bytes into capRing without blocking
if (capFd >= 0 && capAvail < sizeof(capRing)) {
ssize_t r = ::read(capFd, capRing + capAvail, sizeof(capRing) - capAvail);
if (r > 0) {
capAvail += static_cast<size_t>(r);
}
}
// 1. Receive incoming RTP / SRTP / ZRTP packets // 1. Receive incoming RTP / SRTP / ZRTP packets
uint8_t rxPkt[1500]; uint8_t rxPkt[1500];
while (true) { while (true) {
@@ -2388,9 +2483,9 @@ class RtpAudioSession {
const uint8_t* payload = rxPkt + hdrLen; const uint8_t* payload = rxPkt + hdrLen;
size_t payLen = pktLen - hdrLen; size_t payLen = pktLen - hdrLen;
if (!playFp || payLen == 0) continue; if (playFd < 0 || payLen == 0) continue;
int16_t pcmDecoded[960]; int16_t pcmDecoded[1920];
size_t decodedSamples = 0; size_t decodedSamples = 0;
switch (rxCodec) { switch (rxCodec) {
@@ -2398,28 +2493,28 @@ class RtpAudioSession {
if (opusDec) { if (opusDec) {
int r = opus_decode(opusDec, payload, int r = opus_decode(opusDec, payload,
static_cast<opus_int32>(payLen), static_cast<opus_int32>(payLen),
pcmDecoded, 960, 0); pcmDecoded, 1920, 0);
if (r > 0) decodedSamples = static_cast<size_t>(r); if (r > 0) decodedSamples = static_cast<size_t>(r);
} }
break; break;
case SipCodecId::G722: case SipCodecId::G722:
decodedSamples = g722Dec.decodeFrame(payload, payLen, pcmDecoded, 960); decodedSamples = g722Dec.decodeFrame(payload, payLen, pcmDecoded, 1920);
break; break;
case SipCodecId::Pcmu: case SipCodecId::Pcmu:
decodedSamples = std::min<size_t>(payLen, 960); decodedSamples = std::min<size_t>(payLen, 1920);
for (size_t i = 0; i < decodedSamples; ++i) { for (size_t i = 0; i < decodedSamples; ++i) {
pcmDecoded[i] = ulawToLinear(payload[i]); pcmDecoded[i] = ulawToLinear(payload[i]);
} }
break; break;
case SipCodecId::Pcma: case SipCodecId::Pcma:
decodedSamples = std::min<size_t>(payLen, 960); decodedSamples = std::min<size_t>(payLen, 1920);
for (size_t i = 0; i < decodedSamples; ++i) { for (size_t i = 0; i < decodedSamples; ++i) {
pcmDecoded[i] = alawToLinear(payload[i]); pcmDecoded[i] = alawToLinear(payload[i]);
} }
break; break;
case SipCodecId::Gsm: case SipCodecId::Gsm:
if (gsmDec) { if (gsmDec) {
for (size_t off = 0; off + 33 <= payLen && decodedSamples + 160 <= 960; off += 33) { for (size_t off = 0; off + 33 <= payLen && decodedSamples + 160 <= 1920; off += 33) {
gsm_byte frame[33]; gsm_byte frame[33];
std::memcpy(frame, payload + off, 33); std::memcpy(frame, payload + off, 33);
if (gsm_decode(gsmDec, frame, pcmDecoded + decodedSamples) == 0) { if (gsm_decode(gsmDec, frame, pcmDecoded + decodedSamples) == 0) {
@@ -2429,15 +2524,15 @@ class RtpAudioSession {
} }
break; break;
case SipCodecId::G726_32: case SipCodecId::G726_32:
decodedSamples = g726Dec.decodeFrame(payload, payLen, pcmDecoded, 960); decodedSamples = g726Dec.decodeFrame(payload, payLen, pcmDecoded, 1920);
break; break;
case SipCodecId::Dvi4_8k: case SipCodecId::Dvi4_8k:
case SipCodecId::Dvi4_16k: case SipCodecId::Dvi4_16k:
decodedSamples = dvi4Dec.decodeFrame(payload, payLen, pcmDecoded, 960); decodedSamples = dvi4Dec.decodeFrame(payload, payLen, pcmDecoded, 1920);
break; break;
case SipCodecId::L16_8k: case SipCodecId::L16_8k:
case SipCodecId::L16_16k: case SipCodecId::L16_16k:
for (size_t i = 0; i + 1 < payLen && decodedSamples < 960; i += 2) { for (size_t i = 0; i + 1 < payLen && decodedSamples < 1920; i += 2) {
uint16_t be = (static_cast<uint16_t>(payload[i]) << 8) | payload[i + 1]; uint16_t be = (static_cast<uint16_t>(payload[i]) << 8) | payload[i + 1];
pcmDecoded[decodedSamples++] = static_cast<int16_t>(be); pcmDecoded[decodedSamples++] = static_cast<int16_t>(be);
} }
@@ -2445,9 +2540,14 @@ class RtpAudioSession {
} }
if (decodedSamples > 0) { if (decodedSamples > 0) {
if (!playPrimed) {
playPrimed = true;
int16_t silence[960] = {0};
(void)::write(playFd, silence, frameSamples * 3 * sizeof(int16_t));
}
int rxRate = codecAudioSampleRate(rxCodec); int rxRate = codecAudioSampleRate(rxCodec);
if (rxRate == audioRate) { if (rxRate == audioRate) {
std::fwrite(pcmDecoded, sizeof(int16_t), decodedSamples, playFp); (void)::write(playFd, pcmDecoded, decodedSamples * sizeof(int16_t));
} else if (rxRate == 8000 && audioRate == 16000) { } else if (rxRate == 8000 && audioRate == 16000) {
int16_t pcmUp[1920]; int16_t pcmUp[1920];
size_t upCount = 0; size_t upCount = 0;
@@ -2457,17 +2557,16 @@ class RtpAudioSession {
pcmUp[upCount++] = s0; pcmUp[upCount++] = s0;
pcmUp[upCount++] = static_cast<int16_t>((static_cast<int>(s0) + s1) / 2); pcmUp[upCount++] = static_cast<int16_t>((static_cast<int>(s0) + s1) / 2);
} }
std::fwrite(pcmUp, sizeof(int16_t), upCount, playFp); (void)::write(playFd, pcmUp, upCount * sizeof(int16_t));
} else if (rxRate == 16000 && audioRate == 8000) { } else if (rxRate == 16000 && audioRate == 8000) {
int16_t pcmDown[480]; int16_t pcmDown[960];
size_t downCount = 0; size_t downCount = 0;
for (size_t i = 0; i + 1 < decodedSamples && downCount < 480; i += 2) { for (size_t i = 0; i + 1 < decodedSamples && downCount < 960; i += 2) {
pcmDown[downCount++] = static_cast<int16_t>( pcmDown[downCount++] = static_cast<int16_t>(
(static_cast<int>(pcmDecoded[i]) + pcmDecoded[i + 1]) / 2); (static_cast<int>(pcmDecoded[i]) + pcmDecoded[i + 1]) / 2);
} }
std::fwrite(pcmDown, sizeof(int16_t), downCount, playFp); (void)::write(playFd, pcmDown, downCount * sizeof(int16_t));
} }
std::fflush(playFp);
} }
} }
@@ -2476,7 +2575,10 @@ class RtpAudioSession {
periodicZrtpTick(ssrc, now); periodicZrtpTick(ssrc, now);
if (now >= nextTxMs) { if (now >= nextTxMs) {
nextTxMs = now + 20; nextTxMs += 20;
if (now - nextTxMs > 60) {
nextTxMs = now + 20;
}
char dtmfCh = '\0'; char dtmfCh = '\0';
{ {
std::lock_guard<std::mutex> lk(dtmfMtx_); std::lock_guard<std::mutex> lk(dtmfMtx_);
@@ -2513,9 +2615,12 @@ class RtpAudioSession {
ts += codecRtpTimestampStep20ms(codec_) * 3; ts += codecRtpTimestampStep20ms(codec_) * 3;
} else { } else {
int16_t pcmIn[320] = {0}; int16_t pcmIn[320] = {0};
if (capFd >= 0) { if (capAvail >= frameBytes) {
ssize_t r = ::read(capFd, pcmIn, frameSamples * sizeof(int16_t)); std::memcpy(pcmIn, capRing, frameBytes);
(void)r; capAvail -= frameBytes;
if (capAvail > 0) {
std::memmove(capRing, capRing + frameBytes, capAvail);
}
} }
uint8_t pkt[12 + 768 + 16]; uint8_t pkt[12 + 768 + 16];
uint16_t curSeq = seq++; uint16_t curSeq = seq++;
@@ -2596,17 +2701,31 @@ class RtpAudioSession {
if (opusDec) opus_decoder_destroy(opusDec); if (opusDec) opus_decoder_destroy(opusDec);
if (gsmEnc) gsm_destroy(gsmEnc); if (gsmEnc) gsm_destroy(gsmEnc);
if (gsmDec) gsm_destroy(gsmDec); if (gsmDec) gsm_destroy(gsmDec);
if (capFp) ::pclose(capFp); if (capFd >= 0) ::close(capFd);
if (playFp) ::pclose(playFp); if (playFd >= 0) ::close(playFd);
capPid_.store(-1);
playPid_.store(-1);
if (capPid > 1) {
::kill(capPid, SIGKILL);
::waitpid(capPid, nullptr, 0);
}
if (playPid > 1) {
::kill(playPid, SIGKILL);
::waitpid(playPid, nullptr, 0);
}
} }
int sock_ = -1; int sock_ = -1;
struct sockaddr_in remAddr_ {}; struct sockaddr_in remAddr_ {};
std::string activeRemoteIp_;
int activeRemotePort_ = 0;
SipCodecId codec_ = SipCodecId::Pcmu; SipCodecId codec_ = SipCodecId::Pcmu;
int payloadType_ = 0; int payloadType_ = 0;
int dtmfPt_ = 101; int dtmfPt_ = 101;
std::map<int, SipCodecId> rxPtMap_; std::map<int, SipCodecId> rxPtMap_;
std::atomic<bool> running_{false}; std::atomic<bool> running_{false};
std::atomic<pid_t> capPid_{-1};
std::atomic<pid_t> playPid_{-1};
std::thread worker_; std::thread worker_;
std::mutex dtmfMtx_; std::mutex dtmfMtx_;
std::string dtmfQueue_; std::string dtmfQueue_;
@@ -3635,6 +3754,9 @@ int sip_run_main(int argc, char** argv) {
} else if (cmd.rfind("CALL_HANGUP", 0) == 0) { } else if (cmd.rfind("CALL_HANGUP", 0) == 0) {
hangupActiveSipCall(false); hangupActiveSipCall(false);
if (visible) render(); if (visible) render();
} else if (cmd == "HANGUP" || cmd.rfind("HANGUP ", 0) == 0) {
hangupActiveSipCall(true);
if (visible) render();
} else if (cmd.rfind("CALL_MUTE_RING", 0) == 0) { } else if (cmd.rfind("CALL_MUTE_RING", 0) == 0) {
::unlink("/tmp/sxmo_call_ringing"); ::unlink("/tmp/sxmo_call_ringing");
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; " runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
+7 -1
View File
@@ -1411,7 +1411,13 @@ int runSmsApp(int argc, char** argv) {
continue; continue;
} }
if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape) {
hideWindow(); hideWindow();
continue; continue;
} }
+7 -1
View File
@@ -1138,7 +1138,13 @@ int runThemesApp(int argc, char** argv) {
continue; continue;
} }
if (sym == XK_Escape || kc == 124 || sym == XF86XK_PowerOff) { if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XK_Escape) {
hideWindow(); hideWindow();
continue; continue;
} }
+6
View File
@@ -589,6 +589,12 @@ int runWallpapersApp(int argc, char** argv) {
continue; continue;
} }
if (isPowerKey(sym, kc)) {
hideWindow();
openPowerMenuFromPlugin(dpy);
continue;
}
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) { if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
hideWindow(); hideWindow();
continue; continue;
+31 -14
View File
@@ -785,14 +785,19 @@ gboolean onWebProcessTerminated(WebKitWebView* webView,
} }
void ensureAlsaMultimediaRouting() { void ensureAlsaMultimediaRouting() {
static bool routed = false; if (isCallActiveOrRingingFast()) return;
if (routed) return; runAsyncCmd(
routed = true; "outdev=$(cat /tmp/sxmo_audio_out_device 2>/dev/null); "
runAsyncCmd("amixer -q -c 0 cset name='PRI_MI2S_RX Audio Mixer MultiMedia1' 1 >/dev/null 2>&1; " "if [ \"$outdev\" = \"Earpiece\" ] || [ -z \"$outdev\" ]; then "
"amixer -q -c 0 cset name='RX1 MIX1 INP1' 'RX1' >/dev/null 2>&1; " " if [ \"$(cat /tmp/sxmo_jack_plugged 2>/dev/null)\" = \"1\" ]; then "
"amixer -q -c 0 cset name='RX2 MIX1 INP1' 'RX2' >/dev/null 2>&1; " " sxmo_audio.sh out set Headphones >/dev/null 2>&1; "
"amixer -q -c 0 cset name='RDAC2 MUX' 'RX2' >/dev/null 2>&1; " " else "
"amixer -q -c 0 cset name='SPK DAC Switch' 1 >/dev/null 2>&1"); " sxmo_audio.sh out set Speaker >/dev/null 2>&1; "
" fi; "
"fi; "
"amixer -q -c 0 cset \"name='PRI_MI2S_RX Audio Mixer MultiMedia1'\" 1 >/dev/null 2>&1; "
"amixer -q -c 0 cset \"name='RX3 MIX1 INP1'\" 'RX1' >/dev/null 2>&1; "
"amixer -q -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1");
} }
bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) { bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
@@ -801,6 +806,7 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
// Hardware acceleration & Cortex-A7 / 512 MB RAM environment tuning // Hardware acceleration & Cortex-A7 / 512 MB RAM environment tuning
::setenv("GDK_BACKEND", "x11", 1); ::setenv("GDK_BACKEND", "x11", 1);
::setenv("GTK_THEME", "Adwaita:dark", 1); ::setenv("GTK_THEME", "Adwaita:dark", 1);
::setenv("WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS", "1", 1);
::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 0); ::setenv("WEBKIT_DISABLE_COMPOSITING_MODE", "0", 0);
::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 0); ::setenv("WEBKIT_DISABLE_DMABUF_RENDERER", "0", 0);
::setenv("WEBKIT_SKIA_ENABLE_CPU_RENDERING", "0", 0); ::setenv("WEBKIT_SKIA_ENABLE_CPU_RENDERING", "0", 0);
@@ -863,6 +869,7 @@ bool initBrowserEngine(BrowserRuntimeState& st, const std::string& userAgent) {
WebKitWebContext* webCtx = webkit_web_context_new_with_website_data_manager(dataMgr); WebKitWebContext* webCtx = webkit_web_context_new_with_website_data_manager(dataMgr);
g_object_unref(dataMgr); g_object_unref(dataMgr);
webkit_web_context_set_sandbox_enabled(webCtx, FALSE);
webkit_web_context_set_cache_model(webCtx, WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER); webkit_web_context_set_cache_model(webCtx, WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER);
WebKitCookieManager* cookieMgr = webkit_web_context_get_cookie_manager(webCtx); WebKitCookieManager* cookieMgr = webkit_web_context_get_cookie_manager(webCtx);
@@ -1093,8 +1100,6 @@ int webarchy_run_main(int argc, char** argv) {
} else if (visible) { } else if (visible) {
// Shift subwindow outside 240px parent clip while modal is open so media continues playing // Shift subwindow outside 240px parent clip while modal is open so media continues playing
XMoveResizeWindow(neo.dpy, br.webkitXid, 240, 35, 240, 217); XMoveResizeWindow(neo.dpy, br.webkitXid, 240, 35, 240, 217);
} else {
XUnmapWindow(neo.dpy, br.webkitXid);
} }
XFlush(neo.dpy); XFlush(neo.dpy);
}; };
@@ -1309,8 +1314,10 @@ int webarchy_run_main(int argc, char** argv) {
if (isPhonePasscodeLocked()) return; if (isPhonePasscodeLocked()) return;
writeIntFile(activePidPath, static_cast<int>(::getpid())); writeIntFile(activePidPath, static_cast<int>(::getpid()));
closeOtherPlugins("webarchy"); closeOtherPlugins("webarchy");
ensureAlsaMultimediaRouting();
visible = true; visible = true;
neoui_show(); neoui_show();
grabPluginKeyboard(neo.dpy, neo.win);
if (!br.initialized) { if (!br.initialized) {
br.statusMsg = "Starting WPE/WebKit engine..."; br.statusMsg = "Starting WPE/WebKit engine...";
render(); render();
@@ -1320,6 +1327,9 @@ int webarchy_run_main(int argc, char** argv) {
br.statusMsg = "Failed to initialize WebKit display"; br.statusMsg = "Failed to initialize WebKit display";
} }
} }
if (br.initialized && br.webView) {
webkit_web_view_set_is_muted(br.webView, FALSE);
}
syncWebkitVisibility(); syncWebkitVisibility();
grabPluginKeyboard(neo.dpy, neo.win); grabPluginKeyboard(neo.dpy, neo.win);
render(); render();
@@ -1335,6 +1345,10 @@ int webarchy_run_main(int argc, char** argv) {
controlsModalOpen = false; controlsModalOpen = false;
infoModalOpen = false; infoModalOpen = false;
chordPrefix.clear(); chordPrefix.clear();
if (br.initialized && br.webView) {
evalJs(br, "try{document.querySelectorAll('audio,video').forEach(function(m){m.pause();});}catch(e){}");
webkit_web_view_set_is_muted(br.webView, TRUE);
}
syncWebkitVisibility(); syncWebkitVisibility();
neoui_hide(); neoui_hide();
::unlink(activePidPath.c_str()); ::unlink(activePidPath.c_str());
@@ -1353,16 +1367,19 @@ int webarchy_run_main(int argc, char** argv) {
neo.reloadTheme(); neo.reloadTheme();
if (visible) render(); if (visible) render();
} else if (cmd == "OPEN" || cmd.rfind("OPEN ", 0) == 0) { } else if (cmd == "OPEN" || cmd.rfind("OPEN ", 0) == 0) {
std::string newUrl;
if (cmd.size() > 5) { if (cmd.size() > 5) {
std::string arg = trimStr(cmd.substr(5)); std::string arg = trimStr(cmd.substr(5));
if (!arg.empty()) { if (!arg.empty()) {
br.currentUrl = normalizeInputUrlOrSearch(arg); newUrl = normalizeInputUrlOrSearch(arg);
if (br.initialized && br.webView) { br.currentUrl = newUrl;
webkit_web_view_load_uri(br.webView, br.currentUrl.c_str());
}
} }
} }
bool wasInitialized = br.initialized;
openWindow(); openWindow();
if (wasInitialized && !newUrl.empty() && br.initialized && br.webView) {
webkit_web_view_load_uri(br.webView, newUrl.c_str());
}
} }
} }
+14
View File
@@ -2138,6 +2138,20 @@ int main(int argc, char** argv) {
unsigned int kc = ev.xkey.keycode; unsigned int kc = ev.xkey.keycode;
KeySym sym = XLookupKeysym(&ev.xkey, 0); KeySym sym = XLookupKeysym(&ev.xkey, 0);
if (isPress && (sym == XF86XK_PowerOff || kc == 124)) {
unfocusWindow(false);
int64_t tNow = nowMs();
writeSoftkeySuppress(tNow + 500);
overlayCooldownUntilMs = tNow + 500;
int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo",
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (ffd >= 0) {
(void)::write(ffd, "OPEN power\n", 11);
::close(ffd);
}
continue;
}
if (isPress && (sym == XF86XK_AudioLowerVolume || if (isPress && (sym == XF86XK_AudioLowerVolume ||
sym == XF86XK_AudioRaiseVolume)) { sym == XF86XK_AudioRaiseVolume)) {
audioOut.adjustSpeakerVol( audioOut.adjustSpeakerVol(
+32 -5
View File
@@ -143,7 +143,7 @@ static std::string keysymLabel(KeySym ks) {
case XK_Super_L: case XK_Super_L:
case XK_F1: return "LSoft"; case XK_F1: return "LSoft";
case XK_F2: return "RSoft"; case XK_F2: return "RSoft";
case XK_Escape: return "End/Esc"; case XK_Escape: return "Call/Esc";
case XK_asterisk: return "* (Star)"; case XK_asterisk: return "* (Star)";
case XK_numbersign: return "# (Hash)"; case XK_numbersign: return "# (Hash)";
default: { default: {
@@ -1211,15 +1211,37 @@ class RemedyEmulator {
} }
bool handleKeyPress(KeySym ks, unsigned int keycode = 0) { bool handleKeyPress(KeySym ks, unsigned int keycode = 0) {
// Normalize Nokia 8110 4G hardware softkeys & End key // Normalize Nokia 8110 4G hardware softkeys, Call key, & End/Power key
if (keycode == 135 || ks == XK_Menu || ks == XF86XK_KbdLcdMenu1 || if (keycode == 135 || ks == XK_Menu || ks == XF86XK_KbdLcdMenu1 ||
ks == _EVDEVK(0x246)) { ks == _EVDEVK(0x246)) {
ks = XK_F1; ks = XK_F1;
} else if (keycode == 166 || ks == XF86XK_Back || ks == XF86XK_KbdLcdMenu2 || } else if (keycode == 166 || ks == XF86XK_Back || ks == XF86XK_KbdLcdMenu2 ||
ks == _EVDEVK(0x247)) { ks == _EVDEVK(0x247)) {
ks = XK_F2; ks = XK_F2;
} else if (keycode == 124 || ks == XF86XK_PowerOff) { } else if (keycode == 169 || ks == XF86XK_Phone ||
ks == XF86XK_PickupPhone || ks == _EVDEVK(0x0e7)) {
ks = XK_Escape; ks = XK_Escape;
} else if (keycode == 124 || ks == XF86XK_PowerOff) {
cldcRuntime.sound.setPaused(true);
ungrabKeyboard();
int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo",
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (ffd >= 0) {
(void)::write(ffd, "OPEN power\n", 11);
::close(ffd);
} else {
std::system("dmenu power >/dev/null 2>&1");
}
usleep(120000);
for (int wait = 0; wait < 600; ++wait) {
if (::access("/tmp/dwm_plugin_dmenu.active", F_OK) != 0) break;
usleep(50000);
}
XRaiseWindow(neoWin.dpy, neoWin.win);
XSetInputFocus(neoWin.dpy, neoWin.win, RevertToParent, CurrentTime);
grabKeyboard();
appCtx.repaintPending = true;
return true;
} }
if (ks == XF86XK_AudioLowerVolume || ks == XF86XK_AudioRaiseVolume) { if (ks == XF86XK_AudioLowerVolume || ks == XF86XK_AudioRaiseVolume) {
@@ -1329,8 +1351,9 @@ class RemedyEmulator {
return true; return true;
} }
if (mode == EmuUiMode::PAUSED) { if (mode == EmuUiMode::PAUSED) {
if (softIdx == 2) { if (softIdx == 1 || softIdx == 2) {
mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER; mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER;
if (mode == EmuUiMode::BROWSER) renderBrowserMenu();
appCtx.repaintPending = true; appCtx.repaintPending = true;
} }
return true; return true;
@@ -1397,6 +1420,7 @@ class RemedyEmulator {
} }
if (ks == XK_Escape) { if (ks == XK_Escape) {
mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER; mode = hasLoadedMidlet ? EmuUiMode::RUNNING : EmuUiMode::BROWSER;
if (mode == EmuUiMode::BROWSER) renderBrowserMenu();
appCtx.repaintPending = true; appCtx.repaintPending = true;
return true; return true;
} }
@@ -1493,7 +1517,10 @@ class RemedyEmulator {
} }
} }
} else if (ks == XK_Escape) { } else if (ks == XK_Escape) {
return false; pauseSel = 0;
pauseScroll = 0;
mode = EmuUiMode::PAUSED;
renderPauseMenu();
} }
return true; return true;
} }
+10
View File
@@ -993,6 +993,16 @@ int main() {
continue; continue;
} }
if (evType == NEO_EV_CLOSE_REQ) { if (evType == NEO_EV_CLOSE_REQ) {
if (neoui_event_keysym() == XF86XK_PowerOff ||
neoui_event_keycode() == 124) {
::usleep(80000);
while (::access("/tmp/dwm_plugin_dmenu.active", F_OK) == 0) {
::usleep(50000);
}
neoui_raise_and_grab();
render();
continue;
}
gRunning = 0; gRunning = 0;
break; break;
} }
+37
View File
@@ -155,6 +155,30 @@ bool sendPluginFifoMsg(const char* name, const std::string& cmdLine) {
return w == static_cast<ssize_t>(msg.size()); return w == static_cast<ssize_t>(msg.size());
} }
bool isCallActiveOrRingingInNeoui() {
if (::access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
::access("/tmp/sxmo_active_call", F_OK) == 0) {
return true;
}
const char* rdir = std::getenv("XDG_RUNTIME_DIR");
std::string base = (rdir && rdir[0]) ? rdir : "/run/user/10000";
if (::access((base + "/sxmo_jobs/ringing").c_str(), F_OK) == 0) {
return true;
}
DIR* d = ::opendir((base + "/sxmo_calls").c_str());
if (d) {
struct dirent* ent;
while ((ent = ::readdir(d)) != nullptr) {
if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') {
::closedir(d);
return true;
}
}
::closedir(d);
}
return false;
}
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)) {
@@ -2709,6 +2733,19 @@ int neoui_poll_event(int timeout_ms) {
} }
if (ev.type == KeyPress) { if (ev.type == KeyPress) {
if (sym == XF86XK_PowerOff || kc == 124) {
if (bananarchy::isCallActiveOrRingingInNeoui()) {
bananarchy::sendPluginFifoMsg("callscreen", "HANGUP");
continue;
}
if (::access("/tmp/bananarchy_screen_locked", F_OK) != 0) {
neoui_ungrab();
XFlush(dpy);
bananarchy::sendPluginFifoMsg("dmenu", "OPEN power");
ctx->lastEventType = NEO_EV_CLOSE_REQ;
return NEO_EV_CLOSE_REQ;
}
}
if (ctx->chordXdrawer && if (ctx->chordXdrawer &&
(nkey == NEO_KEY_SOFT_LEFT || nkey == NEO_KEY_SOFT_RIGHT)) { (nkey == NEO_KEY_SOFT_LEFT || nkey == NEO_KEY_SOFT_RIGHT)) {
int curBit = (nkey == NEO_KEY_SOFT_LEFT) ? 1 : 2; int curBit = (nkey == NEO_KEY_SOFT_LEFT) ? 1 : 2;
+15 -1
View File
@@ -779,6 +779,8 @@ query_trigger_keys_down(void)
mask |= 4; mask |= 4;
if (km[104 / 8] & (1 << (104 % 8))) if (km[104 / 8] & (1 << (104 % 8)))
mask |= 8; mask |= 8;
if (km[124 / 8] & (1 << (124 % 8)))
mask |= 16;
return mask; return mask;
} }
@@ -1572,6 +1574,8 @@ keypress(XKeyEvent *ev)
len = Xutf8LookupString(xic, ev, buf, sizeof buf, &ksym, &status); len = Xutf8LookupString(xic, ev, buf, sizeof buf, &ksym, &status);
else { else {
len = XLookupString(ev, buf, sizeof buf, &ksym, NULL); len = XLookupString(ev, buf, sizeof buf, &ksym, NULL);
if (ksym == NoSymbol && ev->keycode == 124)
ksym = XF86XK_PowerOff;
status = (len > 0 && ksym != NoSymbol) ? XLookupBoth : status = (len > 0 && ksym != NoSymbol) ? XLookupBoth :
(len > 0) ? XLookupChars : (len > 0) ? XLookupChars :
(ksym != NoSymbol) ? XLookupKeySym : XLookupNone; (ksym != NoSymbol) ? XLookupKeySym : XLookupNone;
@@ -1688,7 +1692,16 @@ insert:
sel = matchend; sel = matchend;
break; break;
case XK_Escape: case XK_Escape:
cancel_session();
return;
case XF86XK_PowerOff: case XF86XK_PowerOff:
if (daemon_mode &&
(menu_mode != MODE_BUILTIN || strcmp(current_builtin_menu, "power") != 0)) {
if (active_client_fd >= 0)
finish_client_session(1, NULL);
open_builtin_menu("power", 0);
return;
}
cancel_session(); cancel_session();
return; return;
case XF86XK_Back: case XF86XK_Back:
@@ -3569,6 +3582,7 @@ process_x11_events(void)
int is_enter = (ks == XK_Return || ks == XK_KP_Enter || int is_enter = (ks == XK_Return || ks == XK_KP_Enter ||
ks == XF86XK_Phone || ks == XF86XK_PickupPhone || ks == XF86XK_Phone || ks == XF86XK_PickupPhone ||
ev.xkey.keycode == 36 || ev.xkey.keycode == 104); ev.xkey.keycode == 36 || ev.xkey.keycode == 104);
int is_power = (ks == XF86XK_PowerOff || ev.xkey.keycode == 124);
if (is_left || is_right) { if (is_left || is_right) {
long long now = dmenu_now_ms(); long long now = dmenu_now_ms();
int which = (is_left ? 1 : 0) | (is_right ? 2 : 0); int which = (is_left ? 1 : 0) | (is_right ? 2 : 0);
@@ -3595,7 +3609,7 @@ process_x11_events(void)
soft_deadline = now + 30; soft_deadline = now + 30;
continue; continue;
} }
if (is_enter) { if (is_enter || is_power) {
if (ev.type == KeyRelease) { if (ev.type == KeyRelease) {
initial_released = 1; initial_released = 1;
continue; continue;
+13
View File
@@ -2261,6 +2261,19 @@ keypress(XEvent *e)
return; return;
} }
if (!is_phone_locked() && CLEANMASK(ev->state) == 0 &&
(keysym == XF86XK_PowerOff || ev->keycode == 124)) {
XUngrabKeyboard(dpy, CurrentTime);
XFlush(dpy);
if (is_plugin_loaded("dmenu")) {
host_spawn_plugin("dmenu", "power");
return;
}
const Arg pwrcmd = { .v = (const char*[]){ "sxmo_appmenu.sh", "power", NULL } };
spawn(&pwrcmd);
return;
}
if (!selmon->sel && !is_phone_locked()) { if (!selmon->sel && !is_phone_locked()) {
if (dispatch_plugin_idle_key(keysym, ev->keycode, CLEANMASK(ev->state))) if (dispatch_plugin_idle_key(keysym, ev->keycode, CLEANMASK(ev->state)))
return; return;
+13
View File
@@ -1212,6 +1212,19 @@ static int xdrawer_run_main(int argc, char** argv) {
continue; continue;
} }
if (sym == XF86XK_PowerOff || ev.xkey.keycode == 124) {
hideWindow(false);
int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo",
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
if (ffd >= 0) {
(void)::write(ffd, "OPEN power\n", 11);
::close(ffd);
} else {
runAsyncCmd("dmenu power >/dev/null 2>&1");
}
break;
}
switch (sym) { switch (sym) {
case XK_Escape: case XK_Escape:
case XK_BackSpace: case XK_BackSpace: