forked from libreshop/libreshop_client
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
086116422f | |||
1bf7af7226 | |||
dc8d2ab523 | |||
1b0469f5de | |||
b8ee888756 | |||
1a9807450f | |||
2fd1b3f10e | |||
3cb478a7d2 | |||
efd99afe06 | |||
a1c4428d37 | |||
27cdc9cc0b | |||
6f627a88aa | |||
b15de193d5 | |||
0ebd26d561 | |||
d9593f3fa0 | |||
51a1bf7f0e | |||
630133f77a | |||
df30905389 | |||
7003a9c8a3 | |||
c6bbfcac10 |
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "source/sandia"]
|
[submodule "source/sandia"]
|
||||||
path = source/sandia
|
path = source/sandia
|
||||||
url = https://git.donut.eu.org/nez/sandia-Wii.git
|
url = https://git.donut.eu.org/libreshop/sandia-Wii.git
|
||||||
|
4
Makefile
4
Makefile
@ -33,13 +33,13 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
|||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# any extra libraries we wish to link with the project
|
# any extra libraries we wish to link with the project
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBS := -lwiiuse -lbte -logc -lm
|
LIBS := -lwiiuse -lbte -logc -lm -ljansson
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
# include and lib
|
# include and lib
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
LIBDIRS :=
|
LIBDIRS := $(PORTLIBS)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# no real need to edit anything past this point unless you need to add additional
|
# no real need to edit anything past this point unless you need to add additional
|
||||||
|
17
source/debug.c
Normal file
17
source/debug.c
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// 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();
|
||||||
|
}
|
7
source/debug.h
Normal file
7
source/debug.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef DEBUG_H
|
||||||
|
#define DEBUG_H
|
||||||
|
|
||||||
|
void debug_pause();
|
||||||
|
void debug_npause();
|
||||||
|
|
||||||
|
#endif
|
24
source/input_macros.h
Normal file
24
source/input_macros.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#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
|
@ -3,9 +3,16 @@
|
|||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <jansson.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "sandia/sandia.h"
|
#include "sandia/sandia.h"
|
||||||
|
|
||||||
|
#include "input_macros.h"
|
||||||
|
|
||||||
|
// Uncomment if this is a development build
|
||||||
|
//#include "debug.h"
|
||||||
|
|
||||||
static void *xfb = NULL;
|
static void *xfb = NULL;
|
||||||
static GXRModeObj *rmode = NULL;
|
static GXRModeObj *rmode = NULL;
|
||||||
|
|
||||||
@ -26,8 +33,10 @@ void logprint(int type, char *message) {
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
printf("\x1b[34m[\x1b[31m--\x1b[34m]");
|
printf("\x1b[34m[\x1b[31m--\x1b[34m]");
|
||||||
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
printf("\x1b[31m!!\x1b[34m]");
|
printf("\x1b[31m!!\x1b[34m]");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
@ -68,6 +77,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
printheader();
|
printheader();
|
||||||
logprint(0, "Welcome to LibreShop!\n");
|
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");
|
logprint(0, "Initializing network.\n");
|
||||||
|
|
||||||
ret = if_config(localip, netmask, gateway, TRUE, 20);
|
ret = if_config(localip, netmask, gateway, TRUE, 20);
|
||||||
@ -79,7 +91,39 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
sandia req = sandia_create("libreshop.donut.eu.org", 80);
|
sandia req = sandia_create("libreshop.donut.eu.org", 80);
|
||||||
sandia_response res = sandia_get_request(&req, "/");
|
sandia_response res = sandia_get_request(&req, "/");
|
||||||
printf("\n%s\n", res.body);
|
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");
|
||||||
sandia_close(&req);
|
sandia_close(&req);
|
||||||
} else {
|
} else {
|
||||||
logprint(0, "Network configuration failed :(\n");
|
logprint(0, "Network configuration failed :(\n");
|
||||||
@ -90,8 +134,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
u32 pressed = WPAD_ButtonsDown(0);
|
u32 pressed = WPAD_ButtonsDown(0);
|
||||||
|
|
||||||
if ( pressed & WPAD_BUTTON_HOME ) {
|
if ( pressed && INPUT_BUTTON_HOME ) {
|
||||||
logprint(0, "HOME pressed, quitting!");
|
logprint(0, "HOME pressed, quitting!\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 9b383cdda825ab4ba2767102b06cbd5dc734dae9
|
Subproject commit 8f4d62429b06bb851f03c21c7796ae69f78541a8
|
Loading…
Reference in New Issue
Block a user