Skip to content

Commit

Permalink
Merge pull request #50 from d3m3vilurr/refactor-input-and-config
Browse files Browse the repository at this point in the history
Increase stability of input process

resolve #42 
resolve #44 
resolve #45
  • Loading branch information
d3m3vilurr authored Oct 14, 2016
2 parents 5f7137e + a342d94 commit e2a6cc7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "graphics.h"
#include "input/vita.h"

#include <psp2/kernel/sysmem.h>

#define MOONLIGHT_PATH "/moonlight"
#define USER_PATHS "."
#define DEFAULT_CONFIG_DIR "/.config"
Expand Down Expand Up @@ -226,6 +228,8 @@ static int ini_handle(void *out, const char *section, const char *name,
config->localaudio = BOOL(value);
} else if (strcmp(name, "disable_powersave") == 0) {
config->disable_powersave = BOOL(value);
} else if (strcmp(name, "mapping") == 0) {
config->mapping = STR(value);
}
}
}
Expand Down Expand Up @@ -297,6 +301,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) {
config->stream.supportsHevc = false;

config->platform = "vita";
config->model = sceKernelGetModelForCDialog();
config->app = "Steam";
config->action = NULL;
config->address = NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/gui/ui_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,10 @@ static int settings_loop(int id, void *context) {
if (was_button_pressed(SCE_CTRL_CROSS)) {
did_change = 1;
if (config.mapping) {
free(config.mapping);
config.mapping = 0;
} else {
config.mapping = "mappings/vita.conf";
config.mapping = strdup("mappings/vita.conf");
}
} break;
case SETTINGS_BACK_DEADZONE:
Expand Down
15 changes: 8 additions & 7 deletions src/input/vita.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ inline uint8_t read_backscreen() {
}
}

if (touch.button & TOUCHSEC_SOUTHWEST) {
if ((touch.button & TOUCHSEC_SOUTHWEST) == 0) {
if (IN_SECTION(BACK_SECTIONS[2], x, y)) {
touch.button |= TOUCHSEC_SOUTHWEST;
continue;
}
}

if (touch.button & TOUCHSEC_SOUTHEAST) {
if ((touch.button & TOUCHSEC_SOUTHEAST) == 0) {
if (IN_SECTION(BACK_SECTIONS[3], x, y)) {
touch.button |= TOUCHSEC_SOUTHEAST;
continue;
Expand Down Expand Up @@ -203,14 +203,14 @@ inline uint8_t read_frontscreen() {
}
}

if (touch.button & TOUCHSEC_SPECIAL_SW) {
if ((touch.button & TOUCHSEC_SPECIAL_SW) == 0) {
if (IN_SECTION(FRONT_SECTIONS[2], x, y)) {
touch.button |= TOUCHSEC_SPECIAL_SW;
continue;
}
}

if (touch.button & TOUCHSEC_SPECIAL_SE) {
if ((touch.button & TOUCHSEC_SPECIAL_SE) == 0) {
if (IN_SECTION(FRONT_SECTIONS[3], x, y)) {
touch.button |= TOUCHSEC_SPECIAL_SE;
continue;
Expand Down Expand Up @@ -341,6 +341,7 @@ inline void vitainput_process(void) {
memset(&touch, 0, sizeof(TouchData));
memset(&curr, 0, sizeof(input_data));

sceCtrlSetSamplingModeExt(SCE_CTRL_MODE_ANALOG_WIDE);
sceCtrlReadBufferPositiveExt2(controller_port, &pad, 1);

sceTouchPeek(SCE_TOUCH_PORT_FRONT, &front, 1);
Expand Down Expand Up @@ -382,8 +383,8 @@ inline void vitainput_process(void) {
is_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_NE),
is_old_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_NE));
special(config.special_keys.sw,
is_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_NW),
is_old_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_NW));
is_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_SW),
is_old_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_SW));
special(config.special_keys.se,
is_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_SE),
is_old_pressed(INPUT_TYPE_TOUCHSCREEN | TOUCHSEC_SPECIAL_SE));
Expand Down Expand Up @@ -473,7 +474,7 @@ bool vitainput_init() {
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);

SceUID thid = sceKernelCreateThread("vitainput_thread", vitainput_thread, 0x10000100, 0x40000, 0, 0, NULL);
SceUID thid = sceKernelCreateThread("vitainput_thread", vitainput_thread, 0, 0x40000, 0, 0, NULL);
if (thid >= 0) {
sceKernelStartThread(thid, 0, NULL);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/input/vita.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ enum {
TOUCHSEC_SOUTHEAST = 0x8,
TOUCHSEC_SPECIAL_NW = 0x10,
TOUCHSEC_SPECIAL_NE = 0x20,
TOUCHSEC_SPECIAL_SW = 0x30,
TOUCHSEC_SPECIAL_SE = 0x40,
TOUCHSEC_SPECIAL_SW = 0x40,
TOUCHSEC_SPECIAL_SE = 0x80,
} TouchScreenSection;

enum {
Expand Down

0 comments on commit e2a6cc7

Please sign in to comment.