camera is almost there... waiting on upstream support from webcam libs lol

This commit is contained in:
Alex Janka 2023-03-19 15:44:45 +11:00
parent 47e2210b88
commit 7bd343ddec
6 changed files with 173 additions and 324 deletions

423
Cargo.lock generated
View file

@ -68,15 +68,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.69" version = "1.0.69"
@ -151,7 +142,7 @@ checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca"
dependencies = [ dependencies = [
"addr2line", "addr2line",
"cc", "cc",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"miniz_oxide", "miniz_oxide",
"object", "object",
@ -168,8 +159,8 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
name = "baseview" name = "baseview"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cocoa 0.24.1", "cocoa",
"core-foundation 0.9.3", "core-foundation",
"keyboard-types", "keyboard-types",
"nix 0.22.3", "nix 0.22.3",
"objc", "objc",
@ -181,29 +172,6 @@ dependencies = [
"xcb-util", "xcb-util",
] ]
[[package]]
name = "bindgen"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239"
dependencies = [
"bitflags",
"cexpr 0.4.0",
"clang-sys",
"clap 2.34.0",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex 0.1.1",
"which",
]
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.61.0" version = "0.61.0"
@ -211,7 +179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a" checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cexpr 0.6.0", "cexpr",
"clang-sys", "clang-sys",
"lazy_static", "lazy_static",
"lazycell", "lazycell",
@ -220,7 +188,7 @@ dependencies = [
"quote", "quote",
"regex", "regex",
"rustc-hash", "rustc-hash",
"shlex 1.1.0", "shlex",
"syn", "syn",
] ]
@ -296,30 +264,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom 5.1.2",
]
[[package]] [[package]]
name = "cexpr" name = "cexpr"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [ dependencies = [
"nom 7.1.3", "nom",
] ]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -345,6 +298,16 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "clang"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c044c781163c001b913cd018fc95a628c50d0d2dfea8bca77dad71edb16e37"
dependencies = [
"clang-sys",
"libc",
]
[[package]] [[package]]
name = "clang-sys" name = "clang-sys"
version = "1.6.0" version = "1.6.0"
@ -356,21 +319,6 @@ dependencies = [
"libloading", "libloading",
] ]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.1.8" version = "4.1.8"
@ -382,7 +330,7 @@ dependencies = [
"clap_lex", "clap_lex",
"is-terminal", "is-terminal",
"once_cell", "once_cell",
"strsim 0.10.0", "strsim",
"termcolor", "termcolor",
"terminal_size", "terminal_size",
] ]
@ -424,21 +372,6 @@ dependencies = [
"cc", "cc",
] ]
[[package]]
name = "cocoa"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
dependencies = [
"bitflags",
"block",
"core-foundation 0.7.0",
"core-graphics 0.19.2",
"foreign-types",
"libc",
"objc",
]
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.24.1" version = "0.24.1"
@ -448,8 +381,8 @@ dependencies = [
"bitflags", "bitflags",
"block", "block",
"cocoa-foundation", "cocoa-foundation",
"core-foundation 0.9.3", "core-foundation",
"core-graphics 0.22.3", "core-graphics",
"foreign-types", "foreign-types",
"libc", "libc",
"objc", "objc",
@ -463,7 +396,7 @@ checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"block", "block",
"core-foundation 0.9.3", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@ -496,16 +429,6 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys 0.7.0",
"libc",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.3" version = "0.9.3"
@ -522,30 +445,12 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b" checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.3" version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "core-graphics"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
dependencies = [
"bitflags",
"core-foundation 0.7.0",
"foreign-types",
"libc",
]
[[package]] [[package]]
name = "core-graphics" name = "core-graphics"
version = "0.22.3" version = "0.22.3"
@ -553,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.3", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@ -566,36 +471,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"core-foundation 0.9.3", "core-foundation",
"foreign-types", "foreign-types",
"libc", "libc",
] ]
[[package]]
name = "core-media-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "273bf3fc5bf51fd06a7766a84788c1540b6527130a0bce39e00567d6ab9f31f1"
dependencies = [
"cfg-if 0.1.10",
"core-foundation-sys 0.7.0",
"libc",
]
[[package]]
name = "core-video-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
dependencies = [
"cfg-if 0.1.10",
"core-foundation-sys 0.7.0",
"core-graphics 0.19.2",
"libc",
"metal 0.18.0",
"objc",
]
[[package]] [[package]]
name = "coreaudio-rs" name = "coreaudio-rs"
version = "0.11.2" version = "0.11.2"
@ -613,7 +493,7 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a9444b94b8024feecc29e01a9706c69c1e26bfee480221c90764200cfd778fb" checksum = "1a9444b94b8024feecc29e01a9706c69c1e26bfee480221c90764200cfd778fb"
dependencies = [ dependencies = [
"bindgen 0.61.0", "bindgen",
] ]
[[package]] [[package]]
@ -622,7 +502,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5" checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5"
dependencies = [ dependencies = [
"core-foundation 0.9.3", "core-foundation",
"core-foundation-sys 0.8.3", "core-foundation-sys 0.8.3",
"coremidi-sys", "coremidi-sys",
] ]
@ -667,7 +547,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c" checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-channel", "crossbeam-channel",
"crossbeam-deque", "crossbeam-deque",
"crossbeam-epoch", "crossbeam-epoch",
@ -681,7 +561,7 @@ version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -691,7 +571,7 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-epoch", "crossbeam-epoch",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -703,7 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695" checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if 1.0.0", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"memoffset 0.8.0", "memoffset 0.8.0",
"scopeguard", "scopeguard",
@ -715,7 +595,7 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
] ]
@ -725,7 +605,7 @@ version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b" checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
] ]
[[package]] [[package]]
@ -819,7 +699,7 @@ dependencies = [
"ident_case", "ident_case",
"proc-macro2", "proc-macro2",
"quote", "quote",
"strsim 0.10.0", "strsim",
"syn", "syn",
] ]
@ -867,19 +747,6 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.2.8" version = "0.2.8"
@ -1046,7 +913,7 @@ dependencies = [
name = "gb-emu" name = "gb-emu"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"clap 4.1.8", "clap",
"cpal", "cpal",
"ctrlc", "ctrlc",
"futures", "futures",
@ -1054,6 +921,7 @@ dependencies = [
"gilrs", "gilrs",
"minifb", "minifb",
"nokhwa", "nokhwa",
"send_wrapper",
] ]
[[package]] [[package]]
@ -1075,7 +943,7 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"js-sys", "js-sys",
"libc", "libc",
"wasi", "wasi",
@ -1101,7 +969,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6789d356476c3280a4e15365d23f62b4b4f1bcdac81fdd552f65807bce4666dd" checksum = "6789d356476c3280a4e15365d23f62b4b4f1bcdac81fdd552f65807bce4666dd"
dependencies = [ dependencies = [
"core-foundation 0.9.3", "core-foundation",
"io-kit-sys", "io-kit-sys",
"js-sys", "js-sys",
"libc", "libc",
@ -1231,12 +1099,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.53" version = "0.1.53"
@ -1297,7 +1159,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -1475,7 +1337,7 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"winapi", "winapi",
] ]
@ -1520,7 +1382,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
] ]
[[package]] [[package]]
@ -1550,6 +1412,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"
@ -1574,21 +1442,6 @@ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "metal"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
dependencies = [
"bitflags",
"block",
"cocoa 0.20.2",
"core-graphics 0.19.2",
"foreign-types",
"log",
"objc",
]
[[package]] [[package]]
name = "metal" name = "metal"
version = "0.24.0" version = "0.24.0"
@ -1777,10 +1630,10 @@ dependencies = [
"backtrace", "backtrace",
"baseview", "baseview",
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if",
"clap 4.1.8", "clap",
"clap-sys", "clap-sys",
"core-foundation 0.9.3", "core-foundation",
"cpal", "cpal",
"crossbeam", "crossbeam",
"jack", "jack",
@ -1830,7 +1683,7 @@ checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cc", "cc",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"memoffset 0.6.5", "memoffset 0.6.5",
] ]
@ -1842,7 +1695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"memoffset 0.6.5", "memoffset 0.6.5",
] ]
@ -1855,7 +1708,7 @@ checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
] ]
@ -1866,7 +1719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"static_assertions", "static_assertions",
] ]
@ -1879,52 +1732,13 @@ checksum = "143c7e68ab35542605825430efb8acaf977de40d4256ebfeed6324b35a6ba89a"
dependencies = [ dependencies = [
"flume", "flume",
"image", "image",
"nokhwa-bindings-linux",
"nokhwa-bindings-macos",
"nokhwa-bindings-windows",
"nokhwa-core", "nokhwa-core",
"opencv",
"paste", "paste",
"rgb",
"thiserror", "thiserror",
] ]
[[package]]
name = "nokhwa-bindings-linux"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "448db09af68e12168b6311423409f679d2da6e75fb158b2d75de2f5d6dc460ca"
dependencies = [
"nokhwa-core",
"v4l",
"v4l2-sys-mit",
]
[[package]]
name = "nokhwa-bindings-macos"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cb2044194c8cc0286a0bfae023caeb434c32900ffe3f3d08565362306437be8"
dependencies = [
"block",
"cocoa-foundation",
"core-media-sys",
"core-video-sys",
"flume",
"nokhwa-core",
"objc",
"once_cell",
]
[[package]]
name = "nokhwa-bindings-windows"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b9bae36d0ce413568cefb94c43748e80f9ae97aa0a9e2d8e18f0275a909746"
dependencies = [
"nokhwa-core",
"once_cell",
"windows 0.43.0",
]
[[package]] [[package]]
name = "nokhwa-core" name = "nokhwa-core"
version = "0.1.0" version = "0.1.0"
@ -1934,19 +1748,10 @@ dependencies = [
"bytes", "bytes",
"image", "image",
"mozjpeg", "mozjpeg",
"opencv",
"thiserror", "thiserror",
] ]
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"memchr",
"version_check",
]
[[package]] [[package]]
name = "nom" name = "nom"
version = "7.1.3" version = "7.1.3"
@ -2085,13 +1890,49 @@ version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
name = "opencv"
version = "0.74.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33bd2442759725e3ce38862b32acb1999de51e9f3f4310f3b01b7f0623091d74"
dependencies = [
"cc",
"clang",
"dunce",
"jobserver",
"libc",
"num-traits",
"once_cell",
"opencv-binding-generator",
"pkg-config",
"rgb",
"semver",
"shlex",
"vcpkg",
]
[[package]]
name = "opencv-binding-generator"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "082d8259f4a7ea455e3553f9a1bc817520eb465a153bbf5ec0cb0b73590ee28d"
dependencies = [
"clang",
"clang-sys",
"dunce",
"maplit",
"once_cell",
"percent-encoding",
"regex",
]
[[package]] [[package]]
name = "orbclient" name = "orbclient"
version = "0.3.43" version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "974465c5e83cf9df05c1e4137b271d29035c902e39e5ad4c1939837e22160af8" checksum = "974465c5e83cf9df05c1e4137b271d29035c902e39e5ad4c1939837e22160af8"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"raw-window-handle 0.3.4", "raw-window-handle 0.3.4",
"redox_syscall", "redox_syscall",
@ -2123,7 +1964,7 @@ version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
@ -2142,6 +1983,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.0.12" version = "1.0.12"
@ -2506,12 +2353,24 @@ version = "0.35.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0" checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"cmake", "cmake",
"libc", "libc",
"version-compare", "version-compare",
] ]
[[package]]
name = "semver"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
[[package]]
name = "send_wrapper"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.156" version = "1.0.156"
@ -2580,12 +2439,6 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]] [[package]]
name = "shlex" name = "shlex"
version = "1.1.0" version = "1.1.0"
@ -2641,12 +2494,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -2670,7 +2517,7 @@ version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"fastrand", "fastrand",
"redox_syscall", "redox_syscall",
"rustix", "rustix",
@ -2696,15 +2543,6 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.39" version = "1.0.39"
@ -2837,24 +2675,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79"
[[package]] [[package]]
name = "v4l" name = "vcpkg"
version = "0.13.1" version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd9946a2fda19c7a729dc72e28b9fd9c653e9b7de954ffe3aecaf51977f88762" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
dependencies = [
"bitflags",
"libc",
"v4l2-sys-mit",
]
[[package]]
name = "v4l2-sys-mit"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c932c06df4af1dfb229f604214f2a87993784596ff33ffdadcba1b5519254e"
dependencies = [
"bindgen 0.56.0",
]
[[package]] [[package]]
name = "vec_map" name = "vec_map"
@ -2947,7 +2771,7 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"wasm-bindgen-macro", "wasm-bindgen-macro",
] ]
@ -2972,7 +2796,7 @@ version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
dependencies = [ dependencies = [
"cfg-if 1.0.0", "cfg-if",
"js-sys", "js-sys",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
@ -3159,7 +2983,7 @@ dependencies = [
"khronos-egl", "khronos-egl",
"libloading", "libloading",
"log", "log",
"metal 0.24.0", "metal",
"naga", "naga",
"objc", "objc",
"parking_lot", "parking_lot",
@ -3184,15 +3008,6 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "which"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "wide" name = "wide"
version = "0.7.8" version = "0.7.8"
@ -3402,7 +3217,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7" checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
dependencies = [ dependencies = [
"nom 7.1.3", "nom",
] ]
[[package]] [[package]]

View file

@ -3,6 +3,10 @@ name = "gb-emu"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[features]
default = []
camera = ["dep:nokhwa", "dep:send_wrapper"]
[dependencies] [dependencies]
gb-emu-lib = { path = "../lib" } gb-emu-lib = { path = "../lib" }
clap = { version = "4.1.8", features = ["derive"] } clap = { version = "4.1.8", features = ["derive"] }
@ -11,4 +15,5 @@ gilrs = "0.10"
cpal = "0.15" cpal = "0.15"
futures = "0.3" futures = "0.3"
ctrlc = "3.2.5" ctrlc = "3.2.5"
nokhwa = { version = "0.10.3", features = ["input-native"] } nokhwa = { version = "0.10.3", features = ["input-opencv"], optional = true }
send_wrapper = { version = "0.6.0", optional = true }

View file

@ -4,40 +4,51 @@ use nokhwa::{
utils::{CameraIndex, RequestedFormat, RequestedFormatType}, utils::{CameraIndex, RequestedFormat, RequestedFormatType},
Camera, Camera,
}; };
use send_wrapper::SendWrapper;
pub struct Webcam { pub struct Webcam {
camera: Camera, camera: SendWrapper<Camera>,
buffer: [u8; 128 * 128],
} }
impl Webcam { impl Webcam {
pub fn new() -> Self { pub fn new() -> Self {
let format = RequestedFormat::new::<pixel_format::LumaFormat>( let format = RequestedFormat::new::<pixel_format::LumaAFormat>(
RequestedFormatType::AbsoluteHighestResolution, RequestedFormatType::AbsoluteHighestResolution,
); );
println!("creating webcam");
Self { Self {
camera: Camera::new(CameraIndex::Index(0), format).unwrap(), camera: SendWrapper::new(Camera::new(CameraIndex::Index(0), format).unwrap()),
buffer: [0; 128 * 128],
} }
} }
} }
impl PocketCamera for Webcam { impl PocketCamera for Webcam {
fn get_image(&mut self) -> [u8; 128 * 128] { fn get_image(&mut self) -> [u8; 128 * 128] {
let frame = self println!("getting image");
.camera self.buffer
.frame()
.unwrap()
.decode_image::<pixel_format::LumaFormat>()
.unwrap();
let mut buffer = [0; 128 * 128];
for y in 0..128 {
for x in 0..128 {
buffer[y * 128 + x] = frame[(x as u32, y as u32)].0[0];
}
}
buffer
} }
fn begin_capture(&mut self) { fn begin_capture(&mut self) {
todo!() let height = self.camera.resolution().height() as usize;
let width = self.camera.resolution().width() as usize;
let frame = self.camera.frame_raw().expect("couldn't get frame");
println!(
"buffer length: {}, resolution length: {}",
frame.len(),
width * height
);
for y in 0..128 {
for x in 0..128 {
self.buffer[y * 128 + x] = frame[((y * width) + x) * 2];
}
}
println!("captured");
}
fn init(&mut self) {
self.camera.open_stream().expect("couldn't open stream");
} }
} }

View file

@ -1,9 +1,11 @@
#![feature(let_chains)] #![feature(let_chains)]
#[cfg(feature = "camera")]
use camera::Webcam;
use clap::{ArgGroup, Parser}; use clap::{ArgGroup, Parser};
use gb_emu_lib::{ use gb_emu_lib::{
connect::{EmulatorMessage, EmulatorOptions, RomFile, SerialTarget}, connect::{EmulatorMessage, EmulatorOptions, NoCamera, RomFile, SerialTarget},
EmulatorCore, EmulatorCore,
}; };
use gilrs::Gilrs; use gilrs::Gilrs;
@ -12,6 +14,7 @@ use std::sync::mpsc::channel;
use window::WindowRenderer; use window::WindowRenderer;
mod audio; mod audio;
#[cfg(feature = "camera")]
mod camera; mod camera;
mod window; mod window;
@ -83,10 +86,16 @@ fn main() {
let (output, _stream) = audio::create_output(); let (output, _stream) = audio::create_output();
let options = EmulatorOptions::new( #[cfg(feature = "webcam")]
let camera = Webcam::new();
#[cfg(not(feature = "webcam"))]
let camera = NoCamera::default();
let options = EmulatorOptions::new_with_camera(
WindowRenderer::new(factor, Some(Gilrs::new().unwrap())), WindowRenderer::new(factor, Some(Gilrs::new().unwrap())),
RomFile::Path(args.rom), RomFile::Path(args.rom),
output, output,
camera,
) )
.with_save_path(args.save) .with_save_path(args.save)
.with_serial_target(if args.connect_serial { .with_serial_target(if args.connect_serial {
@ -99,8 +108,12 @@ fn main() {
.with_verbose(args.verbose) .with_verbose(args.verbose)
.with_tile_window(tile_window); .with_tile_window(tile_window);
println!("made options");
let mut core = EmulatorCore::init(receiver, options); let mut core = EmulatorCore::init(receiver, options);
println!("made core");
match args.step_by { match args.step_by {
Some(step_size) => loop { Some(step_size) => loop {
core.run_stepped(step_size); core.run_stepped(step_size);

View file

@ -71,6 +71,8 @@ pub trait PocketCamera {
fn get_image(&mut self) -> [u8; 128 * 128]; fn get_image(&mut self) -> [u8; 128 * 128];
fn begin_capture(&mut self); fn begin_capture(&mut self);
fn init(&mut self);
} }
pub struct NoCamera { pub struct NoCamera {
@ -95,6 +97,8 @@ impl PocketCamera for NoCamera {
*v = rand::random(); *v = rand::random();
} }
} }
fn init(&mut self) {}
} }
pub(crate) type CameraWrapperRef<C> = Arc<Mutex<CameraWrapper<C>>>; pub(crate) type CameraWrapperRef<C> = Arc<Mutex<CameraWrapper<C>>>;

View file

@ -45,6 +45,7 @@ where
camera: CameraWrapperRef<C>, camera: CameraWrapperRef<C>,
) -> Self { ) -> Self {
let ram = ram_size_kb(ram_size).map(|s| MaybeBufferedSram::new(save_file, s * KB)); let ram = ram_size_kb(ram_size).map(|s| MaybeBufferedSram::new(save_file, s * KB));
camera.lock().unwrap().inner.init();
Self { Self {
data, data,
rom_bank: 1, rom_bank: 1,