added wiringPi exit button, compiler and SDL fixed for PI (need to add defines to allow compiling on PC again

Former-commit-id: 36897ec253d2711781deb41c8a94b67274e7603e
Former-commit-id: 3ed29801dd012902e04581194b606575cf2a94dc
This commit is contained in:
nathan 2017-09-05 09:41:46 +00:00
parent 43283e175e
commit 649c7aa466
4 changed files with 27 additions and 6 deletions

View file

@ -10,8 +10,8 @@ SHAREDIR=$(PREFIX)/share/$(PROGNAME)
EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\" EXTRACFLAGS=-DHTMLPATH=\"$(SHAREDIR)\"
endif endif
CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` CFLAGS=-O2 -g -Wall -W `pkg-config --cflags librtlsdr` -std=c99
LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl-config --libs` -lSDL -lSDL_ttf -lSDL_gfx LIBS=`pkg-config --libs librtlsdr` -lpthread -lm `sdl-config --libs` -lSDL -lSDL_ttf -lSDL_gfx -lwiringPi
CC=gcc CC=gcc

View file

@ -1,10 +1,22 @@
#include "init.h" #include "init.h"
#include "SDL/SDL_getenv.h"
#include <wiringPi.h>
extern void closeFont(TTF_Font *); extern void closeFont(TTF_Font *);
void init(char *title) void init(char *title)
{ {
wiringPiSetupGpio() ;
pinMode(23, INPUT);
pullUpDnControl (23, PUD_UP);
pinMode(22, INPUT);
pullUpDnControl (22, PUD_UP);
putenv((char*)"FRAMEBUFFER=/dev/fb1");
putenv((char*)"SDL_FBDEV=/dev/fb1");
/* Initialise SDL */ /* Initialise SDL */
if (SDL_Init(SDL_INIT_VIDEO) < 0) if (SDL_Init(SDL_INIT_VIDEO) < 0)
@ -22,9 +34,10 @@ void init(char *title)
exit(1); exit(1);
} }
game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, SDL_HWPALETTE|SDL_DOUBLEBUF); SDL_ShowCursor(SDL_DISABLE);
game.screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, SDL_HWPALETTE|SDL_DOUBLEBUF);
if (game.screen == NULL) if (game.screen == NULL)
{ {

View file

@ -1,13 +1,21 @@
#include "input.h" #include "input.h"
#include <wiringPi.h>
void getInput() void getInput()
{ {
if(!digitalRead(23) || !digitalRead(22)) {
exit(0);
}
SDL_Event event; SDL_Event event;
/* Loop through waiting messages and process them */ /* Loop through waiting messages and process them */
while (SDL_PollEvent(&event)) while (SDL_PollEvent(&event))
{ {
fprintf(stderr,"key: %d\n", event.key.keysym.sym);
switch (event.type) switch (event.type)
{ {
/* Closing the Window or pressing Escape will exit the program */ /* Closing the Window or pressing Escape will exit the program */
@ -29,4 +37,4 @@ void getInput()
break; break;
} }
} }
} }

View file

@ -1 +1 @@
dd9da3d4441175ab67ca8209c4dc330f48cf6590 07b6d82450c0a8be87c3ff832b90537a06e9cb20