Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod java;
mod keycodes;
mod navigator;
mod trace;
mod ui;

use custom_event::RuffleEvent;

Expand Down Expand Up @@ -269,6 +270,7 @@ async fn run(app: AndroidApp) {
.with_storage(Box::new(DiskStorageBackend::new(android_storage_dir.clone())))
.with_navigator(navigator)
.with_log(FileLogBackend::new(trace_output.as_deref()))
.with_ui(ui::AndroidUiBackend::new(app.clone()))
.with_video(
ruffle_video_software::backend::SoftwareVideoBackend::new(),
)
Expand Down Expand Up @@ -393,6 +395,15 @@ async fn run(app: AndroidApp) {

InputStatus::Handled
}
InputEvent::TextEvent(state) => {
if let Some(player) = playerbox.as_ref() {
let event = PlayerEvent::Ime(
ruffle_core::events::ImeEvent::Commit(state.text.clone()),
);
player.player.lock().unwrap().handle_event(event);
}
InputStatus::Handled
}
_ => InputStatus::Unhandled,
}) {}
}
Expand Down
94 changes: 94 additions & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
use std::str::FromStr;

use android_activity::AndroidApp;
use ruffle_core::backend::ui::{LanguageIdentifier, UiBackend};
use url::Url;

#[derive(Clone)]
pub struct AndroidUiBackend {
app: AndroidApp,
}

impl AndroidUiBackend {
pub fn new(app: AndroidApp) -> Self {
Self { app }
}
}

impl UiBackend for AndroidUiBackend {
fn mouse_visible(&self) -> bool {
false
}

fn set_mouse_visible(&mut self, visible: bool) {}

fn set_mouse_cursor(&mut self, cursor: ruffle_core::backend::ui::MouseCursor) {}

fn clipboard_content(&mut self) -> String {
"".into()
}

fn set_clipboard_content(&mut self, content: String) {}

fn set_fullscreen(
&mut self,
is_full: bool,
) -> Result<(), ruffle_core::backend::ui::FullscreenError> {
Ok(())
}

fn display_root_movie_download_failed_message(
&self,
_invalid_swf: bool,
_fetched_error: String,
) {
}

fn message(&self, message: &str) {}

fn open_virtual_keyboard(&self) {
self.app.show_soft_input(false);
}

fn close_virtual_keyboard(&self) {
self.app.hide_soft_input(false);
}

fn language(&self) -> ruffle_core::backend::ui::LanguageIdentifier {
LanguageIdentifier::from_str("en-US").unwrap()
}

fn display_unsupported_video(&self, url: Url) {}

fn load_device_font(
&self,
query: &ruffle_core::FontQuery,
register: &mut dyn FnMut(ruffle_core::backend::ui::FontDefinition),
) {
}

fn sort_device_fonts(
&self,
query: &ruffle_core::FontQuery,
register: &mut dyn FnMut(ruffle_core::backend::ui::FontDefinition),
) -> Vec<ruffle_core::FontQuery> {
Vec::new()
}

fn display_file_open_dialog(
&mut self,
filters: Vec<ruffle_core::backend::ui::FileFilter>,
) -> Option<ruffle_core::backend::ui::DialogResultFuture> {
None
}

fn display_file_save_dialog(
&mut self,
file_name: String,
title: String,
) -> Option<ruffle_core::backend::ui::DialogResultFuture> {
None
}

fn close_file_dialog(&mut self) {}
}
Loading