diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..b6ecd427 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +lgpt.pkg text eol=crlf diff --git a/README.md b/README.md new file mode 100644 index 00000000..d60a0400 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# LittleGPTracker +This is a fork of m-.-n's LGPT for Symbian (S60v3) devices. Built and tested on a Nokia E63 (S60v3 FP1). + +At present, everything works - except the keyboard becomes unresponsive when audio is running. To be fixed. + +## Runtime dependencies +You need the Open C/C++ libraries installed; these come with the Qt installer, amongst other places. The separate SIS files are also available in the Open C/C++ plugin (see below). + +## Compile dependencies +You need: + +- an S60 SDK matching your phone (v3, v3 FP1, v3 FP2) - these are not backwards compatible but somewhat forwards +- a suitable version of the GCCE compiler +- the Open C/C++ plug-in +- SDL-S60v3 from here: http://repo.or.cz/w/SDL.s60v3.git + +Unfortunately the Nokia site with the SDKs and tools is now gone. Most of the necessary files can be found here: +http://n8delight.blogspot.com.au/2014/05/for-developers-re-up-of-symbian.html +I also found a copy of Open C/C++ on 4shared (look for s60_open_c_cpp_plug_in_v1_7_en). +The Qt SDK 1.1.x includes compiler, SDK and plug-ins all together, which are suitable for FP2 and above. This can be found here: +ftp://ftp.informatik.hu-berlin.de/pub/Mirrors/ftp.troll.no/QT/qtsdk/ + +To build: +- Install the SDK, which will add it to your PATH or give you a startup link to do so (QtSDK does this). +- Install the compiler, put its bin directory on your PATH +- Install Open C/C++ over the SDK +- `cd SDL-s60v3\symbian`; `bldmake bldfiles`; `abld build gcce` + This installs the resulting files *into the SDK tree* (eek). +- cd LittleGPTracker\projects; make + Assuming the platform is set to S60, this should give you `lgpt.sis` which you can install. + +### Notes +There is a "make run" target which will use `runonphone.exe` (available in the QtSDK, amongst other places). You need the App TRK installed and running on your phone. + +I had to patch a few bits of the FP1 SDK to get the compiler to work! +Notably, I had to replace macros defining `va_list`, `va_start`, `va_end` etc. using `__builtin_va_{list,start,end}`. + +If you use a newer SDK than your phone you might get lucky, or you might not. The FP2/QtSDK built the project nicely, but it refused to run on my phone with "Feature not supported". + +There's a debugger `fdb` in the FShell project at http://fshell.sf.net which can give you stack traces; use `fdb -m e:\` to point it at `lgpt.exe.map` with all the symbols. diff --git a/projects/.gitignore b/projects/.gitignore new file mode 100644 index 00000000..ebafed02 --- /dev/null +++ b/projects/.gitignore @@ -0,0 +1,5 @@ +lgpt.mmp +lgpt.GCCE +lgpt.mif +lgpt.sis +lgpt.mbm diff --git a/projects/Makefile b/projects/Makefile index 59768b2b..00c6d798 100644 --- a/projects/Makefile +++ b/projects/Makefile @@ -4,9 +4,9 @@ .SUFFIXES: #--------------------------------------------------------------------------------- -PLATFORM:= RASPI +PLATFORM:= S60 -include $(PWD)/Makefile.$(PLATFORM) +include Makefile.$(PLATFORM) #--------------------------------------------------------------------------------- # options for FXE @@ -179,6 +179,15 @@ COMMONDIRS := ../sources/System/Console \ ../sources/Externals/Soundfont \ ../sources/Externals/TinyXML +S60DIRS := ../sources/Adapters/Unix/FileSystem \ + ../sources/System/Process \ + ../sources/Adapters/Dummy/Midi \ + ../sources/Adapters/Unix/Process \ + ../sources/Adapters/SDL/GUI \ + ../sources/Adapters/SDL/Timer \ + ../sources/Adapters/S60/System \ + ../sources/Adapters/S60 + #--------------------------------------------------------------------------------- # files definition #--------------------------------------------------------------------------------- @@ -299,6 +308,19 @@ GP2XFILES := GPSDLMain.o \ SDLTimer.o \ GUIFactory.o SDLEventManager.o SDLGUIWindowImp.o +S60FILES := UnixFileSystem.o \ + DummyMidi.o \ + S60Audio.o \ + S60AudioDriver.o \ + Process.o \ + UnixProcess.o \ + SDLTimer.o \ + GUIFactory.o \ + SDLEventManager.o \ + SDLGUIWindowImp.o \ + S60Main.o \ + S60System.o + CAANOOFILES := CAANOOSDLMain.o \ UnixFileSystem.o \ CAANOOMidiService.o \ diff --git a/projects/Makefile.S60 b/projects/Makefile.S60 new file mode 100644 index 00000000..a1538536 --- /dev/null +++ b/projects/Makefile.S60 @@ -0,0 +1,39 @@ +PWD = ${shell pwd} + +ICONSRC = ..\sources\Resources\lgpt_icon.svg + +all: lgpt.sis + +run: lgpt.sis + runonphone -s lgpt.sis lgpt.exe + +lgpt.sis: $(EPOCROOT)/epoc32/build/$(PWD)/lgpt/gcce/urel/lgpt.exe lgpt.pkg lgpt.mif + makesis "-d$(EPOCROOT)" lgpt.pkg + +$(EPOCROOT)/epoc32/build/$(PWD)/lgpt/gcce/urel/lgpt.exe: lgpt.gcce $(SRCS) $(EPOCROOT)/epoc32/release/armv5/urel/sdl.lib + +make -f lgpt.gcce UREL + +lgpt.mif: $(ICONSRC) + mifconv lgpt.mif $(ICONSRC) + +lgpt.mmp: s60/mmpheader + +perl s60/makemmp.pl "$(OFILES)" "$(SOURCES)" $< > $@ + +lgpt.gcce: lgpt.mmp + bldmake bldfiles + makmake lgpt.mmp gcce + +clean: clean-S60 + +clean-S60: lgpt.gcce + make -f lgpt.gcce CLEAN + del lgpt.gcce + del lgpt.mmp + del lgpt.mif + del lgpt.sis + +mrproper: clean + rm -rf $(EPOCROOT)/epoc32/build$(PWD) + +$(EPOCROOT)/epoc32/build/$(PWD)/gcce.make: bld.inf lgpt.mmp + bldmake bldfiles diff --git a/projects/bld.inf b/projects/bld.inf new file mode 100644 index 00000000..300ef388 --- /dev/null +++ b/projects/bld.inf @@ -0,0 +1,2 @@ +prj_mmpfiles +lgpt.mmp diff --git a/projects/lgpt.pkg b/projects/lgpt.pkg new file mode 100644 index 00000000..f5b75364 --- /dev/null +++ b/projects/lgpt.pkg @@ -0,0 +1,36 @@ +&EN + +; standard SIS file header +#{"LGPT"},(0xA0102034),1,0,0 + +;Localised Vendor name +%{"Vendor-EN"} + +;Unique Vendor name +:"Vendor" + +[0x101F7961], 0, 0, 0, {"S60v3"} +[0x1028315F], 0, 0, 0, {"S60v5"} + +;Files to install +"\epoc32\release\gcce\urel\lgpt.exe" - "!:\sys\bin\lgpt.exe" +"\epoc32\data\z\private\10003a3f\import\apps\lgpt.rsc" - "!:\private\10003a3f\import\apps\lgpt.rsc" +"\epoc32\data\z\resource\apps\lgpt_loc.rsc" - "!:\resource\apps\lgpt_loc.rsc" +"lgpt.mif" - "!:\resource\apps\lgpt.mif" + +; For getting meaningful stacktraces with fdb from FShell +"\epoc32\release\gcce\urel\lgpt.exe.map" - "e:\lgpt.exe.map" + +; Demo song include +"lgpt10k\samples\tunedbell.wav" - "c:\data\lgpt\lgpt10k\samples\tunedbell.wav" +"lgpt10k\samples\triangle.wav" - "c:\data\lgpt\lgpt10k\samples\triangle.wav" +"lgpt10k\samples\square.wav" - "c:\data\lgpt\lgpt10k\samples\square.wav" +"lgpt10k\samples\Snaredrum.wav" - "c:\data\lgpt\lgpt10k\samples\Snaredrum.wav" +"lgpt10k\samples\sinus.wav" - "c:\data\lgpt\lgpt10k\samples\sinus.wav" +"lgpt10k\samples\sawtooth.wav" - "c:\data\lgpt\lgpt10k\samples\sawtooth.wav" +"lgpt10k\samples\rezobass.wav" - "c:\data\lgpt\lgpt10k\samples\rezobass.wav" +"lgpt10k\samples\Hihat.wav" - "c:\data\lgpt\lgpt10k\samples\Hihat.wav" +"lgpt10k\samples\Downramp.wav" - "c:\data\lgpt\lgpt10k\samples\Downramp.wav" +"lgpt10k\samples\Bassdrum.wav" - "c:\data\lgpt\lgpt10k\samples\Bassdrum.wav" +"lgpt10k\samples\accordion.wav" - "c:\data\lgpt\lgpt10k\samples\accordion.wav" +"lgpt10k\lgptsav.dat" - "c:\data\lgpt\lgpt10k\lgptsav.dat" diff --git a/projects/lgpt.rss b/projects/lgpt.rss new file mode 100644 index 00000000..929723ba --- /dev/null +++ b/projects/lgpt.rss @@ -0,0 +1,9 @@ +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0xA0102034 + +RESOURCE APP_REGISTRATION_INFO { + app_file="lgpt"; + localisable_resource_file="\\resource\\apps\\lgpt_loc"; +} diff --git a/projects/s60/makemmp.pl b/projects/s60/makemmp.pl new file mode 100644 index 00000000..22cc4530 --- /dev/null +++ b/projects/s60/makemmp.pl @@ -0,0 +1,31 @@ +@files = split /\s+/, $ARGV[0]; +@searchdirs = split /\s+/, $ARGV[1]; +map { s/\.o$// } @files; + +open IN, "<$ARGV[2]" || die; +for () { print }; + +for $dir (@searchdirs) { + print "userinclude $dir\n"; +} + +%seen = (); + +for $dir (@searchdirs) { + next if $dir =~ /^\s*$/; + print "sourcepath $dir\n"; + for $file (@files) { + if (-e "$dir/$file.cpp") { + print "source $file.cpp\n"; + $seen{$file} = 1; + } + if (-e "$dir/$file.c") { + print "source $file.c\n"; + $seen{$file} = 1; + } + } +} + +for (@files) { + die "Did not find source for $_.o!" unless $seen{$_}; +} diff --git a/projects/s60/mmpheader b/projects/s60/mmpheader new file mode 100644 index 00000000..26785652 --- /dev/null +++ b/projects/s60/mmpheader @@ -0,0 +1,54 @@ +target lgpt.exe +targettype exe +uid 0x100039ce 0xa0102034 +vendorid 0 + +epocstacksize 0xA000 +epocheapsize 0x100000 0x4000000 + +start resource lgpt.rss +targetpath \private\10003a3f\import\apps +end +start resource lgpt_loc.rss +targetpath \resource\apps +lang SC +end + +macro SYMBIAN +macro WITH_SDL +macro WITH_ZLIB +macro WITH_PERSONAL_DIR +macro CPP_MEMORY + +systeminclude \epoc32\include\stdapis +systeminclude \epoc32\include\stdapis\stlport +systeminclude \epoc32\include\stdapis\stlport\stl +systeminclude \epoc32\include\stdapis\glib-2.0 +systeminclude \epoc32\include +systeminclude \epoc32\include\SDL + +library libc.lib +library libm.lib +library libpthread.lib +library libstdcpp.lib +staticlibrary sdl.lib +library apgrfx.lib +library apparc.lib +library avkon.lib +library bitgdi.lib +library cone.lib +library eikcore.lib +library euser.lib +library fbscli.lib +library hal.lib +library mediaclientaudiostream.lib +library mmfdevsound.lib +library ws32.lib +library centralrepository.lib +library remconcoreapi.lib +library remconinterfacebase.lib + +capability ReadUserData WriteUserData + +userinclude ../sources +userinclude ../sources/System/System diff --git a/sources/Adapters/S60/S60Audio.cpp b/sources/Adapters/S60/S60Audio.cpp new file mode 100644 index 00000000..178ec6c3 --- /dev/null +++ b/sources/Adapters/S60/S60Audio.cpp @@ -0,0 +1,31 @@ +#include "S60Audio.h" +#include "S60AudioDriver.h" +#include "Services/Audio/AudioOutDriver.h" +#include "System/Console/Trace.h" + +S60Audio::S60Audio(AudioSettings &settings):Audio(settings), + sampleRate_(44100) +{ +} + +S60Audio::~S60Audio() { +} + +void S60Audio::Init() { + S60AudioDriver *drv=new S60AudioDriver(settings_) ; + AudioOutDriver *out=new AudioOutDriver(*drv) ; + Insert(out) ; + sampleRate_=drv->GetSampleRate() ; +} ; + +void S60Audio::Close() { + IteratorPtrit(GetIterator()) ; + for (it->Begin();!it->IsDone();it->Next()) { + AudioOut ¤t=it->CurrentItem() ; + current.Close() ; + } +} ; + +int S60Audio::GetSampleRate() { + return sampleRate_ ; +} ; diff --git a/sources/Adapters/S60/S60Audio.h b/sources/Adapters/S60/S60Audio.h new file mode 100644 index 00000000..7ba49561 --- /dev/null +++ b/sources/Adapters/S60/S60Audio.h @@ -0,0 +1,16 @@ +#ifndef _S60AUDIO_H_ +#define _S60AUDIO_H_ + +#include "Services/Audio/Audio.h" + +class S60Audio: public Audio { +public: + S60Audio(AudioSettings &settings) ; + ~S60Audio() ; + virtual void Init() ; + virtual void Close() ; + virtual int GetSampleRate() ; +private: + int sampleRate_ ; +}; +#endif diff --git a/sources/Adapters/S60/S60AudioDriver.cpp b/sources/Adapters/S60/S60AudioDriver.cpp new file mode 100644 index 00000000..d019de93 --- /dev/null +++ b/sources/Adapters/S60/S60AudioDriver.cpp @@ -0,0 +1,130 @@ +#include "S60AudioDriver.h" +#include +#include "System/Console/Trace.h" +#include "System/System/System.h" +#include "Application/Model/Config.h" +#include + +S60AudioDriver::S60AudioDriver(AudioSettings &settings): + AudioDriver(settings), buffersize_(settings.bufferSize_){ + const char *delta = Config::GetInstance()->GetValue("S60SANDBAGDELTA"); + if (delta) + sandbagdelta_ = atoi(delta); + else + sandbagdelta_ = 11500; // works reliably on Nokia E63 w/ fw 500.x +} + +S60AudioDriver::~S60AudioDriver() { +} + +bool S60AudioDriver::InitDriver() { + return true; +} + +void S60AudioDriver::CloseDriver() { +} ; + +bool S60AudioDriver::StartDriver() { + thread_=new S60AudioDriverThread(this, bufferSize_, sandbagdelta_) ; + thread_->Start() ; + return true ; +} ; + +void S60AudioDriver::StopDriver() { + thread_->RequestTermination(); +} ; + +double S60AudioDriverThread::GetStreamTime() { + return streamTime_; +} + +double S60AudioDriver::GetStreamTime() { + if (!thread_) + return 0; + return thread_->GetStreamTime() ; +} ; + +bool S60AudioDriverThread::Execute() { + _LIT(KThreadName,"lgpt_audio_thread"); + TPtrC threadname(KThreadName); + User::RenameThread(threadname); + + RProcess cur_process; + cur_process.SetPriority(EPriorityHigh); + RThread cur_thread; + cur_thread.SetPriority(EPriorityAbsoluteHigh); + CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler; + CleanupStack::PushL(activeScheduler); + CActiveScheduler::Install(activeScheduler); + dev = CMMFDevSound::NewL(); + dev->InitializeL(*this, KMMFFourCCCodePCM16, EMMFStatePlaying); + CActiveScheduler::Start(); + CleanupStack::PopAndDestroy(activeScheduler); + return true; +} + +void S60AudioDriverThread::RequestTermination() { + terminating = true; +} + +void S60AudioDriverThread::InitializeComplete(TInt aError) { + TInt err; + TMMFPrioritySettings pri; + pri.iPref = EMdaPriorityPreferenceTimeAndQuality; + pri.iPriority = EMdaPriorityMax; + TRAP(err, dev->SetPrioritySettings(pri)); + TMMFCapabilities caps = dev->Config(); + caps.iChannels = EMMFStereo; + caps.iEncoding = EMMFSoundEncoding16BitPCM; + caps.iRate = EMMFSampleRate44100Hz; + caps.iBufferSize = buffersize_; + TRAP(err, dev->SetConfigL(caps)); + samples_pushed = 0; + TRAP(err, dev->PlayInitL()); +} ; + +int S60AudioDriver::FillBuffer(CMMFBuffer *aBuffer) { + AudioBufferData *abd = &(pool_[poolPlayPosition_]); + if (!abd->size_) + OnNewBufferNeeded(); + + CMMFDataBuffer *buf = static_cast(aBuffer); + TDes8 &output = buf->Data(); + output.Copy((TUint8*)abd->buffer_, abd->size_); + return abd->size_ / 4; +} + +void S60AudioDriver::NextBuffer() { + SAFE_FREE(pool_[poolPlayPosition_].buffer_); + poolPlayPosition_=(poolPlayPosition_+1)%SOUND_BUFFER_COUNT; + onAudioBufferTick(); + OnNewBufferNeeded(); +} + +void S60AudioDriverThread::BufferToBeFilled(CMMFBuffer *aBuffer) { + if (terminating) { + dev->Stop(); + CActiveScheduler::Stop(); + return; + } + + samples_pushed += driver->FillBuffer(aBuffer); + + // This is a filthy hack to reduce the amount of buffering (which we can't control) supplied by the OS. + // Once the output sample counter comes up, we start sandbagging to let that buffer drain. + // This is a terrible magic number. + if (sandbagdelta_ && dev->SamplesPlayed()) { + while (dev->SamplesPlayed() < (samples_pushed - sandbagdelta_)) { + User::After(100); + } + } + + TInt err; + TRAP(err, dev->PlayData()); + User::After(100); // yield + streamTime_ = dev->SamplesPlayed() / 44100.; + driver->NextBuffer(); +} + +void S60AudioDriverThread::PlayError(TInt aError) { +} diff --git a/sources/Adapters/S60/S60AudioDriver.h b/sources/Adapters/S60/S60AudioDriver.h new file mode 100644 index 00000000..bca11252 --- /dev/null +++ b/sources/Adapters/S60/S60AudioDriver.h @@ -0,0 +1,64 @@ +#ifndef _S60_SOUND_H_ +#define _S60_SOUND_H_ + +#include "Services/Audio/AudioDriver.h" +#include "System/Process/Process.h" +#include "Foundation/T_Stack.h" +#define Time E32Time +#include +#undef Time + +class S60AudioDriver; + +class S60AudioDriverThread: public SysThread, MDevSoundObserver { +public: + S60AudioDriverThread(S60AudioDriver *driver, int buffersize, int sandbagdelta) + : driver(driver), + terminating(false), + buffersize_(buffersize), + sandbagdelta_(sandbagdelta) {}; + virtual ~S60AudioDriverThread() {} ; + virtual bool Execute() ; + void RequestTermination() ; + double GetStreamTime() ; + +public: // From MDevSoundObserver + void InitializeComplete(TInt aError); + void ToneFinished(TInt aError) {}; + void BufferToBeFilled(CMMFBuffer* aBuffer); + void PlayError(TInt aError); + void BufferToBeEmptied(CMMFBuffer *aBuffer) {}; + void RecordError(TInt aError) {}; + void ConvertError(TInt aError) {}; + void DeviceMessage(TUid aMessageType, const TDesC8 &aMsg) {}; + +private: + CMMFDevSound *dev; + S60AudioDriver *driver; + double streamTime_ ; + int samples_pushed; + bool terminating; + int buffersize_, sandbagdelta_; +} ; + +class S60AudioDriver: public AudioDriver { +public: + S60AudioDriver(AudioSettings &settings) ; + ~S60AudioDriver() ; + // Audio implementation + virtual bool InitDriver() ; + virtual void CloseDriver(); + virtual bool StartDriver() ; + virtual void StopDriver(); + virtual int GetPlayedBufferPercentage() { return 0 ;} ; + virtual int GetSampleRate() { return 44100; } ; + virtual bool Interlaced() { return true ; } ; + virtual double GetStreamTime() ; + + int FillBuffer(CMMFBuffer *aBuffer); + void NextBuffer(); +private: + S60AudioDriverThread * thread_ ; + int buffersize_, sandbagdelta_; +} ; +#endif diff --git a/sources/Adapters/S60/S60Main.cpp b/sources/Adapters/S60/S60Main.cpp new file mode 100644 index 00000000..a266cf2a --- /dev/null +++ b/sources/Adapters/S60/S60Main.cpp @@ -0,0 +1,26 @@ +#include "Application/Application.h" +#include "Adapters/S60/System/S60System.h" +#include "Foundation/T_Singleton.h" +#include +#include +#include "Adapters/SDL/GUI/SDLGUIWindowImp.h" +#include "Application/Persistency/PersistencyService.h" +#include "Adapters/SDL/GUI/SDLGUIWindowImp.h" + +int main(int argc,char *argv[]) +{ + S60System::Boot(argc,argv) ; + + SDLCreateWindowParams params ; + params.title="littlegptracker" ; + params.cacheFonts_=true ; + params.framebuffer_=false ; + + Application::GetInstance()->Init(params) ; + + S60System::MainLoop() ; + S60System::Shutdown() ; +} + + + diff --git a/sources/Adapters/S60/System/S60System.cpp b/sources/Adapters/S60/System/S60System.cpp new file mode 100644 index 00000000..b66f5aae --- /dev/null +++ b/sources/Adapters/S60/System/S60System.cpp @@ -0,0 +1,151 @@ +#include "S60System.h" +#include "Adapters/Unix/FileSystem/UnixFileSystem.h" +#include "Adapters/SDL/GUI/GUIFactory.h" +#include "Adapters/SDL/GUI/SDLGUIWindowImp.h" +#include "Adapters/SDL/GUI/SDLEventManager.h" +#include "Adapters/Unix/Process/UnixProcess.h" +#include "Adapters/S60/S60Audio.h" +#include "Adapters/Dummy/Midi/DummyMidi.h" +#include "Externals/TinyXML/tinyxml.h" +#include "Application/Model/Config.h" +#include "Application/Controllers/ControlRoom.h" +#include "Application/Player/SyncMaster.h" +#include "Application/Commands/NodeList.h" +#include "Adapters/SDL/Timer/SDLTimer.h" +#include "System/Console/Logger.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define Time E32Time +#include + +EventManager *S60System::eventManager_ = NULL ; + +int S60System::MainLoop() { + eventManager_->InstallMappings() ; + eventManager_->MainLoop() ; +} ; + +void S60System::Boot(int argc,char **argv) { + // Install System + System::Install(new S60System()) ; + + // Install FileSystem + FileSystem::Install(new UnixFileSystem()) ; + Path::SetAlias("root","c:/data/lgpt") ; + Path::SetAlias("bin","c:/data/lgpt") ; + Config::GetInstance()->ProcessArguments(argc,argv) ; + + // XXX debug to SD card + unlink("e:/lgpt.log"); + Path logPath("e:\\lgpt.log"); + FileLogger *fileLogger=new FileLogger(logPath); + if(fileLogger->Init().Succeeded()) + { + Trace::GetInstance()->SetLogger(*fileLogger); + } + + // Install GUI Factory + I_GUIWindowFactory::Install(new GUIFactory()) ; + + // Install Timers + TimerService::GetInstance()->Install(new SDLTimerService()) ; + + // Install Sound + AudioSettings hints ; + hints.bufferSize_=0 ; // let OS autosize (ignored on many) + hints.preBufferCount_=0 ; // does nothing + Audio::Install(new S60Audio(hints)) ; + // Install Midi + MidiService::Install(new DummyMidi()) ; + + // Install Threads + SysProcessFactory::Install(new UnixProcessFactory()) ; + + if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) { + return; + } + + SDL_EnableUNICODE(1); + + atexit(SDL_Quit); + + eventManager_=I_GUIWindowFactory::GetInstance()->GetEventManager() ; + eventManager_->Init() ; + + // defaults suitable for qwertyphones eg. E63 + eventManager_->MapAppButton("q", APP_BUTTON_A); + eventManager_->MapAppButton("a", APP_BUTTON_B); + eventManager_->MapAppButton("left", APP_BUTTON_LEFT); + eventManager_->MapAppButton("right", APP_BUTTON_RIGHT); + eventManager_->MapAppButton("up", APP_BUTTON_UP); + eventManager_->MapAppButton("down", APP_BUTTON_DOWN); + eventManager_->MapAppButton("home", APP_BUTTON_L); // green call key + eventManager_->MapAppButton("space", APP_BUTTON_R); // left softkey + eventManager_->MapAppButton("escape", APP_BUTTON_START); // right softkey +} ; + +void S60System::Shutdown() { + delete Audio::GetInstance() ; + exit(0); +} ; + +static int secbase; + +unsigned long S60System::GetClock() { + struct timeval tp; + + gettimeofday(&tp, NULL); + if (!secbase) + { + secbase = tp.tv_sec; + return long(tp.tv_usec/1000.0); + } + return long((tp.tv_sec - secbase)*1000 + tp.tv_usec/1000.0); +} + +int S60System::GetBatteryLevel() { + return -1; +} ; + +void S60System::Sleep(int millisec) { + User::After(millisec*1000); +} + +void *S60System::Malloc(unsigned size) { + void *ptr=malloc(size) ; + return ptr ; +} + +void S60System::Free(void *ptr) { + free(ptr) ; +} + +//extern "C" void *gpmemset(void *s1,unsigned char val,int n) ; + +void S60System::Memset(void *addr,char val,int size) +{ + memset(addr,val,size) ; +} ; + +void *S60System::Memcpy(void *s1, const void *s2, int n) +{ + return memcpy(s1,s2,n); +} + +void S60System::PostQuitMessage() +{ + Trace::Log("S60", "PostQuitMessage called"); + SDLEventManager::GetInstance()->PostQuitMessage() ; +} + +unsigned int S60System::GetMemoryUsage() +{ + return 0; +} diff --git a/sources/Adapters/S60/System/S60System.h b/sources/Adapters/S60/System/S60System.h new file mode 100644 index 00000000..7b5052d4 --- /dev/null +++ b/sources/Adapters/S60/System/S60System.h @@ -0,0 +1,31 @@ +#ifndef _S60_SYSTEM_H_ +#define _S60_SYSTEM_H_ + +#include "System/System/System.h" +#include "UIFramework/SimpleBaseClasses/EventManager.h" +#include + +class S60System: public System { +public: + static void Boot(int argc,char **argv) ; + static void Shutdown() ; + static int MainLoop() ; + +public: // System implementation + virtual unsigned long GetClock() ; + virtual int GetBatteryLevel() ; + virtual void Sleep(int millisec); + virtual void *Malloc(unsigned size) ; + virtual void Free(void *) ; + virtual void Memset(void *addr,char val,int size) ; + virtual void *Memcpy(void *s1, const void *s2, int n) ; + virtual void PostQuitMessage() ; + virtual unsigned int GetMemoryUsage() ; + +private: + static bool invert_ ; + static int lastBattLevel_ ; + static unsigned int lastBeatCount_ ; + static EventManager *eventManager_; +} ; +#endif diff --git a/sources/Adapters/SDL/GUI/SDLEventManager.cpp b/sources/Adapters/SDL/GUI/SDLEventManager.cpp index a598715d..99b9da09 100644 --- a/sources/Adapters/SDL/GUI/SDLEventManager.cpp +++ b/sources/Adapters/SDL/GUI/SDLEventManager.cpp @@ -20,6 +20,7 @@ bool SDLEventManager::Init() { EventManager::Init() ; +#ifndef SYMBIAN if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_TIMER) < 0 ) { return false; @@ -34,22 +35,15 @@ bool SDLEventManager::Init() int joyCount=SDL_NumJoysticks() ; joyCount=(joyCount>MAX_JOY_COUNT)?MAX_JOY_COUNT:joyCount ; - - keyboardCS_=new KeyboardControllerSource("keyboard") ; - const char *dumpIt=Config::GetInstance()->GetValue("DUMPEVENT") ; - if ((dumpIt)&&(!strcmp(dumpIt,"YES"))) - { - dumpEvent_=true ; - } - - for (int i=0;iGetValue("DUMPEVENT") ; + if ((dumpIt)&&(!strcmp(dumpIt,"YES"))) + { + dumpEvent_=true ; + } + for (int i=0;iw; + int screenHeight = modes[0]->h; + windowed_ = false; + #elif defined(PLATFORM_GP2X) int screenWidth = 320; int screenHeight = 240; #elif defined(PLATFORM_PSP) @@ -82,6 +89,9 @@ SDLGUIWindowImp::SDLGUIWindowImp(GUICreateWindowParams &p) Trace::Log("DISPLAY","Using driver %s. Screen (%d,%d) Bpp:%d",driverName,screenWidth,screenHeight,bitDepth_); bool fullscreen=false ; + #ifdef SYMBIAN + fullscreen=true; + #endif const char *fullscreenValue=Config::GetInstance()->GetValue("FULLSCREEN") ; if ((fullscreenValue)&&(!strcmp(fullscreenValue,"YES"))) diff --git a/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp b/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp index e1c678d9..ff7b9f22 100644 --- a/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp +++ b/sources/Adapters/Unix/FileSystem/UnixFileSystem.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/sources/Adapters/Unix/Process/UnixProcess.cpp b/sources/Adapters/Unix/Process/UnixProcess.cpp index 9912ded5..6bb85d0b 100644 --- a/sources/Adapters/Unix/Process/UnixProcess.cpp +++ b/sources/Adapters/Unix/Process/UnixProcess.cpp @@ -22,16 +22,15 @@ SysSemaphore *UnixProcessFactory::CreateNewSemaphore(int initialcount, int maxco } ; UnixSysSemaphore::UnixSysSemaphore(int initialcount,int maxcount) { - sem_=sem_open("n0ssemaphore",O_CREAT,S_IRUSR|S_IWUSR , 0 ); + sem_init(&sem_, 0, initialcount); } ; UnixSysSemaphore::~UnixSysSemaphore() { - sem_close(sem_) ; - sem_unlink("n0ssemaphore") ; + sem_destroy(&sem_); } ; SysSemaphoreResult UnixSysSemaphore::Wait() { - sem_wait(sem_) ; + sem_wait(&sem_) ; return SSR_NO_ERROR ; } ; @@ -44,6 +43,6 @@ SysSemaphoreResult UnixSysSemaphore::WaitTimeout(unsigned long timeout) { } ; SysSemaphoreResult UnixSysSemaphore::Post() { - sem_post(sem_) ; + sem_post(&sem_) ; return SSR_NO_ERROR ; } ; diff --git a/sources/Adapters/Unix/Process/UnixProcess.h b/sources/Adapters/Unix/Process/UnixProcess.h index f69181e3..0f446615 100644 --- a/sources/Adapters/Unix/Process/UnixProcess.h +++ b/sources/Adapters/Unix/Process/UnixProcess.h @@ -19,6 +19,6 @@ class UnixSysSemaphore:public SysSemaphore { virtual SysSemaphoreResult WaitTimeout(unsigned long) ; virtual SysSemaphoreResult Post() ; private: - sem_t *sem_ ; + sem_t sem_; } ; #endif diff --git a/sources/Application/AppWindow.cpp b/sources/Application/AppWindow.cpp index faa12a20..97405248 100644 --- a/sources/Application/AppWindow.cpp +++ b/sources/Application/AppWindow.cpp @@ -408,7 +408,7 @@ bool AppWindow::onEvent(GUIEvent &event) { unsigned short v=1<Lock() ; + //sm->Lock() ; switch(event.GetType()) { @@ -441,7 +441,7 @@ bool AppWindow::onEvent(GUIEvent &event) { default: break ; } - sm->Unlock() ; + //sm->Unlock() ; if (_shouldQuit) { onQuitApp() ; diff --git a/sources/Resources/lgpt_icon.svg b/sources/Resources/lgpt_icon.svg new file mode 100644 index 00000000..8e17a565 --- /dev/null +++ b/sources/Resources/lgpt_icon.svg @@ -0,0 +1,10 @@ + + + + + + + + + +