|
|
|
@ -50,8 +50,9 @@ pub mod button_m {
|
|
|
|
|
use crate::drawables::rect::Rect;
|
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
|
use std::collections::HashSet;
|
|
|
|
|
use crate::canvas::canvas_frame::Drawable;
|
|
|
|
|
use crate::canvas::canvas_frame::{Drawable, Eventable};
|
|
|
|
|
use crate::util::vertex::VertexType;
|
|
|
|
|
use winit::event::Event;
|
|
|
|
|
|
|
|
|
|
pub struct Slider {
|
|
|
|
|
handle : Rect,
|
|
|
|
@ -68,12 +69,17 @@ pub mod button_m {
|
|
|
|
|
|
|
|
|
|
// render the guide first
|
|
|
|
|
|
|
|
|
|
let left_guide_bar = Rect::new((position.0 as f32, position.1 as f32), (0.1, 0.1), 1);
|
|
|
|
|
let right_guide_bar = Rect::new((position.0 + size.0 as f32, position.1 as f32), (0.1, 0.1), 1);
|
|
|
|
|
let line = Rect::new((position.0 as f32, position.1 - (size.1 / 2.0) as f32), (0.1, 0.1), 1);
|
|
|
|
|
let red = (1.0, 0.0, 0.0, 0.0);
|
|
|
|
|
let green = (0.0, 1.0, 0.0, 0.0);
|
|
|
|
|
let blue = (0.0, 1.0, 1.0, 0.0);
|
|
|
|
|
let rg = (1.0, 1.0, 0.0, 0.0);
|
|
|
|
|
|
|
|
|
|
let left_guide_bar = Rect::new((position.0 as f32, position.1 as f32), (0.01, size.1), 1, red);
|
|
|
|
|
let right_guide_bar = Rect::new((position.0 + size.0 as f32, position.1 as f32), (0.01, size.1), 1, blue);
|
|
|
|
|
let line = Rect::new((position.0 as f32, position.1 - (size.1 / 2.0) as f32), (size.0, 0.01), 1, green);
|
|
|
|
|
|
|
|
|
|
let scale = value as f32 / u16::max_value() as f32;
|
|
|
|
|
let handle = Rect::new((position.0 + (size.0 * scale) as f32, position.1 as f32), (0.3, 0.3), 1);
|
|
|
|
|
let handle = Rect::new((position.0 + (size.0 * scale) as f32, position.1 as f32), (0.03, size.1), 1, rg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Slider {
|
|
|
|
@ -97,6 +103,12 @@ pub mod button_m {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Eventable for Slider {
|
|
|
|
|
fn notify(&mut self, event: &Event<'a, _>) -> () {
|
|
|
|
|
unimplemented!()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
pub fn main() {
|
|
|
|
|
hprof::start_frame();
|
|
|
|
@ -170,15 +182,15 @@ pub fn main() {
|
|
|
|
|
|
|
|
|
|
let mut funky_sprite = Sprite::new((0.0, 0.5), (0.5, 0.5), 0, funky_handle.clone());
|
|
|
|
|
let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
|
let rect = Rect::new((-0.5, -0.5), (0.5, 0.5), 1);
|
|
|
|
|
|
|
|
|
|
// let slider = button_m::Slider::new((0.5, 0.1), (0.1,0.1), 30000);
|
|
|
|
|
|
|
|
|
|
let slider = button_m::Slider::new((0.3, 0.04), (-0.5,-0.3), 30000);
|
|
|
|
|
|
|
|
|
|
// how do i register a sprite to get events...
|
|
|
|
|
// explicit is much easier
|
|
|
|
|
|
|
|
|
|
//let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
|
let text_sprite = Text::new((-0.1, -0.1), (10.0, 10.0), 1);
|
|
|
|
|
// let text_sprite = Text::new((-0.1, -0.1), (10.0, 10.0), 1);
|
|
|
|
|
//let test_polygon = Poly::new_with_color((-0.5, -0.5), (0.5, 0.5), 1, (1.0,0.0,0.0,0.0));
|
|
|
|
|
|
|
|
|
|
drop(q2);
|
|
|
|
@ -188,40 +200,40 @@ pub fn main() {
|
|
|
|
|
|
|
|
|
|
let event_loop_proxy = events_loop.create_proxy();
|
|
|
|
|
|
|
|
|
|
std::thread::spawn(move || {
|
|
|
|
|
|
|
|
|
|
let mut gilrs = Gilrs::new().unwrap();
|
|
|
|
|
// Iterate over all connected gamepads
|
|
|
|
|
let mut gamepad : Option<Gamepad> = None;
|
|
|
|
|
for (_id, gamepad_) in gilrs.gamepads() {
|
|
|
|
|
if gamepad_.name() == "PS4" {
|
|
|
|
|
gamepad = Some(gamepad_);
|
|
|
|
|
}
|
|
|
|
|
println!("{} is {:?} {:?}", gamepad_.name(), gamepad_.power_info(), gamepad_.id());
|
|
|
|
|
}
|
|
|
|
|
let mut active_gamepad = None;
|
|
|
|
|
|
|
|
|
|
loop {
|
|
|
|
|
|
|
|
|
|
while let Some(GilEvent { id, event, time }) = gilrs.next_event() {
|
|
|
|
|
println!("{:?} New event from {}: {:?}", time, id, event);
|
|
|
|
|
active_gamepad = Some(id);
|
|
|
|
|
event_loop_proxy.send_event(TrEvent::GamepadEvent {
|
|
|
|
|
gil_event: GilEvent {id, event, time}
|
|
|
|
|
}).ok();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// // You can also use cached gamepad state
|
|
|
|
|
// if let Some(gamepad) = active_gamepad.map(|id| gilrs.gamepad(id)) {
|
|
|
|
|
// if gamepad.is_pressed(Button::South) {
|
|
|
|
|
// println!("Button South is pressed (XBox - A, PS - X)");
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
std::thread::sleep(std::time::Duration::from_millis(50));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// std::thread::spawn(move || {
|
|
|
|
|
//
|
|
|
|
|
// let mut gilrs = Gilrs::new().unwrap();
|
|
|
|
|
// // Iterate over all connected gamepads
|
|
|
|
|
// let mut gamepad : Option<Gamepad> = None;
|
|
|
|
|
// for (_id, gamepad_) in gilrs.gamepads() {
|
|
|
|
|
// if gamepad_.name() == "PS4" {
|
|
|
|
|
// gamepad = Some(gamepad_);
|
|
|
|
|
// }
|
|
|
|
|
// println!("{} is {:?} {:?}", gamepad_.name(), gamepad_.power_info(), gamepad_.id());
|
|
|
|
|
// }
|
|
|
|
|
// let mut active_gamepad = None;
|
|
|
|
|
//
|
|
|
|
|
// loop {
|
|
|
|
|
//
|
|
|
|
|
// while let Some(GilEvent { id, event, time }) = gilrs.next_event() {
|
|
|
|
|
// println!("{:?} New event from {}: {:?}", time, id, event);
|
|
|
|
|
// active_gamepad = Some(id);
|
|
|
|
|
// event_loop_proxy.send_event(TrEvent::GamepadEvent {
|
|
|
|
|
// gil_event: GilEvent {id, event, time}
|
|
|
|
|
// }).ok();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // // You can also use cached gamepad state
|
|
|
|
|
// // if let Some(gamepad) = active_gamepad.map(|id| gilrs.gamepad(id)) {
|
|
|
|
|
// // if gamepad.is_pressed(Button::South) {
|
|
|
|
|
// // println!("Button South is pressed (XBox - A, PS - X)");
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
//
|
|
|
|
|
// std::thread::sleep(std::time::Duration::from_millis(50));
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
// Events loop is borrowed from the surface
|
|
|
|
|
events_loop.run(move |event, _, control_flow| {
|
|
|
|
@ -258,9 +270,9 @@ pub fn main() {
|
|
|
|
|
|
|
|
|
|
let mut canvas_frame = CanvasFrame::default();
|
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
|
canvas_frame.draw(&text_sprite);
|
|
|
|
|
// canvas_frame.draw(&text_sprite);
|
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
|
// canvas_frame.draw(&slider);
|
|
|
|
|
canvas_frame.draw(&slider);
|
|
|
|
|
|
|
|
|
|
let mut compu_frame = CompuFrame::new();
|
|
|
|
|
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
|