Still Crashes switch
This commit is contained in:
parent
7cfcdbbb24
commit
96ece6a0e3
8
Makefile
8
Makefile
|
@ -42,7 +42,7 @@ BUILD := build
|
||||||
SOURCES := source
|
SOURCES := source
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := include
|
INCLUDES := include
|
||||||
#ROMFS := RomFS
|
#ROMFS := romfs
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# options for code generation
|
# options for code generation
|
||||||
|
@ -59,8 +59,10 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||||
ASFLAGS := -g $(ARCH)
|
ASFLAGS := -g $(ARCH)
|
||||||
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||||
|
|
||||||
#LIBS := `sdl2-config --libs` -lSDL2_ttf -lSDL2_image -lmupdf -lmupdf-third
|
LIBS := `sdl2-config --libs` -lSDL2_ttf -lSDL2_image
|
||||||
LIBS := `aarch64-none-elf-pkg-config --libs sdl2` -lSDL2_ttf -lSDL2_image -lmupdf -lmupdf-third
|
#LIBS := -lSDL2 -lSDL2_ttf -lSDL2_gfx -lSDL2_image -lnx
|
||||||
|
#LIBS := `aarch64-none-elf-pkg-config --libs sdl2` -lSDL2_ttf #-lSDL2_image -lmupdf -lmupdf-third
|
||||||
|
LIBS := `aarch64-none-elf-pkg-config --libs SDL2 SDL2_ttf SDL2_mixer`
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
# list of directories containing libraries, this must be the top level containing
|
# list of directories containing libraries, this must be the top level containing
|
||||||
|
|
Binary file not shown.
|
@ -1,18 +1,32 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <switch.h>
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_ttf.h>
|
#include <SDL2/SDL_ttf.h>
|
||||||
|
|
||||||
//#include "menu_book_reader.h"
|
void draw_rects(SDL_Renderer *renderer, int x, int y) {
|
||||||
|
// R
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||||
|
SDL_Rect r = {x, y, 64, 64};
|
||||||
|
SDL_RenderFillRect(renderer, &r);
|
||||||
|
|
||||||
|
// G
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||||
|
SDL_Rect g = {x + 64, y, 64, 64};
|
||||||
|
SDL_RenderFillRect(renderer, &g);
|
||||||
|
|
||||||
|
// B
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);
|
||||||
|
SDL_Rect b = {x + 128, y, 64, 64};
|
||||||
|
SDL_RenderFillRect(renderer, &b);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_Window *window;
|
SDL_Window *window;
|
||||||
SDL_Renderer *renderer;
|
SDL_Renderer *renderer;
|
||||||
int done = 0;
|
int done = 0, x = 0, w = 1920, h = 1080;
|
||||||
|
|
||||||
//romfsInit();
|
|
||||||
|
|
||||||
// mandatory at least on switch, else gfx is not properly closed
|
// mandatory at least on switch, else gfx is not properly closed
|
||||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0) {
|
||||||
|
@ -40,8 +54,10 @@ int main(int argc, char *argv[]) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*TTF_Init();
|
romfsInit();
|
||||||
TTF_Font *arialUnicode = TTF_OpenFont("RomFs:/arial-unicode-ms.ttf", 30);
|
|
||||||
|
TTF_Init();
|
||||||
|
/*TTF_Font *arialUnicode = TTF_OpenFont("RomFs:/arial-unicode-ms.ttf", 30);
|
||||||
if (!arialUnicode) {
|
if (!arialUnicode) {
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -59,14 +75,60 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Menu_OpenBook("/switch/eBookReader/books/test.epub");
|
while (!done) {
|
||||||
|
while (SDL_PollEvent(&event)) {
|
||||||
|
switch (event.type) {
|
||||||
|
case SDL_JOYAXISMOTION:
|
||||||
|
SDL_Log("Joystick %d axis %d value: %d\n",
|
||||||
|
event.jaxis.which,
|
||||||
|
event.jaxis.axis, event.jaxis.value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_JOYBUTTONDOWN:
|
||||||
|
SDL_Log("Joystick %d button %d down\n",
|
||||||
|
event.jbutton.which, event.jbutton.button);
|
||||||
|
// https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L52
|
||||||
|
// seek for joystick #0
|
||||||
|
if (event.jbutton.which == 0) {
|
||||||
|
if (event.jbutton.button == 0) {
|
||||||
|
// (A) button down
|
||||||
|
} else if (event.jbutton.button == 10) {
|
||||||
|
// (+) button down
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||||
|
SDL_RenderClear(renderer);
|
||||||
|
|
||||||
|
// fill window bounds
|
||||||
|
SDL_SetRenderDrawColor(renderer, 111, 111, 111, 255);
|
||||||
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
|
SDL_Rect f = {0, 0, w, h};
|
||||||
|
SDL_RenderFillRect(renderer, &f);
|
||||||
|
|
||||||
|
draw_rects(renderer, x, 0);
|
||||||
|
draw_rects(renderer, x, h - 64);
|
||||||
|
|
||||||
|
SDL_RenderPresent(renderer);
|
||||||
|
|
||||||
|
x++;
|
||||||
|
if (x > w - 192) {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Menu_OpenBook(renderer, SDL_GetWindowSurface(window), font, "/switch/eBookReader/books/test.epub");
|
||||||
|
|
||||||
|
//TTF_Quit();
|
||||||
SDL_DestroyRenderer(renderer);
|
SDL_DestroyRenderer(renderer);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
|
|
||||||
//TTF_CloseFont(arialUnicode);
|
|
||||||
//TTF_Quit();
|
|
||||||
//romfsExit();
|
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue