From 78491e79192897c50b4b8a4e644c0757b04a6d2d Mon Sep 17 00:00:00 2001 From: Hanno Rein Date: Sun, 5 Nov 2023 15:33:04 -0500 Subject: [PATCH] keybaord --- src/server.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/server.c b/src/server.c index 625f4ec13..d813c6f23 100644 --- a/src/server.c +++ b/src/server.c @@ -367,27 +367,28 @@ void* reb_server_start(void* args){ sendBytes(clientS, bufp, sizep); free(bufp); }else if (!strncasecmp(uri, "/keyboard/",10)) { - //int key = 0; - //sscanf(uri, "/keyboard/%d", &key); - //switch (key){ - // case 'Q': - // data->r->status = REB_STATUS_USER; + int key = 0; + sscanf(uri, "/keyboard/%d", &key); + switch (key){ + case 'Q': + data->r->status = REB_STATUS_USER; // fprintf(stream, "ok.\n"); - // break; - // case ' ': - // if (data->r->status == REB_STATUS_PAUSED){ - // printf("Resume.\n"); - // data->r->status = REB_STATUS_RUNNING; - // }else{ - // printf("Pause.\n"); - // data->r->status = REB_STATUS_PAUSED; - // } + break; + case ' ': + if (data->r->status == REB_STATUS_PAUSED){ + printf("Resume.\n"); + data->r->status = REB_STATUS_RUNNING; + }else{ + printf("Pause.\n"); + data->r->status = REB_STATUS_PAUSED; + } // fprintf(stream, "ok.\n"); - // break; - // default: - // fprintf(stream, "Unknown key received: %d\n",key); - // break; - //} + break; + default: + reb_server_cerror(clientS, "Unknown key received."); + continue; + break; + } //fflush(stream); }else if (!strcasecmp(uri, "/") || !strcasecmp(uri, "/index.html") || !strcasecmp(uri, "/rebound.html")) { FILE *f = fopen("rebound.html", "rb");