Changeset 12496 in vbox for trunk/src/VBox/Frontends/VirtualBox4
- Timestamp:
- Sep 16, 2008 3:46:57 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 36622
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox4/src/linux/keyboard-new.c
r12495 r12496 121 121 scan = sun_key_scan[keysym & 0xff]; 122 122 else if (keysym == 0x20) /* Spacebar */ 123 123 scan = 0x39; 124 124 else if (keysym == 0xFE03) /* ISO level3 shift, aka AltGr */ 125 126 125 scan = 0x138; 126 else if (use_builtin_table != 0) 127 127 scan = main_keyboard_type_scans[builtin_table_number][code]; 128 128 else … … 204 204 /** Does this key match? */ 205 205 int ok = 0; 206 207 208 209 206 /* search for a match in layout table */ 207 for (key = 0; (key < MAIN_LEN) && (0 == ok); key++) { 208 if ( ((*lkey)[key][0] == ckey[keyc][0]) 209 && ((*lkey)[key][1] == ckey[keyc][1]) 210 210 ) { 211 211 ok = 1; 212 213 214 215 216 212 } 213 } 214 /* count the matches and mismatches */ 215 if (0 != ok) { 216 match++; 217 217 /* How well in sequence are the keys? For dvorak layouts. */ 218 219 220 218 if (key > pkey) { 219 if (1 == direction) { 220 ++seq; 221 221 } else { 222 222 direction = -1; 223 223 } 224 225 226 227 224 } 225 if (key < pkey) { 226 if (1 != direction) { 227 ++seq; 228 228 } else { 229 229 direction = 1; 230 230 } 231 232 233 231 } 232 pkey = key; 233 } else { 234 234 #ifdef DEBUG 235 235 /* print spaces instead of \0's */ … … 244 244 keyc, str, ckey[keyc][0], ckey[keyc][1])); 245 245 #endif /* DEBUG defined */ 246 246 } 247 247 } 248 248 } 249 249 LOG_KB_2(("Matches=%d, seq=%d\n", match, seq)); 250 250 if ( (match > max_score) 251 251 || ((match == max_score) && (seq > max_seq)) 252 252 ) { 253 253 /* best match so far */ … … 330 330 && (0xFE03 != keysym) /* ISO level3 shift, aka AltGr */ 331 331 ) { 332 333 334 332 unsigned found = 0; 333 334 /* we seem to need to search the layout-dependent scancodes */ 335 335 char unshifted = keysym & 0xFF; 336 336 char shifted = XKeycodeToKeysym(display, keyc, 1) & 0xFF; 337 338 337 /* find a key which matches */ 338 for (keyn = 0; (0 == found) && (keyn<MAIN_LEN); keyn++) { 339 339 if ( ((*lkey)[keyn][0] == unshifted) 340 340 && ((*lkey)[keyn][1] == shifted) … … 342 342 found = 1; 343 343 } 344 345 346 347 348 349 350 351 352 353 354 344 } 345 if (0 != found) { 346 /* got it */ 347 scan = main_key_scan[keyn - 1]; 348 /* We keep track of the number of keys that we found a 349 * match for to see if the layout is optimal or not. 350 * We ignore the 102nd key though (key number 48), since 351 * not all keyboards have it. */ 352 if (keyn != 48) 353 ++matches; 354 } 355 355 if (0 == scan) { 356 356 /* print spaces instead of \0's */ … … 376 376 keyc, str, unshifted, shifted, scan)); 377 377 } 378 378 } 379 379 } 380 380 keyc2scan[keyc] = scan;
Note:
See TracChangeset
for help on using the changeset viewer.