diff --git a/dev_in.c b/dev_in.c index 3a872a5..fb5814e 100644 --- a/dev_in.c +++ b/dev_in.c @@ -532,7 +532,7 @@ void* dev_in_thread_func(void *ptr) { if (dev_in_data->communication.type == ipc_client_socket) { for (int msg_idx = 0; msg_idx < controller_msg_count; ++msg_idx) { - const int write_res = write(dev_in_data->communication.endpoint.socket.fd, (void*)&controller_msg[0], sizeof(in_message_t)); + const int write_res = write(dev_in_data->communication.endpoint.socket.fd, (void*)&controller_msg[msg_idx], sizeof(in_message_t)); if (write_res < 0) { fprintf(stderr, "Error in writing input event messages: %d -- connection will be drop and retried\n", write_res); @@ -543,7 +543,7 @@ void* dev_in_thread_func(void *ptr) { } } else if (dev_in_data->communication.type == ipc_unix_pipe) { for (int msg_idx = 0; msg_idx < controller_msg_count; ++msg_idx) { - const int write_res = write(dev_in_data->communication.endpoint.pipe.in_message_pipe_fd, (void*)&controller_msg[0], sizeof(in_message_t)); + const int write_res = write(dev_in_data->communication.endpoint.pipe.in_message_pipe_fd, (void*)&controller_msg[msg_idx], sizeof(in_message_t)); if (write_res < 0) { fprintf(stderr, "Error in writing input event messages: %d\n", write_res); } diff --git a/dev_out.c b/dev_out.c index 43e7319..27b4209 100644 --- a/dev_out.c +++ b/dev_out.c @@ -326,7 +326,7 @@ void *dev_out_thread_func(void *ptr) { // send out game-generated events to sockets if (dev_out_data->communication.type == ipc_unix_pipe) { for (int msg_idx = 0; msg_idx < out_msgs_count; ++msg_idx) { - const int write_res = write(dev_out_data->communication.endpoint.pipe.out_message_pipe_fd, (void*)&out_msgs, sizeof(out_message_t)); + const int write_res = write(dev_out_data->communication.endpoint.pipe.out_message_pipe_fd, (void*)&out_msgs[msg_idx], sizeof(out_message_t)); if (write_res != sizeof(out_message_t)) { fprintf(stderr, "Error in writing out_message to out_message_pipe: %d\n", write_res); } @@ -336,7 +336,7 @@ void *dev_out_thread_func(void *ptr) { for (int i = 0; i < MAX_CONNECTED_CLIENTS; ++i) { if (dev_out_data->communication.endpoint.ssocket.clients[i] > 0) { for (int msg_idx = 0; msg_idx < out_msgs_count; ++msg_idx) { - const int write_res = write(dev_out_data->communication.endpoint.ssocket.clients[i], (void*)&out_msgs, sizeof(out_message_t)); + const int write_res = write(dev_out_data->communication.endpoint.ssocket.clients[i], (void*)&out_msgs[msg_idx], sizeof(out_message_t)); if (write_res != sizeof(out_message_t)) { fprintf(stderr, "Error in writing out_message to socket number %d: %d\n", i, write_res); close(dev_out_data->communication.endpoint.ssocket.clients[i]);