From ec653f5a9fb7c78ef82e34e3d8812be7420d2644 Mon Sep 17 00:00:00 2001 From: johann peyrard Date: Wed, 18 Jan 2017 21:45:26 +0100 Subject: [PATCH] set the AudioDriver to 44.1KHz the Select and Start in InputManager are mirrored to Square and Triangle for Vita add the sceIOmkdir to the right directory --- picoloop/AudioDriverPSVita.cpp | 2 +- picoloop/InputManager.cpp | 6 ++++ picoloop/Makefile.PatternPlayer_psvita_SDL2 | 2 ++ picoloop/Master.h | 1 - picoloop/PatternPlayer.cpp | 2 +- picoloop/PatternReader.cpp | 32 ++++++++++++--------- picoloop/SYSTEM.h | 5 +++- picoloop/SYSTEMLINUX.cpp | 32 +++++++++++++++++++-- picoloop/SYSTEMPSVITA.cpp | 27 +++++++++++++++-- 9 files changed, 87 insertions(+), 22 deletions(-) diff --git a/picoloop/AudioDriverPSVita.cpp b/picoloop/AudioDriverPSVita.cpp index 58ff2fb1..4d0240f6 100644 --- a/picoloop/AudioDriverPSVita.cpp +++ b/picoloop/AudioDriverPSVita.cpp @@ -15,7 +15,7 @@ AudioDriver::AudioDriver() sdlAudioSpecWanted->channels = 2; /* 1 = mono, 2 = stereo */ sdlAudioSpecWanted->samples = BUFFER_FRAME; /* Good low-latency value for callback */ sce_size = 2048; - sce_freq = 8; + sce_freq = 7; //sce_mode = SCE_AUDIO_OUT_MODE_MONO; sce_mode = SCE_AUDIO_OUT_MODE_STEREO; sce_vol = SCE_AUDIO_VOLUME_0DB; diff --git a/picoloop/InputManager.cpp b/picoloop/InputManager.cpp index d44d7e0d..1285ae0e 100644 --- a/picoloop/InputManager.cpp +++ b/picoloop/InputManager.cpp @@ -234,6 +234,7 @@ int InputManager::handleKey() if (!(pad.buttons & keypadtotest) && m_key_state[keypadtotest]==1) { m_key_state[keypadtotest]=0; keypressrelease=1; keydown=0; key=1; keypadtotest_valid=keypadtotest; } + keypadtotest=SCE_CTRL_START; if ((pad.buttons & keypadtotest) && (m_key_state[keypadtotest]==0)) { m_key_state[keypadtotest]=1; keypressrelease=1; keydown=1; key=1; keypadtotest_valid=keypadtotest; } @@ -249,6 +250,11 @@ int InputManager::handleKey() if (keypressrelease) { this->updateState(keypadtotest_valid,keydown); + if (keypadtotest_valid == SCE_CTRL_TRIANGLE) + this->updateState(SCE_CTRL_START,keydown); + if (keypadtotest_valid == SCE_CTRL_SQUARE) + this->updateState(SCE_CTRL_SELECT,keydown); + last_key=keypadtotest_valid; if (keydown) last_event=KEYPRESSED; else last_event=KEYRELEASED; diff --git a/picoloop/Makefile.PatternPlayer_psvita_SDL2 b/picoloop/Makefile.PatternPlayer_psvita_SDL2 index ef818a31..a17744b1 100644 --- a/picoloop/Makefile.PatternPlayer_psvita_SDL2 +++ b/picoloop/Makefile.PatternPlayer_psvita_SDL2 @@ -14,6 +14,8 @@ CFLAGS += -I. #CXXFLAGS += -D__SDL20__ -DPSVITA -D__SDL_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 #CXXFLAGS += -DDEBUG_PRINTF -D__SDL20__ -DPSVITA -D__SDL_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 #CXXFLAGS += -DDEBUG_PRINTF -D__SDL20__ -DPSVITA -D__PSVITA_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 -Wpointer-arith +#CXXFLAGS += -O2 -D__SDL20__ -DPSVITA -D__PSVITA_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 -Wpointer-arith +#CXXFLAGS += -O2 -DDEBUG_PRINTF -D__SDL20__ -DPSVITA -D__PSVITA_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 -Wpointer-arith CXXFLAGS += -O2 -D__SDL20__ -DPSVITA -D__PSVITA_AUDIO__ -fpermissive -std=c++11 -I. -I$(VITASDK)/arm-vita-eabi/include/ -L$(VITASDK)/arm-vita-eabi/lib -lSDL2 -Wpointer-arith #SRC_C :=$(call rwildcard, src/, *.c) diff --git a/picoloop/Master.h b/picoloop/Master.h index 70fa16e0..a0b1dac1 100644 --- a/picoloop/Master.h +++ b/picoloop/Master.h @@ -331,7 +331,6 @@ enum { #ifdef LINUX_RASPI1 - //#define __FPU__ 0 #define SCREEN_WIDTH 320 diff --git a/picoloop/PatternPlayer.cpp b/picoloop/PatternPlayer.cpp index 177d33b6..72baf67f 100644 --- a/picoloop/PatternPlayer.cpp +++ b/picoloop/PatternPlayer.cpp @@ -3943,7 +3943,7 @@ int main(int argc,char **argv) int cpu_speed; int running=1; -#if defined(PSVITA) && defined(DEBUGPRINTF) +#if defined(PSVITA) && defined(DEBUG_PRINTF) psp2shell_init(3333,0); SDL_Delay(5000); psp2shell_print("Start\n"); diff --git a/picoloop/PatternReader.cpp b/picoloop/PatternReader.cpp index 7fe17c42..5fe5c664 100644 --- a/picoloop/PatternReader.cpp +++ b/picoloop/PatternReader.cpp @@ -65,7 +65,8 @@ int PatternReader::saveSong(SongSequencer & SS) unsigned char line[MAX_SONG_LENGHT_BY_PROJECT]; int i; int j; - sprintf(filename,"bank/bank%d/song.pic",bank); + //sprintf(filename,"bank/bank%d/song.pic",bank); + sprintf(filename,"%s/bank/bank%d/song.pic",GETPICOLOOPUSERSTORAGE(),bank); fd=fopen(filename,"w"); if (fd==0) { @@ -88,7 +89,7 @@ int PatternReader::loadSong(SongSequencer & SS) unsigned char line[MAX_SONG_LENGHT_BY_PROJECT]={0}; int i; int j; - sprintf(filename,"bank/bank%d/song.pic",bank); + sprintf(filename,"%s/bank/bank%d/song.pic",GETPICOLOOPUSERSTORAGE(),bank); fd=fopen(filename,"r"); if (fd==0) { @@ -114,7 +115,8 @@ int PatternReader::loadSong(SongSequencer & SS) bool PatternReader::PatternRemove(int PatternNumber,int TrackNumber) { char filename[1024]; - sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + //sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + sprintf(filename,"%s/bank/bank%d/dataP%dT%d.pic",GETPICOLOOPUSERSTORAGE(),bank,PatternNumber,TrackNumber); if (unlink(filename)==0) { loadedData[PatternNumber][TrackNumber]=DATA_DOES_NOT_EXIST_ON_STORAGE; @@ -146,7 +148,8 @@ bool PatternReader::PatternDataExist(int PatternNumber,int TrackNumber) //line=(char*)malloc(1024); //fd=fopen(fn.c_str(),"r+"); - sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + //sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + sprintf(filename,"%s/bank/bank%d/dataP%dT%d.pic",GETPICOLOOPUSERSTORAGE(),bank,PatternNumber,TrackNumber); fd=fopen(filename,"r+"); if (fd==0) { @@ -296,7 +299,8 @@ bool PatternReader::readPatternData(int PatternNumber,int TrackNumber, Pattern & return true; } - sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + //sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); + sprintf(filename,"%s/bank/bank%d/dataP%dT%d.pic",GETPICOLOOPUSERSTORAGE(),bank,PatternNumber,TrackNumber); //check if file name can be open @@ -709,21 +713,21 @@ bool PatternReader::writePattern(int PatternNumber, int TrackNumber, Pattern & P mode_t mode; int sizeoflinemax=1024; - //mode=0666; - //mode=S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IWGRP|S_IROTH|S_IWOTH; - //mode=0755; + // Create the path to the storage if it does not exist + // Should be good^Wbetter if I check if it exist before launching bunch of syscall + // Without any check... + sprintf(path, GETPICOLOOPUSERSTORAGE()); + MKDIR(path); - sprintf(path, "bank"); - //mkdir(path,mode); + sprintf(path, "%s/%s",GETPICOLOOPUSERSTORAGE(),"bank"); MKDIR(path); - sprintf(path, "bank/bank%d",bank); - //mkdir(path,mode); + sprintf(path, "%s/bank/bank%d",GETPICOLOOPUSERSTORAGE(),bank); MKDIR(path); - sprintf(filename,"bank/bank%d/dataP%dT%d.pic",bank,PatternNumber,TrackNumber); - + sprintf(filename,"%s/bank/bank%d/dataP%dT%d.pic",GETPICOLOOPUSERSTORAGE(),bank,PatternNumber,TrackNumber); + //return 0; // printf("SIZE:%d\n",P.getSize()); // exit(1); diff --git a/picoloop/SYSTEM.h b/picoloop/SYSTEM.h index a56fad2a..14b68951 100644 --- a/picoloop/SYSTEM.h +++ b/picoloop/SYSTEM.h @@ -1 +1,4 @@ -int MKDIR(const char *pathname); +int MKDIR(const char *pathname); +char * GETHOME(); +char * GETPICOLOOPUSERSTORAGE(); +char * GETPICOLOOPSYSTEMSTORAGE(); diff --git a/picoloop/SYSTEMLINUX.cpp b/picoloop/SYSTEMLINUX.cpp index c3a082e8..e7594f6f 100644 --- a/picoloop/SYSTEMLINUX.cpp +++ b/picoloop/SYSTEMLINUX.cpp @@ -2,11 +2,39 @@ #define __SYSTEM__ #include "SYSTEM.h" - - +#include +#include +#include +#include +#include #include #include +#define MAXHOMEPATH 256 + + +char * GETPICOLOOPSYSTEMSTORAGE() +{ + //static char * systemstorage="/usr/share/picoloop/"; + static char * systemstorage="./"; + return systemstorage; +} + +char * GETPICOLOOPUSERSTORAGE() +{ + static char picoloophome[MAXHOMEPATH]; + //snprintf(picoloophome,"%s/.picoloop/",GETHOME()); + sprintf(picoloophome,"./"); + return picoloophome; +} + +char * GETHOME() +{ + static char homedir[MAXHOMEPATH]; + sprintf(homedir, MAXHOMEPATH, "%s", getenv("HOME")); + return homedir; +} + int MKDIR(const char *pathname) { mode_t mode; diff --git a/picoloop/SYSTEMPSVITA.cpp b/picoloop/SYSTEMPSVITA.cpp index e0e5f5d1..2a2aab60 100644 --- a/picoloop/SYSTEMPSVITA.cpp +++ b/picoloop/SYSTEMPSVITA.cpp @@ -2,18 +2,41 @@ #define __SYSTEM__ #include "SYSTEM.h" - +#include "Master.h" +#define MAXHOMEPATH 256 //#include //#include #include +#include + +char * GETHOME() +{ + static char homedir[MAXHOMEPATH]; + sprintf(homedir,"ux0:/app/PICOLOOP1"); + return homedir; +} + +char * GETPICOLOOPUSERSTORAGE() +{ + static char homedir[MAXHOMEPATH]; + sprintf(homedir,"ux0:/data/PICOLOOP1"); + return homedir; +} +char * GETPICOLOOPSYSTEMSTORAGE() +{ + static char homedir[MAXHOMEPATH]; + sprintf(homedir,"ux0:/app/PICOLOOP1"); + return homedir; +} int MKDIR(const char *pathname) { SceMode mode; //mode_t mode; - mode=0755; + mode=0777; //mkdir(pathname,mode); + DPRINTF("Creating directory %s",pathname); sceIoMkdir(pathname,mode); }