From 51f650139508331b6679aab30b46603263ac6342 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Thu, 14 Mar 2019 12:53:44 +0000 Subject: [PATCH 01/11] Handling network packet for exiting gimx --- core/controller.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/controller.c b/core/controller.c index e2f446c4..7371062c 100644 --- a/core/controller.c +++ b/core/controller.c @@ -203,6 +203,9 @@ static int network_read_callback(void * user) adapters[adapter].send_command = 1; } break; + case E_NETWORK_PACKET_EXIT: + set_done(1); + break; } // require a report to be sent immediately, except for a Sixaxis controller working over bluetooth if(adapters[adapter].ctype == C_TYPE_SIXAXIS && adapters[adapter].atype == E_ADAPTER_TYPE_BLUETOOTH) From ecf36ffdb43584015c1f282f7ef532202cf35456 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Thu, 21 Mar 2019 18:03:27 -0300 Subject: [PATCH 02/11] Set configuration through network --- core/calibration.c | 34 ++++++++++++++++++++++++++++++++++ core/controller.c | 23 +++++++++++++++++++++++ core/include/calibration.h | 3 +++ 3 files changed, 60 insertions(+) diff --git a/core/calibration.c b/core/calibration.c index e7acc66c..21fcb157 100644 --- a/core/calibration.c +++ b/core/calibration.c @@ -456,6 +456,40 @@ void cal_key(int sym, int down) #define DEADZONE_MAX(AXIS) \ (controller_get_mean_unsigned(ctype, AXIS) / controller_get_axis_scale(ctype, AXIS) / 2) +void cal_setSensibility(double s) +{ + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + double ratio = *mcal->my / *mcal->mx; + *mcal->mx = s; + *mcal->my = *mcal->mx * ratio; +} + +void cal_setDeadzoneX(int dx) +{ + e_controller_type ctype = adapter_get(cal_get_controller(current_mouse))->ctype; + s_mouse_control* mc = cfg_get_mouse_control(current_mouse); + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + if (mcal->dzx && dx < DEADZONE_MAX(rel_axis_rstick_x)) { + *mcal->dzx = dx; + mc->merge[mc->index].x = 1; + mc->merge[mc->index].y = 0; + mc->change = 1; + } + +} +void cal_setDeadzoneY(int dy) +{ + e_controller_type ctype = adapter_get(cal_get_controller(current_mouse))->ctype; + s_mouse_control* mc = cfg_get_mouse_control(current_mouse); + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + if (mcal->dzy && dy < DEADZONE_MAX(rel_axis_rstick_y)) { + *mcal->dzy = dy; + mc->merge[mc->index].x = 0; + mc->merge[mc->index].y = 1; + mc->change = 1; + } +} + /* * Use the mouse wheel to calibrate the mouse. */ diff --git a/core/controller.c b/core/controller.c index 7371062c..9f1ddd06 100644 --- a/core/controller.c +++ b/core/controller.c @@ -26,6 +26,8 @@ #include #include +#include "calibration.h" +#include #define BAUDRATE 500000 //bps #define SERIAL_TIMEOUT 1000 //millisecond @@ -136,6 +138,24 @@ static void adapter_dump_state(int adapter) gstatus("\n"); } +static void handlePacketConfig(const s_network_packet_config* buf) +{ + if (buf->sensibility < FLT_MAX) { + printf("setting sensibility=%f\n",buf->sensibility); + cal_setSensibility(buf->sensibility); + } + int dx=buf->dead_zone_X; + if (dx < INT16_MAX) { + printf("setting dx=%d\n",dx); + cal_setDeadzoneX(dx); + } + int dy=buf->dead_zone_Y; + if (dy < INT16_MAX) { + printf("setting dy=%d\n",dy); + cal_setDeadzoneY(dy); + } +} + /* * Read a packet from a remote GIMX client. * The packet can be: @@ -206,6 +226,9 @@ static int network_read_callback(void * user) case E_NETWORK_PACKET_EXIT: set_done(1); break; + case E_NETWORK_PACKET_SETCONFIG: + handlePacketConfig((s_network_packet_config*) buf); + break; } // require a report to be sent immediately, except for a Sixaxis controller working over bluetooth if(adapters[adapter].ctype == C_TYPE_SIXAXIS && adapters[adapter].atype == E_ADAPTER_TYPE_BLUETOOTH) diff --git a/core/include/calibration.h b/core/include/calibration.h index 84ec0d15..8d03c018 100644 --- a/core/include/calibration.h +++ b/core/include/calibration.h @@ -38,5 +38,8 @@ void cal_init(); int cal_get_controller(int); void cal_set_controller(int, int); void calibration_test(); +void cal_setSensibility(double); +void cal_setDeadzoneX(int); +void cal_setDeadzoneY(int); #endif /* CALIBRATION_H_ */ From baa66ef5a6cb7fa70bba3052cc2d747dc70ffb81 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Fri, 22 Mar 2019 11:26:16 -0300 Subject: [PATCH 03/11] get configuration through network --- core/controller.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/core/controller.c b/core/controller.c index 9f1ddd06..d86563e1 100644 --- a/core/controller.c +++ b/core/controller.c @@ -144,18 +144,29 @@ static void handlePacketConfig(const s_network_packet_config* buf) printf("setting sensibility=%f\n",buf->sensibility); cal_setSensibility(buf->sensibility); } - int dx=buf->dead_zone_X; + int16_t dx=ntohs(buf->dead_zone_X); if (dx < INT16_MAX) { printf("setting dx=%d\n",dx); cal_setDeadzoneX(dx); } - int dy=buf->dead_zone_Y; + int16_t dy=ntohs(buf->dead_zone_Y); if (dy < INT16_MAX) { printf("setting dy=%d\n",dy); cal_setDeadzoneY(dy); } } +static s_network_packet_config handlePacketGetConfig() +{ + s_network_packet_config config_pkg; + const s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + config_pkg.packet_type = E_NETWORK_PACKET_GETCONFIG; + config_pkg.sensibility = *mcal->mx; + config_pkg.dead_zone_X = htons(*mcal->dzx); + config_pkg.dead_zone_Y = htons(*mcal->dzy); + return config_pkg; +} + /* * Read a packet from a remote GIMX client. * The packet can be: @@ -227,8 +238,20 @@ static int network_read_callback(void * user) set_done(1); break; case E_NETWORK_PACKET_SETCONFIG: + handlePacketConfig((s_network_packet_config*) buf); break; + case E_NETWORK_PACKET_GETCONFIG: + { + s_network_packet_config config_pkg = handlePacketGetConfig(); + if (udp_sendto(adapters[adapter].src_fd, (void *) &config_pkg, sizeof(config_pkg), (struct sockaddr*) &sa, salen) < 0) { + gwarn("%s: can't send configuration values\n", __func__); + return 0; + } + break; + } + default: + gwarn("%s: packet_type not recognized",__func__); } // require a report to be sent immediately, except for a Sixaxis controller working over bluetooth if(adapters[adapter].ctype == C_TYPE_SIXAXIS && adapters[adapter].atype == E_ADAPTER_TYPE_BLUETOOTH) From b305de7c05d2ca9e0f289774232e4b5f854ff14d Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Fri, 22 Mar 2019 19:06:01 -0300 Subject: [PATCH 04/11] Fixed network byte order on network API --- core/controller.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/core/controller.c b/core/controller.c index d86563e1..2ef79e84 100644 --- a/core/controller.c +++ b/core/controller.c @@ -138,20 +138,33 @@ static void adapter_dump_state(int adapter) gstatus("\n"); } +static float float_swap(float x) +{ + union V { + float f; + uint32_t i; + }; + union V val; + val.f = x; + val.i = htonl(val.i); + return val.f; +} + static void handlePacketConfig(const s_network_packet_config* buf) { - if (buf->sensibility < FLT_MAX) { - printf("setting sensibility=%f\n",buf->sensibility); - cal_setSensibility(buf->sensibility); + float s = float_swap(buf->sensibility); + if (s < FLT_MAX && s >= 0) { + printf("setting sensibility=%f\n", s); + cal_setSensibility(s); } - int16_t dx=ntohs(buf->dead_zone_X); + int16_t dx = ntohs(buf->dead_zone_X); if (dx < INT16_MAX) { - printf("setting dx=%d\n",dx); + printf("setting dx=%d\n", dx); cal_setDeadzoneX(dx); } - int16_t dy=ntohs(buf->dead_zone_Y); + int16_t dy = ntohs(buf->dead_zone_Y); if (dy < INT16_MAX) { - printf("setting dy=%d\n",dy); + printf("setting dy=%d\n", dy); cal_setDeadzoneY(dy); } } @@ -161,7 +174,7 @@ static s_network_packet_config handlePacketGetConfig() s_network_packet_config config_pkg; const s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); config_pkg.packet_type = E_NETWORK_PACKET_GETCONFIG; - config_pkg.sensibility = *mcal->mx; + config_pkg.sensibility = float_swap(*mcal->mx); config_pkg.dead_zone_X = htons(*mcal->dzx); config_pkg.dead_zone_Y = htons(*mcal->dzy); return config_pkg; From 289d26b5ead91bda7c0322bb6077fb6a593e3e18 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Thu, 28 Mar 2019 11:08:55 -0300 Subject: [PATCH 05/11] Network api for saving calibration --- core/calibration.c | 34 ++++++++++++++++++++-------------- core/controller.c | 6 ++++++ core/include/calibration.h | 2 ++ 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/core/calibration.c b/core/calibration.c index 21fcb157..937075f0 100644 --- a/core/calibration.c +++ b/core/calibration.c @@ -273,6 +273,24 @@ static void cal_display() } } +void cal_save() +{ + current_cal = NONE; + if (cfgw_modify_file(gimx_params.config_file)) { + gwarn(_("error writting the config file %s\n"), gimx_params.config_file); + } + ginfo(_("calibration done\n")); +} + +void cal_update_display() +{ + if (gimx_params.curses) { + display_calibration(); + } else { + cal_display(); + } +} + /* * Use keys to calibrate the mouse. */ @@ -319,12 +337,7 @@ void cal_key(int sym, int down) } else { - current_cal = NONE; - if (cfgw_modify_file(gimx_params.config_file)) - { - gwarn(_("error writting the config file %s\n"), gimx_params.config_file); - } - ginfo(_("calibration done\n")); + cal_save(); } } else if(current_cal != NONE) @@ -442,14 +455,7 @@ void cal_key(int sym, int down) if(prev != current_cal) { - if(gimx_params.curses) - { - display_calibration(); - } - else - { - cal_display(); - } + cal_update_display(); } } diff --git a/core/controller.c b/core/controller.c index 2ef79e84..4c3900fe 100644 --- a/core/controller.c +++ b/core/controller.c @@ -263,6 +263,12 @@ static int network_read_callback(void * user) } break; } + case E_NETWORK_PACKET_SAVECALIBRATION: + { + cal_save(); + cal_update_display(); + break; + } default: gwarn("%s: packet_type not recognized",__func__); } diff --git a/core/include/calibration.h b/core/include/calibration.h index 8d03c018..99a1ceac 100644 --- a/core/include/calibration.h +++ b/core/include/calibration.h @@ -41,5 +41,7 @@ void calibration_test(); void cal_setSensibility(double); void cal_setDeadzoneX(int); void cal_setDeadzoneY(int); +void cal_save(); +void cal_update_display(); #endif /* CALIBRATION_H_ */ From 1add0f1b8bde3717cbef2671b7d100f88f818d8f Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Mon, 8 Apr 2019 21:52:55 -0300 Subject: [PATCH 06/11] New packet types definition --- shared/gimx-network-protocol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/gimx-network-protocol b/shared/gimx-network-protocol index a4b269da..077351da 160000 --- a/shared/gimx-network-protocol +++ b/shared/gimx-network-protocol @@ -1 +1 @@ -Subproject commit a4b269da0b35df9e4aea2000868fadbd1326af53 +Subproject commit 077351da250b001dd8b7e4a682fd8fdd775ec2d1 From bb2b2047b20afc6ed809918f79190b05f45374f4 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Fri, 12 Apr 2019 08:41:00 -0300 Subject: [PATCH 07/11] Check for packet size; Changed code style; --- .gitmodules | 2 +- core/calibration.c | 6 +++--- core/controller.c | 18 ++++++++++-------- core/include/calibration.h | 6 +++--- shared/gimx-network-protocol | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.gitmodules b/.gitmodules index 3be32c7a..bc412e46 100644 --- a/.gitmodules +++ b/.gitmodules @@ -30,7 +30,7 @@ url = https://github.com/matlo/gimxcommon.git [submodule "shared/gimx-network-protocol"] path = shared/gimx-network-protocol - url = https://github.com/matlo/gimx-network-protocol.git + url = https://github.com/Lucashsmello/gimx-network-protocol.git [submodule "shared/gimxlog"] path = shared/gimxlog url = https://github.com/matlo/gimxlog.git diff --git a/core/calibration.c b/core/calibration.c index 937075f0..efed094d 100644 --- a/core/calibration.c +++ b/core/calibration.c @@ -462,7 +462,7 @@ void cal_key(int sym, int down) #define DEADZONE_MAX(AXIS) \ (controller_get_mean_unsigned(ctype, AXIS) / controller_get_axis_scale(ctype, AXIS) / 2) -void cal_setSensibility(double s) +void cal_set_sensibility(double s) { s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); double ratio = *mcal->my / *mcal->mx; @@ -470,7 +470,7 @@ void cal_setSensibility(double s) *mcal->my = *mcal->mx * ratio; } -void cal_setDeadzoneX(int dx) +void cal_set_deadzone_x(int dx) { e_controller_type ctype = adapter_get(cal_get_controller(current_mouse))->ctype; s_mouse_control* mc = cfg_get_mouse_control(current_mouse); @@ -483,7 +483,7 @@ void cal_setDeadzoneX(int dx) } } -void cal_setDeadzoneY(int dy) +void cal_set_deadzone_y(int dy) { e_controller_type ctype = adapter_get(cal_get_controller(current_mouse))->ctype; s_mouse_control* mc = cfg_get_mouse_control(current_mouse); diff --git a/core/controller.c b/core/controller.c index 4c3900fe..cd63c55b 100644 --- a/core/controller.c +++ b/core/controller.c @@ -153,19 +153,16 @@ static float float_swap(float x) static void handlePacketConfig(const s_network_packet_config* buf) { float s = float_swap(buf->sensibility); - if (s < FLT_MAX && s >= 0) { - printf("setting sensibility=%f\n", s); - cal_setSensibility(s); + if (s >= 0) { + cal_set_sensibility(s); } int16_t dx = ntohs(buf->dead_zone_X); if (dx < INT16_MAX) { - printf("setting dx=%d\n", dx); - cal_setDeadzoneX(dx); + cal_set_deadzone_x(dx); } int16_t dy = ntohs(buf->dead_zone_Y); if (dy < INT16_MAX) { - printf("setting dy=%d\n", dy); - cal_setDeadzoneY(dy); + cal_set_deadzone_y(dy); } } @@ -251,7 +248,11 @@ static int network_read_callback(void * user) set_done(1); break; case E_NETWORK_PACKET_SETCONFIG: - + if ((unsigned int) nread != sizeof(s_network_packet_config)) + { + gwarn("%s: wrong packet size: %u %zu\n", __func__, nread, sizeof(s_network_packet_config)); + return 0; + } handlePacketConfig((s_network_packet_config*) buf); break; case E_NETWORK_PACKET_GETCONFIG: @@ -271,6 +272,7 @@ static int network_read_callback(void * user) } default: gwarn("%s: packet_type not recognized",__func__); + break; } // require a report to be sent immediately, except for a Sixaxis controller working over bluetooth if(adapters[adapter].ctype == C_TYPE_SIXAXIS && adapters[adapter].atype == E_ADAPTER_TYPE_BLUETOOTH) diff --git a/core/include/calibration.h b/core/include/calibration.h index 99a1ceac..1ad72e8d 100644 --- a/core/include/calibration.h +++ b/core/include/calibration.h @@ -38,9 +38,9 @@ void cal_init(); int cal_get_controller(int); void cal_set_controller(int, int); void calibration_test(); -void cal_setSensibility(double); -void cal_setDeadzoneX(int); -void cal_setDeadzoneY(int); +void cal_set_sensibility(double); +void cal_set_deadzone_x(int); +void cal_set_deadzone_y(int); void cal_save(); void cal_update_display(); diff --git a/shared/gimx-network-protocol b/shared/gimx-network-protocol index 077351da..d304b1ea 160000 --- a/shared/gimx-network-protocol +++ b/shared/gimx-network-protocol @@ -1 +1 @@ -Subproject commit 077351da250b001dd8b7e4a682fd8fdd775ec2d1 +Subproject commit d304b1ea09e0d5d5570725f1aac3dd5265632c3e From c88ba15bdae7290f088cbb7512ce7c0623f5ef08 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Fri, 12 Apr 2019 08:53:33 -0300 Subject: [PATCH 08/11] Code style --- core/controller.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/controller.c b/core/controller.c index cd63c55b..be40ed8d 100644 --- a/core/controller.c +++ b/core/controller.c @@ -150,7 +150,7 @@ static float float_swap(float x) return val.f; } -static void handlePacketConfig(const s_network_packet_config* buf) +static void handle_packet_config(const s_network_packet_config* buf) { float s = float_swap(buf->sensibility); if (s >= 0) { @@ -166,7 +166,7 @@ static void handlePacketConfig(const s_network_packet_config* buf) } } -static s_network_packet_config handlePacketGetConfig() +static s_network_packet_config handle_packet_get_config() { s_network_packet_config config_pkg; const s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); @@ -253,11 +253,11 @@ static int network_read_callback(void * user) gwarn("%s: wrong packet size: %u %zu\n", __func__, nread, sizeof(s_network_packet_config)); return 0; } - handlePacketConfig((s_network_packet_config*) buf); + handle_packet_config((s_network_packet_config*) buf); break; case E_NETWORK_PACKET_GETCONFIG: { - s_network_packet_config config_pkg = handlePacketGetConfig(); + s_network_packet_config config_pkg = handle_packet_get_config(); if (udp_sendto(adapters[adapter].src_fd, (void *) &config_pkg, sizeof(config_pkg), (struct sockaddr*) &sa, salen) < 0) { gwarn("%s: can't send configuration values\n", __func__); return 0; From 43d3f0c2fd652082a5da0c13710abb20c7e6fda8 Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Sun, 14 Apr 2019 15:15:01 -0300 Subject: [PATCH 09/11] Set exponent and yx_ratio through network --- core/calibration.c | 29 +++++++++++++++++++++++++++++ core/controller.c | 26 +++++++++++++++++++++----- core/include/calibration.h | 3 +++ shared/gimx-network-protocol | 2 +- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/core/calibration.c b/core/calibration.c index efed094d..69d396d0 100644 --- a/core/calibration.c +++ b/core/calibration.c @@ -496,6 +496,35 @@ void cal_set_deadzone_y(int dy) } } +void cal_set_exponent_x(double e) +{ + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + if (mcal->ex) + { + *mcal->ex = e; + } +} + +void cal_set_exponent_y(double e) +{ + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + if (mcal->ey) + { + *mcal->ey = e; + } +} + +/** + * This function does *only* changes the sensibility on the vertical axis so that y/x = r. + */ +void cal_set_yxratio(double r){ + s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); + if (mcal->mx && mcal->my) + { + *mcal->my = *mcal->mx * r; + } +} + /* * Use the mouse wheel to calibrate the mouse. */ diff --git a/core/controller.c b/core/controller.c index be40ed8d..a80cea88 100644 --- a/core/controller.c +++ b/core/controller.c @@ -152,18 +152,31 @@ static float float_swap(float x) static void handle_packet_config(const s_network_packet_config* buf) { + float ex, ey, yx_ratio; float s = float_swap(buf->sensibility); - if (s >= 0) { + if (s >= 0) { //Does negative sensibility makes sense? cal_set_sensibility(s); } - int16_t dx = ntohs(buf->dead_zone_X); + int16_t dx = ntohs(buf->dead_zone_x); if (dx < INT16_MAX) { cal_set_deadzone_x(dx); } - int16_t dy = ntohs(buf->dead_zone_Y); + int16_t dy = ntohs(buf->dead_zone_y); if (dy < INT16_MAX) { cal_set_deadzone_y(dy); } + ex = float_swap(buf->exponent_x); + if (ex >= 0) { + cal_set_exponent_x(ex); + } + ey = float_swap(buf->exponent_y); + if (ey >= 0) { + cal_set_exponent_y(ey); + } + yx_ratio = float_swap(buf->yx_ratio); + if (yx_ratio >= 0) { + cal_set_yxratio(yx_ratio); + } } static s_network_packet_config handle_packet_get_config() @@ -172,8 +185,11 @@ static s_network_packet_config handle_packet_get_config() const s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); config_pkg.packet_type = E_NETWORK_PACKET_GETCONFIG; config_pkg.sensibility = float_swap(*mcal->mx); - config_pkg.dead_zone_X = htons(*mcal->dzx); - config_pkg.dead_zone_Y = htons(*mcal->dzy); + config_pkg.dead_zone_x = htons(*mcal->dzx); + config_pkg.dead_zone_y = htons(*mcal->dzy); + config_pkg.yx_ratio = float_swap((*mcal->my) / (*mcal->mx)); + config_pkg.exponent_x = float_swap(*mcal->ex); + config_pkg.exponent_y = float_swap(*mcal->ey); return config_pkg; } diff --git a/core/include/calibration.h b/core/include/calibration.h index 1ad72e8d..de752513 100644 --- a/core/include/calibration.h +++ b/core/include/calibration.h @@ -41,6 +41,9 @@ void calibration_test(); void cal_set_sensibility(double); void cal_set_deadzone_x(int); void cal_set_deadzone_y(int); +void cal_set_exponent_x(double); +void cal_set_exponent_y(double); +void cal_set_yxratio(double); void cal_save(); void cal_update_display(); diff --git a/shared/gimx-network-protocol b/shared/gimx-network-protocol index d304b1ea..605c07b9 160000 --- a/shared/gimx-network-protocol +++ b/shared/gimx-network-protocol @@ -1 +1 @@ -Subproject commit d304b1ea09e0d5d5570725f1aac3dd5265632c3e +Subproject commit 605c07b93ddf3409d2d7cc90e8f418c2d4258e3b From 3adfcdea56090122fe3215b9804e4249a3c1152c Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Sun, 14 Apr 2019 15:42:51 -0300 Subject: [PATCH 10/11] Fixed changed config values not appearing on "--curses" interface when using network api. --- core/controller.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/controller.c b/core/controller.c index a80cea88..a4fee92b 100644 --- a/core/controller.c +++ b/core/controller.c @@ -270,6 +270,7 @@ static int network_read_callback(void * user) return 0; } handle_packet_config((s_network_packet_config*) buf); + cal_update_display(); break; case E_NETWORK_PACKET_GETCONFIG: { From 7993984a49513073ad44f7f8595ddadcf494ec1e Mon Sep 17 00:00:00 2001 From: Lucashsmello Date: Tue, 9 Feb 2021 23:10:39 -0300 Subject: [PATCH 11/11] small adaptations for GIMX 8.0 udp module --- core/controller.c | 16 ++++++++-------- shared/gimxudp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/controller.c b/core/controller.c index 969daab3..ab1a28d9 100644 --- a/core/controller.c +++ b/core/controller.c @@ -320,7 +320,7 @@ static float float_swap(float x) }; union V val; val.f = x; - val.i = htonl(val.i); + val.i = gudp_htonl(val.i); return val.f; } @@ -331,11 +331,11 @@ static void handle_packet_config(const s_network_packet_config* buf) if (s >= 0) { //Does negative sensibility makes sense? cal_set_sensibility(s); } - int16_t dx = ntohs(buf->dead_zone_x); + int16_t dx = gudp_ntohs(buf->dead_zone_x); if (dx < INT16_MAX) { cal_set_deadzone_x(dx); } - int16_t dy = ntohs(buf->dead_zone_y); + int16_t dy = gudp_ntohs(buf->dead_zone_y); if (dy < INT16_MAX) { cal_set_deadzone_y(dy); } @@ -359,8 +359,8 @@ static s_network_packet_config handle_packet_get_config() const s_mouse_cal* mcal = cal_get_mouse(current_mouse, current_conf); config_pkg.packet_type = E_NETWORK_PACKET_GETCONFIG; config_pkg.sensibility = float_swap(*mcal->mx); - config_pkg.dead_zone_x = htons(*mcal->dzx); - config_pkg.dead_zone_y = htons(*mcal->dzy); + config_pkg.dead_zone_x = gudp_htons(*mcal->dzx); + config_pkg.dead_zone_y = gudp_htons(*mcal->dzy); config_pkg.yx_ratio = float_swap((*mcal->my) / (*mcal->mx)); config_pkg.exponent_x = float_swap(*mcal->ex); config_pkg.exponent_y = float_swap(*mcal->ey); @@ -434,9 +434,9 @@ static int network_read_callback(void * user, const void * buf, int status, stru set_done(1); break; case E_NETWORK_PACKET_SETCONFIG: - if ((unsigned int) nread != sizeof(s_network_packet_config)) + if ((unsigned int) status != sizeof(s_network_packet_config)) { - gwarn("%s: wrong packet size: %u %zu\n", __func__, nread, sizeof(s_network_packet_config)); + gwarn("%s: wrong packet size: %u %zu\n", __func__, status, sizeof(s_network_packet_config)); return 0; } handle_packet_config((s_network_packet_config*) buf); @@ -445,7 +445,7 @@ static int network_read_callback(void * user, const void * buf, int status, stru case E_NETWORK_PACKET_GETCONFIG: { s_network_packet_config config_pkg = handle_packet_get_config(); - if (udp_sendto(adapters[adapter].src_fd, (void *) &config_pkg, sizeof(config_pkg), (struct sockaddr*) &sa, salen) < 0) { + if (gudp_send(adapters[adapter].src_socket, (void *) &config_pkg, sizeof(config_pkg), address) < 0) { gwarn("%s: can't send configuration values\n", __func__); return 0; } diff --git a/shared/gimxudp b/shared/gimxudp index 472e4629..8894f5d3 160000 --- a/shared/gimxudp +++ b/shared/gimxudp @@ -1 +1 @@ -Subproject commit 472e4629f6c756e12ead616fcf1c653a95438bdf +Subproject commit 8894f5d36c047ff1a044a5144d3680cd5130cab9