BT pair dialog.

This commit is contained in:
sorgelig
2019-04-03 13:00:21 +08:00
parent 51f4db89bf
commit e7ba2551d5
4 changed files with 69 additions and 19 deletions

View File

@@ -1504,10 +1504,18 @@ static void joy_analog(int num, int axis, int offset)
}
}
static int ps3_sel = 0;
int is_ps3_sel()
{
return ps3_sel;
}
static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int dev)
{
static int key_mapped = 0;
if (ev->type == EV_KEY && input[dev].vid == 0x054c && input[dev].pid == 0x0268 && ev->code == 0x13a) ps3_sel = ev->value;
if (ev->type == EV_KEY && mapping && mapping_type == 3 && ev->code == input[dev].mmap[17]) ev->code = KEY_ENTER;
int map_skip = (ev->type == EV_KEY && ev->code == KEY_SPACE && ((mapping_dev >= 0 && mapping_type==1) || mapping_button<0));
@@ -2275,13 +2283,17 @@ int input_test(int getchar)
if (ev.code == 60) break; //ps3 accel axis
if (ev.code == 59) break; //ps3 accel axis
//reduce flood from PS3 gamepad
if (input[i].vid == 0x054c && input[i].pid == 0x0268)
{ if (ev.code <= 5 && ev.value > 118 && ev.value < 138) break; }
//reduce flood from DUALSHOCK 3/4
if (input[i].vid == 0x054c && (input[i].pid == 0x0268 || input[i].pid == 0x05c4 || input[i].pid == 0x09cc))
{
if (ev.code <= 5 && ev.value > 118 && ev.value < 138) break;
}
//aliexpress USB encoder floods messages
if (input[i].vid == 0x0079 && input[i].pid == 0x0006)
{ if (ev.code == 2) break; }
{
if (ev.code == 2) break;
}
printf("Input event: type=EV_ABS, Axis=%d, Offset:=%d, jnum=%d, ID:%04x:%04x.", ev.code, ev.value, input[i].num, input[i].vid, input[i].pid);
printf(" ABS_INFO: min = %d max = %d", absinfo.minimum, absinfo.maximum);

View File

@@ -36,6 +36,7 @@ int toggle_kbdled(int mask);
void input_notify_mode();
int input_poll(int getchar);
int is_key_pressed(int key);
int is_ps3_sel();
void start_map_setting(int cnt);
int get_map_button();

View File

@@ -103,6 +103,7 @@ enum MENU
MENU_KBDMAP1,
MENU_SCRIPTS,
MENU_SCRIPTS1,
MENU_BTPAIR,
// Mist/atari specific pages
MENU_MIST_MAIN1,
@@ -469,9 +470,20 @@ static uint32_t menu_key_get(void)
// currently no key pressed
if (!c)
{
static unsigned long longpress = 0, longpress_consumed = 0;
static unsigned char last_but = 0;
unsigned char but = user_io_menu_button();
if (!but && last_but) c = KEY_F12;
if (but && !last_but) longpress = GetTimer(3000);
if (but && CheckTimer(longpress) && !longpress_consumed)
{
longpress_consumed = 1;
menustate = MENU_BTPAIR;
}
if (!but && last_but && !longpress_consumed) c = KEY_F12;
if (!but) longpress_consumed = 0;
last_but = but;
}
return(c);
@@ -662,8 +674,6 @@ const char* get_rbf_name_bootcore(char *str)
return NULL;
}
return p + 1;
}
void HandleUI(void)
@@ -733,6 +743,13 @@ void HandleUI(void)
}
break;
case KEY_F11:
if (user_io_osd_is_visible())
{
menustate = MENU_BTPAIR;
}
break;
// Within the menu the esc key acts as the menu key. problem:
// if the menu is left with a press of ESC, then the follwing
// break code for the ESC key when the key is released will
@@ -3467,19 +3484,25 @@ void HandleUI(void)
printSysInfo();
break;
case MENU_BTPAIR:
OsdSetSize(16);
OsdEnable(DISABLE_KEYBOARD);
parentstate = MENU_BTPAIR;
//fall through
case MENU_SCRIPTS:
helptext = 0;
menumask = 1;
menusub = 0;
OsdSetTitle(flist_SelectedItem()->d_name, 0);
OsdSetTitle((parentstate == MENU_BTPAIR) ? "BT Pairing" : flist_SelectedItem()->d_name, 0);
menustate = MENU_SCRIPTS1;
parentstate = MENU_SCRIPTS;
if (parentstate != MENU_BTPAIR) parentstate = MENU_SCRIPTS;
for (int i = 0; i < OsdGetSize() - 1; i++) OsdWrite(i, "", 0, 0);
OsdWrite(OsdGetSize() - 1, " Cancel", menusub == 0, 0);
for (int i = 0; i < script_lines; i++) strcpy(script_output[i], "");
script_line=0;
script_exited = false;
script_pipe=popen(getFullPath(SelectedPath), "r");
script_pipe=popen((parentstate != MENU_BTPAIR) ? getFullPath(SelectedPath) : is_ps3_sel() ? "/usr/sbin/btpair sixaxis" : "/usr/sbin/btpair", "r");
script_file = fileno(script_pipe);
fcntl(script_file, F_SETFL, O_NONBLOCK);
break;
@@ -3491,7 +3514,7 @@ void HandleUI(void)
if (fgets(script_line_output, script_line_length, script_pipe) != NULL)
{
script_line_output[strcspn(script_line_output, "\n")] = 0;
if (script_line < OsdGetSize() - 1)
if (script_line < OsdGetSize() - 2)
{
strcpy(script_output[script_line++], script_line_output);
}
@@ -3500,7 +3523,7 @@ void HandleUI(void)
strcpy(script_output[script_line], script_line_output);
for (int i = 0; i < script_line; i++) strcpy(script_output[i], script_output[i+1]);
};
for (int i = 0; i < OsdGetSize() - 1; i++) OsdWrite(i, script_output[i], 0, 0);
for (int i = 0; i < OsdGetSize() - 2; i++) OsdWrite(i, script_output[i], 0, 0);
};
}
else {
@@ -3508,23 +3531,31 @@ void HandleUI(void)
script_exited=true;
OsdWrite(OsdGetSize() - 1, " OK", menusub == 0, 0);
};
};
if (select || menu)
};
if (select || (script_exited && menu))
{
if (!script_exited)
{
strcpy(script_command, "killall ");
strcat(script_command, flist_SelectedItem()->d_name);
strcat(script_command, (parentstate == MENU_BTPAIR) ? "btpair" : flist_SelectedItem()->d_name);
system(script_command);
pclose(script_pipe);
script_exited=true;
script_exited = true;
};
menustate = MENU_FIRMWARE1;
menusub = 3;
if (parentstate == MENU_BTPAIR)
{
menustate = MENU_NONE1;
}
else
{
menustate = MENU_FIRMWARE1;
menusub = 3;
}
}
break;
case MENU_KBDMAP:
helptext = 0;
menumask = 1;
@@ -3961,3 +3992,8 @@ void Info(const char *message, int timeout, int width, int height, int frame)
menustate = MENU_INFO;
}
}
void menu_bt_pair()
{
menustate = MENU_BTPAIR;
}

1
menu.h
View File

@@ -28,5 +28,6 @@ extern char joy_bnames[32][32];
extern int joy_bcount;
void open_joystick_setup();
void menu_bt_pair();
#endif