| 874 | template <vkb::BindingType bindingType> |
| 875 | inline bool Gui<bindingType>::input_event(const InputEvent &input_event) |
| 876 | { |
| 877 | auto &io = ImGui::GetIO(); |
| 878 | auto capture_move_event = false; |
| 879 | |
| 880 | if (input_event.get_source() == EventSource::Keyboard) |
| 881 | { |
| 882 | const auto &key_event = static_cast<const KeyInputEvent &>(input_event); |
| 883 | |
| 884 | if (key_event.get_action() == KeyAction::Down) |
| 885 | { |
| 886 | io.KeysDown[static_cast<int>(key_event.get_code())] = true; |
| 887 | } |
| 888 | else if (key_event.get_action() == KeyAction::Up) |
| 889 | { |
| 890 | io.KeysDown[static_cast<int>(key_event.get_code())] = false; |
| 891 | } |
| 892 | } |
| 893 | else if (input_event.get_source() == EventSource::Mouse) |
| 894 | { |
| 895 | const auto &mouse_button = static_cast<const MouseButtonInputEvent &>(input_event); |
| 896 | |
| 897 | io.MousePos = ImVec2{mouse_button.get_pos_x() * content_scale_factor, |
| 898 | mouse_button.get_pos_y() * content_scale_factor}; |
| 899 | |
| 900 | auto button_id = static_cast<int>(mouse_button.get_button()); |
| 901 | |
| 902 | if (mouse_button.get_action() == MouseAction::Down) |
| 903 | { |
| 904 | io.MouseDown[button_id] = true; |
| 905 | } |
| 906 | else if (mouse_button.get_action() == MouseAction::Up) |
| 907 | { |
| 908 | io.MouseDown[button_id] = false; |
| 909 | } |
| 910 | else if (mouse_button.get_action() == MouseAction::Move) |
| 911 | { |
| 912 | capture_move_event = io.WantCaptureMouse; |
| 913 | } |
| 914 | } |
| 915 | else if (input_event.get_source() == EventSource::Touchscreen) |
| 916 | { |
| 917 | const auto &touch_event = static_cast<const TouchInputEvent &>(input_event); |
| 918 | |
| 919 | io.MousePos = ImVec2{touch_event.get_pos_x(), touch_event.get_pos_y()}; |
| 920 | |
| 921 | if (touch_event.get_action() == TouchAction::Down) |
| 922 | { |
| 923 | io.MouseDown[touch_event.get_pointer_id()] = true; |
| 924 | } |
| 925 | else if (touch_event.get_action() == TouchAction::Up) |
| 926 | { |
| 927 | io.MouseDown[touch_event.get_pointer_id()] = false; |
| 928 | } |
| 929 | else if (touch_event.get_action() == TouchAction::Move) |
| 930 | { |
| 931 | capture_move_event = io.WantCaptureMouse; |
| 932 | } |
| 933 | } |
nothing calls this directly
no test coverage detected