mirror of
https://github.com/joel16/VitaShell.git
synced 2024-11-23 03:39:39 +00:00
Improved controls
This commit is contained in:
parent
d498044c2e
commit
840c604b9d
@ -56,7 +56,7 @@ static int file_open(struct archive *a, void *client_data) {
|
||||
if (archive_data->fd < 0)
|
||||
return ARCHIVE_FATAL;
|
||||
|
||||
archive_data->buffer = memalign(64, TRANSFER_SIZE);
|
||||
archive_data->buffer = memalign(4096, TRANSFER_SIZE);
|
||||
archive_data->block_size = TRANSFER_SIZE;
|
||||
|
||||
return ARCHIVE_OK;
|
||||
@ -635,7 +635,7 @@ int extractArchiveFile(const char *src_path, const char *dst_path, FileProcessPa
|
||||
return fddst;
|
||||
}
|
||||
|
||||
void *buf = memalign(64, TRANSFER_SIZE);
|
||||
void *buf = memalign(4096, TRANSFER_SIZE);
|
||||
|
||||
while (1) {
|
||||
int read = archiveFileRead(fdsrc, buf, TRANSFER_SIZE);
|
||||
|
@ -229,17 +229,17 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
|
||||
readPad();
|
||||
|
||||
// Cancel
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Display off
|
||||
if (pressed_buttons & SCE_CTRL_TRIANGLE) {
|
||||
if (pressed_pad[PAD_TRIANGLE]) {
|
||||
scePowerRequestDisplayOff();
|
||||
}
|
||||
|
||||
// Toggle play/pause
|
||||
if (pressed_buttons & SCE_CTRL_ENTER) {
|
||||
if (pressed_pad[PAD_ENTER]) {
|
||||
if (isPlayingFunct() && getPlayingSpeedFunct() == 0) {
|
||||
pauseFunct();
|
||||
} 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();
|
||||
|
||||
if (pressed_buttons & SCE_CTRL_LEFT) {
|
||||
if (pressed_pad[PAD_LEFT]) {
|
||||
int i;
|
||||
for (i = 0; i < N_SPEED; i++) {
|
||||
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;
|
||||
for (i = 0; i < N_SPEED; i++) {
|
||||
if (speed_list[i] == speed) {
|
||||
@ -280,8 +280,8 @@ int audioPlayer(const char *file, int type, FileList *list, FileListEntry *entry
|
||||
|
||||
// Previous/next song.
|
||||
if (getPercentageFunct() == 100.0f || endOfStreamFunct() ||
|
||||
pressed_buttons & SCE_CTRL_LTRIGGER || pressed_buttons & SCE_CTRL_RTRIGGER) {
|
||||
int previous = pressed_buttons & SCE_CTRL_LTRIGGER;
|
||||
pressed_pad[PAD_LTRIGGER] || pressed_pad[PAD_RTRIGGER]) {
|
||||
int previous = pressed_pad[PAD_LTRIGGER];
|
||||
if (previous && strcmp(cur_time_string, "00:00:00") != 0) {
|
||||
lrcParseClose(lyrics);
|
||||
endFunct();
|
||||
|
@ -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]);
|
||||
|
||||
// Draw arrow for 'More'
|
||||
if (ctx->entries[i].more) {
|
||||
if (ctx->entries[i].flags & CTX_FLAG_MORE) {
|
||||
char *arrow = RIGHT_ARROW;
|
||||
|
||||
if (ctx->sel == i) {
|
||||
@ -156,7 +156,7 @@ void contextMenuCtrl() {
|
||||
if (!cur_ctx)
|
||||
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) {
|
||||
int 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) {
|
||||
int i;
|
||||
for (i = 0; i < cur_ctx->n_entries; i++) {
|
||||
@ -183,12 +183,12 @@ void contextMenuCtrl() {
|
||||
}
|
||||
|
||||
// Close
|
||||
if (pressed_buttons & SCE_CTRL_TRIANGLE) {
|
||||
if (pressed_pad[PAD_TRIANGLE]) {
|
||||
ctx_menu_mode = CONTEXT_MENU_CLOSING;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
ctx_menu_mode = CONTEXT_MENU_MORE_CLOSING;
|
||||
} else {
|
||||
@ -197,7 +197,7 @@ void contextMenuCtrl() {
|
||||
}
|
||||
|
||||
// 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 (cur_ctx->callback)
|
||||
ctx_menu_mode = cur_ctx->callback(cur_ctx->sel, cur_ctx->context);
|
||||
|
@ -27,10 +27,15 @@ enum ContextMenuVisibilities {
|
||||
CTX_VISIBLE,
|
||||
};
|
||||
|
||||
enum ContextMenuFlags {
|
||||
CTX_FLAG_MORE = 0x1,
|
||||
CTX_FLAG_BARRIER = 0x2,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int name;
|
||||
int pos;
|
||||
int more;
|
||||
int flags;
|
||||
int visibility;
|
||||
} MenuEntry;
|
||||
|
||||
|
@ -158,14 +158,14 @@ static int decompressGzip(uint8_t *dst, int size_dst, uint8_t *src, int size_src
|
||||
}
|
||||
|
||||
int coredumpViewer(const char *file) {
|
||||
void *buffer = memalign(64, BIG_BUFFER_SIZE);
|
||||
void *buffer = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
int size = ReadFile(file, buffer, BIG_BUFFER_SIZE);
|
||||
|
||||
if (*(uint16_t *)buffer == 0x8B1F) {
|
||||
void *out_buf = memalign(64, BIG_BUFFER_SIZE);
|
||||
void *out_buf = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!out_buf) {
|
||||
free(buffer);
|
||||
return -2;
|
||||
@ -266,7 +266,7 @@ int coredumpViewer(const char *file) {
|
||||
while (1) {
|
||||
readPad();
|
||||
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
4
file.c
4
file.c
@ -125,7 +125,7 @@ int getFileSha1(const char *file, uint8_t *pSha1Out, FileProcessParam *param) {
|
||||
return fd;
|
||||
|
||||
// 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
|
||||
while (1) {
|
||||
@ -348,7 +348,7 @@ int copyFile(const char *src_path, const char *dst_path, FileProcessParam *param
|
||||
return fddst;
|
||||
}
|
||||
|
||||
void *buf = memalign(64, TRANSFER_SIZE);
|
||||
void *buf = memalign(4096, TRANSFER_SIZE);
|
||||
|
||||
while (1) {
|
||||
int read = sceIoRead(fdsrc, buf, TRANSFER_SIZE);
|
||||
|
2
file.h
2
file.h
@ -29,7 +29,7 @@
|
||||
#define MAX_DIR_LEVELS 32
|
||||
|
||||
#define DIRECTORY_SIZE (4 * 1024)
|
||||
#define TRANSFER_SIZE (64 * 1024)
|
||||
#define TRANSFER_SIZE (128 * 1024)
|
||||
|
||||
#define HOME_PATH "home"
|
||||
#define DIR_UP ".."
|
||||
|
20
hex.c
20
hex.c
@ -74,7 +74,7 @@ static HexListEntry *hexListGetNthEntry(HexList *list, int n) {
|
||||
int hexViewer(const char *file) {
|
||||
int text_viewer = 0;
|
||||
|
||||
uint8_t *buffer = memalign(64, BIG_BUFFER_SIZE);
|
||||
uint8_t *buffer = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
@ -116,7 +116,7 @@ int hexViewer(const char *file) {
|
||||
readPad();
|
||||
|
||||
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) {
|
||||
rel_pos -= 0x10;
|
||||
} else if (base_pos > 0) {
|
||||
@ -137,7 +137,7 @@ int hexViewer(const char *file) {
|
||||
// Read
|
||||
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) < ((MAX_POSITION - 1) * 0x10)) {
|
||||
rel_pos += 0x10;
|
||||
@ -163,7 +163,7 @@ int hexViewer(const char *file) {
|
||||
}
|
||||
|
||||
// Page skip
|
||||
if (hold_buttons & SCE_CTRL_LTRIGGER) {
|
||||
if (hold_pad[PAD_LTRIGGER]) {
|
||||
if ((base_pos + rel_pos) != 0) {
|
||||
if ((base_pos-0x10*0x10) >= 0) {
|
||||
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 ((base_pos + rel_pos+0x1F0) < size) {
|
||||
base_pos += 0x10*0x10;
|
||||
@ -217,17 +217,17 @@ int hexViewer(const char *file) {
|
||||
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)
|
||||
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)
|
||||
nibble_pos++;
|
||||
}
|
||||
|
||||
// Cancel or switch to text viewer
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL || pressed_buttons & SCE_CTRL_SQUARE) {
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL] || pressed_pad[PAD_SQUARE]) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
text_viewer = 0;
|
||||
} else {
|
||||
text_viewer = 1;
|
||||
@ -241,7 +241,7 @@ int hexViewer(const char *file) {
|
||||
}
|
||||
|
||||
// Increase nibble
|
||||
if (modify_allowed && hold_buttons & SCE_CTRL_ENTER) {
|
||||
if (modify_allowed && hold_pad[PAD_ENTER]) {
|
||||
changed = 1;
|
||||
int cur_pos = rel_pos + base_pos + nibble_pos / 2;
|
||||
|
||||
|
5
init.c
5
init.c
@ -176,8 +176,9 @@ static void initSceAppUtil() {
|
||||
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_TIME_FORMAT, &time_format);
|
||||
|
||||
if (enter_button == SCE_SYSTEM_PARAM_ENTER_BUTTON_CIRCLE) {
|
||||
SCE_CTRL_ENTER = SCE_CTRL_CIRCLE;
|
||||
SCE_CTRL_CANCEL = SCE_CTRL_CROSS;
|
||||
setEnterButton(1);
|
||||
} else {
|
||||
setEnterButton(0);
|
||||
}
|
||||
|
||||
// Set common dialog config
|
||||
|
@ -119,6 +119,8 @@ void loadLanguage(int id) {
|
||||
LANGUAGE_ENTRY(RENAME),
|
||||
LANGUAGE_ENTRY(NEW_FOLDER),
|
||||
LANGUAGE_ENTRY(PROPERTIES),
|
||||
LANGUAGE_ENTRY(SEND),
|
||||
LANGUAGE_ENTRY(RECEIVE),
|
||||
LANGUAGE_ENTRY(MORE),
|
||||
LANGUAGE_ENTRY(COMPRESS),
|
||||
LANGUAGE_ENTRY(INSTALL_ALL),
|
||||
|
@ -78,6 +78,8 @@ enum LanguageContainer {
|
||||
RENAME,
|
||||
NEW_FOLDER,
|
||||
PROPERTIES,
|
||||
SEND,
|
||||
RECEIVE,
|
||||
MORE,
|
||||
COMPRESS,
|
||||
INSTALL_ALL,
|
||||
|
20
main.c
20
main.c
@ -1287,12 +1287,12 @@ static int fileBrowserMenuCtrl() {
|
||||
int refresh = 0;
|
||||
|
||||
// Settings menu
|
||||
if (pressed_buttons & SCE_CTRL_START) {
|
||||
if (pressed_pad[PAD_START]) {
|
||||
openSettingsMenu();
|
||||
}
|
||||
|
||||
// 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 (is_safe_mode) {
|
||||
infoDialog(language_container[EXTENDED_PERMISSIONS_REQUIRED]);
|
||||
@ -1331,14 +1331,14 @@ static int fileBrowserMenuCtrl() {
|
||||
}
|
||||
|
||||
// QR
|
||||
if (hold2_buttons & SCE_CTRL_LTRIGGER && hold2_buttons & SCE_CTRL_RTRIGGER && enabledQR()) {
|
||||
if (hold_pad[PAD_LTRIGGER] && hold_pad[PAD_RTRIGGER] && enabledQR()) {
|
||||
startQR();
|
||||
initMessageDialog(MESSAGE_DIALOG_QR_CODE, language_container[QR_SCANNING]);
|
||||
setDialogStep(DIALOG_STEP_QR);
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
if (rel_pos > 0) {
|
||||
@ -1350,7 +1350,7 @@ static int fileBrowserMenuCtrl() {
|
||||
if (old_pos != base_pos + rel_pos) {
|
||||
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;
|
||||
|
||||
if ((rel_pos + 1) < file_list.length) {
|
||||
@ -1367,7 +1367,7 @@ static int fileBrowserMenuCtrl() {
|
||||
}
|
||||
|
||||
// Context menu trigger
|
||||
if (pressed_buttons & SCE_CTRL_TRIANGLE) {
|
||||
if (pressed_pad[PAD_TRIANGLE]) {
|
||||
if (getContextMenuMode() == CONTEXT_MENU_CLOSED) {
|
||||
if (dir_level > 0) {
|
||||
setContextMenu(&context_menu_main);
|
||||
@ -1384,7 +1384,7 @@ static int fileBrowserMenuCtrl() {
|
||||
// Not at 'home'
|
||||
if (dir_level > 0) {
|
||||
// Mark entry
|
||||
if (pressed_buttons & SCE_CTRL_SQUARE) {
|
||||
if (pressed_pad[PAD_SQUARE]) {
|
||||
FileListEntry *file_entry = fileListGetNthEntry(&file_list, base_pos + rel_pos);
|
||||
if (file_entry && strcmp(file_entry->name, DIR_UP) != 0) {
|
||||
if (!fileListFindEntry(&mark_list, file_entry->name)) {
|
||||
@ -1396,7 +1396,7 @@ static int fileBrowserMenuCtrl() {
|
||||
}
|
||||
|
||||
// Back
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
scroll_count = 0;
|
||||
fileListEmpty(&mark_list);
|
||||
dirUp();
|
||||
@ -1406,7 +1406,7 @@ static int fileBrowserMenuCtrl() {
|
||||
}
|
||||
|
||||
// Handle
|
||||
if (pressed_buttons & SCE_CTRL_ENTER) {
|
||||
if (pressed_pad[PAD_ENTER]) {
|
||||
scroll_count = 0;
|
||||
|
||||
fileListEmpty(&mark_list);
|
||||
@ -1759,7 +1759,7 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
// No custom config, in case they are damaged or unuseable
|
||||
readPad();
|
||||
if (current_buttons & SCE_CTRL_LTRIGGER)
|
||||
if (current_pad[PAD_LTRIGGER])
|
||||
use_custom_config = 0;
|
||||
|
||||
// Load settings
|
||||
|
@ -62,6 +62,8 @@ enum MenuMainEntrys {
|
||||
MENU_MAIN_ENTRY_PROPERTIES,
|
||||
MENU_MAIN_ENTRY_SORT_BY,
|
||||
MENU_MAIN_ENTRY_MORE,
|
||||
MENU_MAIN_ENTRY_SEND,
|
||||
MENU_MAIN_ENTRY_RECEIVE,
|
||||
};
|
||||
|
||||
MenuEntry menu_main_entries[] = {
|
||||
@ -73,8 +75,10 @@ MenuEntry menu_main_entries[] = {
|
||||
{ RENAME, 7, 0, CTX_INVISIBLE },
|
||||
{ NEW_FOLDER, 9, 0, CTX_INVISIBLE },
|
||||
{ PROPERTIES, 10, 0, CTX_INVISIBLE },
|
||||
{ SORT_BY, 12, 1, CTX_VISIBLE },
|
||||
{ MORE, 13, 1, CTX_INVISIBLE },
|
||||
{ SORT_BY, 12, CTX_FLAG_MORE, CTX_VISIBLE },
|
||||
{ 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))
|
||||
|
@ -76,7 +76,7 @@ static int zipAddFile(zipFile zf, const char *path, int filename_start, int leve
|
||||
}
|
||||
|
||||
// Add file to zip
|
||||
void *buf = memalign(64, TRANSFER_SIZE);
|
||||
void *buf = memalign(4096, TRANSFER_SIZE);
|
||||
|
||||
uint64_t seek = 0;
|
||||
|
||||
|
18
photo.c
18
photo.c
@ -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) {
|
||||
char *buffer = memalign(64, BIG_BUFFER_SIZE);
|
||||
char *buffer = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
@ -190,19 +190,19 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
|
||||
readPad();
|
||||
|
||||
// Cancel
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
break;
|
||||
}
|
||||
|
||||
// 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 old_base_pos = *base_pos;
|
||||
int old_rel_pos = *rel_pos;
|
||||
FileListEntry *old_entry = entry;
|
||||
|
||||
int previous = pressed_buttons & SCE_CTRL_LEFT;
|
||||
int previous = pressed_pad[PAD_LEFT];
|
||||
while (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
|
||||
if (pressed_buttons & SCE_CTRL_ENTER) {
|
||||
if (pressed_pad[PAD_ENTER]) {
|
||||
time = sceKernelGetProcessTimeWide();
|
||||
|
||||
x = width / 2.0f;
|
||||
@ -263,13 +263,13 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
|
||||
}
|
||||
|
||||
// Rotate
|
||||
if (pressed_buttons & SCE_CTRL_LTRIGGER) {
|
||||
if (pressed_pad[PAD_LTRIGGER]) {
|
||||
rad -= M_PI_2;
|
||||
if (rad < 0)
|
||||
rad += M_TWOPI;
|
||||
|
||||
photoMode(&zoom, width, height, rad, mode);
|
||||
} else if (pressed_buttons & SCE_CTRL_RTRIGGER) {
|
||||
} else if (pressed_pad[PAD_RTRIGGER]) {
|
||||
rad += M_PI_2;
|
||||
if (rad >= M_TWOPI)
|
||||
rad -= M_TWOPI;
|
||||
@ -278,11 +278,11 @@ int photoViewer(const char *file, int type, FileList *list, FileListEntry *entry
|
||||
}
|
||||
|
||||
// Zoom
|
||||
if (current_buttons & SCE_CTRL_RIGHT_ANALOG_DOWN) {
|
||||
if (current_pad[PAD_RIGHT_ANALOG_DOWN]) {
|
||||
time = sceKernelGetProcessTimeWide();
|
||||
mode = MODE_CUSTOM;
|
||||
zoom /= ZOOM_FACTOR;
|
||||
} else if (current_buttons & SCE_CTRL_RIGHT_ANALOG_UP) {
|
||||
} else if (current_pad[PAD_RIGHT_ANALOG_UP]) {
|
||||
time = sceKernelGetProcessTimeWide();
|
||||
mode = MODE_CUSTOM;
|
||||
zoom *= ZOOM_FACTOR;
|
||||
|
@ -351,7 +351,7 @@ int initPropertyDialog(char *path, FileListEntry *entry) {
|
||||
}
|
||||
|
||||
void propertyDialogCtrl() {
|
||||
if (pressed_buttons & SCE_CTRL_ENTER) {
|
||||
if (pressed_pad[PAD_ENTER]) {
|
||||
info_done = 1;
|
||||
sceKernelWaitThreadEnd(info_thid, NULL, NULL);
|
||||
property_dialog.status = PROPERTY_DIALOG_CLOSING;
|
||||
|
2
psarc.c
2
psarc.c
@ -361,7 +361,7 @@ int extractPsarcFile(const char *src_path, const char *dst_path, FileProcessPara
|
||||
return fddst;
|
||||
}
|
||||
|
||||
void *buf = memalign(64, TRANSFER_SIZE);
|
||||
void *buf = memalign(4096, TRANSFER_SIZE);
|
||||
|
||||
while (1) {
|
||||
int read = psarcFileRead(fdsrc, buf, TRANSFER_SIZE);
|
||||
|
@ -59,6 +59,8 @@ DELETE = "Delete"
|
||||
RENAME = "Rename"
|
||||
NEW_FOLDER = "New folder"
|
||||
PROPERTIES = "Properties"
|
||||
SEND = "Send"
|
||||
RECEIVE = "Receive"
|
||||
MORE = "More"
|
||||
COMPRESS = "Compress"
|
||||
INSTALL_ALL = "Install all"
|
||||
|
12
settings.c
12
settings.c
@ -319,7 +319,7 @@ void settingsMenuCtrl() {
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
switch (option->type) {
|
||||
@ -341,12 +341,12 @@ void settingsMenuCtrl() {
|
||||
case SETTINGS_OPTION_TYPE_OPTIONS:
|
||||
{
|
||||
if (option->value) {
|
||||
if (pressed_buttons & SCE_CTRL_LEFT) {
|
||||
if (pressed_pad[PAD_LEFT]) {
|
||||
if (*(option->value) > 0)
|
||||
(*(option->value))--;
|
||||
else
|
||||
*(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)
|
||||
(*(option->value))++;
|
||||
else
|
||||
@ -360,14 +360,14 @@ void settingsMenuCtrl() {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
settings_menu.option_sel--;
|
||||
} else if (settings_menu.entry_sel > 0) {
|
||||
settings_menu.entry_sel--;
|
||||
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) {
|
||||
settings_menu.option_sel++;
|
||||
} else if (settings_menu.entry_sel < n_settings_entries - 1) {
|
||||
@ -377,7 +377,7 @@ void settingsMenuCtrl() {
|
||||
}
|
||||
|
||||
// Close
|
||||
if (pressed_buttons & (SCE_CTRL_CANCEL | SCE_CTRL_START)) {
|
||||
if (pressed_pad[PAD_START] || pressed_pad[PAD_CANCEL]) {
|
||||
closeSettingsMenu();
|
||||
}
|
||||
}
|
||||
|
8
sfo.c
8
sfo.c
@ -102,7 +102,7 @@ int setSfoString(void *buffer, const char *name, const char *string) {
|
||||
}
|
||||
|
||||
int SFOReader(const char *file) {
|
||||
uint8_t *buffer = memalign(64, BIG_BUFFER_SIZE);
|
||||
uint8_t *buffer = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!buffer)
|
||||
return -1;
|
||||
|
||||
@ -128,17 +128,17 @@ int SFOReader(const char *file) {
|
||||
while (1) {
|
||||
readPad();
|
||||
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
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) {
|
||||
rel_pos--;
|
||||
} else if (base_pos > 0) {
|
||||
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) < MAX_POSITION) {
|
||||
rel_pos++;
|
||||
|
26
text.c
26
text.c
@ -508,7 +508,7 @@ int textViewer(const char *file) {
|
||||
if (!s)
|
||||
return -1;
|
||||
|
||||
char *buffer_base = memalign(64, BIG_BUFFER_SIZE);
|
||||
char *buffer_base = memalign(4096, BIG_BUFFER_SIZE);
|
||||
if (!buffer_base)
|
||||
return -1;
|
||||
|
||||
@ -599,7 +599,7 @@ int textViewer(const char *file) {
|
||||
contextMenuCtrl();
|
||||
} else {
|
||||
// Context menu trigger
|
||||
if (pressed_buttons & SCE_CTRL_TRIANGLE) {
|
||||
if (pressed_pad[PAD_TRIANGLE]) {
|
||||
if (getContextMenuMode() == CONTEXT_MENU_CLOSED) {
|
||||
setContextMenu(&context_menu_text);
|
||||
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) {
|
||||
s->rel_pos--;
|
||||
} else {
|
||||
@ -637,7 +637,7 @@ int textViewer(const char *file) {
|
||||
}
|
||||
}
|
||||
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->rel_pos + 1) < MAX_POSITION) {
|
||||
if (s->base_pos+s->rel_pos < s->n_lines - 1)
|
||||
@ -687,7 +687,7 @@ int textViewer(const char *file) {
|
||||
int target_offset = 0;
|
||||
|
||||
// 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++) {
|
||||
if (s->search_result_offsets[i] > entry_end_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
|
||||
else if (pressed_buttons & SCE_CTRL_LTRIGGER) {
|
||||
else if (pressed_pad[PAD_LTRIGGER]) {
|
||||
for (i = s->n_search_results-1; i >= 0; i--) {
|
||||
if (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 {
|
||||
// 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;
|
||||
if (s->base_pos < 0) {
|
||||
s->base_pos = 0;
|
||||
@ -755,7 +755,7 @@ int textViewer(const char *file) {
|
||||
|
||||
// buffer modifying actions
|
||||
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];
|
||||
|
||||
char line[MAX_LINE_CHARACTERS];
|
||||
@ -767,18 +767,18 @@ int textViewer(const char *file) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Cancel
|
||||
if (pressed_buttons & SCE_CTRL_CANCEL) {
|
||||
if (pressed_pad[PAD_CANCEL]) {
|
||||
if (s->n_search_results) {
|
||||
s->n_search_results = 0;
|
||||
} else {
|
||||
@ -792,7 +792,7 @@ int textViewer(const char *file) {
|
||||
}
|
||||
|
||||
// (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 line_selected = 1;
|
||||
|
||||
|
@ -180,7 +180,7 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
|
||||
switch (uncommon_dialog.buttonType) {
|
||||
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.buttonId = SCE_MSG_DIALOG_BUTTON_ID_OK;
|
||||
}
|
||||
@ -190,12 +190,12 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
|
||||
|
||||
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.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.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO;
|
||||
}
|
||||
@ -205,12 +205,12 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
|
||||
|
||||
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.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.buttonId = SCE_MSG_DIALOG_BUTTON_ID_NO;
|
||||
}
|
||||
@ -220,7 +220,7 @@ SceCommonDialogStatus sceMsgDialogGetStatus(void) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
123
utils.c
123
utils.c
@ -27,7 +27,9 @@
|
||||
#include "bm.h"
|
||||
|
||||
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 void *net_memory = NULL;
|
||||
@ -93,8 +95,8 @@ int checkMemoryCardFreeSpace(const char *path, uint64_t size) {
|
||||
|
||||
char *p = strchr(path, ':');
|
||||
if (p) {
|
||||
strncpy(device, path, p-path + 1);
|
||||
device[p-path + 1] = '\0';
|
||||
strncpy(device, path, p - path + 1);
|
||||
device[p - path + 1] = '\0';
|
||||
}
|
||||
|
||||
if (strcmp(device, "ux0:") == 0) {
|
||||
@ -158,60 +160,121 @@ void powerUnlock() {
|
||||
lock_power = 0;
|
||||
}
|
||||
|
||||
void readPad() {
|
||||
static int hold_n = 0, hold2_n = 0;
|
||||
void setEnterButton(int enter_button) {
|
||||
circle_enter_button = enter_button;
|
||||
}
|
||||
|
||||
void readPad() {
|
||||
memset(&pad, 0, sizeof(SceCtrlData));
|
||||
sceCtrlPeekBufferPositive(0, &pad, 1);
|
||||
|
||||
memcpy(&old_pad, current_pad, sizeof(Pad));
|
||||
memset(¤t_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) {
|
||||
pad.buttons |= SCE_CTRL_LEFT_ANALOG_UP;
|
||||
current_pad[PAD_LEFT_ANALOG_UP] = 1;
|
||||
} 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) {
|
||||
pad.buttons |= SCE_CTRL_LEFT_ANALOG_LEFT;
|
||||
current_pad[PAD_LEFT_ANALOG_LEFT] = 1;
|
||||
} 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) {
|
||||
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_UP;
|
||||
current_pad[PAD_RIGHT_ANALOG_UP] = 1;
|
||||
} 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) {
|
||||
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_LEFT;
|
||||
current_pad[PAD_RIGHT_ANALOG_LEFT] = 1;
|
||||
} else if (pad.rx > ANALOG_CENTER + ANALOG_THRESHOLD) {
|
||||
pad.buttons |= SCE_CTRL_RIGHT_ANALOG_RIGHT;
|
||||
current_pad[PAD_RIGHT_ANALOG_RIGHT] = 1;
|
||||
}
|
||||
|
||||
old_buttons = current_buttons;
|
||||
current_buttons = pad.buttons;
|
||||
pressed_buttons = current_buttons & ~old_buttons;
|
||||
released_buttons = ~current_buttons & old_buttons;
|
||||
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_buttons = pressed_buttons;
|
||||
hold2_buttons = pressed_buttons;
|
||||
hold_pad[i] = pressed_pad[i];
|
||||
hold2_pad[i] = pressed_pad[i];
|
||||
|
||||
if ((old_buttons & current_buttons) == current_buttons) {
|
||||
if (hold_n >= 10) {
|
||||
hold_buttons = current_buttons;
|
||||
hold_n = 6;
|
||||
if (current_pad[i]) {
|
||||
if (hold_count[i] >= 10) {
|
||||
hold_pad[i] = 1;
|
||||
hold_count[i] = 6;
|
||||
}
|
||||
|
||||
if (hold2_n >= 10) {
|
||||
hold2_buttons = current_buttons;
|
||||
hold2_n = 10;
|
||||
if (hold2_count[i] >= 10) {
|
||||
hold2_pad[i] = 1;
|
||||
hold2_count[i] = 10;
|
||||
}
|
||||
|
||||
hold_n++;
|
||||
hold2_n++;
|
||||
hold_count[i]++;
|
||||
hold2_count[i]++;
|
||||
} else {
|
||||
hold_n = 0;
|
||||
hold2_n = 0;
|
||||
hold_count[i] = 0;
|
||||
hold2_count[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (circle_enter_button) {
|
||||
old_pad[PAD_ENTER] = old_pad[PAD_CIRCLE];
|
||||
current_pad[PAD_ENTER] = current_pad[PAD_CIRCLE];
|
||||
pressed_pad[PAD_ENTER] = pressed_pad[PAD_CIRCLE];
|
||||
released_pad[PAD_ENTER] = released_pad[PAD_CIRCLE];
|
||||
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 {
|
||||
old_pad[PAD_ENTER] = old_pad[PAD_CROSS];
|
||||
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
47
utils.h
@ -21,31 +21,43 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define ALIGN_CENTER(a, b) (((a)-(b)) / 2)
|
||||
#define ALIGN_RIGHT(x, w) ((x)-(w))
|
||||
#define ALIGN_CENTER(a, b) (((a) - (b)) / 2)
|
||||
#define ALIGN_RIGHT(x, w) ((x) - (w))
|
||||
|
||||
#define ANALOG_CENTER 128
|
||||
#define ANALOG_THRESHOLD 64
|
||||
#define ANALOG_SENSITIVITY 16
|
||||
|
||||
enum {
|
||||
SCE_CTRL_RIGHT_ANALOG_UP = 0x00200000,
|
||||
SCE_CTRL_RIGHT_ANALOG_RIGHT = 0x00400000,
|
||||
SCE_CTRL_RIGHT_ANALOG_DOWN = 0x00800000,
|
||||
SCE_CTRL_RIGHT_ANALOG_LEFT = 0x01000000,
|
||||
|
||||
SCE_CTRL_LEFT_ANALOG_UP = 0x02000000,
|
||||
SCE_CTRL_LEFT_ANALOG_RIGHT = 0x04000000,
|
||||
SCE_CTRL_LEFT_ANALOG_DOWN = 0x08000000,
|
||||
SCE_CTRL_LEFT_ANALOG_LEFT = 0x10000000,
|
||||
/*
|
||||
SCE_CTRL_ENTER = 0x20000000,
|
||||
SCE_CTRL_CANCEL = 0x40000000,
|
||||
*/
|
||||
enum PadButtons {
|
||||
PAD_UP,
|
||||
PAD_DOWN,
|
||||
PAD_LEFT,
|
||||
PAD_RIGHT,
|
||||
PAD_LTRIGGER,
|
||||
PAD_RTRIGGER,
|
||||
PAD_TRIANGLE,
|
||||
PAD_CIRCLE,
|
||||
PAD_CROSS,
|
||||
PAD_SQUARE,
|
||||
PAD_START,
|
||||
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 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);
|
||||
|
||||
@ -63,6 +75,7 @@ void initPowerTickThread();
|
||||
void powerLock();
|
||||
void powerUnlock();
|
||||
|
||||
void setEnterButton(int circle);
|
||||
void readPad();
|
||||
int holdButtons(SceCtrlData *pad, uint32_t buttons, uint64_t time);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user