MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / HandleKeyPress

Function HandleKeyPress

src/Window_X11.c:629–661  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627}
628
629static 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
663static void HandleKeyRelease(XEvent* e) {
664 int key = TryGetKey(&e->xkey);

Callers 1

Window_ProcessEventsFunction · 0.85

Calls 4

TryGetKeyFunction · 0.85
Input_SetPressedFunction · 0.85
Convert_Utf8ToCodepointFunction · 0.85
Event_RaiseIntFunction · 0.85

Tested by

no test coverage detected