Compare commits

..

No commits in common. "main" and "sandia" have entirely different histories.
main ... sandia

7 changed files with 7 additions and 99 deletions

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "source/sandia"]
path = source/sandia
url = https://git.donut.eu.org/libreshop/sandia-Wii.git
url = https://git.donut.eu.org/nez/sandia-Wii.git

View File

@ -33,13 +33,13 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS := -lwiiuse -lbte -logc -lm -ljansson
LIBS := -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS)
LIBDIRS :=
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional

View File

@ -1,17 +0,0 @@
// debug features for libreshop_client
#include <stdio.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
void debug_pause() {
while(1) {
WPAD_ScanPads();
if (WPAD_ButtonsDown(0)) break;
}
}
void debug_npause() {
printf("Press any button to continue...\n");
VIDEO_WaitVSync();
debug_pause();
}

View File

@ -1,7 +0,0 @@
#ifndef DEBUG_H
#define DEBUG_H
void debug_pause();
void debug_npause();
#endif

View File

@ -1,24 +0,0 @@
#ifndef INPUT_MACROS_H
#define INPUT_MACROS_H
#include <wiiuse/wpad.h>
// Input definitions table
// TODO: GameCube controller support
// Macro name Classic Controller Wii Remote
#define INPUT_BUTTON_HOME (WPAD_CLASSIC_BUTTON_HOME || WPAD_BUTTON_HOME )
#define INPUT_BUTTON_PLUS (WPAD_CLASSIC_BUTTON_PLUS || WPAD_BUTTON_PLUS )
#define INPUT_BUTTON_MINUS (WPAD_CLASSIC_BUTTON_MINUS || WPAD_BUTTON_MINUS )
#define INPUT_BUTTON_A (WPAD_CLASSIC_BUTTON_Y || WPAD_BUTTON_A )
#define INPUT_BUTTON_B (WPAD_CLASSIC_BUTTON_B || WPAD_BUTTON_B )
#define INPUT_BUTTON_X (WPAD_CLASSIC_BUTTON_X || WPAD_BUTTON_1 )
#define INPUT_BUTTON_Y (WPAD_CLASSIC_BUTTON_A || WPAD_BUTTON_2 )
#define INPUT_BUTTON_UP (WPAD_CLASSIC_BUTTON_UP || WPAD_BUTTON_UP )
#define INPUT_BUTTON_DOWN (WPAD_CLASSIC_BUTTON_DOWN || WPAD_BUTTON_DOWN )
#define INPUT_BUTTON_LEFT (WPAD_CLASSIC_BUTTON_LEFT || WPAD_BUTTON_LEFT )
#define INPUT_BUTTON_RIGHT (WPAD_CLASSIC_BUTTON_RIGHT || WPAD_BUTTON_RIGHT )
#endif // INPUT_MACROS_H

View File

@ -3,16 +3,9 @@
#include <gccore.h>
#include <network.h>
#include <wiiuse/wpad.h>
#include <jansson.h>
#include <stdbool.h>
#include "sandia/sandia.h"
#include "input_macros.h"
// Uncomment if this is a development build
//#include "debug.h"
static void *xfb = NULL;
static GXRModeObj *rmode = NULL;
@ -33,10 +26,8 @@ void logprint(int type, char *message) {
break;
case 2:
printf("\x1b[34m[\x1b[31m--\x1b[34m]");
break;
case 3:
printf("\x1b[31m!!\x1b[34m]");
break;
default:
printf(" ");
}
@ -77,9 +68,6 @@ int main(int argc, char **argv) {
printheader();
logprint(0, "Welcome to LibreShop!\n");
#ifdef DEBUG_H
logprint(2, "Warning! You are running a DEBUG build.\n");
#endif
logprint(0, "Initializing network.\n");
ret = if_config(localip, netmask, gateway, TRUE, 20);
@ -91,39 +79,7 @@ int main(int argc, char **argv) {
sandia req = sandia_create("libreshop.donut.eu.org", 80);
sandia_response res = sandia_get_request(&req, "/");
bool lastWasNewline = false;
int resBodyLength = strlen(res.body);
for (int i = 0; i < resBodyLength; i++) {
if (res.body[i] == '\r') continue;
if (res.body[i] == '\n') {
if (lastWasNewline) {
int rBL = resBodyLength - i;
char* body = malloc(rBL);
for (int j = 0; j < rBL; j++) {
body[j] = res.body[j + i + 1];
}
json_error_t error;
json_t *root = json_loads(body, 0, &error);
if (!root || !json_is_array(root)) {
printf("failed decoding\n");
}
else {
printf("%s\n", body);
for (int j = 0; j < json_array_size(root); j++) {
json_t *data = json_array_get(root, j);
printf("%s\n", json_string_value(data));
}
}
break;
}
else lastWasNewline = true;
}
else lastWasNewline = false;
}
printf("\n");
printf("\n%s\n", res.body);
sandia_close(&req);
} else {
logprint(0, "Network configuration failed :(\n");
@ -134,8 +90,8 @@ int main(int argc, char **argv) {
u32 pressed = WPAD_ButtonsDown(0);
if ( pressed && INPUT_BUTTON_HOME ) {
logprint(0, "HOME pressed, quitting!\n");
if ( pressed & WPAD_BUTTON_HOME ) {
logprint(0, "HOME pressed, quitting!");
exit(0);
}

@ -1 +1 @@
Subproject commit 8f4d62429b06bb851f03c21c7796ae69f78541a8
Subproject commit 9b383cdda825ab4ba2767102b06cbd5dc734dae9