Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Banz99 committed Aug 5, 2021
1 parent 89bd9f0 commit 21feb40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions mc_mitm/source/mcmitm_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ 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)
*out = temp;
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)
Expand Down Expand Up @@ -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;
Expand All @@ -126,28 +126,28 @@ namespace ams::mitm {
temp[0] = 0;
temp[1] = 0;
temp[2] = 0;
while(i<str_len && value[i] !=')' && k <= 2){
if(value[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];
}
}
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<uint8_t>(std::strtoul(buf, nullptr, 16));
std::memcpy(buf, value + 3, 2);
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions mc_mitm/source/mcmitm_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 21feb40

Please sign in to comment.