Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get software keyboard input without max byte size parameter #157

Merged
merged 25 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
742ec8d
Get swkbd input without max byte size parameter
FenrirWolf Feb 11, 2024
2864c06
Don't include nul terminator when passing string data back to Rust
FenrirWolf Feb 12, 2024
5413e77
Use .is_null() instead of comparing to std::ptr::null()
FenrirWolf Feb 12, 2024
3a2000f
Use references and make unsafe blocks more fine-grained
FenrirWolf Feb 12, 2024
bd19f97
Use rust functions instead of memcpy and memset
FenrirWolf Feb 14, 2024
fa6f98d
Simplify string conversion code
FenrirWolf Feb 14, 2024
f867d96
Use if let instead of unwrap for nullable callback
FenrirWolf Feb 14, 2024
61f9131
Remove mention of deleted function
FenrirWolf Feb 14, 2024
4de7652
swkbd_input_text is still an unsafe fn
FenrirWolf Feb 14, 2024
2fcdd11
Simplify string output logic
FenrirWolf Feb 14, 2024
f527623
Fix off-by-one error in swkbd_message_callback
FenrirWolf Feb 14, 2024
b6fc9a2
Simplify some code + rename vars
FenrirWolf Feb 14, 2024
bf3ca2a
Force consistent use of unsafe blocks
FenrirWolf Feb 15, 2024
271d1b5
Fix yet another off-by-one error
FenrirWolf Feb 15, 2024
757afe9
Make swkbd_input_text a method for SoftwareKeyboard
FenrirWolf Feb 16, 2024
cfd276c
Get rid of static mut by using our own callback data
FenrirWolf Feb 16, 2024
03b417d
code_point -> code_unit
FenrirWolf Feb 17, 2024
d6f22dc
Use .cast() in more places
FenrirWolf Feb 17, 2024
f715fc6
Add some comments
FenrirWolf Feb 17, 2024
1446583
MessageCallbackData doesn't need to be a struct member
FenrirWolf Feb 17, 2024
0576e34
Remove redudant imports
FenrirWolf Feb 19, 2024
cb67d92
SoftwareKeyboard::get_string -> SoftwareKeyboard::launch
FenrirWolf Feb 19, 2024
9c33e49
Use next_multiple_of instead of bitshifts
FenrirWolf Feb 20, 2024
6d6f9c0
Update CI nightly version
FenrirWolf Feb 20, 2024
636c8d7
Update MSRV to 1.73
FenrirWolf Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
toolchain:
# Run against a "known good" nightly. Rustc version is 1 day behind the toolchain date
- nightly-2023-06-01
- nightly-2024-02-18
# Check for breakage on latest nightly
- nightly

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
strategy:
matrix:
toolchain:
- nightly-2023-06-01
- nightly-2024-02-18
- nightly
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion ctru-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ categories = ["os", "api-bindings", "hardware-support"]
exclude = ["examples"]
license = "Zlib"
edition = "2021"
rust-version = "1.70"
rust-version = "1.73"

[lib]
crate-type = ["rlib"]
Expand All @@ -24,6 +24,7 @@ shim-3ds = { git = "https://github.com/rust3ds/shim-3ds.git" }
pthread-3ds = { git = "https://github.com/rust3ds/pthread-3ds.git" }
libc = "0.2.121"
bitflags = "2.3.3"
widestring = "1.0.2"

[build-dependencies]
toml = "0.5"
Expand Down
2 changes: 1 addition & 1 deletion ctru-rs/examples/file-explorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl<'a> FileExplorer<'a> {
fn get_input_and_run(&mut self, action: impl FnOnce(&mut Self, String)) {
let mut keyboard = SoftwareKeyboard::default();

match keyboard.get_string(2048, self.apt, self.gfx) {
match keyboard.launch(self.apt, self.gfx) {
Ok((path, Button::Right)) => {
// Clicked "OK".
action(self, path);
Expand Down
4 changes: 2 additions & 2 deletions ctru-rs/examples/software-keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ fn main() {

// Check if the user request to write some input.
if hid.keys_down().contains(KeyPad::A) {
// Raise the software keyboard. You can perform different actions depending on which
// Launch the software keyboard. You can perform different actions depending on which
// software button the user pressed.
match keyboard.get_string(2048, &apt, &gfx) {
match keyboard.launch(&apt, &gfx) {
Ok((text, Button::Right)) => println!("You entered: {text}"),
Ok((_, Button::Left)) => println!("Cancelled"),
Ok((_, Button::Middle)) => println!("How did you even press this?"),
Expand Down
Loading
Loading