MCPcopy Create free account
hub / github.com/ProjectPhysX/FluidX3D / input_detection

Function input_detection

src/graphics.cpp:643–682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641 XFreeCursor(x11_display, x11_cursor);
642}
643void input_detection() {
644 XEvent x11_event;
645 while(running) {
646 XNextEvent(x11_display, &x11_event);
647 if(!x11_cursor_movement_captured&&x11_event.type==MotionNotify) { // to avoid cursor movement being captured before cursor has been centered
648 camera.input_mouse_moved((int)x11_event.xmotion.x, (int)x11_event.xmotion.y);
649 x11_cursor_movement_captured = true;
650 } else if(x11_event.type==ButtonPress) { // counterpart: ButtonRelease
651 const int x11_button = x11_event.xbutton.button;
652 if(x11_button==Button4) { // scroll up
653 camera.input_scroll_up();
654 } else if(x11_button==Button5) { // scroll down
655 camera.input_scroll_down();
656 } else if(x11_button==Button1||x11_button==Button2||x11_button==Button3) {
657 if(!camera.lockmouse) {
658 show_cursor();
659 } else {
660 hide_cursor();
661 XWarpPointer(x11_display, x11_window, x11_window, 0, 0, camera.width, camera.height, (int)camera.width/2, (int)camera.height/2); // reset cursor
662 }
663 camera.input_key('U');
664 }
665 } else if(x11_event.type==KeyPress) {
666 const int key = key_linux((int)x11_event.xkey.keycode);
667 if(key=='U') {
668 if(!camera.lockmouse) {
669 show_cursor();
670 } else {
671 hide_cursor();
672 XWarpPointer(x11_display, x11_window, x11_window, 0, 0, camera.width, camera.height, (int)camera.width/2, (int)camera.height/2); // reset cursor
673 }
674 }
675 camera.set_key_state(key, true);
676 key_bindings(key);
677 } else if(x11_event.type==KeyRelease) {
678 const int key = key_linux((int)x11_event.xkey.keycode);
679 camera.set_key_state(key, false);
680 }
681 }
682}
683int main(int argc, char* argv[]) {
684 main_arguments = get_main_arguments(argc, argv);
685

Callers

nothing calls this directly

Calls 10

show_cursorFunction · 0.85
hide_cursorFunction · 0.85
key_linuxFunction · 0.85
key_bindingsFunction · 0.85
key_pressFunction · 0.85
input_mouse_movedMethod · 0.80
input_scroll_upMethod · 0.80
input_scroll_downMethod · 0.80
input_keyMethod · 0.80
set_key_stateMethod · 0.80

Tested by

no test coverage detected