Skip to content

Commit c393815

Browse files
committed
Add input support; extract glfw crate.
1 parent 4b2f9c5 commit c393815

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

crates/processing_ffi/src/lib.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,17 @@ pub extern "C" fn processing_input_mouse_button(surface_id: u64, button: u8, pre
14441444
PROCESSING_MOUSE_MIDDLE => MouseButton::Middle,
14451445
PROCESSING_MOUSE_RIGHT => MouseButton::Right,
14461446
_ => {
1447+
<<<<<<< HEAD
14471448
return Err(ProcessingError::InvalidArgument(format!(
14481449
"invalid mouse button: {button}"
14491450
)));
1451+
=======
1452+
return Err(
1453+
ProcessingError::InvalidArgument(format!(
1454+
"invalid mouse button: {button}"
1455+
)),
1456+
);
1457+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
14501458
}
14511459
};
14521460
input_set_mouse_button(Entity::from_bits(surface_id), btn, pressed)
@@ -1474,7 +1482,13 @@ pub extern "C" fn processing_input_char(surface_id: u64, key_code: u32, codepoin
14741482
error::check(|| {
14751483
let kc = key_code_from_u32(key_code)?;
14761484
let ch = char::from_u32(codepoint).ok_or_else(|| {
1485+
<<<<<<< HEAD
14771486
ProcessingError::InvalidArgument(format!("invalid codepoint: {codepoint}"))
1487+
=======
1488+
ProcessingError::InvalidArgument(format!(
1489+
"invalid codepoint: {codepoint}"
1490+
))
1491+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
14781492
})?;
14791493
input_set_char(Entity::from_bits(surface_id), kc, ch)
14801494
});
@@ -1501,7 +1515,11 @@ pub extern "C" fn processing_input_focus(surface_id: u64, focused: bool) {
15011515
#[unsafe(no_mangle)]
15021516
pub extern "C" fn processing_input_flush() {
15031517
error::clear_error();
1518+
<<<<<<< HEAD
15041519
error::check(input_flush);
1520+
=======
1521+
error::check(|| input_flush());
1522+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15051523
}
15061524

15071525
#[unsafe(no_mangle)]
@@ -1531,7 +1549,11 @@ pub extern "C" fn processing_pmouse_y(surface_id: u64) -> f32 {
15311549
#[unsafe(no_mangle)]
15321550
pub extern "C" fn processing_mouse_is_pressed() -> bool {
15331551
error::clear_error();
1552+
<<<<<<< HEAD
15341553
error::check(input_mouse_is_pressed).unwrap_or(false)
1554+
=======
1555+
error::check(|| input_mouse_is_pressed()).unwrap_or(false)
1556+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15351557
}
15361558

15371559
#[unsafe(no_mangle)]
@@ -1551,7 +1573,11 @@ pub extern "C" fn processing_mouse_button() -> i8 {
15511573
#[unsafe(no_mangle)]
15521574
pub extern "C" fn processing_key_is_pressed() -> bool {
15531575
error::clear_error();
1576+
<<<<<<< HEAD
15541577
error::check(input_key_is_pressed).unwrap_or(false)
1578+
=======
1579+
error::check(|| input_key_is_pressed()).unwrap_or(false)
1580+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15551581
}
15561582

15571583
#[unsafe(no_mangle)]
@@ -1573,25 +1599,42 @@ pub extern "C" fn processing_key() -> u32 {
15731599
#[unsafe(no_mangle)]
15741600
pub extern "C" fn processing_key_code() -> u32 {
15751601
error::clear_error();
1602+
<<<<<<< HEAD
15761603
error::check(|| input_key_code().map(|opt| opt.map(key_code_to_u32).unwrap_or(0))).unwrap_or(0)
1604+
=======
1605+
error::check(|| input_key_code().map(|opt| opt.map(key_code_to_u32).unwrap_or(0)))
1606+
.unwrap_or(0)
1607+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15771608
}
15781609

15791610
#[unsafe(no_mangle)]
15801611
pub extern "C" fn processing_moved_x() -> f32 {
15811612
error::clear_error();
1613+
<<<<<<< HEAD
15821614
error::check(input_moved_x).unwrap_or(0.0)
1615+
=======
1616+
error::check(|| input_moved_x()).unwrap_or(0.0)
1617+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15831618
}
15841619

15851620
#[unsafe(no_mangle)]
15861621
pub extern "C" fn processing_moved_y() -> f32 {
15871622
error::clear_error();
1623+
<<<<<<< HEAD
15881624
error::check(input_moved_y).unwrap_or(0.0)
1625+
=======
1626+
error::check(|| input_moved_y()).unwrap_or(0.0)
1627+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15891628
}
15901629

15911630
#[unsafe(no_mangle)]
15921631
pub extern "C" fn processing_mouse_wheel() -> f32 {
15931632
error::clear_error();
1633+
<<<<<<< HEAD
15941634
error::check(input_mouse_wheel).unwrap_or(0.0)
1635+
=======
1636+
error::check(|| input_mouse_wheel()).unwrap_or(0.0)
1637+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
15951638
}
15961639

15971640
fn key_code_from_u32(val: u32) -> processing::prelude::error::Result<KeyCode> {
@@ -1701,9 +1744,15 @@ fn key_code_from_u32(val: u32) -> processing::prelude::error::Result<KeyCode> {
17011744
PROCESSING_KEY_ALT_RIGHT => Ok(KeyCode::AltRight),
17021745
PROCESSING_KEY_SUPER_RIGHT => Ok(KeyCode::SuperRight),
17031746
PROCESSING_KEY_CONTEXT_MENU => Ok(KeyCode::ContextMenu),
1747+
<<<<<<< HEAD
17041748
_ => Err(ProcessingError::InvalidArgument(format!(
17051749
"unknown key code: {val}"
17061750
))),
1751+
=======
1752+
_ => Err(ProcessingError::InvalidArgument(
1753+
format!("unknown key code: {val}"),
1754+
)),
1755+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
17071756
}
17081757
}
17091758

crates/processing_pyo3/src/graphics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use crate::color::{ColorMode, extract_color_with_mode};
2-
use crate::color::{ColorMode, extract_color_with_mode};
3-
use crate::glfw::GlfwContext;
42
use crate::glfw::GlfwContext;
53
use crate::input;
64
use crate::math::{extract_vec2, extract_vec3, extract_vec4};
7-
use crate::math::{extract_vec2, extract_vec3, extract_vec4};
85
use bevy::{
96
color::{ColorToPacked, Srgba},
107
math::Vec4,

crates/processing_pyo3/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ mod mewnala {
319319
#[pymodule_export]
320320
const F12: u32 = 301;
321321

322+
<<<<<<< HEAD
322323
// color space constants for color_mode()
323324
#[pymodule_export]
324325
const SRGB: u8 = 0;
@@ -341,6 +342,8 @@ mod mewnala {
341342
#[pymodule_export]
342343
const XYZ: u8 = 9;
343344

345+
=======
346+
>>>>>>> 6ad893c (Add input support; extract glfw crate.)
344347
#[pymodule]
345348
mod math {
346349
use super::*;

0 commit comments

Comments
 (0)