Add mouse position input function
This commit is contained in:
@@ -11,5 +11,9 @@ key_state: proc(key: Key) -> Action
|
|||||||
// implementation in platform package, to prevent cyclic dependency
|
// implementation in platform package, to prevent cyclic dependency
|
||||||
mouse_button_state: proc(button: Mouse_Button) -> Action
|
mouse_button_state: proc(button: Mouse_Button) -> Action
|
||||||
|
|
||||||
|
// Returns the position of the mouse cursor
|
||||||
|
// implementation in platform package, to prevent cyclic dependency
|
||||||
|
mouse_position: proc() -> (x_pos: f32, y_pos: f32)
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
// Private functions
|
// Private functions
|
||||||
|
|||||||
@@ -52,11 +52,7 @@ os_init :: proc(settings: core.Settings) {
|
|||||||
// Register input functions
|
// Register input functions
|
||||||
input.key_state = key_state
|
input.key_state = key_state
|
||||||
input.mouse_button_state = mouse_button_state
|
input.mouse_button_state = mouse_button_state
|
||||||
|
input.mouse_position = mouse_position
|
||||||
// TODO: Figure out proper vsync, found 3 spots so far
|
|
||||||
// - glfw.SwapInterval(0) this is only for OpenGL it seems?
|
|
||||||
// - glfw.SetWindowMonitor(refresh)
|
|
||||||
// - wgpu presentMode = .Fifo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os_destroy :: proc() {
|
os_destroy :: proc() {
|
||||||
@@ -157,6 +153,12 @@ mouse_button_state :: proc(button: input.Mouse_Button) -> input.Action {
|
|||||||
return input_action(glfw.GetMouseButton(state.os.window, i32(button)))
|
return input_action(glfw.GetMouseButton(state.os.window, i32(button)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@(private = "file")
|
||||||
|
mouse_position :: proc() -> (x_pos: f32, y_pos: f32) {
|
||||||
|
x_pos_f64, y_pos_64 := glfw.GetCursorPos(state.os.window)
|
||||||
|
return f32(x_pos_f64), f32(y_pos_64)
|
||||||
|
}
|
||||||
|
|
||||||
@(private = "file")
|
@(private = "file")
|
||||||
input_action :: proc(action: i32) -> input.Action {
|
input_action :: proc(action: i32) -> input.Action {
|
||||||
if action == glfw.RELEASE do return input.Action.Release
|
if action == glfw.RELEASE do return input.Action.Release
|
||||||
|
|||||||
Reference in New Issue
Block a user