vanilla/app/mainwindow.cpp
itsmattkc bfae42ba04 Squashed commit of the following:
commit 51a1ca73ad257b32053faf293ef0dc5eb0bd0181
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 16:11:50 2024 -0700

    try installing binfmt-support

commit a1c2cbcf4add6e304684ce815f7644399f550723
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:53:54 2024 -0700

    back to static i suppose

commit 70a8db69a1b7be39bb082d8aec57493ea42d069f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:52:57 2024 -0700

    try binfmt only?

commit 1bb5a2025e1b070a22abe5fb3ac01dcf13e9147d
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:52:02 2024 -0700

    try installing qemu-user-binfmt?

commit cb0710e57ac7da46d5e25c170d9f4843c360c688
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:45:51 2024 -0700

    install qemu-user-static

commit 06a1bde5e98d18c16f55e0d92bea6beb00b97e81
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:43:53 2024 -0700

    try building aarch64

commit 939201a538ce40320003033b55fc76258c97fa24
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:43:46 2024 -0700

    initialize managed value

commit 7b21f934512ba55d735cc3d003d92e879d3e575f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 15:43:32 2024 -0700

    use more parallel building

commit da50fd5d5f8f17edbc76026cc3b448874c3f2e9a
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:54:41 2024 -0700

    name artifact after uploading

commit 0b10c1ea02842eba77d008a824e0f276fb95b39a
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:51:08 2024 -0700

    pull docker image rather than build in CI

commit 344316a6654e3c2e355555fd60f65c064663ca5d
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:38:23 2024 -0700

    create appdir

    This works!

commit e9f22966f7aab63e360c12fc3b388953c9b0fc85
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:13:42 2024 -0700

    auto configure wpa supplicant with cmake

commit cd088b6a8613d47d73dbb6cd1d8bbd4f1390eeba
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:13:21 2024 -0700

    ensure pipe is installed

commit 9b576758333a230172c1b05e09f9bd8fca8175cc
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 28 12:13:03 2024 -0700

    Update .gitignore

commit 9f0e5655f77d84288ecb29d278072df539cea7e2
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 21:32:06 2024 -0700

    disable non x86_64 builds for now

commit 518a37cf7ee105a389786252dc435f0d9a65d29b
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 21:31:40 2024 -0700

    disable connect button disabling

commit d5bcbc709b7038046332e0e164d114ec96b27bb7
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 14:58:20 2024 -0700

    add files to gitignore

commit 874eddeb6fca586aee32ee2105221175a022ccb2
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 14:57:19 2024 -0700

    don't build arm32 for now since we know it doesn't work for some reason

commit ba52be114ecd081c9bfcb464a1bae6270f995d1b
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 14:56:17 2024 -0700

    fix comment

commit 6fbf28fabfbfac5855bae1367df2a2ffcade9f8c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 12:39:56 2024 -0700

    no need for TARGETARCH anymore

commit 83c0c80b7836b32ed5ad242709b18781c5941221
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Mon May 27 12:38:36 2024 -0700

    fix va arg call

commit 60a4a18e244b3c3e31abbdff113150366fd3c9b2
Author: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date:   Sat May 25 18:31:30 2024 -0700

    disable ffmpeg qt integration

commit c091b3bbe376eea76d52ea9902944ee5c5fea51c
Author: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date:   Sat May 25 01:32:40 2024 -0700

    get rid of dumb superfluous qt shit

commit f06a66e402a59889f056416ac5b95debdd6b1e85
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 23:31:13 2024 -0700

    Update Dockerfile

commit 22f8af190251600a7e631486651e6fdc4cd70750
Author: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 15:51:04 2024 -0700

    link pipe with pthread

commit ad6d581b85c3ec221e2379045d9b28bf6ddaf92c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 14:40:42 2024 -0700

    fix cmake

commit 28336979a0de1ceac7c196362d6e2567da151dbe
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 14:34:02 2024 -0700

    build cmake manually

commit 5fb7f386c80a58a8406314936942d5e8ae09e87b
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 14:23:29 2024 -0700

    oops

commit 86cdaa7bdc6bef8f4aa0952af0a945980c381db4
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 14:21:57 2024 -0700

    sigh

commit 5333ecb8bc43bac54fb54da97c368721e6a63a3c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 13:35:36 2024 -0700

    you fucking moron

