forked from mmozeiko/pkgi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpkgi.h
More file actions
126 lines (95 loc) · 3.93 KB
/
pkgi.h
File metadata and controls
126 lines (95 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#pragma once
#include <stdint.h>
#include <stdarg.h>
// values compatible with psp2/ctrl.h header
#define PKGI_BUTTON_SELECT 0x00000001
#define PKGI_BUTTON_START 0x00000008
#define PKGI_BUTTON_UP 0x00000010
#define PKGI_BUTTON_RIGHT 0x00000020
#define PKGI_BUTTON_DOWN 0x00000040
#define PKGI_BUTTON_LEFT 0x00000080
#define PKGI_BUTTON_LT 0x00000100
#define PKGI_BUTTON_RT 0x00000200
#define PKGI_BUTTON_X 0x00004000 // cross
#define PKGI_BUTTON_O 0x00002000 // circle
#define PKGI_BUTTON_T 0x00001000 // triangle
#define PKGI_BUTTON_S 0x00008000 // square
#define PKGI_UNUSED(x) (void)(x)
typedef struct pkgi_input {
uint64_t delta; // microseconds from previous frame
uint32_t pressed; // button pressed in last frame
uint32_t down; // button is currently down
uint32_t active; // button is pressed in last frame, or held down for a long time (10 frames)
} pkgi_input;
#define PKGI_COUNTOF(arr) (sizeof(arr)/sizeof(0[arr]))
#ifdef PKGI_ENABLE_LOGGING
#define LOG(msg, ...) pkgi_log(msg, ## __VA_ARGS__)
#else
#define LOG(...)
#endif
void pkgi_log(const char* msg, ...);
int pkgi_snprintf(char* buffer, uint32_t size, const char* msg, ...);
void pkgi_vsnprintf(char* buffer, uint32_t size, const char* msg, va_list args);
char* pkgi_strstr(const char* str, const char* sub);
int pkgi_stricontains(const char* str, const char* sub);
int pkgi_stricmp(const char* a, const char* b);
void pkgi_strncpy(char* dst, uint32_t size, const char* src);
char* pkgi_strrchr(const char* str, char ch);
void pkgi_memcpy(void* dst, const void* src, uint32_t size);
void pkgi_memmove(void* dst, const void* src, uint32_t size);
int pkgi_memequ(const void* a, const void* b, uint32_t size);
int pkgi_is_unsafe_mode(void);
int pkgi_ok_button(void);
int pkgi_cancel_button(void);
void pkgi_start(void);
int pkgi_update(pkgi_input* input);
void pkgi_swap(void);
void pkgi_end(void);
int pkgi_battery_present();
int pkgi_bettery_get_level();
int pkgi_battery_is_low();
int pkgi_battery_is_charging();
uint64_t pkgi_get_free_space(void);
const char* pkgi_get_pkgi_folder(void);
const char* pkgi_get_app_folder(void);
int pkgi_is_incomplete(const char* titleid);
int pkgi_is_installed(const char* titleid);
int pkgi_install(const char* titleid);
uint32_t pkgi_time_msec();
typedef void pkgi_thread_entry(void);
void pkgi_start_thread(const char* name, pkgi_thread_entry* start);
void pkgi_sleep(uint32_t msec);
int pkgi_load(const char* name, void* data, uint32_t max);
int pkgi_save(const char* name, const void* data, uint32_t size);
void pkgi_lock_process(void);
void pkgi_unlock_process(void);
void pkgi_dialog_lock(void);
void pkgi_dialog_unlock(void);
void pkgi_dialog_input_text(const char* title, const char* text);
int pkgi_dialog_input_update(void);
void pkgi_dialog_input_get_text(char* text, uint32_t size);
int pkgi_check_free_space(uint64_t http_length);
typedef struct pkgi_http pkgi_http;
pkgi_http* pkgi_http_get(const char* url, const char* content, uint64_t offset);
int pkgi_http_response_length(pkgi_http* http, int64_t* length);
int pkgi_http_read(pkgi_http* http, void* buffer, uint32_t size);
void pkgi_http_close(pkgi_http* http);
int pkgi_mkdirs(char* path);
void pkgi_rm(const char* file);
int64_t pkgi_get_size(const char* path);
// creates file (if it exists, truncates size to 0)
void* pkgi_create(const char* path);
// open existing file in read/write, fails if file does not exist
void* pkgi_openrw(const char* path);
// open file for writing, next write will append data to end of it
void* pkgi_append(const char* path);
void pkgi_close(void* f);
int pkgi_read(void* f, void* buffer, uint32_t size);
int pkgi_write(void* f, const void* buffer, uint32_t size);
// UI stuff
void pkgi_clip_set(int x, int y, int w, int h);
void pkgi_clip_remove(void);
void pkgi_draw_rect(int x, int y, int w, int h, uint32_t color);
void pkgi_draw_text(int x, int y, uint32_t color, const char* text);
int pkgi_text_width(const char* text);
int pkgi_text_height(const char* text);