MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / input_event

Method input_event

framework/gui.h:876–989  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874template <vkb::BindingType bindingType>
875inline 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 }

Callers

nothing calls this directly

Calls 9

get_sourceMethod · 0.80
get_actionMethod · 0.80
get_codeMethod · 0.80
get_pos_xMethod · 0.80
get_pos_yMethod · 0.80
get_buttonMethod · 0.80
get_pointer_idMethod · 0.80
startMethod · 0.80
get_touch_pointsMethod · 0.80

Tested by

no test coverage detected