| 158 | } |
| 159 | |
| 160 | void KeyMappingXcb::base_keysyms() |
| 161 | { |
| 162 | keysym_mapping.clear(); |
| 163 | |
| 164 | /* Map all keycode + modifier combinations to the keysym obtained without modifiers */ |
| 165 | |
| 166 | /* Gather the list of valid X11 KeyCode values */ |
| 167 | xcb_keycode_t min_keycode = xcb_get_setup(conn)->min_keycode; |
| 168 | xcb_keycode_t max_keycode = xcb_get_setup(conn)->max_keycode; |
| 169 | |
| 170 | /* Retrieve the current keyboard mapping */ |
| 171 | xcb_get_keyboard_mapping_cookie_t keyboard_mapping_cookie = xcb_get_keyboard_mapping(conn, min_keycode, max_keycode - min_keycode + 1); |
| 172 | xcb_get_keyboard_mapping_reply_t* keyboard_mapping = xcb_get_keyboard_mapping_reply(conn, keyboard_mapping_cookie, nullptr); |
| 173 | xcb_keysym_t* keyboard_keysyms = xcb_get_keyboard_mapping_keysyms(keyboard_mapping); |
| 174 | int keysym_length = xcb_get_keyboard_mapping_keysyms_length(keyboard_mapping); |
| 175 | |
| 176 | for (int kc=0; kc<keysym_length; kc+=keyboard_mapping->keysyms_per_keycode) { |
| 177 | for (int k=0; k<keyboard_mapping->keysyms_per_keycode; k++) { |
| 178 | xcb_keysym_t ks = keyboard_keysyms[kc + k]; |
| 179 | |
| 180 | if (ks == XCB_NO_SYMBOL) continue; |
| 181 | |
| 182 | /* Some modifiers switch my azerty layout into qwerty, so we |
| 183 | * prioritize keysyms that are mapped to themselves. */ |
| 184 | |
| 185 | if (ks == keyboard_keysyms[kc]) |
| 186 | keysym_mapping[ks] = ks; |
| 187 | else { |
| 188 | if (keysym_mapping.find(ks) == keysym_mapping.end()) { |
| 189 | keysym_mapping[ks] = keyboard_keysyms[kc]; |
| 190 | } |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | free(keyboard_mapping); |
| 196 | } |
| 197 | |
| 198 | keysym_t KeyMappingXcb::nativeToKeysym(int keycode) |
| 199 | { |