From 5e348148df61707c88b750590bb84f36d2f9691c Mon Sep 17 00:00:00 2001 From: Vasiliy Horbachenko Date: Sat, 17 Sep 2016 22:44:58 +0300 Subject: [PATCH 1/2] ability to use special keys and mouse input simultaneously; special key area used by mouse input if key not set; top-right touch anywhere on menus to go back to stream; remove use_fronttouchscreen option --- .gitignore | 1 + src/config.c | 3 - src/gui/guilib.c | 35 ++++++++++- src/gui/guilib.h | 3 +- src/gui/ui.c | 19 +++++- src/gui/ui_settings.c | 16 +---- src/input/vita.c | 136 ++++++++++++++++++++++-------------------- 7 files changed, 127 insertions(+), 86 deletions(-) diff --git a/.gitignore b/.gitignore index a007feab..2f348080 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/* +.DS_Store diff --git a/src/config.c b/src/config.c index 0b52b388..6362efc9 100644 --- a/src/config.c +++ b/src/config.c @@ -248,8 +248,6 @@ bool config_file_parse(char* filename, PCONFIGURATION config) { config->sops = strcmp("true", value) == 0; } else if (strcmp(key, "localaudio") == 0) { config->localaudio = strcmp("true", value) == 0; - } else if (strcmp(key, "fronttouchscreen_buttons") == 0) { - config->fronttouchscreen_buttons = strcmp("true", value) == 0; } else if (strcmp(key, "backtouchscreen_deadzone") == 0) { sscanf(value, "%d,%d,%d,%d", @@ -311,7 +309,6 @@ void config_save(char* filename, PCONFIGURATION config) { if (strcmp(config->app, "Steam") != 0) write_config_string(fd, "app", config->app); - write_config_bool(fd, "fronttouchscreen_buttons", config->fronttouchscreen_buttons); write_config_bool(fd, "disable_powersave", config->disable_powersave); char value[256]; diff --git a/src/gui/guilib.c b/src/gui/guilib.c index bd3231f1..f526edf1 100644 --- a/src/gui/guilib.c +++ b/src/gui/guilib.c @@ -21,6 +21,9 @@ #define BUTTON_DELAY 150 * 1000 +static gui_draw_callback gui_global_draw_callback; +static gui_loop_callback gui_global_loop_callback; + struct menu_geom make_geom_centered(int w, int h) { struct menu_geom geom = {0}; geom.x = WIDTH / 2 - w / 2; @@ -104,6 +107,7 @@ void draw_statusbar(struct menu_geom geom) { battery_color); } +SceTouchData touch_data; SceCtrlData ctrl_new_pad; static SceRtcTick button_current_tick, button_until_tick; @@ -124,6 +128,18 @@ bool is_button_down(short id) { return ctrl_new_pad.buttons & id; } +#define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10) +bool is_rectangle_touched(int lx, int ly, int rx, int ry) { + for (int i = 0; i < touch_data.reportNum; i++) { + int x = lerp(touch_data.report[i].x, 1919, WIDTH); + int y = lerp(touch_data.report[i].y, 1087, HEIGHT); + if (x < lx || x > rx || y < ly || y > ry) continue; + return true; + } + + return false; +} + void draw_menu(struct menu_entry menu[], int total_elements, struct menu_geom geom, int cursor, int offset) { vita2d_draw_rectangle(geom.x, geom.y, geom.width, geom.height, 0x10ffffff); @@ -265,6 +281,7 @@ void draw_alert(char *message, struct menu_geom geom, char *buttons_captions[], void gui_ctrl_begin() { sceCtrlPeekBufferPositive(0, &ctrl_new_pad, 1); + sceTouchPeek(SCE_TOUCH_PORT_FRONT, &touch_data, 1); } void gui_ctrl_end() { @@ -335,6 +352,11 @@ int display_menu( if (draw_callback && tick_number > 3) { draw_callback(); } + + if (gui_global_draw_callback && tick_number > 3) { + gui_global_draw_callback(); + } + draw_menu(menu, total_elements, geom, cursor, offset); int real_cursor = 0; @@ -356,6 +378,10 @@ int display_menu( exit_code = cb(menu[real_cursor].id, context); } + if (gui_global_loop_callback) { + gui_global_loop_callback(menu[real_cursor].id, context); + } + if (was_button_pressed(SCE_CTRL_CIRCLE)) { if (!back_cb || back_cb(context) == 0) { exit_code = 1; @@ -445,8 +471,15 @@ void flash_message(char *format, ...) { vita2d_swap_buffers(); } -void guilib_init() { +void drw() { + vita2d_draw_rectangle(0, 0, 150, 150, 0xffffffff); +} + +void guilib_init(gui_loop_callback global_loop_cb, gui_draw_callback global_draw_cb) { vita2d_init(); vita2d_set_clear_color(0xff000000); gui_font = vita2d_load_default_pgf(); + + gui_global_draw_callback = global_draw_cb; + gui_global_loop_callback = global_loop_cb; } diff --git a/src/gui/guilib.h b/src/gui/guilib.h index 24be3d48..25a5a054 100644 --- a/src/gui/guilib.h +++ b/src/gui/guilib.h @@ -26,6 +26,7 @@ typedef void (*gui_draw_callback) (void); bool was_button_pressed(short id); bool is_button_down(short id); +bool is_rectangle_touched(int lx, int ly, int rx, int ry); int display_menu( struct menu_entry menu[], @@ -49,4 +50,4 @@ void display_error(char *format, ...); void flash_message(char *format, ...); -void guilib_init(); +void guilib_init(gui_loop_callback global_loop_cb, gui_draw_callback global_draw_cb); diff --git a/src/gui/ui.c b/src/gui/ui.c index 10dbdb0a..d2732147 100644 --- a/src/gui/ui.c +++ b/src/gui/ui.c @@ -7,6 +7,7 @@ #include "ui_connect.h" #include "../config.h" +#include "../connection.h" #include #include @@ -77,8 +78,24 @@ int ui_main_menu() { return display_menu(menu, idx, &geom, &ui_main_menu_loop, &ui_main_menu_back, NULL, NULL); } +int global_loop(int cursor, void *ctx) { + if (is_rectangle_touched(0, 0, 150, 150)) { + if (connection_get_status() == LI_MINIMIZED) { + vitapower_config(config); + vitainput_config(config); + + sceKernelDelayThread(500 * 1000); + connection_resume(); + + while (connection_get_status() == LI_CONNECTED) { + sceKernelDelayThread(500 * 1000); + } + } + } +} + void gui_init() { - guilib_init(); + guilib_init(&global_loop, NULL); } void gui_loop() { diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 7c1b1ae3..9fd6f805 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -338,7 +338,6 @@ enum { SETTINGS_RESOLUTION = 100, SETTINGS_FPS, SETTINGS_BITRATE, - SETTINGS_FRONTTOUCHSCREEN, SETTINGS_DISABLE_POWERSAVE, SETTINGS_ENABLE_MAPPING, SETTINGS_BACK_DEADZONE, @@ -349,10 +348,9 @@ enum { SETTINGS_VIEW_RESOLUTION = 1, SETTINGS_VIEW_FPS, SETTINGS_VIEW_BITRATE, - SETTINGS_VIEW_FRONTTOUCHSCREEN = 5, - SETTINGS_VIEW_DISABLE_POWERSAVE = 7, + SETTINGS_VIEW_DISABLE_POWERSAVE = 5, SETTINGS_VIEW_ENABLE_MAPPING, - SETTINGS_VIEW_BACK_DEADZONE = 11 + SETTINGS_VIEW_BACK_DEADZONE = 9 }; static int move_idx_in_array(char *array[], int count, char *find, int index_dist) { @@ -434,11 +432,6 @@ static int settings_loop(int id, void *context) { } } } break; - case SETTINGS_FRONTTOUCHSCREEN: - if (was_button_pressed(SCE_CTRL_CROSS)) { - did_change = 1; - config.fronttouchscreen_buttons = !config.fronttouchscreen_buttons; - } break; case SETTINGS_DISABLE_POWERSAVE: if (was_button_pressed(SCE_CTRL_CROSS)) { did_change = 1; @@ -477,9 +470,6 @@ static int settings_loop(int id, void *context) { sprintf(current, "%d", config.stream.bitrate); strcpy(menu[SETTINGS_VIEW_BITRATE].subname, current); - sprintf(current, "%s", config.fronttouchscreen_buttons ? "yes" : "no"); - strcpy(menu[SETTINGS_VIEW_FRONTTOUCHSCREEN].subname, current); - sprintf(current, "%s", config.disable_powersave ? "yes" : "no"); strcpy(menu[SETTINGS_VIEW_DISABLE_POWERSAVE].subname, current); @@ -514,8 +504,6 @@ int ui_settings_menu() { // --------- menu[idx++] = (struct menu_entry) { .name = "Input", .disabled = true, .separator = true }; - idx++; menu[SETTINGS_VIEW_FRONTTOUCHSCREEN] = (struct menu_entry) { .name = "Use front touchscreen for buttons", .id = SETTINGS_FRONTTOUCHSCREEN }; - menu[idx++] = (struct menu_entry) { .name = "", .disabled = true, .subname = "Disables mouse input and special keys." }; idx++; menu[SETTINGS_VIEW_DISABLE_POWERSAVE] = (struct menu_entry) { .name = "Disable power save", .id = SETTINGS_DISABLE_POWERSAVE }; idx++; menu[SETTINGS_VIEW_ENABLE_MAPPING] = (struct menu_entry) { .name = "Enable mapping file", .id = SETTINGS_ENABLE_MAPPING }; diff --git a/src/input/vita.c b/src/input/vita.c index e7a4d70d..91c9eecf 100644 --- a/src/input/vita.c +++ b/src/input/vita.c @@ -48,17 +48,17 @@ static struct mapping map = {0}; #define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10) -static bool check_touch(SceTouchData scr, int lx, int ly, int rx, int ry) { +static int check_touch(SceTouchData scr, int lx, int ly, int rx, int ry) { for (int i = 0; i < scr.reportNum; i++) { int x = lerp(scr.report[i].x, 1919, WIDTH); int y = lerp(scr.report[i].y, 1087, HEIGHT); if (x < lx || x > rx || y < ly || y > ry) continue; - return true; + return i; } - return false; + return -1; } -static bool check_touch_sector(SceTouchData scr, int section) { +int check_touch_sector(SceTouchData scr, int section) { int vertical = (WIDTH - config.back_deadzone.left - config.back_deadzone.right) / 2 + config.back_deadzone.left, horizontal = (HEIGHT - config.back_deadzone.top - config.back_deadzone.bottom) / 2 + config.back_deadzone.top; @@ -176,12 +176,12 @@ static short pad_value(SceCtrlData pad, int sec) { bool check_input(short identifier, SceCtrlData pad, SceTouchData screen, SceTouchData front, SceTouchData back) { if (identifier >= TOUCHSEC_NORTHWEST && identifier < TOUCHSEC_SPECIAL_SW) { - return check_touch_sector(screen, identifier); + return check_touch_sector(screen, identifier) != -1; } else if (identifier >= TOUCHSEC_SPECIAL_SW && identifier <= TOUCHSEC_SPECIAL_NE) { if (config.fronttouchscreen_buttons == true) { return false; } else { - return check_touch_sector(front, identifier); + return check_touch_sector(front, identifier) != -1; } } else { identifier = identifier + 1; @@ -213,7 +213,7 @@ static void special_input(SceTouchData screen, int *btn) { unsigned int type = config_code & INPUT_TYPE_MASK; unsigned int code = config_code & INPUT_VALUE_MASK; - if (check_touch_sector(screen, identifier) && !current_status) { + if (check_touch_sector(screen, identifier) != -1 && !current_status) { switch (type) { case INPUT_TYPE_SPECIAL: if (code == INPUT_SPECIAL_KEY_PAUSE) { @@ -231,7 +231,7 @@ static void special_input(SceTouchData screen, int *btn) { LiSendKeyboardEvent(code, KEY_ACTION_DOWN, 0); break; } - } else if (!check_touch_sector(screen, identifier) && current_status) { + } else if (check_touch_sector(screen, identifier) == -1 && current_status) { special_input_status[idx] = false; switch (type) { @@ -281,72 +281,78 @@ void vitainput_process(void) { sceTouchPeek(SCE_TOUCH_PORT_BACK, &back, 1); sceRtcGetCurrentTick(¤t); - if (config.fronttouchscreen_buttons == false) { - switch (front_state) { - case NO_TOUCH_ACTION: - if (front.reportNum > 0) { - front_state = ON_SCREEN_TOUCH; - finger_count = front.reportNum; - sceRtcTickAddMicroseconds(&until, ¤t, MOUSE_ACTION_DELAY); + input_data input = {0}; + + SceTouchData buttons_screen = config.fronttouchscreen_buttons ? front : back; + special_input(front, &input.button); + + for (int i = TOUCHSEC_SPECIAL_NW, touchIdx = -1; i <= TOUCHSEC_SPECIAL_SE; i++) { + unsigned int config_code = special_input_config_code(i); + if (config_code && (touchIdx = check_touch_sector(front, i)) != -1) { + for (int n = 0, idx = 0; n < front.reportNum; n++) { + if (n != touchIdx) { + front.report[idx++] = front.report[n]; } - break; - case ON_SCREEN_TOUCH: - if (sceRtcCompareTick(¤t, &until) < 0) { - if (front.reportNum < finger_count) { - // TAP - if (mouse_click(front, finger_count, true)) { - front_state = SCREEN_TAP; - sceRtcTickAddMicroseconds(&until, ¤t, MOUSE_ACTION_DELAY); - } else { - front_state = NO_TOUCH_ACTION; - } - } else if (front.reportNum > finger_count) { - // finger count changed - finger_count = front.reportNum; + } + + front.reportNum--; + } + } + + switch (front_state) { + case NO_TOUCH_ACTION: + if (front.reportNum > 0) { + front_state = ON_SCREEN_TOUCH; + finger_count = front.reportNum; + sceRtcTickAddMicroseconds(&until, ¤t, MOUSE_ACTION_DELAY); + } + break; + case ON_SCREEN_TOUCH: + if (sceRtcCompareTick(¤t, &until) < 0) { + if (front.reportNum < finger_count) { + // TAP + if (mouse_click(front, finger_count, true)) { + front_state = SCREEN_TAP; + sceRtcTickAddMicroseconds(&until, ¤t, MOUSE_ACTION_DELAY); + } else { + front_state = NO_TOUCH_ACTION; } - } else { - front_state = SWIPE_START; + } else if (front.reportNum > finger_count) { + // finger count changed + finger_count = front.reportNum; } - break; - case SCREEN_TAP: - if (sceRtcCompareTick(¤t, &until) >= 0) { - mouse_click(front, finger_count, false); + } else { + front_state = SWIPE_START; + } + break; + case SCREEN_TAP: + if (sceRtcCompareTick(¤t, &until) >= 0) { + mouse_click(front, finger_count, false); - front_state = NO_TOUCH_ACTION; + front_state = NO_TOUCH_ACTION; + } + break; + case SWIPE_START: + memcpy(&front_old, &front, sizeof(front_old)); + front_state = ON_SCREEN_SWIPE; + break; + case ON_SCREEN_SWIPE: + if (front.reportNum > 0) { + switch (front.reportNum) { + case 1: + move_mouse(front_old, front); + break; + case 2: + move_wheel(front_old, front); + break; } - break; - case SWIPE_START: memcpy(&front_old, &front, sizeof(front_old)); - front_state = ON_SCREEN_SWIPE; - break; - case ON_SCREEN_SWIPE: - if (front.reportNum > 0) { - switch (front.reportNum) { - case 1: - move_mouse(front_old, front); - break; - case 2: - move_wheel(front_old, front); - break; - } - memcpy(&front_old, &front, sizeof(front_old)); - } else { - front_state = NO_TOUCH_ACTION; - } - break; - } - - for (int i = TOUCHSEC_SPECIAL_NW; i <= TOUCHSEC_SPECIAL_SE; i++) { - if (check_touch_sector(front, i)) { + } else { front_state = NO_TOUCH_ACTION; } - } + break; } - input_data input = {0}; - - SceTouchData buttons_screen = config.fronttouchscreen_buttons ? front : back; - INPUT(map.btn_dpad_up, UP_FLAG); INPUT(map.btn_dpad_up, UP_FLAG); INPUT(map.btn_dpad_left, LEFT_FLAG); @@ -367,8 +373,6 @@ void vitainput_process(void) { INPUT(map.btn_thumbl, LB_FLAG); INPUT(map.btn_thumbr, RB_FLAG); - special_input(front, &input.button); - // TRIGGERS input.left_trigger = CHECK_INPUT(map.btn_tl) ? 0xff : 0; input.right_trigger = CHECK_INPUT(map.btn_tr) ? 0xff : 0; From a17d7937b7822f36306c3cc932e98e52f65c096e Mon Sep 17 00:00:00 2001 From: Vasiliy Horbachenko Date: Sat, 17 Sep 2016 23:24:51 +0300 Subject: [PATCH 2/2] little input and ui cleanup; ability to use axis for special keys --- src/config.h | 1 - src/gui/ui_settings.c | 16 +++--- src/input/vita.c | 113 ++++++++++++++++++++++-------------------- src/input/vita.h | 13 +++-- 4 files changed, 77 insertions(+), 66 deletions(-) diff --git a/src/config.h b/src/config.h index 12b35ca1..5cf1ce2c 100644 --- a/src/config.h +++ b/src/config.h @@ -51,7 +51,6 @@ typedef struct _CONFIGURATION { bool fullscreen; bool forcehw; bool unsupported_version; - bool fronttouchscreen_buttons; struct touchscreen_deadzone back_deadzone; struct special_keys special_keys; bool disable_powersave; diff --git a/src/gui/ui_settings.c b/src/gui/ui_settings.c index 9fd6f805..cebb0b2d 100644 --- a/src/gui/ui_settings.c +++ b/src/gui/ui_settings.c @@ -22,17 +22,19 @@ #include static unsigned int settings_special_codes[] = {0, INPUT_SPECIAL_KEY_PAUSE | INPUT_TYPE_SPECIAL, - 1024 | INPUT_TYPE_GAMEPAD, - 256 | INPUT_TYPE_GAMEPAD, - 512 | INPUT_TYPE_GAMEPAD, - 64 | INPUT_TYPE_GAMEPAD, - 128 | INPUT_TYPE_GAMEPAD, + SPECIAL_FLAG | INPUT_TYPE_GAMEPAD, + LB_FLAG | INPUT_TYPE_GAMEPAD, + RB_FLAG | INPUT_TYPE_GAMEPAD, + LS_CLK_FLAG | INPUT_TYPE_GAMEPAD, + RS_CLK_FLAG | INPUT_TYPE_GAMEPAD, + LEFT_TRIGGER | INPUT_TYPE_AXIS, + RIGHT_TRIGGER | INPUT_TYPE_AXIS, BUTTON_LEFT | INPUT_TYPE_MOUSE, BUTTON_RIGHT | INPUT_TYPE_MOUSE, BUTTON_MIDDLE | INPUT_TYPE_MOUSE, 27, 73, 77, 9, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123 }; static char *settings_special_names[] = {"None", "Pause stream", - "Special (XBox button)", "LB", "RB", "LS", "RS", + "Special (XBox button)", "LB", "RB", "LS", "RS", "LT", "RT", "LMB", "RMB", "MMB", "Esc", "I", "M", "Tab", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" }; static bool settings_loop_setup = 1; @@ -278,7 +280,7 @@ static void special_keys_draw() { int special_offset = config.special_keys.offset, special_size = config.special_keys.size; - unsigned int color = 0xffffffff; + unsigned int color = 0xff006000; for (int i = TOUCHSEC_SPECIAL_NW; i <= TOUCHSEC_SPECIAL_SE; i++) { switch (i) { diff --git a/src/input/vita.c b/src/input/vita.c index 91c9eecf..9cd70e12 100644 --- a/src/input/vita.c +++ b/src/input/vita.c @@ -46,6 +46,16 @@ static struct mapping map = {0}; +typedef struct input_data { + short button; + char left_trigger; + char right_trigger; + short lx; + short ly; + short rx; + short ry; +} input_data; + #define lerp(value, from_max, to_max) ((((value*10) * (to_max*10))/(from_max*10))/10) static int check_touch(SceTouchData scr, int lx, int ly, int rx, int ry) { @@ -174,15 +184,9 @@ static short pad_value(SceCtrlData pad, int sec) { return (short) (value * 256 - (1 << 15) + 128); } -bool check_input(short identifier, SceCtrlData pad, SceTouchData screen, SceTouchData front, SceTouchData back) { - if (identifier >= TOUCHSEC_NORTHWEST && identifier < TOUCHSEC_SPECIAL_SW) { +bool check_input(short identifier, SceCtrlData pad, SceTouchData screen) { + if (identifier >= TOUCHSEC_NORTHWEST && identifier <= TOUCHSEC_SOUTHEAST) { return check_touch_sector(screen, identifier) != -1; - } else if (identifier >= TOUCHSEC_SPECIAL_SW && identifier <= TOUCHSEC_SPECIAL_NE) { - if (config.fronttouchscreen_buttons == true) { - return false; - } else { - return check_touch_sector(front, identifier) != -1; - } } else { identifier = identifier + 1; return pad.buttons & identifier; @@ -205,7 +209,7 @@ static int special_input_config_code(short identifier) { } static bool special_input_status[4] = {0, 0, 0, 0}; -static void special_input(SceTouchData screen, int *btn) { +static void special_input(SceTouchData screen, input_data *input) { for (int identifier = TOUCHSEC_SPECIAL_NW; identifier <= TOUCHSEC_SPECIAL_SE; identifier++) { int idx = identifier - TOUCHSEC_SPECIAL_NW; bool current_status = special_input_status[idx]; @@ -220,12 +224,22 @@ static void special_input(SceTouchData screen, int *btn) { connection_minimize(); } break; case INPUT_TYPE_GAMEPAD: - *btn |= code; + input->button |= code; break; case INPUT_TYPE_MOUSE: special_input_status[idx] = true; LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, code); break; + case INPUT_TYPE_AXIS: + switch (code) { + case LEFT_TRIGGER: + input->left_trigger = 0xff; + break; + case RIGHT_TRIGGER: + input->right_trigger = 0xff; + break; + } + break; case INPUT_TYPE_KEYBOARD: special_input_status[idx] = true; LiSendKeyboardEvent(code, KEY_ACTION_DOWN, 0); @@ -246,8 +260,8 @@ static void special_input(SceTouchData screen, int *btn) { } } -#define CHECK_INPUT(id) check_input((id), pad, buttons_screen, front, back) -#define INPUT(id, flag) if (check_input((id), pad, buttons_screen, front, back)) input.button |= (flag); +#define CHECK_INPUT(id) check_input((id), pad, back) +#define INPUT(id, flag) if (check_input((id), pad, back)) input.button |= (flag); static SceCtrlData pad; static SceTouchData front; @@ -261,16 +275,6 @@ static SceRtcTick current, until; static int special_status; -typedef struct input_data { - short button; - char left_trigger; - char right_trigger; - short lx; - short ly; - short rx; - short ry; -} input_data; - static input_data old; void vitainput_process(void) { @@ -283,9 +287,40 @@ void vitainput_process(void) { input_data input = {0}; - SceTouchData buttons_screen = config.fronttouchscreen_buttons ? front : back; - special_input(front, &input.button); + // buttons + INPUT(map.btn_dpad_up, UP_FLAG); + INPUT(map.btn_dpad_up, UP_FLAG); + INPUT(map.btn_dpad_left, LEFT_FLAG); + INPUT(map.btn_dpad_down, DOWN_FLAG); + INPUT(map.btn_dpad_right, RIGHT_FLAG); + + INPUT(map.btn_start, PLAY_FLAG); + INPUT(map.btn_select, BACK_FLAG); + + INPUT(map.btn_north, Y_FLAG); + INPUT(map.btn_east, B_FLAG); + INPUT(map.btn_south, A_FLAG); + INPUT(map.btn_west, X_FLAG); + + INPUT(map.btn_tl2, LS_CLK_FLAG); + INPUT(map.btn_tr2, RS_CLK_FLAG); + + INPUT(map.btn_thumbl, LB_FLAG); + INPUT(map.btn_thumbr, RB_FLAG); + + // AXIS + input.left_trigger = CHECK_INPUT(map.btn_tl) ? 0xff : 0; + input.right_trigger = CHECK_INPUT(map.btn_tr) ? 0xff : 0; + + input.lx = pad_value(pad, map.abs_x), + input.ly = pad_value(pad, map.abs_y), + input.rx = pad_value(pad, map.abs_rx), + input.ry = pad_value(pad, map.abs_ry); + + // special touchscreen buttons + special_input(front, &input); + // remove touches for special actions for (int i = TOUCHSEC_SPECIAL_NW, touchIdx = -1; i <= TOUCHSEC_SPECIAL_SE; i++) { unsigned int config_code = special_input_config_code(i); if (config_code && (touchIdx = check_touch_sector(front, i)) != -1) { @@ -299,6 +334,7 @@ void vitainput_process(void) { } } + // mouse switch (front_state) { case NO_TOUCH_ACTION: if (front.reportNum > 0) { @@ -353,35 +389,6 @@ void vitainput_process(void) { break; } - INPUT(map.btn_dpad_up, UP_FLAG); - INPUT(map.btn_dpad_up, UP_FLAG); - INPUT(map.btn_dpad_left, LEFT_FLAG); - INPUT(map.btn_dpad_down, DOWN_FLAG); - INPUT(map.btn_dpad_right, RIGHT_FLAG); - - INPUT(map.btn_start, PLAY_FLAG); - INPUT(map.btn_select, BACK_FLAG); - - INPUT(map.btn_north, Y_FLAG); - INPUT(map.btn_east, B_FLAG); - INPUT(map.btn_south, A_FLAG); - INPUT(map.btn_west, X_FLAG); - - INPUT(map.btn_tl2, LS_CLK_FLAG); - INPUT(map.btn_tr2, RS_CLK_FLAG); - - INPUT(map.btn_thumbl, LB_FLAG); - INPUT(map.btn_thumbr, RB_FLAG); - - // TRIGGERS - input.left_trigger = CHECK_INPUT(map.btn_tl) ? 0xff : 0; - input.right_trigger = CHECK_INPUT(map.btn_tr) ? 0xff : 0; - - input.lx = pad_value(pad, map.abs_x), - input.ly = pad_value(pad, map.abs_y), - input.rx = pad_value(pad, map.abs_rx), - input.ry = pad_value(pad, map.abs_ry); - if (memcmp(&input, &old, sizeof(input_data)) != 0) { LiSendControllerEvent(input.button, input.left_trigger, input.right_trigger, input.lx, -1 * input.ly, input.rx, -1 * input.ry); diff --git a/src/input/vita.h b/src/input/vita.h index a0b9e9eb..7000c3f4 100644 --- a/src/input/vita.h +++ b/src/input/vita.h @@ -40,16 +40,19 @@ enum { LEFTX, LEFTY, RIGHTX, - RIGHTY + RIGHTY, + LEFT_TRIGGER, + RIGHT_TRIGGER } PadSection; -#define INPUT_TYPE_MASK 0xffff0000 +#define INPUT_TYPE_MASK 0xffff0000 #define INPUT_VALUE_MASK 0x0000ffff #define INPUT_TYPE_KEYBOARD 0x00000000 -#define INPUT_TYPE_SPECIAL 0x00010000 -#define INPUT_TYPE_MOUSE 0x00020000 -#define INPUT_TYPE_GAMEPAD 0x00030000 +#define INPUT_TYPE_SPECIAL 0x00010000 +#define INPUT_TYPE_MOUSE 0x00020000 +#define INPUT_TYPE_GAMEPAD 0x00030000 +#define INPUT_TYPE_AXIS 0x00040000 enum { INPUT_SPECIAL_KEY_PAUSE