| 627 | } |
| 628 | |
| 629 | static void HandleKeyPress(XEvent* e) { |
| 630 | char data[64]; |
| 631 | int i, key, status; |
| 632 | cc_codepoint cp; |
| 633 | char* chars = data; |
| 634 | Status status_type; |
| 635 | |
| 636 | key = TryGetKey(&e->xkey); |
| 637 | if (key) Input_SetPressed(key); |
| 638 | |
| 639 | #ifdef CC_BUILD_XIM |
| 640 | if (win_xic) { |
| 641 | status = Xutf8LookupString(win_xic, &e->xkey, data, Array_Elems(data), NULL, &status_type); |
| 642 | while (status > 0) |
| 643 | { |
| 644 | i = Convert_Utf8ToCodepoint(&cp, (cc_uint8*)chars, status); |
| 645 | if (!i) break; |
| 646 | |
| 647 | Event_RaiseInt(&InputEvents.Press, cp); |
| 648 | status -= i; chars += i; |
| 649 | } |
| 650 | return; |
| 651 | } |
| 652 | #endif |
| 653 | |
| 654 | /* Treat the 8 bit characters as first 256 unicode codepoints */ |
| 655 | /* This only really works for latin keys (e.g. so some finnish keys still work) */ |
| 656 | status = XLookupString(&e->xkey, data, Array_Elems(data), NULL, NULL); |
| 657 | for (i = 0; i < status; i++) |
| 658 | { |
| 659 | Event_RaiseInt(&InputEvents.Press, (cc_uint8)data[i]); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | static void HandleKeyRelease(XEvent* e) { |
| 664 | int key = TryGetKey(&e->xkey); |
no test coverage detected