commit 593e80e330caa026a3d05621fd8ba958e8eae78c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 12:48:40 2024 -0700

    always save cache after build

commit e55449e7ca98422694419245000d4700f51da04f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 12:45:23 2024 -0700

    don't bother with ack for button/touch

commit d2df3676105053bd45e8544641635167a4d86134
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 12:44:09 2024 -0700

    use actual byte for rumble info

commit 2ef512e8a2de80df367ee4ca4df29997cb4e88f9
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 12:43:52 2024 -0700

    actually read the data payload from the pipe

commit 135f2a31f2b11f392d4cfcefc08046bae810031e
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 12:43:33 2024 -0700

    nicer sync animation

commit 0dfca4710623b948b1a5278da8ee1fc23fb7c68a
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 11:21:25 2024 -0700

    attempt to build both x86_64 and arm64

commit a48041466990b86a4bb746ea0a89b15e18e34e6a
Merge: d622309 3b3b11d
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 11:18:20 2024 -0700

    Merge branch 'master' into ci

commit d622309cd697bbc7da20276421b3c5cef2f4de86
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Fri May 24 11:18:02 2024 -0700

    use other dockerfile

commit 1236186aa2f9c977cc929585f2e8d86265caa04b
Author: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date:   Thu May 23 12:20:59 2024 -0700

    Update Dockerfile

commit a36cbc3e11293bb8f8b4aef4b0724c6d57b3bb3d
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Thu May 23 12:01:12 2024 -0700

    abs path to dhclient and force stdout in wpa supplicant build

commit 0677e1f03d8cb16da98c83478da312c885d2a160
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Thu May 23 11:20:28 2024 -0700

    don't hash dockerfile for cache ID

commit a416cc6ce123b0cc20e53c46728e52744a9c873c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Thu May 23 11:00:59 2024 -0700

    copy dhclient and libOpenGL into AppDir

commit e46f7b63ff8ec269de728597ed7b65604e90cbce
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 14:30:26 2024 -0700

    Update Dockerfile

commit 4bf49d818623d10c2518e8dbc3bcc5c62a958cee
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 13:46:48 2024 -0700

    Update Dockerfile

commit 3289f48be2011277ca2fdfb5565f2b1b6107f99e
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 13:46:14 2024 -0700

    copy config into place

commit eb400f7636ab5847cca253fa73a97aa57716bade
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 12:58:17 2024 -0700

    oops

commit c76857e4e65fe9cbf54740efc9b859ab15acb3f1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 12:56:59 2024 -0700

    try different stuff

commit fbbe8816eedfaf7094547b138e35a296f41a2e3f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 12:55:08 2024 -0700

    build using docker

commit 43c15518d7ac547cd0cf34b64790629717ddaf05
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 12:44:14 2024 -0700

    Create Dockerfile

commit 7a503bb2d75259dfb5016ef2565704664016a2d7
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 11:45:55 2024 -0700

    install desktop file and icon

commit 6f081759bab541dff53cb9a935b7a03db904f902
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 09:35:31 2024 -0700

    we're gonna packaging using system libraries and don't need any of this stuff

commit 0671b18eb5e5ba6bfb60c957d8cc8502b74af132
Author: MattKC <34096995+itsmattkc@users.noreply.github.com>
Date:   Wed May 22 08:22:35 2024 -0700

    start work on arm64 build [skip ci]

commit 2d87806c1f796c548430537789f1908307f7ced2
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 22:04:52 2024 -0700

    skip more steps if cache is restored successfully

commit da1ad1b783ad57b7d8909df26e9b9379fafa45d7
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 22:00:59 2024 -0700

    fixed more xcb libraries

commit 5e5c3216d233d4fff5d53197fadd3bfdeebec3d6
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 21:53:05 2024 -0700

    enable verbose debugging

commit 68df89f7be1deb04db09c239409a80496448f2a9
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 21:41:39 2024 -0700

    fixed xcb deps

commit 8e8a634ab81c8891efee5e2dc6b104ee33d45fb0
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 21:16:11 2024 -0700

    install xcb libs

commit d37f22265f4c998d685bea6e4fc4ec559bd13e69
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 20:57:38 2024 -0700

    install libxcb-glx0-dev libts-dev

