Skip to content

Commit

Permalink
Hold direction buttons to change IP
Browse files Browse the repository at this point in the history
  • Loading branch information
Crayon2000 committed May 25, 2024
1 parent 3cedb82 commit 301cab5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- TBD
- Hold direction buttons to change IP.

## [1.3.0] - 2024-03-18

Expand Down
32 changes: 24 additions & 8 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,36 @@ int main(int argc, char **argv)

bool running = true;

uint32_t wait_time_horizontal = 0;
uint32_t wait_time_vertical = 0;
const uint8_t wait_time = 14;

// Insert the IP address (some code was taken from the IP Address selector of geckiine made by brienj)
while(running == true) {
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &error);
if (vpad_data.trigger & VPAD_BUTTON_LEFT && selected_digit > 0) {
selected_digit--;
if (vpad_data.hold & VPAD_BUTTON_LEFT) {
if (vpad_data.trigger & VPAD_BUTTON_LEFT || wait_time_horizontal++ > wait_time) {
selected_digit--;
wait_time_horizontal = 0;
}
}
if (vpad_data.trigger & VPAD_BUTTON_RIGHT && selected_digit < 3) {
selected_digit++;
if (vpad_data.hold & VPAD_BUTTON_RIGHT) {
if (vpad_data.trigger & VPAD_BUTTON_RIGHT || wait_time_horizontal++ > wait_time) {
selected_digit++;
wait_time_horizontal = 0;
}
}
if (vpad_data.trigger & VPAD_BUTTON_UP) {
IP[selected_digit] = (IP[selected_digit] < 255) ? (IP[selected_digit] + 1) : 0;
if (vpad_data.hold & VPAD_BUTTON_UP) {
if (vpad_data.trigger & VPAD_BUTTON_UP || wait_time_vertical++ > wait_time) {
IP[selected_digit] = (IP[selected_digit] < 255) ? (IP[selected_digit] + 1) : 0;
wait_time_vertical = 0;
}
}
if (vpad_data.trigger & VPAD_BUTTON_DOWN) {
IP[selected_digit] = (IP[selected_digit] > 0) ? (IP[selected_digit] - 1) : 255;
if (vpad_data.hold & VPAD_BUTTON_DOWN) {
if (vpad_data.trigger & VPAD_BUTTON_DOWN || wait_time_vertical++ > wait_time) {
IP[selected_digit] = (IP[selected_digit] > 0) ? (IP[selected_digit] - 1) : 255;
wait_time_vertical = 0;
}
}

if(ConsoleDrawStart() == true) {
Expand Down
6 changes: 3 additions & 3 deletions source/vpad_to_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ void pad_to_json(PADData pad_data, char* out, uint32_t out_size)
json_t *extension = json_object();
json_object_set_new_nocheck(wiiremote, "extension", extension);
json_object_set_new_nocheck(extension, "type", json_string("nunchuk"));
json_object_set_new_nocheck(extension, "hold", json_integer(pad_data.kpad[i]->nunchuck.hold));
json_object_set_new_nocheck(extension, "stickX", json_real(pad_data.kpad[i]->nunchuck.stick.x));
json_object_set_new_nocheck(extension, "stickY", json_real(pad_data.kpad[i]->nunchuck.stick.y));
json_object_set_new_nocheck(extension, "hold", json_integer(pad_data.kpad[i]->nunchuk.hold));
json_object_set_new_nocheck(extension, "stickX", json_real(pad_data.kpad[i]->nunchuk.stick.x));
json_object_set_new_nocheck(extension, "stickY", json_real(pad_data.kpad[i]->nunchuk.stick.y));
}
break;
case WPAD_EXT_CLASSIC:
Expand Down

0 comments on commit 301cab5

Please sign in to comment.