Struct playdate_sys::ffi::playdate_sys

source ·
#[repr(C)]
pub struct playdate_sys {
Show 44 fields pub realloc: Option<unsafe extern "C" fn(ptr: *mut c_void, size: usize) -> *mut c_void>, pub formatString: Option<unsafe extern "C" fn(ret: *mut *mut c_char, fmt: *const c_char, ...) -> c_int>, pub logToConsole: Option<unsafe extern "C" fn(fmt: *const c_char, ...)>, pub error: Option<unsafe extern "C" fn(fmt: *const c_char, ...)>, pub getLanguage: Option<unsafe extern "C" fn() -> PDLanguage>, pub getCurrentTimeMilliseconds: Option<unsafe extern "C" fn() -> c_uint>, pub getSecondsSinceEpoch: Option<unsafe extern "C" fn(milliseconds: *mut c_uint) -> c_uint>, pub drawFPS: Option<unsafe extern "C" fn(x: c_int, y: c_int)>, pub setUpdateCallback: Option<unsafe extern "C" fn(update: PDCallbackFunction, userdata: *mut c_void)>, pub getButtonState: Option<unsafe extern "C" fn(current: *mut PDButtons, pushed: *mut PDButtons, released: *mut PDButtons)>, pub setPeripheralsEnabled: Option<unsafe extern "C" fn(mask: PDPeripherals)>, pub getAccelerometer: Option<unsafe extern "C" fn(outx: *mut c_float, outy: *mut c_float, outz: *mut c_float)>, pub getCrankChange: Option<unsafe extern "C" fn() -> c_float>, pub getCrankAngle: Option<unsafe extern "C" fn() -> c_float>, pub isCrankDocked: Option<unsafe extern "C" fn() -> c_int>, pub setCrankSoundsDisabled: Option<unsafe extern "C" fn(flag: c_int) -> c_int>, pub getFlipped: Option<unsafe extern "C" fn() -> c_int>, pub setAutoLockDisabled: Option<unsafe extern "C" fn(disable: c_int)>, pub setMenuImage: Option<unsafe extern "C" fn(bitmap: *mut LCDBitmap, xOffset: c_int)>, pub addMenuItem: Option<unsafe extern "C" fn(title: *const c_char, callback: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>, pub addCheckmarkMenuItem: Option<unsafe extern "C" fn(title: *const c_char, value: c_int, callback: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>, pub addOptionsMenuItem: Option<unsafe extern "C" fn(title: *const c_char, optionTitles: *mut *const c_char, optionsCount: c_int, f: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>, pub removeAllMenuItems: Option<unsafe extern "C" fn()>, pub removeMenuItem: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem)>, pub getMenuItemValue: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> c_int>, pub setMenuItemValue: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, value: c_int)>, pub getMenuItemTitle: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> *const c_char>, pub setMenuItemTitle: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, title: *const c_char)>, pub getMenuItemUserdata: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> *mut c_void>, pub setMenuItemUserdata: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, ud: *mut c_void)>, pub getReduceFlashing: Option<unsafe extern "C" fn() -> c_int>, pub getElapsedTime: Option<unsafe extern "C" fn() -> c_float>, pub resetElapsedTime: Option<unsafe extern "C" fn()>, pub getBatteryPercentage: Option<unsafe extern "C" fn() -> c_float>, pub getBatteryVoltage: Option<unsafe extern "C" fn() -> c_float>, pub getTimezoneOffset: Option<unsafe extern "C" fn() -> i32>, pub shouldDisplay24HourTime: Option<unsafe extern "C" fn() -> c_int>, pub convertEpochToDateTime: Option<unsafe extern "C" fn(epoch: u32, datetime: *mut PDDateTime)>, pub convertDateTimeToEpoch: Option<unsafe extern "C" fn(datetime: *mut PDDateTime) -> u32>, pub clearICache: Option<unsafe extern "C" fn()>, pub setButtonCallback: Option<unsafe extern "C" fn(cb: PDButtonCallbackFunction, buttonud: *mut c_void, queuesize: c_int)>, pub setSerialMessageCallback: Option<unsafe extern "C" fn(callback: Option<unsafe extern "C" fn(data: *const c_char)>)>, pub vaFormatString: Option<unsafe extern "C" fn(outstr: *mut *mut c_char, fmt: *const c_char, args: va_list) -> c_int>, pub parseString: Option<unsafe extern "C" fn(str_: *const c_char, format: *const c_char, ...) -> c_int>,
}

Fields§

§realloc: Option<unsafe extern "C" fn(ptr: *mut c_void, size: usize) -> *mut c_void>

void* playdate->system->realloc(void* ptr, size_t size)

Allocates heap space if ptr is NULL, else reallocates the given pointer. If size is zero, frees the given pointer.

§formatString: Option<unsafe extern "C" fn(ret: *mut *mut c_char, fmt: *const c_char, ...) -> c_int>

int playdate->system->formatString(char **outstring, const char *format, ...)

Creates a formatted string and returns it via the outstring argument. The arguments and return value match libc’s asprintf(): the format string is standard printf() style, the string returned in outstring should be freed by the caller when it’s no longer in use, and the return value is the length of the formatted string.

§logToConsole: Option<unsafe extern "C" fn(fmt: *const c_char, ...)>

void playdate->system->logToConsole(const char* format, ...)

Calls the log function.

Equivalent to print() in the Lua API.

§error: Option<unsafe extern "C" fn(fmt: *const c_char, ...)>

void playdate->system->error(const char* format, ...)

Calls the log function, outputting an error in red to the console, then pauses execution.

§getLanguage: Option<unsafe extern "C" fn() -> PDLanguage>

PDLanguage playdate->system->getLanguage(void);

Returns the current language of the system.

§getCurrentTimeMilliseconds: Option<unsafe extern "C" fn() -> c_uint>

unsigned int playdate->system->getCurrentTimeMilliseconds(void)

Returns the number of milliseconds since…​some arbitrary point in time. This should present a consistent timebase while a game is running, but the counter will be disabled when the device is sleeping.

§getSecondsSinceEpoch: Option<unsafe extern "C" fn(milliseconds: *mut c_uint) -> c_uint>

unsigned int playdate->system->getSecondsSinceEpoch(unsigned int *milliseconds)

Returns the number of seconds (and sets milliseconds if not NULL) elapsed since midnight (hour 0), January 1, 2000.

§drawFPS: Option<unsafe extern "C" fn(x: c_int, y: c_int)>

void playdate->system->drawFPS(int x, int y)

Calculates the current frames per second and draws that value at x, y.

§setUpdateCallback: Option<unsafe extern "C" fn(update: PDCallbackFunction, userdata: *mut c_void)>

void playdate->system->setUpdateCallback(PDCallbackFunction* update, void* userdata)

PDCallbackFunction

int PDCallbackFunction(void* userdata);

Replaces the default Lua run loop function with a custom update function. The update function should return a non-zero number to tell the system to update the display, or zero if update isn’t needed.

§getButtonState: Option<unsafe extern "C" fn(current: *mut PDButtons, pushed: *mut PDButtons, released: *mut PDButtons)>

void playdate->system->getButtonState(PDButtons* current, PDButtons* pushed, PDButtons* released)

Sets the value pointed to by current to a bitmask indicating which buttons are currently down. pushed and released reflect which buttons were pushed or released over the previous update cycle—at the nominal frame rate of 50 ms, fast button presses can be missed if you just poll the instantaneous state.

§setPeripheralsEnabled: Option<unsafe extern "C" fn(mask: PDPeripherals)>

void playdate->system->setPeripheralsEnabled(PDPeripherals mask)

By default, the accelerometer is disabled to save (a small amount of) power. To use a peripheral, it must first be enabled via this function. Accelerometer data is not available until the next update cycle after it’s enabled.

PDPeripherals

kNone
kAccelerometer
§getAccelerometer: Option<unsafe extern "C" fn(outx: *mut c_float, outy: *mut c_float, outz: *mut c_float)>

void playdate->system->getAccelerometer(float* outx, float* outy, float* outz)

Returns the last-read accelerometer data.

§getCrankChange: Option<unsafe extern "C" fn() -> c_float>

float playdate->system->getCrankChange(void)

Returns the angle change of the crank since the last time this function was called. Negative values are anti-clockwise.

§getCrankAngle: Option<unsafe extern "C" fn() -> c_float>

float playdate->system->getCrankAngle(void)

Returns the current position of the crank, in the range 0-360. Zero is pointing up, and the value increases as the crank moves clockwise, as viewed from the right side of the device.

§isCrankDocked: Option<unsafe extern "C" fn() -> c_int>

int playdate->system->isCrankDocked(void)

Returns 1 or 0 indicating whether or not the crank is folded into the unit.

§setCrankSoundsDisabled: Option<unsafe extern "C" fn(flag: c_int) -> c_int>

int playdate->system->setCrankSoundsDisabled(int disable)

The function returns the previous value for this setting.

§getFlipped: Option<unsafe extern "C" fn() -> c_int>

int playdate->system->getFlipped()

Returns 1 if the global “flipped” system setting is set, otherwise 0.

§setAutoLockDisabled: Option<unsafe extern "C" fn(disable: c_int)>

void playdate->system->setAutoLockDisabled(int disable)

Disables or enables the 3 minute auto lock feature. When called, the timer is reset to 3 minutes.

§setMenuImage: Option<unsafe extern "C" fn(bitmap: *mut LCDBitmap, xOffset: c_int)>

void playdate->system->setMenuImage(LCDBitmap* bitmap, int xOffset);

A game can optionally provide an image to be displayed alongside the system menu. bitmap must be a 400x240 LCDBitmap. All important content should be in the left half of the image in an area 200 pixels wide, as the menu will obscure the rest. The right side of the image will be visible briefly as the menu animates in and out.

Optionally, a non-zero xoffset, can be provided. This must be a number between 0 and 200 and will cause the menu image to animate to a position offset left by xoffset pixels as the menu is animated in.

This function could be called in response to the kEventPause event in your implementation of eventHandler().

§addMenuItem: Option<unsafe extern "C" fn(title: *const c_char, callback: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>

PDMenuItem* playdate->system->addMenuItem(const char* title, PDMenuItemCallbackFunction* callback, void* userdata)

title will be the title displayed by the menu item.

Adds a new menu item to the System Menu. When invoked by the user, this menu item will:

  1. Invoke your callback function.

  2. Hide the System Menu.

  3. Unpause your game and call eventHandler() with the kEventResume event.

Your game can then present an options interface to the player, or take other action, in whatever manner you choose.

The returned menu item is freed when removed from the menu; it does not need to be freed manually.

§addCheckmarkMenuItem: Option<unsafe extern "C" fn(title: *const c_char, value: c_int, callback: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>

PDMenuItem* playdate->system->addCheckmarkMenuItem(const char* title, int value, PDMenuItemCallbackFunction* callback, void* userdata)

Adds a new menu item that can be checked or unchecked by the player.

title will be the title displayed by the menu item.

value should be 0 for unchecked, 1 for checked.

If this menu item is interacted with while the system menu is open, callback will be called when the menu is closed.

The returned menu item is freed when removed from the menu; it does not need to be freed manually.

§addOptionsMenuItem: Option<unsafe extern "C" fn(title: *const c_char, optionTitles: *mut *const c_char, optionsCount: c_int, f: PDMenuItemCallbackFunction, userdata: *mut c_void) -> *mut PDMenuItem>

PDMenuItem* playdate->system->addOptionsMenuItem(const char* title, const char** options, int optionsCount, PDMenuItemCallbackFunction* callback, void* userdata)

Adds a new menu item that allows the player to cycle through a set of options.

title will be the title displayed by the menu item.

options should be an array of strings representing the states this menu item can cycle through. Due to limited horizontal space, the option strings and title should be kept short for this type of menu item.

optionsCount should be the number of items contained in options.

If this menu item is interacted with while the system menu is open, callback will be called when the menu is closed.

The returned menu item is freed when removed from the menu; it does not need to be freed manually.

§removeAllMenuItems: Option<unsafe extern "C" fn()>

void playdate->system->removeAllMenuItems()

Removes all custom menu items from the system menu.

§removeMenuItem: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem)>

void playdate->system->removeMenuItem(PDMenuItem *menuItem)

Removes the menu item from the system menu.

§getMenuItemValue: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> c_int>

int playdate->system->getMenuItemValue(PDMenuItem *menuItem)

§setMenuItemValue: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, value: c_int)>

void playdate->system->setMenuItemValue(PDMenuItem *menuItem, int value)

Gets or sets the integer value of the menu item.

For checkmark menu items, 1 means checked, 0 unchecked. For option menu items, the value indicates the array index of the currently selected option.

§getMenuItemTitle: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> *const c_char>

const char* playdate->system->getMenuItemTitle(PDMenuItem *menuItem)

§setMenuItemTitle: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, title: *const c_char)>

void playdate->system->setMenuItemTitle(PDMenuItem *menuItem, const char* title)

Gets or sets the display title of the menu item.

§getMenuItemUserdata: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem) -> *mut c_void>

void* playdate->system->getMenuItemUserdata(PDMenuItem *menuItem)

§setMenuItemUserdata: Option<unsafe extern "C" fn(menuItem: *mut PDMenuItem, ud: *mut c_void)>

void playdate->system->setMenuItemUserdata(PDMenuItem *menuItem, void* userdata)

Gets or sets the userdata value associated with this menu item.

§getReduceFlashing: Option<unsafe extern "C" fn() -> c_int>

int playdate->system->getReduceFlashing()

Returns 1 if the global “reduce flashing” system setting is set, otherwise 0.

§getElapsedTime: Option<unsafe extern "C" fn() -> c_float>

float playdate->system->getElapsedTime()

Returns the number of seconds since playdate.resetElapsedTime() was called. The value is a floating-point number with microsecond accuracy.

§resetElapsedTime: Option<unsafe extern "C" fn()>

void playdate->system->resetElapsedTime(void)

Resets the high-resolution timer.

§getBatteryPercentage: Option<unsafe extern "C" fn() -> c_float>

float playdate->system->getBatteryPercentage()

Returns a value from 0-100 denoting the current level of battery charge. 0 = empty; 100 = full.

§getBatteryVoltage: Option<unsafe extern "C" fn() -> c_float>

float playdate->system->getBatteryVoltage()

Returns the battery’s current voltage level.

§getTimezoneOffset: Option<unsafe extern "C" fn() -> i32>

int32_t playdate->system->getTimezoneOffset()

Returns the system timezone offset from GMT, in seconds.

§shouldDisplay24HourTime: Option<unsafe extern "C" fn() -> c_int>

int playdate->system->shouldDisplay24HourTime()

Returns 1 if the user has set the 24-Hour Time preference in the Settings program.

§convertEpochToDateTime: Option<unsafe extern "C" fn(epoch: u32, datetime: *mut PDDateTime)>

void playdate->system->convertEpochToDateTime(uint32_t epoch, struct PDDateTime* datetime)

Converts the given epoch time to a PDDateTime.

§convertDateTimeToEpoch: Option<unsafe extern "C" fn(datetime: *mut PDDateTime) -> u32>

uint32_t playdate->system->convertDateTimeToEpoch(struct PDDateTime* datetime)

Converts the given PDDateTime to an epoch time.

§clearICache: Option<unsafe extern "C" fn()>

float playdate->system->clearICache()

Flush the CPU instruction cache, on the very unlikely chance you’re modifying instruction code on the fly. (If you don’t know what I’m talking about, you don’t need this. :smile:)

§setButtonCallback: Option<unsafe extern "C" fn(cb: PDButtonCallbackFunction, buttonud: *mut c_void, queuesize: c_int)>§setSerialMessageCallback: Option<unsafe extern "C" fn(callback: Option<unsafe extern "C" fn(data: *const c_char)>)>

void playdate->system->setSerialMessageCallback(void (*callback)(const char* data));

Provides a callback to receive messages sent to the device over the serial port using the msg command. If no device is connected, you can send these messages to a game in the simulator by entering !msg <message> in the Lua console.

§vaFormatString: Option<unsafe extern "C" fn(outstr: *mut *mut c_char, fmt: *const c_char, args: va_list) -> c_int>

int playdate->system->vaFormatString(char **ret, const char *format, va_list args)

Allocates and formats a string using a variadic va_list argument, in the style of vasprintf(). The string returned via ret should be freed by the caller when it is no longer in use. The return value from the function is the length of the formatted string.

§parseString: Option<unsafe extern "C" fn(str_: *const c_char, format: *const c_char, ...) -> c_int>

int playdate->system->parseString(const char *str, const char *format, ...)

Like libc sscanf(), parses a string according to a format string and places the values into pointers passed in after the format. The return value is the number of items matched.

Trait Implementations§

source§

impl Clone for playdate_sys

source§

fn clone(&self) -> playdate_sys

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for playdate_sys

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for playdate_sys

source§

fn default() -> playdate_sys

Returns the “default value” for a type. Read more
source§

impl Hash for playdate_sys

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
source§

impl Ord for playdate_sys

source§

fn cmp(&self, other: &playdate_sys) -> Ordering

This method returns an [Ordering] between self and other. Read more
1.21.0§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for playdate_sys

source§

fn eq(&self, other: &playdate_sys) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for playdate_sys

source§

fn partial_cmp(&self, other: &playdate_sys) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for playdate_sys

source§

impl Eq for playdate_sys

source§

impl StructuralPartialEq for playdate_sys

Auto Trait Implementations§

§

impl Freeze for playdate_sys

§

impl RefUnwindSafe for playdate_sys

§

impl Send for playdate_sys

§

impl Sync for playdate_sys

§

impl Unpin for playdate_sys

§

impl UnwindSafe for playdate_sys

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 176 bytes