commit 1b2a1507ad3886b3d78d1a8f172164334fc4f6de
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 20:46:58 2024 -0700

    install libpulse-dev

commit e00a6a4750b787ce6b28264c0babeb79ada9491c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 20:46:09 2024 -0700

    install libatspi2.0-dev

commit 35dce7046e3263b978d707d3bbda89774b61a5e1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 20:20:07 2024 -0700

    install libx11-xcb-dev

commit bd61c3af2df71077c793d0c61325727bbaa619a1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 20:07:36 2024 -0700

    install libxkbcommon-x11-dev

commit e517b27ac893d847b99e781603e3b98b2ee00d57
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 19:58:48 2024 -0700

    install libxkbcommon-dev

commit 4057fca7a74a5a07caae9c992e034b913dc127a1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 19:51:48 2024 -0700

    ensure qt 6 builds with xcb

commit e85626b918a9e6e3ffb5db4dc35ced76e0a869b5
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 18:52:32 2024 -0700

    build ICU with rpath

commit 41bb9525fc1aac8d63bc7b190bba0bc4472b28ba
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 18:17:47 2024 -0700

    remove libicu

commit c1a507dcf1c26bbbc4895525a9bdb196aaae5880
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 17:18:48 2024 -0700

    allow ICU post checkout hook

commit 6408f043836f809743f12d289f1f986c78da0954
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 17:14:55 2024 -0700

    install ICU and cache everything else

commit 9f4855654d53a5d4aa5f2b022558db51f30a3124
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:51:11 2024 -0700

    set LDFLAGS

commit 8903b8f841bf9257a7c4b31ae0c6e6578f1d3c63
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:47:45 2024 -0700

    move to build stage

commit e9eb176fd7860840a884649778f54f0eee200587
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:39:49 2024 -0700

    list stuff in pkgconfig folder

commit 3aacef645b8ef549a97a7e8219761d728ec0a61f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:36:01 2024 -0700

    print PKG_CONFIG_PATH

commit 5bc07a6e7aa2db8a09c961876fc8378e3aeb83a9
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:22:23 2024 -0700

    export maybe?

commit 56412231e5530905e346339d1ab69eabed4570e1
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:18:57 2024 -0700

    fix pkg_config_path

commit 19d188a13fc7f35dec68f182be8fa29627932ca2
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:16:23 2024 -0700

    set pkg_config_path

commit 4cccf4ce25e484ddef15d9cab9b80176341da6b9
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:09:15 2024 -0700

    install libnl manually

commit 07ebf31177db4c199a4b5d4b5e5685aee12917fe
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 16:01:49 2024 -0700

    install desktop-file-utils

commit 49dc4906e0648e37704f806a59678cd288fa3097
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:59:56 2024 -0700

    fix chmod typo

commit 49f9b827eb20602fdf71e89c639b69647463ec63
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:58:14 2024 -0700

    grab appimagetool

commit d9f54867c8505069354291501a780ecee1ffddbb
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:53:57 2024 -0700

    fix pathing in deploy

commit 3f67fbd6b5a6ae8964b61a4f0cd980c8354d7ed6
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:51:54 2024 -0700

    link with pthread

commit b51d6b6973cd910f8a67cc0df4d6b6b652a1f4b6
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:50:07 2024 -0700

    install libnl-genl-3

commit f7db3360168572e00f484a38114ac9d1e727b902
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 15:48:16 2024 -0700

    install libnl3

commit b44465706c89ef470becb1e0b0c686197c39ff14
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 14:58:38 2024 -0700

    cache deps post-build

commit 168dbb6fd26bc83f87700d73ee1ff4aa3bf6edd0
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 14:53:07 2024 -0700

    put wpa supplicant config in place

commit 359c39cba8b4a48dea68288cd8a1a705c8c6945f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 13:46:32 2024 -0700

    install ffmpeg and sdl2

commit 60fdde71462fadf4b5d0df01542fab424aec5590
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 13:01:59 2024 -0700

    try git protocol

commit fe16f0234d438ad6ed2b4301ce328a5f0008b35b
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 13:00:33 2024 -0700

    build later version because why not

commit e4bfdef10b1dcd882174fbe63e19e89d746ac3ab
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 12:50:31 2024 -0700

    install gles2 and egl

