Commit 8b5b22e
committed
Caps Lock synchronization between Mac and Beeb
Fixes issue where Mac Caps Lock key did not affect the emulated BBC
Micro's Caps Lock state or LED indicator, and also goes to some lengths
to ensure the states remain synchronized even when the BeebEm is not
in focus.
Key changes:
1. Fixed Alt key mapping bug
- Was incorrectly mapped to VK_CAPITAL (Caps Lock)
- Now correctly mapped to VK_MENU (Windows Alt key code)
2. Implemented Caps Lock handler with 50 ms pulse
- Sends DOWN+UP pulse when Mac Caps Lock toggles
- 50 ms delay = 40 ms Windows default + 25% safety margin
3. Added state synchronization
- On startup: Syncs after BBC LED initialization detected which
indicates the point in BBC MOS initialization after which
Caps Lock state changes will be recognized
- On focus gain: Re-syncs when window becomes active
- Prevents desync when Caps Lock changed while app unfocused
Testing note:
macOS debounces Caps Lock key events internally to prevent
accidental engagement of Caps Lock. Very rapid presses are
filtered by macOS itself, and won't reach BeebEm. The physical
LED on the macOS Caps Lock reflects the debounced state.
Implementation notes:
- BBC Caps Lock at keyboard matrix row 4, column 0
- IC32 bit 6 controls BBC keyboard Caps Lock LED (active-low)
- BBC MOS toggles Caps Lock state on key DOWN only
- Uses GCD dispatch_after for async key-up event after delay1 parent 6345580 commit 8b5b22e
File tree
3 files changed
+126
-15
lines changed- XCode/Project
- Src/MacBridge
- Swift/BeebControllers
3 files changed
+126
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
447 | 489 | | |
448 | 490 | | |
449 | 491 | | |
| |||
488 | 530 | | |
489 | 531 | | |
490 | 532 | | |
| 533 | + | |
491 | 534 | | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | 535 | | |
496 | 536 | | |
497 | 537 | | |
| |||
524 | 564 | | |
525 | 565 | | |
526 | 566 | | |
527 | | - | |
528 | | - | |
| 567 | + | |
| 568 | + | |
529 | 569 | | |
530 | 570 | | |
531 | | - | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
532 | 610 | | |
533 | 611 | | |
534 | 612 | | |
535 | | - | |
| 613 | + | |
| 614 | + | |
536 | 615 | | |
537 | 616 | | |
538 | 617 | | |
| |||
628 | 707 | | |
629 | 708 | | |
630 | 709 | | |
631 | | - | |
632 | 710 | | |
633 | 711 | | |
634 | 712 | | |
| |||
Lines changed: 36 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
317 | 321 | | |
318 | 322 | | |
319 | 323 | | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
320 | 335 | | |
321 | 336 | | |
322 | 337 | | |
| |||
345 | 360 | | |
346 | 361 | | |
347 | 362 | | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
354 | 383 | | |
0 commit comments