41 |
static int min_keycode; |
static int min_keycode; |
42 |
static uint16 remote_modifier_state = 0; |
static uint16 remote_modifier_state = 0; |
43 |
|
|
44 |
|
static void update_modifier_state(uint16 modifiers, BOOL pressed); |
45 |
|
|
46 |
static void |
static void |
47 |
add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname) |
add_to_keymap(char *keyname, uint8 scancode, uint16 modifiers, char *mapname) |
48 |
{ |
{ |
249 |
return tr; |
return tr; |
250 |
} |
} |
251 |
|
|
252 |
printf("No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym)); |
fprintf(stderr, "No translation for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym)); |
253 |
|
|
254 |
/* not in keymap, try to interpret the raw scancode */ |
/* not in keymap, try to interpret the raw scancode */ |
255 |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
if ((keycode >= min_keycode) && (keycode <= 0x60)) |
256 |
{ |
{ |
257 |
tr.scancode = keycode - min_keycode; |
tr.scancode = keycode - min_keycode; |
258 |
printf("Sending guessed scancode 0x%x\n", tr.scancode); |
fprintf(stderr, "Sending guessed scancode 0x%x\n", tr.scancode); |
259 |
} |
} |
260 |
else |
else |
261 |
{ |
{ |
262 |
printf("No good guess for keycode 0x%x found\n", keycode); |
fprintf(stderr, "No good guess for keycode 0x%x found\n", keycode); |
263 |
} |
} |
264 |
|
|
265 |
return tr; |
return tr; |
309 |
case XK_Multi_key: |
case XK_Multi_key: |
310 |
return True; |
return True; |
311 |
break; |
break; |
312 |
|
case XK_Num_Lock: |
313 |
|
return True; |
314 |
|
break; |
315 |
default: |
default: |
316 |
break; |
break; |
317 |
} |
} |
377 |
!= MASK_HAS_BITS(remote_modifier_state, MapNumLockMask)) |
!= MASK_HAS_BITS(remote_modifier_state, MapNumLockMask)) |
378 |
{ |
{ |
379 |
/* The remote modifier state is not correct */ |
/* The remote modifier state is not correct */ |
380 |
DEBUG_KBD(("Remote NumLock state is incorrect. Toggling\n")); |
uint16 new_remote_state = 0; |
381 |
|
|
382 |
if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)) |
if (MASK_HAS_BITS(tr.modifiers, MapNumLockMask)) |
383 |
{ |
{ |
384 |
/* Needs this modifier. Toggle */ |
DEBUG_KBD(("Remote NumLock state is incorrect, activating NumLock.\n")); |
385 |
rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK); |
new_remote_state |= KBD_FLAG_NUMLOCK; |
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK); |
|
386 |
} |
} |
387 |
else |
else |
388 |
{ |
{ |
389 |
/* Should not use this modifier. Toggle */ |
DEBUG_KBD(("Remote NumLock state is incorrect, deactivating NumLock.\n")); |
|
rdp_send_scancode(ev_time, RDP_KEYPRESS, SCANCODE_CHAR_NUMLOCK); |
|
|
rdp_send_scancode(ev_time, RDP_KEYRELEASE, SCANCODE_CHAR_NUMLOCK); |
|
390 |
} |
} |
|
} |
|
391 |
|
|
392 |
|
rdp_send_input(0, RDP_INPUT_SYNCHRONIZE, 0, new_remote_state, 0); |
393 |
|
update_modifier_state(SCANCODE_CHAR_NUMLOCK, True); |
394 |
|
} |
395 |
} |
} |
396 |
|
|
397 |
|
|
398 |
static void |
static void |
399 |
update_modifier_state(uint16 modifiers, BOOL pressed) |
update_modifier_state(uint16 modifiers, BOOL pressed) |
400 |
{ |
{ |
401 |
|
#ifdef WITH_DEBUG_KBD |
402 |
|
uint16 old_modifier_state; |
403 |
|
|
404 |
|
old_modifier_state = remote_modifier_state; |
405 |
|
#endif |
406 |
|
|
|
DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n", |
|
|
remote_modifier_state, pressed)); |
|
407 |
switch (modifiers) |
switch (modifiers) |
408 |
{ |
{ |
409 |
case SCANCODE_CHAR_LSHIFT: |
case SCANCODE_CHAR_LSHIFT: |
444 |
} |
} |
445 |
break; |
break; |
446 |
} |
} |
447 |
DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state)); |
|
448 |
|
#ifdef WITH_DEBUG_KBD |
449 |
|
if (old_modifier_state != remote_modifier_state) |
450 |
|
{ |
451 |
|
DEBUG_KBD(("Before updating modifier_state:0x%x, pressed=0x%x\n", |
452 |
|
old_modifier_state, pressed)); |
453 |
|
DEBUG_KBD(("After updating modifier_state:0x%x\n", remote_modifier_state)); |
454 |
|
} |
455 |
|
#endif |
456 |
|
|
457 |
} |
} |
458 |
|
|
471 |
} |
} |
472 |
else |
else |
473 |
{ |
{ |
474 |
DEBUG_KBD(("Sending scancode=0x%x, flags=0x%x\n", scancode, flags); |
DEBUG_KBD(("Sending scancode=0x%x, flags=0x%x\n", scancode, flags)); |
475 |
rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0)); |
rdp_send_input(time, RDP_INPUT_SCANCODE, flags, scancode, 0); |
476 |
} |
} |
477 |
} |
} |