the hub
the hub
This commit is contained in:
parent
a94a0949a7
commit
599c41ef1b
|
@ -29,26 +29,30 @@ void InputBufferAdd(struct InputBuffer *buf, struct InputRecord *rec)
|
|||
*buf_get(buf, buf->len++) = *rec;
|
||||
}
|
||||
|
||||
void *input_thread_loop(struct InputThreadHandle *hand)
|
||||
void *input_thread_loop(void *arg)
|
||||
{
|
||||
struct InputThreadHandle *hand = arg;
|
||||
struct InputBuffer tmp_buf = { .len = 0, .start = 0 };
|
||||
|
||||
while (!hand->is_terminating) {
|
||||
printf("\tinput cycle");
|
||||
if (!PlatformReadInput(&tmp_buf)) {
|
||||
hand->err = true;
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
hand->err = pthread_mutex_lock(&hand->mutex);
|
||||
if (hand->err)
|
||||
return;
|
||||
return nullptr;
|
||||
|
||||
InputBufferTransfer(&tmp_buf, hand->buf);
|
||||
|
||||
hand->err = pthread_mutex_unlock(&hand->mutex);
|
||||
if (hand->err)
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool BeginInputThread(struct InputThreadHandle *hand, struct InputBuffer *buf)
|
||||
|
|
|
@ -88,7 +88,7 @@ bool copy_mouse_event(struct InputRecord *rec, MOUSE_EVENT_RECORD *win_mouse)
|
|||
return true;
|
||||
}
|
||||
|
||||
if (win_mouse->dwEventFlags & (MOUSE_WHEELED | MOUSE_HWHEELED) != 0) {
|
||||
if ((win_mouse->dwEventFlags & (MOUSE_WHEELED | MOUSE_HWHEELED)) != 0) {
|
||||
rec->type = AXIS;
|
||||
rec->bind = win_mouse->dwEventFlags == MOUSE_WHEELED;
|
||||
rec->axis.value = win_mouse->dwButtonState;
|
||||
|
|
|
@ -33,7 +33,17 @@ int main()
|
|||
if (!BeginInputThread(&input, &ctrl.buf))
|
||||
ErrorExit("Input handle failed to initialize");
|
||||
|
||||
printf("woah");
|
||||
CtrlMap(&ctrl, 0, BUTTON, 'A');
|
||||
|
||||
while (true) {
|
||||
bool poll = CtrlPoll(&ctrl);
|
||||
printf("poll: %u\n", poll);
|
||||
|
||||
struct InputAxis *a = CtrlGet(&ctrl, 0, BUTTON);
|
||||
printf("get: %llu\n", a);
|
||||
|
||||
printf("val: %u\n", a->but.value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue