Improved controls

This commit is contained in:
TheFloW 2018-01-25 22:22:07 +01:00
parent d498044c2e
commit 840c604b9d
24 changed files with 231 additions and 139 deletions

View File

@ -56,7 +56,7 @@ static int file_open(struct archive *a, void *client_data) {
if (archive_data->fd < 0) if (archive_data->fd < 0)
return ARCHIVE_FATAL; return ARCHIVE_FATAL;
archive_data->buffer = memalign(64, TRANSFER_SIZE); archive_data->buffer = memalign(4096, TRANSFER_SIZE);
archive_data->block_size = TRANSFER_SIZE; archive_data->block_size = TRANSFER_SIZE;
return ARCHIVE_OK; return ARCHIVE_OK;
@ -635,7 +635,7 @@ int extractArchiveFile(const char *src_path, const char *dst_path, FileProcessPa
return fddst; return fddst;
} }
void *buf = memalign(64, TRANSFER_SIZE); void *buf = memalign(4096, TRANSFER_SIZE);
while (1) { while (1) {
int read = archiveFileRead(fdsrc, buf, TRANSFER_SIZE); int read = archiveFileRead(fdsrc, buf, TRANSFER_SIZE);

View File

@ -229,17 +229,17 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
readPad(); readPad();
// Cancel // Cancel
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
break; break;
} }
// Display off // Display off
if (pressed_buttons & SCE_CTRL_TRIANGLE) { if (pressed_pad[PAD_TRIANGLE]) {
scePowerRequestDisplayOff(); scePowerRequestDisplayOff();
} }
// Toggle play/pause // Toggle play/pause
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
if (isPlayingFunct() && getPlayingSpeedFunct() == 0) { if (isPlayingFunct() && getPlayingSpeedFunct() == 0) {
pauseFunct(); pauseFunct();
} else { } else {
@ -248,10 +248,10 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
} }
} }
if (pressed_buttons & SCE_CTRL_LEFT || pressed_buttons & SCE_CTRL_RIGHT) { if (pressed_pad[PAD_LEFT] || pressed_pad[PAD_RIGHT]) {
int speed = getPlayingSpeedFunct(); int speed = getPlayingSpeedFunct();
if (pressed_buttons & SCE_CTRL_LEFT) { if (pressed_pad[PAD_LEFT]) {
int i; int i;
for (i = 0; i < N_SPEED; i++) { for (i = 0; i < N_SPEED; i++) {
if (speed_list[i] == speed) { if (speed_list[i] == speed) {
@ -262,7 +262,7 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
} }
} }
if (pressed_buttons & SCE_CTRL_RIGHT) { if (pressed_pad[PAD_RIGHT]) {
int i; int i;
for (i = 0; i < N_SPEED; i++) { for (i = 0; i < N_SPEED; i++) {
if (speed_list[i] == speed) { if (speed_list[i] == speed) {
@ -280,8 +280,8 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
// Previous/next song. // Previous/next song.
if (getPercentageFunct() == 100.0f || endOfStreamFunct() || if (getPercentageFunct() == 100.0f || endOfStreamFunct() ||
pressed_buttons & SCE_CTRL_LTRIGGER || pressed_buttons & SCE_CTRL_RTRIGGER) { pressed_pad[PAD_LTRIGGER] || pressed_pad[PAD_RTRIGGER]) {
int previous = pressed_buttons & SCE_CTRL_LTRIGGER; int previous = pressed_pad[PAD_LTRIGGER];
if (previous && strcmp(cur_time_string, "00:00:00") != 0) { if (previous && strcmp(cur_time_string, "00:00:00") != 0) {
lrcParseClose(lyrics); lrcParseClose(lyrics);
endFunct(); endFunct();

View File

@ -114,7 +114,7 @@ void drawContextMenu() {
pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + CONTEXT_MENU_MARGIN, y, color, language_container[ctx->entries[i].name]); pgf_draw_text(SCREEN_WIDTH - ctx_cur_menu_width + CONTEXT_MENU_MARGIN, y, color, language_container[ctx->entries[i].name]);
// Draw arrow for 'More' // Draw arrow for 'More'
if (ctx->entries[i].more) { if (ctx->entries[i].flags & CTX_FLAG_MORE) {
char *arrow = RIGHT_ARROW; char *arrow = RIGHT_ARROW;
if (ctx->sel == i) { if (ctx->sel == i) {
@ -156,7 +156,7 @@ void contextMenuCtrl() {
if (!cur_ctx) if (!cur_ctx)
return; return;
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) {
int i; int i;
for (i = cur_ctx->n_entries - 1; i >= 0; i--) { for (i = cur_ctx->n_entries - 1; i >= 0; i--) {
@ -168,7 +168,7 @@ void contextMenuCtrl() {
} }
} }
} }
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) {
int i; int i;
for (i = 0; i < cur_ctx->n_entries; i++) { for (i = 0; i < cur_ctx->n_entries; i++) {
@ -183,12 +183,12 @@ void contextMenuCtrl() {
} }
// Close // Close
if (pressed_buttons & SCE_CTRL_TRIANGLE) { if (pressed_pad[PAD_TRIANGLE]) {
ctx_menu_mode = CONTEXT_MENU_CLOSING; ctx_menu_mode = CONTEXT_MENU_CLOSING;
} }
// Back // Back
if (pressed_buttons & SCE_CTRL_CANCEL || pressed_buttons & SCE_CTRL_LEFT) { if (pressed_pad[PAD_CANCEL] || pressed_pad[PAD_LEFT]) {
if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { if (ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) {
ctx_menu_mode = CONTEXT_MENU_MORE_CLOSING; ctx_menu_mode = CONTEXT_MENU_MORE_CLOSING;
} else { } else {
@ -197,7 +197,7 @@ void contextMenuCtrl() {
} }
// Handle // Handle
if (pressed_buttons & SCE_CTRL_ENTER || pressed_buttons & SCE_CTRL_RIGHT) { if (pressed_pad[PAD_ENTER] || pressed_pad[PAD_RIGHT]) {
if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) { if (ctx_menu_mode == CONTEXT_MENU_OPENED || ctx_menu_mode == CONTEXT_MENU_MORE_OPENED) {
if (cur_ctx->callback) if (cur_ctx->callback)
ctx_menu_mode = cur_ctx->callback(cur_ctx->sel, cur_ctx->context); ctx_menu_mode = cur_ctx->callback(cur_ctx->sel, cur_ctx->context);

View File

@ -27,10 +27,15 @@ enum ContextMenuVisibilities {
CTX_VISIBLE, CTX_VISIBLE,
}; };
enum ContextMenuFlags {
CTX_FLAG_MORE = 0x1,
CTX_FLAG_BARRIER = 0x2,
};
typedef struct { typedef struct {
int name; int name;
int pos; int pos;
int more; int flags;
int visibility; int visibility;
} MenuEntry; } MenuEntry;

View File

@ -158,14 +158,14 @@ static int decompressGzip(uint8_t *dst, int size_dst, uint8_t *src, int size_src
} }
int coredumpViewer(const char *file) { int coredumpViewer(const char *file) {
void *buffer = memalign(64, BIG_BUFFER_SIZE); void *buffer = memalign(4096, BIG_BUFFER_SIZE);
if (!buffer) if (!buffer)
return -1; return -1;
int size = ReadFile(file, buffer, BIG_BUFFER_SIZE); int size = ReadFile(file, buffer, BIG_BUFFER_SIZE);
if (*(uint16_t *)buffer == 0x8B1F) { if (*(uint16_t *)buffer == 0x8B1F) {
void *out_buf = memalign(64, BIG_BUFFER_SIZE); void *out_buf = memalign(4096, BIG_BUFFER_SIZE);
if (!out_buf) { if (!out_buf) {
free(buffer); free(buffer);
return -2; return -2;
@ -266,7 +266,7 @@ int coredumpViewer(const char *file) {
while (1) { while (1) {
readPad(); readPad();
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
break; break;
} }

4
file.c
View File

@ -125,7 +125,7 @@ int getFileSha1(const char *file, uint8_t *pSha1Out, FileProcessParam *param) {
return fd; return fd;
// Open up the buffer for copying data into // Open up the buffer for copying data into
void *buf = memalign(64, TRANSFER_SIZE); void *buf = memalign(4096, TRANSFER_SIZE);
// Actually take the SHA1 sum // Actually take the SHA1 sum
while (1) { while (1) {
@ -348,7 +348,7 @@ int copyFile(const char *src_path, const char *dst_path, FileProcessParam *param
return fddst; return fddst;
} }
void *buf = memalign(64, TRANSFER_SIZE); void *buf = memalign(4096, TRANSFER_SIZE);
while (1) { while (1) {
int read = sceIoRead(fdsrc, buf, TRANSFER_SIZE); int read = sceIoRead(fdsrc, buf, TRANSFER_SIZE);

2
file.h
View File

@ -29,7 +29,7 @@
#define MAX_DIR_LEVELS 32 #define MAX_DIR_LEVELS 32
#define DIRECTORY_SIZE (4 * 1024) #define DIRECTORY_SIZE (4 * 1024)
#define TRANSFER_SIZE (64 * 1024) #define TRANSFER_SIZE (128 * 1024)
#define HOME_PATH "home" #define HOME_PATH "home"
#define DIR_UP ".." #define DIR_UP ".."

20
hex.c
View File

@ -74,7 +74,7 @@ static HexListEntry *hexListGetNthEntry(HexList *list, int n) {
int hexViewer(const char *file) { int hexViewer(const char *file) {
int text_viewer = 0; int text_viewer = 0;
uint8_t *buffer = memalign(64, BIG_BUFFER_SIZE); uint8_t *buffer = memalign(4096, BIG_BUFFER_SIZE);
if (!buffer) if (!buffer)
return -1; return -1;
@ -116,7 +116,7 @@ int hexViewer(const char *file) {
readPad(); readPad();
if (!isMessageDialogRunning()) { if (!isMessageDialogRunning()) {
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
if (rel_pos > 0) { if (rel_pos > 0) {
rel_pos -= 0x10; rel_pos -= 0x10;
} else if (base_pos > 0) { } else if (base_pos > 0) {
@ -137,7 +137,7 @@ int hexViewer(const char *file) {
// Read // Read
memcpy(list.head->data, buffer+base_pos, 0x10); memcpy(list.head->data, buffer+base_pos, 0x10);
} }
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
if ((rel_pos+0x10) < size) { if ((rel_pos+0x10) < size) {
if ((rel_pos+0x10) < ((MAX_POSITION - 1) * 0x10)) { if ((rel_pos+0x10) < ((MAX_POSITION - 1) * 0x10)) {
rel_pos += 0x10; rel_pos += 0x10;
@ -163,7 +163,7 @@ int hexViewer(const char *file) {
} }
// Page skip // Page skip
if (hold_buttons & SCE_CTRL_LTRIGGER) { if (hold_pad[PAD_LTRIGGER]) {
if ((base_pos + rel_pos) != 0) { if ((base_pos + rel_pos) != 0) {
if ((base_pos-0x10*0x10) >= 0) { if ((base_pos-0x10*0x10) >= 0) {
base_pos -= 0x10*0x10; base_pos -= 0x10*0x10;
@ -182,7 +182,7 @@ int hexViewer(const char *file) {
} }
} }
if (hold_buttons & SCE_CTRL_RTRIGGER) { if (hold_pad[PAD_RTRIGGER]) {
if (size >= 0xF0) { if (size >= 0xF0) {
if ((base_pos + rel_pos+0x1F0) < size) { if ((base_pos + rel_pos+0x1F0) < size) {
base_pos += 0x10*0x10; base_pos += 0x10*0x10;
@ -217,17 +217,17 @@ int hexViewer(const char *file) {
nibble_pos = max_nibble; nibble_pos = max_nibble;
} }
if (hold_buttons & SCE_CTRL_LEFT || hold2_buttons & SCE_CTRL_LEFT_ANALOG_LEFT) { if (hold_pad[PAD_LEFT] || hold2_pad[PAD_LEFT_ANALOG_LEFT]) {
if (nibble_pos > 0) if (nibble_pos > 0)
nibble_pos--; nibble_pos--;
} else if (hold_buttons & SCE_CTRL_RIGHT || hold2_buttons & SCE_CTRL_LEFT_ANALOG_RIGHT) { } else if (hold_pad[PAD_RIGHT] || hold2_pad[PAD_LEFT_ANALOG_RIGHT]) {
if (nibble_pos < max_nibble) if (nibble_pos < max_nibble)
nibble_pos++; nibble_pos++;
} }
// Cancel or switch to text viewer // Cancel or switch to text viewer
if (pressed_buttons & SCE_CTRL_CANCEL || pressed_buttons & SCE_CTRL_SQUARE) { if (pressed_pad[PAD_CANCEL] || pressed_pad[PAD_SQUARE]) {
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
text_viewer = 0; text_viewer = 0;
} else { } else {
text_viewer = 1; text_viewer = 1;
@ -241,7 +241,7 @@ int hexViewer(const char *file) {
} }
// Increase nibble // Increase nibble
if (modify_allowed && hold_buttons & SCE_CTRL_ENTER) { if (modify_allowed && hold_pad[PAD_ENTER]) {
changed = 1; changed = 1;
int cur_pos = rel_pos + base_pos + nibble_pos / 2; int cur_pos = rel_pos + base_pos + nibble_pos / 2;

5
init.c
View File

@ -176,8 +176,9 @@ static void initSceAppUtil() {
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_TIME_FORMAT, &time_format); sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_TIME_FORMAT, &time_format);
if (enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) { if (enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) {
SCE_CTRL_ENTER = SCE_CTRL_CIRCLE; setEnterButton(1);
SCE_CTRL_CANCEL = SCE_CTRL_CROSS; } else {
setEnterButton(0);
} }
// Set common dialog config // Set common dialog config

View File

@ -119,6 +119,8 @@ void loadLanguage(int id) {
LANGUAGE_ENTRY(RENAME), LANGUAGE_ENTRY(RENAME),
LANGUAGE_ENTRY(NEW_FOLDER), LANGUAGE_ENTRY(NEW_FOLDER),
LANGUAGE_ENTRY(PROPERTIES), LANGUAGE_ENTRY(PROPERTIES),
LANGUAGE_ENTRY(SEND),
LANGUAGE_ENTRY(RECEIVE),
LANGUAGE_ENTRY(MORE), LANGUAGE_ENTRY(MORE),
LANGUAGE_ENTRY(COMPRESS), LANGUAGE_ENTRY(COMPRESS),
LANGUAGE_ENTRY(INSTALL_ALL), LANGUAGE_ENTRY(INSTALL_ALL),

View File

@ -78,6 +78,8 @@ enum LanguageContainer {
RENAME, RENAME,
NEW_FOLDER, NEW_FOLDER,
PROPERTIES, PROPERTIES,
SEND,
RECEIVE,
MORE, MORE,
COMPRESS, COMPRESS,
INSTALL_ALL, INSTALL_ALL,

20
main.c
View File

@ -1287,12 +1287,12 @@ static int fileBrowserMenuCtrl() {
int refresh = 0; int refresh = 0;
// Settings menu // Settings menu
if (pressed_buttons & SCE_CTRL_START) { if (pressed_pad[PAD_START]) {
openSettingsMenu(); openSettingsMenu();
} }
// SELECT button // SELECT button
if (pressed_buttons & SCE_CTRL_SELECT) { if (pressed_pad[PAD_SELECT]) {
if (vitashell_config.select_button == SELECT_BUTTON_MODE_USB && sceKernelGetModel() == SCE_KERNEL_MODEL_VITA) { if (vitashell_config.select_button == SELECT_BUTTON_MODE_USB && sceKernelGetModel() == SCE_KERNEL_MODEL_VITA) {
if (is_safe_mode) { if (is_safe_mode) {
infoDialog(language_container[EXTENDED_PERMISSIONS_REQUIRED]); infoDialog(language_container[EXTENDED_PERMISSIONS_REQUIRED]);
@ -1331,14 +1331,14 @@ static int fileBrowserMenuCtrl() {
} }
// QR // QR
if (hold2_buttons & SCE_CTRL_LTRIGGER && hold2_buttons & SCE_CTRL_RTRIGGER && enabledQR()) { if (hold_pad[PAD_LTRIGGER] && hold_pad[PAD_RTRIGGER] && enabledQR()) {
startQR(); startQR();
initMessageDialog(MESSAGE_DIALOG_QR_CODE, language_container[QR_SCANNING]); initMessageDialog(MESSAGE_DIALOG_QR_CODE, language_container[QR_SCANNING]);
setDialogStep(DIALOG_STEP_QR); setDialogStep(DIALOG_STEP_QR);
} }
// Move // Move
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
int old_pos = base_pos + rel_pos; int old_pos = base_pos + rel_pos;
if (rel_pos > 0) { if (rel_pos > 0) {
@ -1350,7 +1350,7 @@ static int fileBrowserMenuCtrl() {
if (old_pos != base_pos + rel_pos) { if (old_pos != base_pos + rel_pos) {
scroll_count = 0; scroll_count = 0;
} }
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
int old_pos = base_pos + rel_pos; int old_pos = base_pos + rel_pos;
if ((rel_pos + 1) < file_list.length) { if ((rel_pos + 1) < file_list.length) {
@ -1367,7 +1367,7 @@ static int fileBrowserMenuCtrl() {
} }
// Context menu trigger // Context menu trigger
if (pressed_buttons & SCE_CTRL_TRIANGLE) { if (pressed_pad[PAD_TRIANGLE]) {
if (getContextMenuMode() == CONTEXT_MENU_CLOSED) { if (getContextMenuMode() == CONTEXT_MENU_CLOSED) {
if (dir_level > 0) { if (dir_level > 0) {
setContextMenu(&context_menu_main); setContextMenu(&context_menu_main);
@ -1384,7 +1384,7 @@ static int fileBrowserMenuCtrl() {
// Not at 'home' // Not at 'home'
if (dir_level > 0) { if (dir_level > 0) {
// Mark entry // Mark entry
if (pressed_buttons & SCE_CTRL_SQUARE) { if (pressed_pad[PAD_SQUARE]) {
FileListEntry *file_entry = fileListGetNthEntry(&file_list, base_pos + rel_pos); FileListEntry *file_entry = fileListGetNthEntry(&file_list, base_pos + rel_pos);
if (file_entry && strcmp(file_entry->name, DIR_UP) != 0) { if (file_entry && strcmp(file_entry->name, DIR_UP) != 0) {
if (!fileListFindEntry(&mark_list, file_entry->name)) { if (!fileListFindEntry(&mark_list, file_entry->name)) {
@ -1396,7 +1396,7 @@ static int fileBrowserMenuCtrl() {
} }
// Back // Back
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
scroll_count = 0; scroll_count = 0;
fileListEmpty(&mark_list); fileListEmpty(&mark_list);
dirUp(); dirUp();
@ -1406,7 +1406,7 @@ static int fileBrowserMenuCtrl() {
} }
// Handle // Handle
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
scroll_count = 0; scroll_count = 0;
fileListEmpty(&mark_list); fileListEmpty(&mark_list);
@ -1759,7 +1759,7 @@ int main(int argc, const char *argv[]) {
// No custom config, in case they are damaged or unuseable // No custom config, in case they are damaged or unuseable
readPad(); readPad();
if (current_buttons & SCE_CTRL_LTRIGGER) if (current_pad[PAD_LTRIGGER])
use_custom_config = 0; use_custom_config = 0;
// Load settings // Load settings

View File

@ -62,6 +62,8 @@ enum MenuMainEntrys {
MENU_MAIN_ENTRY_PROPERTIES, MENU_MAIN_ENTRY_PROPERTIES,
MENU_MAIN_ENTRY_SORT_BY, MENU_MAIN_ENTRY_SORT_BY,
MENU_MAIN_ENTRY_MORE, MENU_MAIN_ENTRY_MORE,
MENU_MAIN_ENTRY_SEND,
MENU_MAIN_ENTRY_RECEIVE,
}; };
MenuEntry menu_main_entries[] = { MenuEntry menu_main_entries[] = {
@ -73,8 +75,10 @@ MenuEntry menu_main_entries[] = {
{ RENAME, 7, 0, CTX_INVISIBLE }, { RENAME, 7, 0, CTX_INVISIBLE },
{ NEW_FOLDER, 9, 0, CTX_INVISIBLE }, { NEW_FOLDER, 9, 0, CTX_INVISIBLE },
{ PROPERTIES, 10, 0, CTX_INVISIBLE }, { PROPERTIES, 10, 0, CTX_INVISIBLE },
{ SORT_BY, 12, 1, CTX_VISIBLE }, { SORT_BY, 12, CTX_FLAG_MORE, CTX_VISIBLE },
{ MORE, 13, 1, CTX_INVISIBLE }, { MORE, 13, CTX_FLAG_MORE, CTX_INVISIBLE },
{ SEND, 17, CTX_FLAG_BARRIER, CTX_INVISIBLE },
{ RECEIVE, 18, 0, CTX_INVISIBLE },
}; };
#define N_MENU_MAIN_ENTRIES (sizeof(menu_main_entries) / sizeof(MenuEntry)) #define N_MENU_MAIN_ENTRIES (sizeof(menu_main_entries) / sizeof(MenuEntry))

View File

@ -76,7 +76,7 @@ static int zipAddFile(zipFile zf, const char *path, int filename_start, int leve
} }
// Add file to zip // Add file to zip
void *buf = memalign(64, TRANSFER_SIZE); void *buf = memalign(4096, TRANSFER_SIZE);
uint64_t seek = 0; uint64_t seek = 0;

18
photo.c
View File

@ -168,7 +168,7 @@ static void resetImageInfo(vita2d_texture *tex, float *width, float *height, flo
} }
int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry, int *base_pos, int *rel_pos) { int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry, int *base_pos, int *rel_pos) {
char *buffer = memalign(64, BIG_BUFFER_SIZE); char *buffer = memalign(4096, BIG_BUFFER_SIZE);
if (!buffer) if (!buffer)
return -1; return -1;
@ -190,19 +190,19 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
readPad(); readPad();
// Cancel // Cancel
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
break; break;
} }
// Previous/next image. // Previous/next image.
if (pressed_buttons & SCE_CTRL_LEFT || pressed_buttons & SCE_CTRL_RIGHT) { if (pressed_pad[PAD_LEFT] || pressed_pad[PAD_RIGHT]) {
int available = 0; int available = 0;
int old_base_pos = *base_pos; int old_base_pos = *base_pos;
int old_rel_pos = *rel_pos; int old_rel_pos = *rel_pos;
FileListEntry *old_entry = entry; FileListEntry *old_entry = entry;
int previous = pressed_buttons & SCE_CTRL_LEFT; int previous = pressed_pad[PAD_LEFT];
while (previous ? entry->previous : entry->next) { while (previous ? entry->previous : entry->next) {
entry = previous ? entry->previous : entry->next; entry = previous ? entry->previous : entry->next;
@ -252,7 +252,7 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
} }
// Photo mode // Photo mode
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
time = sceKernelGetProcessTimeWide(); time = sceKernelGetProcessTimeWide();
x = width / 2.0f; x = width / 2.0f;
@ -263,13 +263,13 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
} }
// Rotate // Rotate
if (pressed_buttons & SCE_CTRL_LTRIGGER) { if (pressed_pad[PAD_LTRIGGER]) {
rad -= M_PI_2; rad -= M_PI_2;
if (rad < 0) if (rad < 0)
rad += M_TWOPI; rad += M_TWOPI;
photoMode(&zoom, width, height, rad, mode); photoMode(&zoom, width, height, rad, mode);
} else if (pressed_buttons & SCE_CTRL_RTRIGGER) { } else if (pressed_pad[PAD_RTRIGGER]) {
rad += M_PI_2; rad += M_PI_2;
if (rad >= M_TWOPI) if (rad >= M_TWOPI)
rad -= M_TWOPI; rad -= M_TWOPI;
@ -278,11 +278,11 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
} }
// Zoom // Zoom
if (current_buttons & SCE_CTRL_RIGHT_ANALOG_DOWN) { if (current_pad[PAD_RIGHT_ANALOG_DOWN]) {
time = sceKernelGetProcessTimeWide(); time = sceKernelGetProcessTimeWide();
mode = MODE_CUSTOM; mode = MODE_CUSTOM;
zoom /= ZOOM_FACTOR; zoom /= ZOOM_FACTOR;
} else if (current_buttons & SCE_CTRL_RIGHT_ANALOG_UP) { } else if (current_pad[PAD_RIGHT_ANALOG_UP]) {
time = sceKernelGetProcessTimeWide(); time = sceKernelGetProcessTimeWide();
mode = MODE_CUSTOM; mode = MODE_CUSTOM;
zoom *= ZOOM_FACTOR; zoom *= ZOOM_FACTOR;

View File

@ -351,7 +351,7 @@ int initPropertyDialog(char *path, FileListEntry *entry) {
} }
void propertyDialogCtrl() { void propertyDialogCtrl() {
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
info_done = 1; info_done = 1;
sceKernelWaitThreadEnd(info_thid, NULL, NULL); sceKernelWaitThreadEnd(info_thid, NULL, NULL);
property_dialog.status = PROPERTY_DIALOG_CLOSING; property_dialog.status = PROPERTY_DIALOG_CLOSING;

View File

@ -361,7 +361,7 @@ int extractPsarcFile(const char *src_path, const char *dst_path, FileProcessPara
return fddst; return fddst;
} }
void *buf = memalign(64, TRANSFER_SIZE); void *buf = memalign(4096, TRANSFER_SIZE);
while (1) { while (1) {
int read = psarcFileRead(fdsrc, buf, TRANSFER_SIZE); int read = psarcFileRead(fdsrc, buf, TRANSFER_SIZE);

View File

@ -59,6 +59,8 @@ DELETE = "Delete"
RENAME = "Rename" RENAME = "Rename"
NEW_FOLDER = "New folder" NEW_FOLDER = "New folder"
PROPERTIES = "Properties" PROPERTIES = "Properties"
SEND = "Send"
RECEIVE = "Receive"
MORE = "More" MORE = "More"
COMPRESS = "Compress" COMPRESS = "Compress"
INSTALL_ALL = "Install all" INSTALL_ALL = "Install all"

View File

@ -319,7 +319,7 @@ void settingsMenuCtrl() {
} }
// Change options // Change options
if (pressed_buttons & (SCE_CTRL_ENTER | SCE_CTRL_LEFT | SCE_CTRL_RIGHT)) { if (pressed_pad[PAD_ENTER] || pressed_pad[PAD_LEFT] || pressed_pad[PAD_RIGHT]) {
changed = 1; changed = 1;
switch (option->type) { switch (option->type) {
@ -341,12 +341,12 @@ void settingsMenuCtrl() {
case SETTINGS_OPTION_TYPE_OPTIONS: case SETTINGS_OPTION_TYPE_OPTIONS:
{ {
if (option->value) { if (option->value) {
if (pressed_buttons & SCE_CTRL_LEFT) { if (pressed_pad[PAD_LEFT]) {
if (*(option->value) > 0) if (*(option->value) > 0)
(*(option->value))--; (*(option->value))--;
else else
*(option->value) = option->n_options - 1; *(option->value) = option->n_options - 1;
} else if (pressed_buttons & (SCE_CTRL_ENTER | SCE_CTRL_RIGHT)) { } else if (pressed_pad[PAD_ENTER] || pressed_pad[PAD_RIGHT]) {
if (*(option->value) < option->n_options - 1) if (*(option->value) < option->n_options - 1)
(*(option->value))++; (*(option->value))++;
else else
@ -360,14 +360,14 @@ void settingsMenuCtrl() {
} }
// Move // Move
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
if (settings_menu.option_sel > 0) { if (settings_menu.option_sel > 0) {
settings_menu.option_sel--; settings_menu.option_sel--;
} else if (settings_menu.entry_sel > 0) { } else if (settings_menu.entry_sel > 0) {
settings_menu.entry_sel--; settings_menu.entry_sel--;
settings_menu.option_sel = settings_menu_entries[settings_menu.entry_sel].n_options - 1; settings_menu.option_sel = settings_menu_entries[settings_menu.entry_sel].n_options - 1;
} }
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
if (settings_menu.option_sel < settings_menu_entries[settings_menu.entry_sel].n_options - 1) { if (settings_menu.option_sel < settings_menu_entries[settings_menu.entry_sel].n_options - 1) {
settings_menu.option_sel++; settings_menu.option_sel++;
} else if (settings_menu.entry_sel < n_settings_entries - 1) { } else if (settings_menu.entry_sel < n_settings_entries - 1) {
@ -377,7 +377,7 @@ void settingsMenuCtrl() {
} }
// Close // Close
if (pressed_buttons & (SCE_CTRL_CANCEL | SCE_CTRL_START)) { if (pressed_pad[PAD_START] || pressed_pad[PAD_CANCEL]) {
closeSettingsMenu(); closeSettingsMenu();
} }
} }

8
sfo.c
View File

@ -102,7 +102,7 @@ int setSfoString(void *buffer, const char *name, const char *string) {
} }
int SFOReader(const char *file) { int SFOReader(const char *file) {
uint8_t *buffer = memalign(64, BIG_BUFFER_SIZE); uint8_t *buffer = memalign(4096, BIG_BUFFER_SIZE);
if (!buffer) if (!buffer)
return -1; return -1;
@ -128,17 +128,17 @@ int SFOReader(const char *file) {
while (1) { while (1) {
readPad(); readPad();
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
break; break;
} }
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
if (rel_pos > 0) { if (rel_pos > 0) {
rel_pos--; rel_pos--;
} else if (base_pos > 0) { } else if (base_pos > 0) {
base_pos--; base_pos--;
} }
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
if ((rel_pos + 1) < sfo_header->count) { if ((rel_pos + 1) < sfo_header->count) {
if ((rel_pos + 1) < MAX_POSITION) { if ((rel_pos + 1) < MAX_POSITION) {
rel_pos++; rel_pos++;

26
text.c
View File

@ -508,7 +508,7 @@ int textViewer(const char *file) {
if (!s) if (!s)
return -1; return -1;
char *buffer_base = memalign(64, BIG_BUFFER_SIZE); char *buffer_base = memalign(4096, BIG_BUFFER_SIZE);
if (!buffer_base) if (!buffer_base)
return -1; return -1;
@ -599,7 +599,7 @@ int textViewer(const char *file) {
contextMenuCtrl(); contextMenuCtrl();
} else { } else {
// Context menu trigger // Context menu trigger
if (pressed_buttons & SCE_CTRL_TRIANGLE) { if (pressed_pad[PAD_TRIANGLE]) {
if (getContextMenuMode() == CONTEXT_MENU_CLOSED) { if (getContextMenuMode() == CONTEXT_MENU_CLOSED) {
setContextMenu(&context_menu_text); setContextMenu(&context_menu_text);
setContextMenuVisibilities(s); setContextMenuVisibilities(s);
@ -607,7 +607,7 @@ int textViewer(const char *file) {
} }
} }
if (hold_buttons & SCE_CTRL_UP || hold2_buttons & SCE_CTRL_LEFT_ANALOG_UP) { if (hold_pad[PAD_UP] || hold2_pad[PAD_LEFT_ANALOG_UP]) {
if (s->rel_pos > 0) { if (s->rel_pos > 0) {
s->rel_pos--; s->rel_pos--;
} else { } else {
@ -637,7 +637,7 @@ int textViewer(const char *file) {
} }
} }
s->copy_reset = 1; s->copy_reset = 1;
} else if (hold_buttons & SCE_CTRL_DOWN || hold2_buttons & SCE_CTRL_LEFT_ANALOG_DOWN) { } else if (hold_pad[PAD_DOWN] || hold2_pad[PAD_LEFT_ANALOG_DOWN]) {
if (s->offset_list[s->rel_pos + 1] < s->size) { if (s->offset_list[s->rel_pos + 1] < s->size) {
if ((s->rel_pos + 1) < MAX_POSITION) { if ((s->rel_pos + 1) < MAX_POSITION) {
if (s->base_pos+s->rel_pos < s->n_lines - 1) if (s->base_pos+s->rel_pos < s->n_lines - 1)
@ -687,7 +687,7 @@ int textViewer(const char *file) {
int target_offset = 0; int target_offset = 0;
// Skip to next search result // Skip to next search result
if (pressed_buttons & SCE_CTRL_RTRIGGER) { if (pressed_pad[PAD_RTRIGGER]) {
for (i = 0; i < s->n_search_results; i++) { for (i = 0; i < s->n_search_results; i++) {
if (s->search_result_offsets[i] > entry_end_offset) { if (s->search_result_offsets[i] > entry_end_offset) {
target_offset = s->search_result_offsets[i] - entry_start_offset; target_offset = s->search_result_offsets[i] - entry_start_offset;
@ -695,7 +695,7 @@ int textViewer(const char *file) {
} }
} }
} // Skip to next last result } // Skip to next last result
else if (pressed_buttons & SCE_CTRL_LTRIGGER) { else if (pressed_pad[PAD_LTRIGGER]) {
for (i = s->n_search_results-1; i >= 0; i--) { for (i = s->n_search_results-1; i >= 0; i--) {
if (s->search_result_offsets[i] < entry_start_offset) { if (s->search_result_offsets[i] < entry_start_offset) {
target_offset = s->search_result_offsets[i] - entry_start_offset; target_offset = s->search_result_offsets[i] - entry_start_offset;
@ -732,9 +732,9 @@ int textViewer(const char *file) {
} }
} else { } else {
// Page skip // Page skip
if (hold_buttons & SCE_CTRL_LTRIGGER || hold_buttons & SCE_CTRL_RTRIGGER) { if (hold_pad[PAD_LTRIGGER] || hold_pad[PAD_RTRIGGER]) {
if (hold_buttons & SCE_CTRL_LTRIGGER) { // Skip page up if (hold_pad[PAD_LTRIGGER]) { // Skip page up
s->base_pos = s->base_pos-MAX_ENTRIES; s->base_pos = s->base_pos-MAX_ENTRIES;
if (s->base_pos < 0) { if (s->base_pos < 0) {
s->base_pos = 0; s->base_pos = 0;
@ -755,7 +755,7 @@ int textViewer(const char *file) {
// buffer modifying actions // buffer modifying actions
if (s->modify_allowed && !s->search_running) { if (s->modify_allowed && !s->search_running) {
if(s->edit_line <= 0 && pressed_buttons & SCE_CTRL_ENTER) { if(s->edit_line <= 0 && pressed_pad[PAD_ENTER]) {
int line_start = s->offset_list[s->base_pos+s->rel_pos]; int line_start = s->offset_list[s->base_pos+s->rel_pos];
char line[MAX_LINE_CHARACTERS]; char line[MAX_LINE_CHARACTERS];
@ -767,18 +767,18 @@ int textViewer(const char *file) {
} }
// Delete line // Delete line
if (pressed_buttons & SCE_CTRL_LEFT && s->n_copied_lines < MAX_COPY_BUFFER_SIZE) { if (pressed_pad[PAD_LEFT] && s->n_copied_lines < MAX_COPY_BUFFER_SIZE) {
delete_line(s, s->base_pos+s->rel_pos); delete_line(s, s->base_pos+s->rel_pos);
} }
// Insert new line // Insert new line
if (pressed_buttons & SCE_CTRL_RIGHT) { if (pressed_pad[PAD_RIGHT]) {
insert_line(s, "\n", s->base_pos+s->rel_pos + 1); insert_line(s, "\n", s->base_pos+s->rel_pos + 1);
} }
} }
// Cancel // Cancel
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
if (s->n_search_results) { if (s->n_search_results) {
s->n_search_results = 0; s->n_search_results = 0;
} else { } else {
@ -792,7 +792,7 @@ int textViewer(const char *file) {
} }
// (De-)select current line // (De-)select current line
if (pressed_buttons & SCE_CTRL_SQUARE) { if (pressed_pad[PAD_SQUARE]) {
int cur_line = s->base_pos+s->rel_pos; int cur_line = s->base_pos+s->rel_pos;
int line_selected = 1; int line_selected = 1;

View File

@ -180,7 +180,7 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
switch (uncommon_dialog.buttonType) { switch (uncommon_dialog.buttonType) {
case SCE_MSG_DIALOG_BUTTON_TYPE_OK: case SCE_MSG_DIALOG_BUTTON_TYPE_OK:
{ {
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_OK; uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_OK;
} }
@ -190,12 +190,12 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
case SCE_MSG_DIALOG_BUTTON_TYPE_YESNO: case SCE_MSG_DIALOG_BUTTON_TYPE_YESNO:
{ {
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_YES; uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_YES;
} }
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO; uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO;
} }
@ -205,12 +205,12 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
case SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL: case SCE_MSG_DIALOG_BUTTON_TYPE_OK_CANCEL:
{ {
if (pressed_buttons & SCE_CTRL_ENTER) { if (pressed_pad[PAD_ENTER]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_YES; uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_YES;
} }
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO; uncommon_dialog.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO;
} }
@ -220,7 +220,7 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
case SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL: case SCE_MSG_DIALOG_BUTTON_TYPE_CANCEL:
{ {
if (pressed_buttons & SCE_CTRL_CANCEL) { if (pressed_pad[PAD_CANCEL]) {
uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING; uncommon_dialog.dialog_status = UNCOMMON_DIALOG_CLOSING;
} }

131
utils.c
View File

@ -27,7 +27,9 @@
#include "bm.h" #include "bm.h"
SceCtrlData pad; SceCtrlData pad;
uint32_t old_buttons, current_buttons, pressed_buttons, hold_buttons, hold2_buttons, released_buttons; Pad old_pad, current_pad, pressed_pad, released_pad, hold_pad, hold2_pad;
Pad hold_count, hold2_count;
int circle_enter_button = 0;
static int netdbg_sock = -1; static int netdbg_sock = -1;
static void *net_memory = NULL; static void *net_memory = NULL;
@ -93,8 +95,8 @@ int checkMemoryCardFreeSpace(const char *path, uint64_t size) {
char *p = strchr(path, ':'); char *p = strchr(path, ':');
if (p) { if (p) {
strncpy(device, path, p-path + 1); strncpy(device, path, p - path + 1);
device[p-path + 1] = '\0'; device[p - path + 1] = '\0';
} }
if (strcmp(device, "ux0:") == 0) { if (strcmp(device, "ux0:") == 0) {
@ -158,60 +160,121 @@ void powerUnlock() {
lock_power = 0; lock_power = 0;
} }
void readPad() { void setEnterButton(int enter_button) {
static int hold_n = 0, hold2_n = 0; circle_enter_button = enter_button;
}
void readPad() {
memset(&pad, 0, sizeof(SceCtrlData)); memset(&pad, 0, sizeof(SceCtrlData));
sceCtrlPeekBufferPositive(0, &pad, 1); sceCtrlPeekBufferPositive(0, &pad, 1);
memcpy(&old_pad, current_pad, sizeof(Pad));
memset(&current_pad, 0, sizeof(Pad));
if (pad.buttons & SCE_CTRL_UP)
current_pad[PAD_UP] = 1;
if (pad.buttons & SCE_CTRL_DOWN)
current_pad[PAD_DOWN] = 1;
if (pad.buttons & SCE_CTRL_LEFT)
current_pad[PAD_LEFT] = 1;
if (pad.buttons & SCE_CTRL_RIGHT)
current_pad[PAD_RIGHT] = 1;
if (pad.buttons & SCE_CTRL_LTRIGGER)
current_pad[PAD_LTRIGGER] = 1;
if (pad.buttons & SCE_CTRL_RTRIGGER)
current_pad[PAD_RTRIGGER] = 1;
if (pad.buttons & SCE_CTRL_TRIANGLE)
current_pad[PAD_TRIANGLE] = 1;
if (pad.buttons & SCE_CTRL_CIRCLE)
current_pad[PAD_CIRCLE] = 1;
if (pad.buttons & SCE_CTRL_CROSS)
current_pad[PAD_CROSS] = 1;
if (pad.buttons & SCE_CTRL_SQUARE)
current_pad[PAD_SQUARE] = 1;
if (pad.buttons & SCE_CTRL_START)
current_pad[PAD_START] = 1;
if (pad.buttons & SCE_CTRL_SELECT)
current_pad[PAD_SELECT] = 1;
if (pad.ly < ANALOG_CENTER - ANALOG_THRESHOLD) { if (pad.ly < ANALOG_CENTER - ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_LEFT_ANALOG_UP; current_pad[PAD_LEFT_ANALOG_UP] = 1;
} else if (pad.ly > ANALOG_CENTER + ANALOG_THRESHOLD) { } else if (pad.ly > ANALOG_CENTER + ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_LEFT_ANALOG_DOWN; current_pad[PAD_LEFT_ANALOG_DOWN] = 1;
} }
if (pad.lx < ANALOG_CENTER - ANALOG_THRESHOLD) { if (pad.lx < ANALOG_CENTER - ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_LEFT_ANALOG_LEFT; current_pad[PAD_LEFT_ANALOG_LEFT] = 1;
} else if (pad.lx > ANALOG_CENTER + ANALOG_THRESHOLD) { } else if (pad.lx > ANALOG_CENTER + ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_LEFT_ANALOG_RIGHT; current_pad[PAD_LEFT_ANALOG_RIGHT] = 1;
} }
if (pad.ry < ANALOG_CENTER - ANALOG_THRESHOLD) { if (pad.ry < ANALOG_CENTER - ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_UP; current_pad[PAD_RIGHT_ANALOG_UP] = 1;
} else if (pad.ry > ANALOG_CENTER + ANALOG_THRESHOLD) { } else if (pad.ry > ANALOG_CENTER + ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_DOWN; current_pad[PAD_RIGHT_ANALOG_DOWN] = 1;
} }
if (pad.rx < ANALOG_CENTER - ANALOG_THRESHOLD) { if (pad.rx < ANALOG_CENTER - ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_LEFT; current_pad[PAD_RIGHT_ANALOG_LEFT] = 1;
} else if (pad.rx > ANALOG_CENTER + ANALOG_THRESHOLD) { } else if (pad.rx > ANALOG_CENTER + ANALOG_THRESHOLD) {
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_RIGHT; current_pad[PAD_RIGHT_ANALOG_RIGHT] = 1;
} }
int i;
for (i = 0; i < PAD_N_BUTTONS; i++) {
pressed_pad[i] = current_pad[i] & ~old_pad[i];
released_pad[i] = ~current_pad[i] & old_pad[i];
hold_pad[i] = pressed_pad[i];
hold2_pad[i] = pressed_pad[i];
if (current_pad[i]) {
if (hold_count[i] >= 10) {
hold_pad[i] = 1;
hold_count[i] = 6;
}
old_buttons = current_buttons; if (hold2_count[i] >= 10) {
current_buttons = pad.buttons; hold2_pad[i] = 1;
pressed_buttons = current_buttons & ~old_buttons; hold2_count[i] = 10;
released_buttons = ~current_buttons & old_buttons; }
hold_buttons = pressed_buttons; hold_count[i]++;
hold2_buttons = pressed_buttons; hold2_count[i]++;
} else {
if ((old_buttons & current_buttons) == current_buttons) { hold_count[i] = 0;
if (hold_n >= 10) { hold2_count[i] = 0;
hold_buttons = current_buttons;
hold_n = 6;
} }
}
if (hold2_n >= 10) {
hold2_buttons = current_buttons; if (circle_enter_button) {
hold2_n = 10; old_pad[PAD_ENTER] = old_pad[PAD_CIRCLE];
} current_pad[PAD_ENTER] = current_pad[PAD_CIRCLE];
pressed_pad[PAD_ENTER] = pressed_pad[PAD_CIRCLE];
hold_n++; released_pad[PAD_ENTER] = released_pad[PAD_CIRCLE];
hold2_n++; hold_pad[PAD_ENTER] = hold_pad[PAD_CIRCLE];
hold2_pad[PAD_ENTER] = hold2_pad[PAD_CIRCLE];
old_pad[PAD_CANCEL] = old_pad[PAD_CROSS];
current_pad[PAD_CANCEL] = current_pad[PAD_CROSS];
pressed_pad[PAD_CANCEL] = pressed_pad[PAD_CROSS];
released_pad[PAD_CANCEL] = released_pad[PAD_CROSS];
hold_pad[PAD_CANCEL] = hold_pad[PAD_CROSS];
hold2_pad[PAD_CANCEL] = hold2_pad[PAD_CROSS];
} else { } else {
hold_n = 0; old_pad[PAD_ENTER] = old_pad[PAD_CROSS];
hold2_n = 0; current_pad[PAD_ENTER] = current_pad[PAD_CROSS];
pressed_pad[PAD_ENTER] = pressed_pad[PAD_CROSS];
released_pad[PAD_ENTER] = released_pad[PAD_CROSS];
hold_pad[PAD_ENTER] = hold_pad[PAD_CROSS];
hold2_pad[PAD_ENTER] = hold2_pad[PAD_CROSS];
old_pad[PAD_CANCEL] = old_pad[PAD_CIRCLE];
current_pad[PAD_CANCEL] = current_pad[PAD_CIRCLE];
pressed_pad[PAD_CANCEL] = pressed_pad[PAD_CIRCLE];
released_pad[PAD_CANCEL] = released_pad[PAD_CIRCLE];
hold_pad[PAD_CANCEL] = hold_pad[PAD_CIRCLE];
hold2_pad[PAD_CANCEL] = hold2_pad[PAD_CIRCLE];
} }
} }

47
utils.h
View File

@ -21,31 +21,43 @@
#include "main.h" #include "main.h"
#define ALIGN_CENTER(a, b) (((a)-(b)) / 2) #define ALIGN_CENTER(a, b) (((a) - (b)) / 2)
#define ALIGN_RIGHT(x, w) ((x)-(w)) #define ALIGN_RIGHT(x, w) ((x) - (w))
#define ANALOG_CENTER 128 #define ANALOG_CENTER 128
#define ANALOG_THRESHOLD 64 #define ANALOG_THRESHOLD 64
#define ANALOG_SENSITIVITY 16 #define ANALOG_SENSITIVITY 16
enum { enum PadButtons {
SCE_CTRL_RIGHT_ANALOG_UP = 0x00200000, PAD_UP,
SCE_CTRL_RIGHT_ANALOG_RIGHT = 0x00400000, PAD_DOWN,
SCE_CTRL_RIGHT_ANALOG_DOWN = 0x00800000, PAD_LEFT,
SCE_CTRL_RIGHT_ANALOG_LEFT = 0x01000000, PAD_RIGHT,
PAD_LTRIGGER,
SCE_CTRL_LEFT_ANALOG_UP = 0x02000000, PAD_RTRIGGER,
SCE_CTRL_LEFT_ANALOG_RIGHT = 0x04000000, PAD_TRIANGLE,
SCE_CTRL_LEFT_ANALOG_DOWN = 0x08000000, PAD_CIRCLE,
SCE_CTRL_LEFT_ANALOG_LEFT = 0x10000000, PAD_CROSS,
/* PAD_SQUARE,
SCE_CTRL_ENTER = 0x20000000, PAD_START,
SCE_CTRL_CANCEL = 0x40000000, PAD_SELECT,
*/ PAD_ENTER,
PAD_CANCEL,
PAD_LEFT_ANALOG_UP,
PAD_LEFT_ANALOG_DOWN,
PAD_LEFT_ANALOG_LEFT,
PAD_LEFT_ANALOG_RIGHT,
PAD_RIGHT_ANALOG_UP,
PAD_RIGHT_ANALOG_DOWN,
PAD_RIGHT_ANALOG_LEFT,
PAD_RIGHT_ANALOG_RIGHT,
PAD_N_BUTTONS
}; };
typedef uint8_t Pad[PAD_N_BUTTONS];
extern SceCtrlData pad; extern SceCtrlData pad;
extern uint32_t old_buttons, current_buttons, pressed_buttons, hold_buttons, hold2_buttons, released_buttons; extern Pad old_pad, current_pad, pressed_pad, released_pad, hold_pad, hold2_pad;
float easeOut(float x0, float x1, float a, float b); float easeOut(float x0, float x1, float a, float b);
@ -63,6 +75,7 @@ void initPowerTickThread();
void powerLock(); void powerLock();
void powerUnlock(); void powerUnlock();
void setEnterButton(int circle);
void readPad(); void readPad();
int holdButtons(SceCtrlData *pad, uint32_t buttons, uint64_t time); int holdButtons(SceCtrlData *pad, uint32_t buttons, uint64_t time);