mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-25 08:18:43 -06:00
stuff
This commit is contained in:
parent
517838e2ae
commit
7dc33c2dce
|
@ -68,6 +68,14 @@ target_sdk_version = 30
|
||||||
required = true
|
required = true
|
||||||
glEsVersion = 0x00030000
|
glEsVersion = 0x00030000
|
||||||
|
|
||||||
|
[[package.metadata.android.uses_feature]]
|
||||||
|
name = "android.hardware.touchscreen.multitouch"
|
||||||
|
required = true
|
||||||
|
|
||||||
|
[[package.metadata.android.uses_feature]]
|
||||||
|
name = "android.hardware.touchscreen.multitouch.distinct"
|
||||||
|
required = true
|
||||||
|
|
||||||
[package.metadata.android.application.activity]
|
[package.metadata.android.application.activity]
|
||||||
config_changes = "orientation|keyboardHidden|screenLayout|screenSize"
|
config_changes = "orientation|keyboardHidden|screenLayout|screenSize"
|
||||||
exported = true
|
exported = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use glam::UVec2;
|
use glam::UVec2;
|
||||||
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
use shipyard::{World, Component, AllStoragesViewMut, SparseSet, NonSendSync, UniqueView};
|
||||||
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch};
|
use winit::event::{Event, DeviceEvent, DeviceId, WindowEvent, Touch, RawKeyEvent, TouchPhase};
|
||||||
use crate::rendering::Renderer;
|
use crate::rendering::Renderer;
|
||||||
|
|
||||||
pub mod player_actions;
|
pub mod player_actions;
|
||||||
|
@ -36,17 +36,25 @@ pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "raw-evt"))]
|
#[cfg(not(feature = "raw-evt"))]
|
||||||
WindowEvent::KeyboardInput { device_id, input, is_synthetic } => {
|
WindowEvent::KeyboardInput { device_id, event, .. } => {
|
||||||
world.add_entity((
|
world.add_entity((
|
||||||
EventComponent,
|
EventComponent,
|
||||||
InputDeviceEvent {
|
InputDeviceEvent {
|
||||||
device_id: *device_id,
|
device_id: *device_id,
|
||||||
event: DeviceEvent::Key(*input)
|
event: DeviceEvent::Key(RawKeyEvent {
|
||||||
|
physical_key: event.physical_key,
|
||||||
|
state: event.state,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowEvent::Touch(touch) => {
|
WindowEvent::Touch(touch) => {
|
||||||
|
// if matches!(touch.phase, TouchPhase::Started | TouchPhase::Cancelled | TouchPhase::Ended) {
|
||||||
|
// println!("TOUCH ==================== {:#?}", touch);
|
||||||
|
// } else {
|
||||||
|
// println!("TOUCH MOVED {:?} {}", touch.phase, touch.id);
|
||||||
|
// }
|
||||||
world.add_entity((
|
world.add_entity((
|
||||||
EventComponent,
|
EventComponent,
|
||||||
TouchEvent(*touch)
|
TouchEvent(*touch)
|
||||||
|
@ -73,7 +81,7 @@ pub fn process_glutin_events(world: &mut World, event: &Event<()>) {
|
||||||
OnBeforeExitEvent
|
OnBeforeExitEvent
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ fn process_touch_events(
|
||||||
let position = dvec2(event.0.location.x, event.0.location.y);
|
let position = dvec2(event.0.location.x, event.0.location.y);
|
||||||
match event.0.phase {
|
match event.0.phase {
|
||||||
TouchPhase::Started => {
|
TouchPhase::Started => {
|
||||||
|
//println!("touch started: finger {}", event.0.id);
|
||||||
touch_state.fingers.insert(event.0.id, Finger {
|
touch_state.fingers.insert(event.0.id, Finger {
|
||||||
id: event.0.id,
|
id: event.0.id,
|
||||||
device_id: event.0.device_id,
|
device_id: event.0.device_id,
|
||||||
|
@ -146,6 +147,7 @@ fn process_touch_events(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TouchPhase::Ended | TouchPhase::Cancelled => {
|
TouchPhase::Ended | TouchPhase::Cancelled => {
|
||||||
|
//println!("touch ended: finger {}", event.0.id);
|
||||||
touch_state.fingers.remove(&event.0.id);
|
touch_state.fingers.remove(&event.0.id);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,8 @@ fn attach_console() {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
#[cfg(target_os = "android")]
|
#[cfg(target_os = "android")]
|
||||||
pub fn android_main(app: android_activity::AndroidApp) {
|
pub fn android_main(app: android_activity::AndroidApp) {
|
||||||
|
use android_activity::WindowManagerFlags;
|
||||||
|
app.set_window_flags(WindowManagerFlags::FULLSCREEN, WindowManagerFlags::empty());
|
||||||
kubi_main(app)
|
kubi_main(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,6 +204,13 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
||||||
world.add_workload(render);
|
world.add_workload(render);
|
||||||
world.add_workload(after_frame_end);
|
world.add_workload(after_frame_end);
|
||||||
|
|
||||||
|
//Save _visualizer.json
|
||||||
|
#[cfg(feature = "generate_visualizer_data")]
|
||||||
|
std::fs::write(
|
||||||
|
"_visualizer.json",
|
||||||
|
serde_json::to_string(&world.workloads_info()).unwrap(),
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
//Run pre-startup procedure
|
//Run pre-startup procedure
|
||||||
world.run_workload(pre_startup).unwrap();
|
world.run_workload(pre_startup).unwrap();
|
||||||
|
|
||||||
|
@ -217,31 +226,41 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Initialize renderer
|
|
||||||
{
|
|
||||||
let settings = world.borrow::<UniqueView<GameSettings>>().unwrap();
|
|
||||||
world.add_unique_non_send_sync(Renderer::init(&event_loop, &settings));
|
|
||||||
}
|
|
||||||
world.add_unique(BackgroundColor(vec3(0.5, 0.5, 1.)));
|
|
||||||
|
|
||||||
//Save _visualizer.json
|
|
||||||
#[cfg(feature = "generate_visualizer_data")]
|
|
||||||
std::fs::write(
|
|
||||||
"_visualizer.json",
|
|
||||||
serde_json::to_string(&world.workloads_info()).unwrap(),
|
|
||||||
).unwrap();
|
|
||||||
|
|
||||||
//Run startup systems
|
|
||||||
world.run_workload(startup).unwrap();
|
|
||||||
|
|
||||||
//Run the event loop
|
//Run the event loop
|
||||||
let mut last_update = Instant::now();
|
let mut last_update = Instant::now();
|
||||||
|
let mut ready = false;
|
||||||
event_loop.run(move |event, window_target| {
|
event_loop.run(move |event, window_target| {
|
||||||
|
//Wait for the window to become active (required for android)
|
||||||
|
if !ready {
|
||||||
|
if Event::Resumed != event {
|
||||||
|
window_target.set_control_flow(ControlFlow::Wait);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Initialize renderer
|
||||||
|
{
|
||||||
|
let settings = world.borrow::<UniqueView<GameSettings>>().unwrap();
|
||||||
|
world.add_unique_non_send_sync(Renderer::init(window_target, &settings));
|
||||||
|
}
|
||||||
|
world.add_unique(BackgroundColor(vec3(0.5, 0.5, 1.)));
|
||||||
|
|
||||||
|
//Run startup systems
|
||||||
|
world.run_workload(startup).unwrap();
|
||||||
|
|
||||||
|
ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
window_target.set_control_flow(ControlFlow::Poll);
|
window_target.set_control_flow(ControlFlow::Poll);
|
||||||
|
|
||||||
process_glutin_events(&mut world, &event);
|
process_glutin_events(&mut world, &event);
|
||||||
|
|
||||||
#[allow(clippy::collapsible_match, clippy::single_match)]
|
#[allow(clippy::collapsible_match, clippy::single_match)]
|
||||||
match event {
|
match event {
|
||||||
|
#[cfg(target_os = "android")]
|
||||||
|
Event::Suspended => {
|
||||||
|
window_target.exit();
|
||||||
|
}
|
||||||
|
|
||||||
Event::WindowEvent { event, .. } => match event {
|
Event::WindowEvent { event, .. } => match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
log::info!("exit requested");
|
log::info!("exit requested");
|
||||||
|
@ -249,6 +268,7 @@ pub fn kubi_main(#[cfg(target_os = "android")] app: android_activity::AndroidApp
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
|
|
||||||
Event::AboutToWait => {
|
Event::AboutToWait => {
|
||||||
//Update delta time (maybe move this into a system?)
|
//Update delta time (maybe move this into a system?)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue