Please note the following important changes:
- Experimental feature: added read/write access for all games to top-level /Shared folder
Having a way for games to share data has been a feature request for a long time. We tried to imagine all the use cases here and thought about how we’d support them, but looking at it that way it becomes a big hairy mess. So instead we’re doing the simplest thing imaginable: adding a top-level shared folder that any game can read from and write to, with no enforced structure whatsoever, and we’ll just see what happens. My hope is that after testing this out the community comes up with a set of best practices that we then build API around--or at least put into documentation. Further discussion here. - Added callbacks for receiving messages via the serial port msg command
Lua:playdate.serialMessageReceived(message)
C:playdate->system->setSerialMessageCallback(void (*callback)(const char* data));
As a convenient way to get data into the Playdate runtime I've added amsg
command that takes a string at a time and sends it to a callback. This is much easier than sending it one character at a time withbtn
or usingeval
which takes compiled Lua bytecode. Related: - Serial port can now receive more than 64 KB/s..which will help if you’re sending a lot of data via
msg
. Also you can now display full frame rate video on the device using thebitmap
command. - added playdate.setButtonQueueSize() and pd->system->setButtonCallback(), an optional button event queue and callback for more precise button handling. These lets you detect multiple button presses in one update cycle. In Lua you get the normal
playdate.XButttonDown/Up()
callback and in C you pass in a callback function. In both cases the callback function is passed the time of the event, in case that’s useful. - C API: added pd->system->parseString()
- C API: added pd->system->vaFormatString()
These provide the libc functions sscanf() and vasprintf(), respectively. You don’t miss them until you need them! - added MicSource enum to pd->sound->setMicCallback to specify internal/headset/either source
- added optional source arg (“internal” or “headset”) to snd.micinput.startListening()
The Playdate hardware has a chip (TS3S227E, if you’re curious) that automatically detects whether something plugged into the headphone jack has a microphone and which pin layout (standard vs OMTP) it uses. It works great for normal headphones but it can get in the way if you’re trying to use a speaker/mic splitter to connect an external source to the microphone. These functions give manual control over the mic source so we no longer need to cross fingers and perform dark rituals to get the connection working. - C API: added copyUserdata callback function to synth->setGenerator
- C API: added synth->copy()
- Copied sample synths and wavetable synths now work correctly
Before this release we had a bug where synths created with the Lua synth:copy() function didn’t create a new instance of the generator’s userdata but instead pointed to the original. To fix this we’ve added a copy callback in setGenerator() that you use to make a unique copy of the userdata for the copied synth’s generator. If the userdata only contains scalar values, you can just alloc a new userdata and memcpy() the original into it; if it contains references to other objects you might need to also duplicate those, or retain them if they use reference counting.
We’ve deprecated the existing function by renaming it tosetGenerator_deprecated()
and added the new argument to a new API function namedsetGenerator()
. This means that existing code will continue to use the old function, but if you recompile against the new API you’ll get an error that yoursetGenerator()
call is missing an argument. Hopefully that’s not too confusing.. I thought it was better than mucking up the API by addingsetGeneratorWithCopyUserdata()
or something like that.
One handy consequence of this is you can now use synth:copy() (or the new C API synth->copy()) to add multiple voices for polyphonic instruments, instead of building each voice from scratch as was previously required. I’ve updated the Lua MIDIPlayer and DrumMachine and C API bach.mid examples to use this.
Check the changelog for what's been updated and please post a new thread in SDK Bug Reports if you run into any problems.