MCPcopy Create free account
hub / github.com/davisking/dlib / get_next_keypress

Function get_next_keypress

tools/python/src/gui.cpp:138–180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138py::object get_next_keypress(image_window& win, bool get_keyboard_modifiers)
139{
140 unsigned long key;
141 bool is_printable;
142 unsigned long state;
143
144 auto state_to_list = [&]() {
145 py::list mods;
146 if (state&base_window::KBD_MOD_SHIFT) mods.append(base_window::KBD_MOD_SHIFT);
147 if (state&base_window::KBD_MOD_CONTROL) mods.append(base_window::KBD_MOD_CONTROL);
148 if (state&base_window::KBD_MOD_ALT) mods.append(base_window::KBD_MOD_ALT);
149 if (state&base_window::KBD_MOD_META) mods.append(base_window::KBD_MOD_META);
150 if (state&base_window::KBD_MOD_CAPS_LOCK) mods.append(base_window::KBD_MOD_CAPS_LOCK);
151 if (state&base_window::KBD_MOD_NUM_LOCK) mods.append(base_window::KBD_MOD_NUM_LOCK);
152 if (state&base_window::KBD_MOD_SCROLL_LOCK) mods.append(base_window::KBD_MOD_SCROLL_LOCK);
153 return mods;
154 };
155
156 if(win.get_next_keypress(key, is_printable, state))
157 {
158 if (is_printable)
159 {
160 if (get_keyboard_modifiers)
161 return py::make_tuple((char)key, state_to_list());
162 else
163 return py::cast((char)key);
164 }
165 else
166 {
167 if (get_keyboard_modifiers)
168 return py::make_tuple(static_cast<base_window::non_printable_keyboard_keys>(key), state_to_list());
169 else
170 return py::cast(static_cast<base_window::non_printable_keyboard_keys>(key));
171 }
172 }
173 else
174 {
175 if (get_keyboard_modifiers)
176 return py::make_tuple(py::none(), py::none());
177 else
178 return py::none();
179 }
180}
181
182template <typename point_type>
183void add_overlay_circle (

Callers 1

get_next_keypressMethod · 0.85

Calls 5

make_tupleFunction · 0.85
noneClass · 0.85
get_next_keypressMethod · 0.80
castFunction · 0.50
appendMethod · 0.45

Tested by

no test coverage detected