commit 15ee9a74eb5845a4263b44dce74b1fdfe861aefd
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 12:29:14 2024 -0700

    improve qt6 build

commit b3018b132aed5f34afbd5f26ca321befab58d74b
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 11:25:29 2024 -0700

    install qt 6

commit fc4d11cb2c405e420dc08fad3c5516163bdbdbcc
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:52:13 2024 -0700

    use apt for deps for now

commit 511c57447f6874e59bde687595ff617d64cc629f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:48:47 2024 -0700

    sudo

commit 4e94bae9fc894ca79ced4d1c08c7cdf25ab9512e
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:48:16 2024 -0700

    withhhhhhhhh

commit 20ccd8f23012bf810b476d82c908bb5c34b3112f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:47:39 2024 -0700

    for fucks sake vscode

commit 67d0e2bad7d33d6d4f599031a905cf01961a7ecb
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:46:30 2024 -0700

    ensure build tools are installed

commit 5f0c2162974f158712e1e3db50f8b5f28625caee
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:45:11 2024 -0700

    probably no need to use ninja

commit 45a20ab4401c0a83bde9eabc15c8e31b474e757f
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:44:24 2024 -0700

    move to the fucking workflows folder

commit d9bd06ac9cced483fd9b035da2ea5215be4f1b0a
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:42:46 2024 -0700

    build all branches

commit bffeb35ac13599b63cacb202975888a3e105822c
Author: itsmattkc <34096995+itsmattkc@users.noreply.github.com>
Date:   Tue May 21 10:38:22 2024 -0700

    initial CI commit
2024-05-29 00:09:17 -07:00

333 lines
10 KiB
C++

