Skip to content

Commit 25e3081

Browse files
committed
Update dependencies
Also switched to vendored imgui until imgui-winit-support is updated
1 parent 92865f2 commit 25e3081

File tree

25 files changed

+750
-257
lines changed

25 files changed

+750
-257
lines changed

core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ debugger-hooks = ["bft-r", "bft-w"]
3131

3232
[dependencies]
3333
emu-utils = { git = "https://github.com/kelpsyberry/emu-utils" }
34-
proc-bitfield = { version = "0.2", features = ["nightly"] }
35-
bitflags = "1.2"
34+
proc-bitfield = { version = "0.3", features = ["nightly"] }
35+
bitflags = "2.4"
3636
cfg-if = "1.0"
3737
slog = { version = "2.7", optional = true }
3838
serde = { version = "1.0", features = ["derive"] }

core/src/cpu/debug.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct MemWatchpointSubTable(pub [Option<Box<MemWatchpointLeafTable>>; 0x800
1111
pub struct MemWatchpointLeafTable(pub [usize; MWLT_ENTRY_COUNT as usize]);
1212

1313
bitflags! {
14+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1415
pub struct MemWatchpointRwMask: u8 {
1516
const READ = 1 << 0;
1617
const WRITE = 1 << 1;
@@ -76,15 +77,9 @@ impl MemWatchpointRootTable {
7677

7778
pub(super) fn remove(&mut self, addr: u32, size: u8, rw: MemWatchpointRwMask) {
7879
let root_i = (addr >> 21) as usize;
79-
let sub_table = match &mut self.0[root_i] {
80-
Some(sub_table_ptr) => sub_table_ptr,
81-
None => return,
82-
};
80+
let Some(sub_table) = &mut self.0[root_i] else { return };
8381
let sub_i = (addr >> 10 & 0x7FF) as usize;
84-
let leaf_table = match &mut sub_table.0[sub_i] {
85-
Some(leaf_table_ptr) => leaf_table_ptr,
86-
None => return,
87-
};
82+
let Some(leaf_table) = &mut sub_table.0[sub_i] else { return };
8883
let mut mask = rw.bits() as usize;
8984
for i in 0..size.trailing_zeros() {
9085
mask |= mask << (2 << i);

core/src/emu/input.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{cpu, utils::Savestate};
33
use bitflags::bitflags;
44

55
bitflags! {
6+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
67
pub struct Keys: u32 {
78
const A = 1;
89
const B = 1 << 1;

frontend/desktop/Cargo.toml

+11-12
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,18 @@ dust-wgpu-2d = { path = "../../render/wgpu-2d" }
3838
dust-wgpu-3d = { path = "../../render/wgpu-3d", features = ["threaded"] }
3939

4040
# UI
41-
winit = { version = "0.27", features = ["serde"] }
42-
wgpu = "0.14"
43-
# TODO: Switch to imgui 0.9 when it's released with the docking API
44-
imgui = { git = "https://github.com/imgui-rs/imgui-rs", features = ["docking", "tables-api"] }
45-
imgui-winit-support = { git = "https://github.com/imgui-rs/imgui-rs" }
41+
winit = { version = "0.29", features = ["serde"] }
42+
wgpu = { git = "https://github.com/gfx-rs/wgpu" }
43+
imgui = { version = "0.11", features = ["docking", "tables-api"] }
44+
imgui-winit-support = { git = "https://github.com/kelpsyberry/imgui-rs" }
4645
imgui-wgpu = { git = "https://github.com/kelpsyberry/imgui-wgpu" }
47-
opener = "0.5"
46+
opener = "0.6"
4847

4948
# System resources
50-
rfd = "0.10"
49+
rfd = "0.12"
5150
directories = "5.0"
52-
copypasta = "0.8"
53-
cpal = "0.14"
51+
copypasta = "0.10"
52+
cpal = "0.15"
5453
chrono = { version = "0.4", features = ["serde"] }
5554
libc = "0.2"
5655

@@ -59,8 +58,8 @@ ahash = "0.8"
5958
futures-executor = "0.3"
6059
crossbeam-channel = "0.5"
6160
parking_lot = "0.12"
62-
bitflags = "1.3"
63-
miniz_oxide = { version = "0.6", features = ["simd"] }
61+
bitflags = "2.4"
62+
miniz_oxide = { version = "0.7", features = ["simd"] }
6463
fatfs = { version = "0.3", optional = true }
6564
tempdir = { version = "0.3", optional = true }
6665

@@ -83,5 +82,5 @@ realfft = { version = "3.0", optional = true }
8382
gdb-protocol = { version = "0.1", optional = true }
8483

8584
[target.'cfg(target_os = "macos")'.dependencies]
86-
cocoa = "0.24"
85+
cocoa = "0.25"
8786
objc = "0.2"

frontend/desktop/src/audio/input/cpal.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,30 @@ impl InputStream {
3838
fract: 0.0,
3939
};
4040

41-
let err_callback = |err| panic!("Error in default audio output device stream: {err}");
41+
let err_callback = |err| panic!("Error in default audio input device stream: {err}");
4242
let stream = match supported_input_config.sample_format() {
4343
SampleFormat::U16 => input_device.build_input_stream(
4444
&supported_input_config.config(),
4545
move |data: &[u16], _| input_data.fill(data),
4646
err_callback,
47+
None,
4748
),
4849
SampleFormat::I16 => input_device.build_input_stream(
4950
&supported_input_config.config(),
5051
move |data: &[i16], _| input_data.fill(data),
5152
err_callback,
53+
None,
5254
),
5355
SampleFormat::F32 => input_device.build_input_stream(
5456
&supported_input_config.config(),
5557
move |data: &[f32], _| input_data.fill(data),
5658
err_callback,
59+
None,
5760
),
61+
_ => panic!("Unsupported audio input sample format"),
5862
}
5963
.ok()?;
60-
stream.play().expect("Couldn't start audio output stream");
64+
stream.play().expect("couldn't start audio input stream");
6165

6266
Some(InputStream {
6367
_stream: stream,
@@ -86,7 +90,7 @@ struct InputData {
8690
}
8791

8892
impl InputData {
89-
fn fill<T: Sample>(&mut self, data: &[T]) {
93+
fn fill<T: Sample>(&mut self, data: &[T]) where f64: cpal::FromSample<T> {
9094
if let Some(interp) = self.interp_rx.try_iter().last() {
9195
self.interp = interp;
9296
}
@@ -95,7 +99,7 @@ impl InputData {
9599
for input_samples in data.chunks(self.channels as usize) {
96100
let mut input_sample = 0.0;
97101
for sample in input_samples {
98-
input_sample += sample.to_f32() as f64;
102+
input_sample += sample.to_sample::<f64>();
99103
}
100104
self.interp
101105
.push_input_sample([input_sample / self.channels as f64]);

frontend/desktop/src/audio/output/cpal.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,24 @@ impl OutputStream {
8383
&supported_output_config.config(),
8484
move |data: &mut [u16], _| output_data.fill(data),
8585
err_callback,
86+
None,
8687
),
8788
SampleFormat::I16 => output_device.build_output_stream(
8889
&supported_output_config.config(),
8990
move |data: &mut [i16], _| output_data.fill(data),
9091
err_callback,
92+
None,
9193
),
9294
SampleFormat::F32 => output_device.build_output_stream(
9395
&supported_output_config.config(),
9496
move |data: &mut [f32], _| output_data.fill(data),
9597
err_callback,
98+
None,
9699
),
100+
_ => panic!("Unsupported audio output sample format"),
97101
}
98102
.ok()?;
99-
stream.play().expect("Couldn't start audio output stream");
103+
stream.play().expect("couldn't start audio output stream");
100104

101105
Some(OutputStream {
102106
_stream: stream,
@@ -143,7 +147,7 @@ struct OutputData {
143147
}
144148

145149
impl OutputData {
146-
fn fill<T: Sample>(&mut self, data: &mut [T]) {
150+
fn fill<T: Sample + cpal::FromSample<f32>>(&mut self, data: &mut [T]) {
147151
if let Some(interp) = self.interp_rx.try_iter().last() {
148152
self.interp = interp;
149153
}
@@ -170,8 +174,8 @@ impl OutputData {
170174
return;
171175
}
172176
let result = self.interp.get_output_sample(fract);
173-
data[output_i] = T::from(&(result[0] as f32 * volume));
174-
data[output_i + 1] = T::from(&(result[1] as f32 * volume));
177+
data[output_i] = T::from_sample(result[0] as f32 * volume);
178+
data[output_i + 1] = T::from_sample(result[1] as f32 * volume);
175179
fract += sample_rate_ratio;
176180
output_i += 2;
177181
}

frontend/desktop/src/debug_views/common/disasm.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use imgui::{Key, MouseButton, StyleColor, StyleVar, Ui, WindowHoveredFlags};
66
use std::{fmt::Write, num::NonZeroU8};
77

88
bitflags::bitflags! {
9+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
910
pub struct Flags: u8 {
1011
// Creation flags
1112
const SHOW_VIEW_OPTIONS = 1 << 0;

frontend/desktop/src/emu/gdb_server.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use gdb_protocol::packet::{CheckedPacket, Kind as PacketKind};
2626
use std::{cell::RefCell, io::Write, net::ToSocketAddrs, rc::Rc, str};
2727

2828
bitflags::bitflags! {
29+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
2930
struct ThreadMask: u8 {
3031
const ARM9 = 1 << 0;
3132
const ARM7 = 1 << 1;

frontend/desktop/src/input.rs

+24-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ pub use map::Map;
33
mod state;
44
pub use state::{Changes, State};
55
pub mod trigger;
6+
pub mod key_codes;
7+
pub use key_codes::{KeyCode, ScanCode};
68

7-
use winit::event::{ScanCode, VirtualKeyCode};
9+
use winit::keyboard::PhysicalKey;
810

911
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
1012
pub enum Action {
@@ -16,4 +18,24 @@ pub enum Action {
1618
ToggleFullWindowScreen,
1719
}
1820

19-
pub type PressedKey = (Option<VirtualKeyCode>, ScanCode);
21+
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
22+
pub enum PressedKey {
23+
KeyCode(KeyCode),
24+
ScanCode(ScanCode),
25+
}
26+
27+
impl TryFrom<PhysicalKey> for PressedKey {
28+
type Error = ();
29+
30+
fn try_from(value: PhysicalKey) -> Result<Self, ()> {
31+
Ok(match value {
32+
PhysicalKey::Code(key_code) => PressedKey::KeyCode(key_code.into()),
33+
PhysicalKey::Unidentified(scan_code) => {
34+
let Ok(scan_code) = scan_code.try_into() else {
35+
return Err(());
36+
};
37+
PressedKey::ScanCode(scan_code)
38+
}
39+
})
40+
}
41+
}

0 commit comments

Comments
 (0)