From 9db68c9754a114cd2c32ab770b1f68a6b1198a8e Mon Sep 17 00:00:00 2001 From: Julia <145168563+julia-aph@users.noreply.github.com> Date: Tue, 30 Apr 2024 01:04:25 -0500 Subject: [PATCH] ;lk' kl; --- source/io/ctrl.c | 2 -- source/io/input.c | 4 ++- source/io/platforms/platform.h | 2 +- source/io/platforms/win.c | 59 ++++++++++++++++++--------------- source/main.c | 10 ++---- test.exe | Bin 85681 -> 85681 bytes 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/source/io/ctrl.c b/source/io/ctrl.c index affe3ed..e99ce18 100644 --- a/source/io/ctrl.c +++ b/source/io/ctrl.c @@ -156,8 +156,6 @@ void CtrlPoll(struct Controller *ctrl) for (size_t i = 0; i < ctrl->recs.head.len; i++) { struct InputRecord *rec = &ctrl->recs.buf[i]; - if (rec->id.type == BUTTON and rec->is_down) - ctrl->str struct InputAxis *axis = find_axis(&ctrl->binds, rec->id); if (axis == nullptr) diff --git a/source/io/input.c b/source/io/input.c index 9440bff..24906c8 100644 --- a/source/io/input.c +++ b/source/io/input.c @@ -20,9 +20,10 @@ void *input_worker(void *arg) struct InputHandle *hand = arg; struct InputRecordBuf tmp_recs = { .head.len = 0, .head.start = 0 }; + struct InputStringBuf tmp_str = { .head.len = 0, .head.start = 0 }; while (!hand->is_terminating) { - if (!PlatformReadInput(&tmp_recs)) { + if (!PlatformReadInput(&tmp_recs, &tmp_str)) { hand->err = true; return nullptr; } @@ -40,6 +41,7 @@ void *input_worker(void *arg) } RingBufferTransfer(&IO_BUF_T, &hand->recs->head, &tmp_recs.head); + RingBufferTransfer(&STR_BUF_T, &hand->str->head, &tmp_str.head); if (pthread_mutex_unlock(&hand->mutex) != 0) { hand->err = true; diff --git a/source/io/platforms/platform.h b/source/io/platforms/platform.h index f4dd9ca..0938bf1 100644 --- a/source/io/platforms/platform.h +++ b/source/io/platforms/platform.h @@ -16,7 +16,7 @@ bool PlatformInit(); bool PlatformGetRefreshRate(u16f *out); -bool PlatformReadInput(struct InputRecordBuf *in); +bool PlatformReadInput(struct InputRecordBuf *in, struct InputStringBuf *str); bool PlatformStopInput(); diff --git a/source/io/platforms/win.c b/source/io/platforms/win.c index f6b91cf..66efe67 100644 --- a/source/io/platforms/win.c +++ b/source/io/platforms/win.c @@ -125,43 +125,48 @@ bool PlatformGetRefreshRate(u16f *out) return true; } -bool dispatch_rec(struct InputRecord *out, struct win_rec *rec) { - u8f type = rec->type - | (rec->is_mouse & rec->mouse.flags) - | (rec->is_key & rec->key.is_down); +bool dispatch_rec( + struct InputRecord *out, + struct InputStringBuf *str, + struct win_rec *rec +) { + u8f type = rec->type | (rec->is_mouse & rec->mouse.flags); switch (type) { - case KEY_EVENT: { - ReadButton(out, rec->key.vk_code, rec->key.is_down); + case KEY_EVENT: { + ReadButton(out, rec->key.vk_code, rec->key.is_down); - return true; - } - case MOUSE_MOVE: { - ReadJoystick(out, 0, rec->mouse.pos.x, rec->mouse.pos.y); + if (rec->key.is_down) + str->head.len += UCS2ToUTF8(str->buf, rec->key.ucs2_char); - return true; - } - case MOUSE_VWHEEL: { - ReadAxis(out, 0, rec->mouse.but); + return true; + } + case MOUSE_MOVE: { + ReadJoystick(out, 0, rec->mouse.pos.x, rec->mouse.pos.y); - return true; - } - case MOUSE_HWHEEL: { - ReadAxis(out, 1, rec->mouse.but); + return true; + } + case MOUSE_VWHEEL: { + ReadAxis(out, 0, rec->mouse.but); - return true; - } - case WINDOW_BUFFER_SIZE_EVENT: { - // TODO: Handle window resizing - - return false; - } + return true; + } + case MOUSE_HWHEEL: { + ReadAxis(out, 1, rec->mouse.but); + + return true; + } + case WINDOW_BUFFER_SIZE_EVENT: { + // TODO: Handle window resizing + + return false; + } } return false; } -bool PlatformReadInput(struct InputRecordBuf *recs) +bool PlatformReadInput(struct InputRecordBuf *recs, struct InputStringBuf *str) { DWORD read_max = RingBufferEmpty(&IO_BUF_T, &recs->head); union record win_buf[read_max]; @@ -175,7 +180,7 @@ bool PlatformReadInput(struct InputRecordBuf *recs) for (size_t i = 0; i < filled; i++) { struct InputRecord *rec = RingBufferNext(&IO_BUF_T, &recs->head); - if (dispatch_rec(rec, &win_buf->native + i)) { + if (dispatch_rec(rec, str, &win_buf->native + i)) { rec->time = now; recs->head.len += 1; } diff --git a/source/main.c b/source/main.c index 3d1091f..56c9fb5 100644 --- a/source/main.c +++ b/source/main.c @@ -27,6 +27,8 @@ struct Game { Time time; }; +struct Event hi; + int main() { if (!PlatformInit()) @@ -51,14 +53,6 @@ int main() CtrlPoll(&ctrl); - struct InputAxis *a = CtrlGet(&ctrl, 0, BUTTON); - printf("%u", a); - printf("\t%u\n", a->is_down); - - char silly[100] = { 0 }; - CtrlInputString(&ctrl, 100, silly); - printf("%s\n", silly); - if (!InputRelease(&input_hand)) ErrorExit("Release failed"); diff --git a/test.exe b/test.exe index cc8b6c2e7cb0856e17a45f661ec5e66afae8e8b9..c3eb1ceaa6ca97331e5f5b58d190cadb3cb4e068 100644 GIT binary patch delta 6331 zcmc&&eOOf0y5H}H;X^=%FBuSJ_!Ja$Kp9Xp2Laudl2&%nJcX7W5lk~QkLdv=OPqs_ zzU8*_Wa-H|p7Ip7P0=(#J3*FL(=xPD{Hh^M?Nd~A?r-g3Fz$KoeV+T*-Osc3@Av-J zyWaJ#wbxpE&urUZ*tWsoSRt2JuUT0nw~SeHatF0&YiO%?=HUWKy4YhENs{C|0PY-! zn_`c+Hbau^p*2QlFSp&~vESx7J~8seEUxt_mao~g?|h6zh1~8tgjzV=FOy#962B7K z%#D5n%qgP~v8+Er8T|i=xU~^JfSN|GzQH+FEA`JJ zI?k{57)p!zM2{4DisgWj(x7x2KsJ zd1}vE(zNe;zDBf@R~hT&+e29iX{I3@61tEMXe&cAy{Mk|MogheZ0c1^f!dS3&e1^Q zV5C{IT#+Sdw-J-FOWd3{GIiA^RCAYlK9iT3oc&}`X)iP?_Nos8vc_`Y7$ldF;@#+vOm@8t~@ z1CXaVc&Dvr@XiLsKFOri-fgVe@0`v)$z$kCE=o?ojL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