input: simplified joystick 2 sets definition.
This commit is contained in:
44
input.cpp
44
input.cpp
@@ -1154,26 +1154,34 @@ int toggle_kbdled(int mask)
|
||||
|
||||
static int mapping = 0;
|
||||
static int mapping_button;
|
||||
static int mapping_dev;
|
||||
static int mapping_dev = -1;
|
||||
static int mapping_type;
|
||||
static int mapping_count;
|
||||
static int mapping_clear;
|
||||
static int mapping_set;
|
||||
|
||||
static uint32_t tmp_axis[4];
|
||||
static int tmp_axis_n = 0;
|
||||
|
||||
void start_map_setting(int cnt)
|
||||
void start_map_setting(int cnt, int set)
|
||||
{
|
||||
mapping_button = 0;
|
||||
mapping = 1;
|
||||
mapping_dev = -1;
|
||||
mapping_type = (cnt<0) ? 3 : cnt ? 1 : 2;
|
||||
mapping_set = set;
|
||||
if (!mapping_set)
|
||||
{
|
||||
mapping_dev = -1;
|
||||
mapping_type = (cnt < 0) ? 3 : cnt ? 1 : 2;
|
||||
}
|
||||
mapping_count = cnt;
|
||||
mapping_clear = 0;
|
||||
tmp_axis_n = 0;
|
||||
|
||||
if (mapping_type <= 1 && is_menu_core()) mapping_button = -6;
|
||||
memset(tmp_axis, 0, sizeof(tmp_axis));
|
||||
|
||||
//un-stick the enter key
|
||||
user_io_kbd(KEY_ENTER, 0);
|
||||
}
|
||||
|
||||
int get_map_button()
|
||||
@@ -1224,9 +1232,6 @@ void finish_map_setting(int dismiss)
|
||||
{
|
||||
for (int i = 0; i < NUMDEV; i++) input[i].has_map = 0;
|
||||
|
||||
if (mapping_button < 0) mapping_button = 0;
|
||||
if (!is_menu_core()) for (uint i = mapping_button; i < BTN_NUM; i++) input[mapping_dev].map[i] = 0;
|
||||
|
||||
if (!dismiss) FileSaveConfig(get_map_name(mapping_dev, 0), &input[mapping_dev].map, sizeof(input[mapping_dev].map));
|
||||
if (is_menu_core()) input[mapping_dev].has_mmap = 0;
|
||||
}
|
||||
@@ -1564,12 +1569,9 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
|
||||
}
|
||||
else
|
||||
{
|
||||
//copy alternative directional buttons, remove system buttons
|
||||
for (uint i = 0; i < sizeof(input[0].map) / sizeof(input[0].map[0]); i++)
|
||||
for (uint i = 8; i < sizeof(input[0].map) / sizeof(input[0].map[0]); i++)
|
||||
{
|
||||
if(i < 4) input[dev].map[i] = (input[dev].map[i] << 16) | (input[dev].map[i + 8] & 0xFFFF);
|
||||
else if(i < 8) input[dev].map[i] = input[dev].map[i] << 16;
|
||||
else input[dev].map[i] = 0;
|
||||
input[dev].map[i] = 0;
|
||||
}
|
||||
}
|
||||
input[dev].has_map++;
|
||||
@@ -1691,19 +1693,21 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
|
||||
{
|
||||
for (uint i = 0; i < sizeof(input[0].map) / sizeof(input[0].map[0]); i++)
|
||||
{
|
||||
input[dev].map[i] = mapping_type ? input[dev].map[i] << 16 : 0;
|
||||
input[dev].map[i] &= mapping_set ? 0x0000FFFF : 0xFFFF0000;
|
||||
}
|
||||
}
|
||||
|
||||
int found = 0;
|
||||
for (int i = 0; i < mapping_button; i++)
|
||||
{
|
||||
if ((input[dev].map[i] & 0xFFFF) == ev->code) found = 1;
|
||||
if (mapping_set && (input[dev].map[i] >> 16) == ev->code) found = 1;
|
||||
if (!mapping_set && (input[dev].map[i] & 0xFFFF) == ev->code) found = 1;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
input[dev].map[mapping_button] = input[dev].map[mapping_button] | (ev->code & 0xFFFF);
|
||||
if (mapping_set) input[dev].map[mapping_button] = (input[dev].map[mapping_button] & 0xFFFF) | (ev->code << 16);
|
||||
else input[dev].map[mapping_button] = (input[dev].map[mapping_button] & 0xFFFF0000) | ev->code;
|
||||
key_mapped = ev->code;
|
||||
}
|
||||
}
|
||||
@@ -1830,7 +1834,15 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int
|
||||
{
|
||||
if (ev->value == 1)
|
||||
{
|
||||
if (idx && mapping_dev >= 0) input[mapping_dev].map[idx] = is_menu_core() ? 0 : (input[mapping_dev].map[idx] & 0xFFFF0000);
|
||||
if (mapping_dev >= 0)
|
||||
{
|
||||
if (idx) input[mapping_dev].map[idx] = 0;
|
||||
else if (mapping_button > 0)
|
||||
{
|
||||
if (is_menu_core()) input[mapping_dev].map[mapping_button] = 0;
|
||||
else input[mapping_dev].map[mapping_button] &= mapping_set ? 0x0000FFFF : 0xFFFF0000;
|
||||
}
|
||||
}
|
||||
mapping_button++;
|
||||
if (mapping_button < 0 && (mapping_button&1)) mapping_button++;
|
||||
}
|
||||
|
||||
2
input.h
2
input.h
@@ -37,7 +37,7 @@ void input_notify_mode();
|
||||
int input_poll(int getchar);
|
||||
int is_key_pressed(int key);
|
||||
|
||||
void start_map_setting(int cnt);
|
||||
void start_map_setting(int cnt, int set = 0);
|
||||
int get_map_button();
|
||||
int get_map_type();
|
||||
int get_map_clear();
|
||||
|
||||
60
menu.cpp
60
menu.cpp
@@ -97,6 +97,8 @@ enum MENU
|
||||
MENU_JOYDIGMAP,
|
||||
MENU_JOYDIGMAP1,
|
||||
MENU_JOYDIGMAP2,
|
||||
MENU_JOYDIGMAP3,
|
||||
MENU_JOYDIGMAP4,
|
||||
MENU_JOYKBDMAP,
|
||||
MENU_JOYKBDMAP1,
|
||||
MENU_KBDMAP,
|
||||
@@ -727,6 +729,8 @@ const char* get_rbf_name_bootcore(char *str)
|
||||
return p + 1;
|
||||
}
|
||||
|
||||
static int joymap_first = 0;
|
||||
|
||||
void HandleUI(void)
|
||||
{
|
||||
switch (user_io_core_type())
|
||||
@@ -1506,6 +1510,7 @@ void HandleUI(void)
|
||||
start_map_setting(joy_bcount ? joy_bcount+4 : 8);
|
||||
menustate = MENU_JOYDIGMAP;
|
||||
menusub = 0;
|
||||
joymap_first = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
@@ -1811,7 +1816,7 @@ void HandleUI(void)
|
||||
|
||||
case MENU_JOYDIGMAP:
|
||||
helptext = 0;
|
||||
menumask = 0;
|
||||
menumask = 1;
|
||||
OsdSetTitle("Define buttons", 0);
|
||||
menustate = MENU_JOYDIGMAP1;
|
||||
parentstate = MENU_JOYDIGMAP;
|
||||
@@ -1819,11 +1824,6 @@ void HandleUI(void)
|
||||
OsdWrite(7, " Esc \x16 Cancel");
|
||||
OsdWrite(8, " Enter \x16 Finish");
|
||||
OsdWrite(9, " Space \x16 Skip");
|
||||
if (!is_menu_core())
|
||||
{
|
||||
OsdWrite(13, " You may define 2 sets of");
|
||||
OsdWrite(14, " buttons on the same gamepad");
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_JOYDIGMAP1:
|
||||
@@ -1833,6 +1833,7 @@ void HandleUI(void)
|
||||
OsdWrite(3);
|
||||
OsdWrite(4, " Clearing");
|
||||
OsdWrite(5);
|
||||
joymap_first = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1905,7 +1906,13 @@ void HandleUI(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (select || menu || get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8))
|
||||
if (!is_menu_core() && (get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8) || (select & get_map_vid() & get_map_pid())) && joymap_first && get_map_type())
|
||||
{
|
||||
finish_map_setting(0);
|
||||
menustate = MENU_JOYDIGMAP3;
|
||||
menusub = 0;
|
||||
}
|
||||
else if (select || menu || get_map_button() >= (joy_bcount ? joy_bcount + 4 : 8))
|
||||
{
|
||||
finish_map_setting(menu);
|
||||
if (is_menu_core())
|
||||
@@ -1930,6 +1937,44 @@ void HandleUI(void)
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_JOYDIGMAP3:
|
||||
for (int i = 0; i < OsdGetSize(); i++) OsdWrite(i);
|
||||
m = 6;
|
||||
menumask = 3;
|
||||
OsdWrite(m++, " Do you want to setup");
|
||||
OsdWrite(m++, " alternative buttons?");
|
||||
OsdWrite(m++, " No", menusub == 0);
|
||||
OsdWrite(m++, " Yes", menusub == 1);
|
||||
parentstate = menustate;
|
||||
menustate = MENU_JOYDIGMAP4;
|
||||
break;
|
||||
|
||||
case MENU_JOYDIGMAP4:
|
||||
if (menu)
|
||||
{
|
||||
menustate = MENU_8BIT_SYSTEM1;
|
||||
menusub = 1;
|
||||
break;
|
||||
}
|
||||
else if (select)
|
||||
{
|
||||
switch (menusub)
|
||||
{
|
||||
case 0:
|
||||
menustate = MENU_8BIT_SYSTEM1;
|
||||
menusub = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
start_map_setting(joy_bcount ? joy_bcount + 4 : 8, 1);
|
||||
menustate = MENU_JOYDIGMAP;
|
||||
menusub = 0;
|
||||
joymap_first = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MENU_JOYKBDMAP:
|
||||
helptext = 0;
|
||||
menumask = 1;
|
||||
@@ -3885,6 +3930,7 @@ void open_joystick_setup()
|
||||
OsdEnable(DISABLE_KEYBOARD);
|
||||
start_map_setting(joy_bcount ? joy_bcount + 4 : 8);
|
||||
menustate = MENU_JOYDIGMAP;
|
||||
joymap_first = 1;
|
||||
}
|
||||
|
||||
void ScrollLongName(void)
|
||||
|
||||
Reference in New Issue
Block a user