From 21feb40039c53139dee3d8312a2fdb121cd6782c Mon Sep 17 00:00:00 2001 From: Banz99 <42299919+Banz99@users.noreply.github.com> Date: Fri, 6 Aug 2021 00:08:17 +0200 Subject: [PATCH] Minor code cleanup --- mc_mitm/source/mcmitm_config.cpp | 20 ++++++++++---------- mc_mitm/source/mcmitm_config.hpp | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mc_mitm/source/mcmitm_config.cpp b/mc_mitm/source/mcmitm_config.cpp index 042a298f..b1ed91fd 100644 --- a/mc_mitm/source/mcmitm_config.cpp +++ b/mc_mitm/source/mcmitm_config.cpp @@ -68,7 +68,7 @@ namespace ams::mitm { *out = atoi(value); } - void ParsePollingRate(const char *value, int32_t *out){ + void ParsePollingRate(const char *value, uint32_t *out){ int32_t temp=8; ParseInt(value, &temp); if(temp >= 0 && temp <= 16) @@ -76,7 +76,7 @@ namespace ams::mitm { else *out = 8; } - void ParseBrightness(const char *value, int32_t *out){ + void ParseBrightness(const char *value, uint32_t *out) { int32_t temp=8; ParseInt(value, &temp); if(temp >= 0 && temp <= 63) @@ -117,7 +117,7 @@ namespace ams::mitm { else *out = 0.0f; } - void ParseRGBstring(const char* value, controller::RGBColour *out){ + void ParseRGBstring(const char* value, controller::RGBColour *out) { uint8_t temp[3]; if (std::strncmp(value, "rgb(", 4) == 0) { value+=4; @@ -126,20 +126,20 @@ namespace ams::mitm { temp[0] = 0; temp[1] = 0; temp[2] = 0; - while(i= '0' && value[i] <= '9') { + while (i < str_len && value[i] !=')' && k <= 2){ + if (value[i] >= '0' && value[i] <= '9') { temp[k] *= 10; temp[k] += value[i] - '0'; } - else if(value[i] == ','){ + else if (value[i] == ','){ k++; } - else if(value[i] != ' ') //Ignore spaces if found + else if (value[i] != ' ') //Ignore spaces if found return; i++; } - if(k==2){ + if (k == 2){ out->r = temp[0]; out->g = temp[1]; out->b = temp[2]; @@ -147,7 +147,7 @@ namespace ams::mitm { } else if (value[0] == '#') { char buf[2 + 1]; - if(strlen(value)>=7){ + if (strlen(value) >= 7) { std::memcpy(buf, value + 1, 2); temp[0] = static_cast(std::strtoul(buf, nullptr, 16)); std::memcpy(buf, value + 3, 2); @@ -164,7 +164,7 @@ namespace ams::mitm { } Result StringifyBluetoothAddress(const bluetooth::Address *address, char *out, size_t out_size) { - if(out_size < 2*sizeof(bluetooth::Address) + 1) + if (out_size < 2*sizeof(bluetooth::Address) + 1) return -1; char ch; diff --git a/mc_mitm/source/mcmitm_config.hpp b/mc_mitm/source/mcmitm_config.hpp index 0dd4b97b..5d24bba2 100644 --- a/mc_mitm/source/mcmitm_config.hpp +++ b/mc_mitm/source/mcmitm_config.hpp @@ -44,8 +44,8 @@ namespace ams::mitm { struct { bool use_western_layout; - int32_t sony_led_brightness; - int32_t dualshock_pollingrate_divisor; + uint32_t sony_led_brightness; + uint32_t dualshock_pollingrate_divisor; bool swap_dpad_lstick; bool invert_lstick_xaxis; bool invert_lstick_yaxis;