Skip to content

Commit

Permalink
Added Event::TextInput
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorKoenders committed Sep 26, 2024
1 parent fc0995e commit 87ab6ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Input {
self.axes.set_value(*gamepad_id, *axis, *value);
}
}
Event::WindowResized { .. } => {}
Event::WindowResized { .. } | Event::TextInput { .. } => {}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/input/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ pub enum Event {
width: u32,
height: u32,
},

TextInput {
text: String,
},
}

impl Event {
Expand Down Expand Up @@ -170,6 +174,14 @@ impl Event {
}
}

SDL_TEXTINPUT => {
let e = &event.text.text;
let text = std::ffi::CStr::from_ptr(e.as_ptr())
.to_string_lossy()
.into_owned();
return Some(Event::TextInput { text });
}

_ => {}
}
}
Expand Down

0 comments on commit 87ab6ec

Please sign in to comment.