#include "mainwindow.h"
#include <QAudioDevice>
#include <QComboBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QMediaDevices>
#include <QMessageBox>
#include <QPushButton>
#include <QSlider>
#include <QSplitter>
#include <QThread>
#include <SDL2/SDL.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <ifaddrs.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <linux/wireless.h>
#include <vanilla.h>
#include "inputconfigdialog.h"
#include "keymap.h"
#include "syncdialog.h"
MainWindow::MainWindow(QWidget *parent) : QWidget(parent)
{
if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0) {
QMessageBox::critical(this, tr("SDL2 Error"), tr("SDL2 failed to initialize. Controller support will be unavailable."));
}
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
m_splitter = new QSplitter(this);
layout->addWidget(m_splitter);
QWidget *configSection = new QWidget(this);
m_splitter->addWidget(configSection);
m_viewer = new Viewer(this);
m_viewer->setMinimumSize(854, 480);
connect(m_viewer, &Viewer::requestExitFullScreen, this, &MainWindow::exitFullScreen);
m_splitter->addWidget(m_viewer);
QVBoxLayout *configOuterLayout = new QVBoxLayout(configSection);
{
QGroupBox *connectionConfigGroupBox = new QGroupBox(tr("Connection"), configSection);
configOuterLayout->addWidget(connectionConfigGroupBox);
QGridLayout *configLayout = new QGridLayout(connectionConfigGroupBox);
int row = 0;
configLayout->addWidget(new QLabel(tr("Wi-Fi Adapter: "), connectionConfigGroupBox), row, 0);
m_wirelessInterfaceComboBox = new QComboBox(connectionConfigGroupBox);
configLayout->addWidget(m_wirelessInterfaceComboBox, row, 1);
row++;
m_syncBtn = new QPushButton(tr("Sync"), connectionConfigGroupBox);
connect(m_syncBtn, &QPushButton::clicked, this, &MainWindow::showSyncDialog);
configLayout->addWidget(m_syncBtn, row, 0, 1, 2);
row++;
m_connectBtn = new QPushButton(connectionConfigGroupBox);
m_connectBtn->setCheckable(true);
//m_connectBtn->setEnabled(vanilla_has_config()); // TODO: Implement this properly through the pipe at some point
m_backend = nullptr;
setConnectedState(false);
connect(m_connectBtn, &QPushButton::clicked, this, &MainWindow::setConnectedState);
configLayout->addWidget(m_connectBtn, row, 0, 1, 2);
}
{
QGroupBox *displayConfigGroupBox = new QGroupBox(tr("Display"), configSection);
configOuterLayout->addWidget(displayConfigGroupBox);
QGridLayout *configLayout = new QGridLayout(displayConfigGroupBox);
int row = 0;
QPushButton *fullScreenBtn = new QPushButton(tr("Full Screen"), configSection);
connect(fullScreenBtn, &QPushButton::clicked, this, &MainWindow::setFullScreen);
configLayout->addWidget(fullScreenBtn, row, 0, 1, 2);
}
{
QGroupBox *soundConfigGroupBox = new QGroupBox(tr("Sound"), configSection);
configOuterLayout->addWidget(soundConfigGroupBox);
QGridLayout *configLayout = new QGridLayout(soundConfigGroupBox);
int row = 0;
configLayout->addWidget(new QLabel(tr("Volume: "), soundConfigGroupBox), row, 0);
QSlider *volumeSlider = new QSlider(Qt::Horizontal, soundConfigGroupBox);
volumeSlider->setMinimum(0);
volumeSlider->setMaximum(100);
volumeSlider->setValue(100);
connect(volumeSlider, &QSlider::valueChanged, this, &MainWindow::volumeChanged);
configLayout->addWidget(volumeSlider, row, 1);
row++;
configLayout->addWidget(new QLabel(tr("Microphone: "), soundConfigGroupBox), row, 0);
m_microphoneComboBox = new QComboBox(soundConfigGroupBox);
m_microphoneComboBox->setMaximumWidth(m_microphoneComboBox->fontMetrics().horizontalAdvance(QStringLiteral("SOMEAMOUNTOFTEXT")));
configLayout->addWidget(m_microphoneComboBox, row, 1);
}
{
QGroupBox *inputConfigGroupBox = new QGroupBox(tr("Input"), configSection);
configOuterLayout->addWidget(inputConfigGroupBox);
QGridLayout *configLayout = new QGridLayout(inputConfigGroupBox);
int row = 0;
configLayout->addWidget(new QLabel(tr("Input: "), inputConfigGroupBox), row, 0);
m_controllerComboBox = new QComboBox(inputConfigGroupBox);
connect(m_controllerComboBox, &QComboBox::currentIndexChanged, this, &MainWindow::setJoystick);
configLayout->addWidget(m_controllerComboBox, row, 1);
row++;
m_controllerMappingButton = new QPushButton(tr("Configure"), m_controllerComboBox);
connect(m_controllerMappingButton, &QPushButton::clicked, this, &MainWindow::showInputConfigDialog);
configLayout->addWidget(m_controllerMappingButton, row, 0, 1, 2);
}
configOuterLayout->addStretch();
m_backend = new Backend();
startObjectOnThread(m_backend);
m_videoDecoder = new VideoDecoder();
startObjectOnThread(m_videoDecoder);
m_gamepadHandler = new GamepadHandler();
startObjectOnThread(m_gamepadHandler);
QMetaObject::invokeMethod(m_gamepadHandler, &GamepadHandler::run, Qt::QueuedConnection);
m_audioHandler = new AudioHandler();
startObjectOnThread(m_audioHandler);
QMetaObject::invokeMethod(m_audioHandler, &AudioHandler::run, Qt::QueuedConnection);
connect(m_backend, &Backend::videoAvailable, m_videoDecoder, &VideoDecoder::sendPacket);
connect(m_backend, &Backend::syncCompleted, this, [this](bool e){if (e) m_connectBtn->setEnabled(true);});
connect(m_videoDecoder, &VideoDecoder::frameReady, m_viewer, &Viewer::setImage);
connect(m_backend, &Backend::audioAvailable, m_audioHandler, &AudioHandler::write);
connect(m_backend, &Backend::vibrate, m_gamepadHandler, &GamepadHandler::vibrate, Qt::DirectConnection);
connect(m_viewer, &Viewer::touch, m_backend, &Backend::updateTouch, Qt::DirectConnection);
connect(m_gamepadHandler, &GamepadHandler::gamepadsChanged, this, &MainWindow::populateControllers);
connect(m_gamepadHandler, &GamepadHandler::buttonStateChanged, m_backend, &Backend::setButton, Qt::DirectConnection);
connect(m_viewer, &Viewer::keyPressed, m_gamepadHandler, &GamepadHandler::keyPressed, Qt::DirectConnection);
connect(m_viewer, &Viewer::keyReleased, m_gamepadHandler, &GamepadHandler::keyReleased, Qt::DirectConnection);
populateWirelessInterfaces();
populateMicrophones();
populateControllers();
KeyMap::instance.load(KeyMap::getConfigFilename());
setWindowTitle(tr("Vanilla"));
}
MainWindow::~MainWindow()
{
QMetaObject::invokeMethod(m_audioHandler, &AudioHandler::close, Qt::QueuedConnection);
m_audioHandler->deleteLater();
m_gamepadHandler->close();
m_gamepadHandler->deleteLater();
m_videoDecoder->deleteLater();
m_backend->interrupt();
m_backend->deleteLater();
for (QThread *t : m_threadMap) {
t->quit();
t->wait();
delete t;
}
SDL_Quit();
delete m_viewer;
}
int isWireless(const char* ifname, char* protocol)
{
int sock = -1;
iwreq pwrq;
memset(&pwrq, 0, sizeof(pwrq));
strncpy(pwrq.ifr_name, ifname, IFNAMSIZ);
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
perror("socket");
return 0;
}
if (ioctl(sock, SIOCGIWNAME, &pwrq) != -1) {
if (protocol) strncpy(protocol, pwrq.u.name, IFNAMSIZ);
close(sock);
return 1;
}
close(sock);
return 0;
}
void MainWindow::populateWirelessInterfaces()
{
m_wirelessInterfaceComboBox->clear();
struct ifaddrs *addrs,*tmp;
getifaddrs(&addrs);
tmp = addrs;
while (tmp)
{
if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) {
if (isWireless(tmp->ifa_name, nullptr))
m_wirelessInterfaceComboBox->addItem(tmp->ifa_name);
}
tmp = tmp->ifa_next;
}
freeifaddrs(addrs);
}
void MainWindow::populateMicrophones()
{
m_microphoneComboBox->clear();
auto inputs = QMediaDevices::audioInputs();
for (auto input : inputs) {
m_microphoneComboBox->addItem(input.description(), input.id());
}
}
void MainWindow::populateControllers()
{
m_controllerComboBox->clear();
m_controllerComboBox->addItem(tr("Keyboard"), -1);
for (int i = 0; i < SDL_NumJoysticks(); i++) {
SDL_Joystick *j = SDL_JoystickOpen(i);
if (j) {
m_controllerComboBox->addItem(SDL_JoystickName(j), i);
SDL_JoystickClose(j);
}
}
}
void MainWindow::showSyncDialog()
{
SyncDialog *d = new SyncDialog(this);
d->setup(m_backend, m_wirelessInterfaceComboBox->currentText());
connect(d, &SyncDialog::finished, d, &SyncDialog::deleteLater);
d->open();
}
void MainWindow::setConnectedState(bool on)
{
m_wirelessInterfaceComboBox->setEnabled(!on);
m_syncBtn->setEnabled(!on);
if (on) {
m_connectBtn->setText(tr("Disconnect"));
QMetaObject::invokeMethod(m_backend, &Backend::connectToConsole, Qt::QueuedConnection, m_wirelessInterfaceComboBox->currentText());
} else {
if (m_backend) {
m_backend->interrupt();
}
m_connectBtn->setText(tr("Connect"));
m_viewer->setImage(QImage());
}
}
void MainWindow::setJoystick(int index)
{
m_controllerMappingButton->setEnabled(index == 0); // Currently we only allow configuring keyboard controls
m_gamepadHandler->setController(index - 1);
}
void MainWindow::setFullScreen()
{
m_viewer->setParent(nullptr);
m_viewer->showFullScreen();
}
void MainWindow::exitFullScreen()
{
m_splitter->addWidget(m_viewer);
}
void MainWindow::volumeChanged(int v)
{
qreal vol = v * 0.01;
vol = QtAudio::convertVolume(vol, QtAudio::LinearVolumeScale, QtAudio::LogarithmicVolumeScale);
QMetaObject::invokeMethod(m_audioHandler, &AudioHandler::setVolume, vol);
}
void MainWindow::showInputConfigDialog()
{
InputConfigDialog *d = new InputConfigDialog(this);
d->open();
}
void MainWindow::startObjectOnThread(QObject *object)
{
QThread *thread = new QThread(this);
object->moveToThread(thread);
thread->start();
m_threadMap.insert(object, thread);
}