Skip to content

Commit

Permalink
fix: io devices
Browse files Browse the repository at this point in the history
  • Loading branch information
kotborealis committed Feb 22, 2023
1 parent 8696abd commit 357cbcf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/wasi-experimental-io-devices/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ maintenance = { status = "experimental" }

[dependencies]
wasmer-wasi = { version = "=3.2.0-alpha.1", path = "../wasi", default-features=false }
wasmer-wasi-types = { path = "../wasi-types", version = "=3.2.0-alpha.1" }
tracing = "0.1"
minifb = { version = "0.23", optional = true }
nix = "0.25.0"
Expand All @@ -30,7 +31,7 @@ enable-serde = [
"wasmer-wasi/enable-serde"
]
# This feature exists, so that "cargo build --all" doesn't
# accidentally link libxcbcommon and libwayland into the CLI
# accidentally link libxcbcommon and libwayland into the CLI
# libraries. When using wasi-experimental-io-devices, users
# have to enable this feature manually
link_external_libs = [
Expand Down
15 changes: 8 additions & 7 deletions lib/wasi-experimental-io-devices/src/link-ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use wasmer_wasi::{
WasiInodes,
};
use wasmer_wasi::{Fd, VirtualFile, WasiFs, WasiFsError, ALL_RIGHTS, VIRTUAL_ROOT_FD};
use wasmer_wasi_types::wasi::Fdflags;

use minifb::{Key, KeyRepeat, MouseButton, Scale, Window, WindowOptions};

Expand Down Expand Up @@ -96,7 +97,7 @@ impl FrameBufferState {
return None;
}
self.x_size = x;
self.y_size = x;
self.y_size = y;

self.data_1.resize((x * y) as usize, 0);
self.data_2.resize((x * y) as usize, 0);
Expand Down Expand Up @@ -126,7 +127,7 @@ impl FrameBufferState {
self.push_input_event(InputEvent::KeyRelease(key))?;
}
}
let keys = self.window.get_keys_pressed(KeyRepeat::No)?;
let keys = self.window.get_keys_pressed(KeyRepeat::No);
for key in keys {
self.keys_pressed.insert(key);
self.push_input_event(InputEvent::KeyPress(key))?;
Expand Down Expand Up @@ -456,7 +457,7 @@ pub fn initialize(inodes: &mut WasiInodes, fs: &mut WasiFs) -> Result<(), String
"_wasmer/dev/fb0".to_string(),
ALL_RIGHTS,
ALL_RIGHTS,
0,
Fdflags::empty(),
)
.map_err(|e| format!("fb: Failed to create dev folder {:?}", e))?
};
Expand All @@ -470,7 +471,7 @@ pub fn initialize(inodes: &mut WasiInodes, fs: &mut WasiFs) -> Result<(), String
"input".to_string(),
ALL_RIGHTS,
ALL_RIGHTS,
0,
Fdflags::empty(),
)
.map_err(|e| format!("fb: Failed to init framebuffer {:?}", e))?;

Expand All @@ -485,7 +486,7 @@ pub fn initialize(inodes: &mut WasiInodes, fs: &mut WasiFs) -> Result<(), String
"fb".to_string(),
ALL_RIGHTS,
ALL_RIGHTS,
0,
Fdflags::empty(),
)
.map_err(|e| format!("fb: Failed to init framebuffer {:?}", e))?;

Expand All @@ -500,7 +501,7 @@ pub fn initialize(inodes: &mut WasiInodes, fs: &mut WasiFs) -> Result<(), String
"virtual_size".to_string(),
ALL_RIGHTS,
ALL_RIGHTS,
0,
Fdflags::empty(),
)
.map_err(|e| format!("fb_resolution: Failed to init framebuffer {:?}", e))?;

Expand All @@ -515,7 +516,7 @@ pub fn initialize(inodes: &mut WasiInodes, fs: &mut WasiFs) -> Result<(), String
"draw".to_string(),
ALL_RIGHTS,
ALL_RIGHTS,
0,
Fdflags::empty(),
)
.map_err(|e| format!("fb_index_display: Failed to init framebuffer {:?}", e))?;

Expand Down

0 comments on commit 357cbcf

Please sign in to comment.