MCPcopy Create free account
hub / github.com/cococry/leif / glfw_cursor_callback

Function glfw_cursor_callback

leif.c:1584–1611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1582 *state.scroll_velocity_ptr = MIN(MAX(*state.scroll_velocity_ptr, -state.theme.div_scroll_max_velocity), state.theme.div_scroll_max_velocity);
1583}
1584void glfw_cursor_callback(GLFWwindow* window, double xpos, double ypos) {
1585 (void)window;
1586 LfMouse* mouse = &state.input.mouse;
1587 // Setting the position values
1588 mouse->xpos = xpos;
1589 mouse->ypos = ypos;
1590
1591 if(mouse->first_mouse_press) {
1592 mouse->xpos_last = xpos;
1593 mouse->ypos_last = ypos;
1594 mouse->first_mouse_press = false;
1595 }
1596 // Delta mouse positions
1597 mouse->xpos_delta = mouse->xpos - mouse->xpos_last;
1598 mouse->ypos_delta = mouse->ypos - mouse->ypos_last;
1599 mouse->xpos_last = xpos;
1600 mouse->ypos_last = ypos;
1601
1602 // Calling User defined callbacks
1603 for(uint32_t i = 0; i < state.input.cursor_pos_cb_count; i++) {
1604 state.input.cursor_pos_cbs[i](window, xpos, ypos);
1605 }
1606
1607 // Populating the cursor event
1608 state.cp_ev.happened = true;
1609 state.cp_ev.x = xpos;
1610 state.cp_ev.y = ypos;
1611}
1612void glfw_char_callback(GLFWwindow* window, uint32_t charcode) {
1613 (void)window;
1614 state.ch_ev.charcode = charcode;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected