mirror of
https://github.com/libretro/RetroArch
synced 2025-03-26 20:37:10 +00:00
remap-redux part2: simplify this code a bit, still not working
This commit is contained in:
parent
e42e79db28
commit
d8d22a9c40
41
.vscode/launch.json
vendored
41
.vscode/launch.json
vendored
@ -5,44 +5,21 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "msys2-mingw64 debug",
|
"name": "(gdb) Attach",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
"request": "launch",
|
"request": "attach",
|
||||||
"program": "${workspaceFolder}/retroarch.exe",
|
"program": "${workspaceFolder}/retroarch.exe",
|
||||||
"args": [],
|
"processId": "${command:pickProcess}",
|
||||||
"stopAtEntry": false,
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"environment": [],
|
|
||||||
"externalConsole": true,
|
|
||||||
"MIMode": "gdb",
|
"MIMode": "gdb",
|
||||||
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
|
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
|
||||||
"setupCommands": [
|
"setupCommands": [
|
||||||
{
|
{
|
||||||
"description": "Enable pretty-printing for gdb",
|
"description": "Enable pretty-printing for gdb",
|
||||||
"text": "-enable-pretty-printing",
|
"text": "-enable-pretty-printing",
|
||||||
"ignoreFailures": true
|
"ignoreFailures": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "msys2-mingw32 debug",
|
|
||||||
"type": "cppdbg",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${workspaceFolder}/retroarch.exe",
|
|
||||||
"args": [],
|
|
||||||
"stopAtEntry": false,
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"environment": [],
|
|
||||||
"externalConsole": true,
|
|
||||||
"MIMode": "gdb",
|
|
||||||
"miDebuggerPath": "c:\\msys64\\mingw32\\bin\\gdb.exe",
|
|
||||||
"setupCommands": [
|
|
||||||
{
|
|
||||||
"description": "Enable pretty-printing for gdb",
|
|
||||||
"text": "-enable-pretty-printing",
|
|
||||||
"ignoreFailures": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -1127,6 +1127,35 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void input_get_state_for_port(void *data, unsigned port, retro_bits_t* p_new_state)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
rarch_joypad_info_t joypad_info;
|
||||||
|
settings_t *settings = (settings_t*)data;
|
||||||
|
const struct retro_keybind *binds = input_config_binds[port];
|
||||||
|
|
||||||
|
BIT256_CLEAR_ALL_PTR(p_new_state);
|
||||||
|
|
||||||
|
joypad_info.joy_idx = settings->uints.input_joypad_map[port];
|
||||||
|
joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx];
|
||||||
|
joypad_info.axis_threshold = input_driver_axis_threshold;
|
||||||
|
|
||||||
|
input_driver_block_libretro_input = false;
|
||||||
|
input_driver_block_hotkey = false;
|
||||||
|
|
||||||
|
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
|
||||||
|
{
|
||||||
|
bool bit_pressed = false;
|
||||||
|
|
||||||
|
if (binds[i].valid && current_input->input_state(current_input_data,
|
||||||
|
joypad_info, &binds, port, RETRO_DEVICE_JOYPAD, 0, i))
|
||||||
|
bit_pressed = true;
|
||||||
|
|
||||||
|
if (bit_pressed)
|
||||||
|
BIT256_SET_PTR(p_new_state, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *input_driver_get_data(void)
|
void *input_driver_get_data(void)
|
||||||
{
|
{
|
||||||
return current_input_data;
|
return current_input_data;
|
||||||
|
@ -343,6 +343,8 @@ void input_menu_keys_pressed(void *data, retro_bits_t* new_state);
|
|||||||
|
|
||||||
void *input_driver_get_data(void);
|
void *input_driver_get_data(void);
|
||||||
|
|
||||||
|
void input_get_state_for_port(void *data, unsigned port, retro_bits_t* p_new_state);
|
||||||
|
|
||||||
const input_driver_t *input_get_ptr(void);
|
const input_driver_t *input_get_ptr(void);
|
||||||
|
|
||||||
void *input_get_data(void);
|
void *input_get_data(void);
|
||||||
|
@ -50,14 +50,12 @@
|
|||||||
|
|
||||||
struct input_mapper
|
struct input_mapper
|
||||||
{
|
{
|
||||||
/* The controller port that will be polled*/
|
|
||||||
uint8_t port;
|
|
||||||
/* Left X, Left Y, Right X, Right Y */
|
/* Left X, Left Y, Right X, Right Y */
|
||||||
int16_t analog[4];
|
int16_t analog[4];
|
||||||
/* the whole keyboard state */
|
/* the whole keyboard state */
|
||||||
uint32_t keys[RETROK_LAST / 32 + 1];
|
uint32_t keys[RETROK_LAST / 32 + 1];
|
||||||
/* This is a bitmask of (1 << key_bind_id). */
|
/* This is a bitmask of (1 << key_bind_id). */
|
||||||
retro_bits_t buttons;
|
retro_bits_t buttons[MAX_USERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
input_mapper_t *input_mapper_new(uint16_t port)
|
input_mapper_t *input_mapper_new(uint16_t port)
|
||||||
@ -68,8 +66,6 @@ input_mapper_t *input_mapper_new(uint16_t port)
|
|||||||
if (!handle)
|
if (!handle)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
handle->port = port;
|
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,9 +78,9 @@ void input_mapper_free(input_mapper_t *handle)
|
|||||||
|
|
||||||
bool flag = false;
|
bool flag = false;
|
||||||
|
|
||||||
bool input_mapper_button_pressed(input_mapper_t *handle, int id)
|
bool input_mapper_button_pressed(input_mapper_t *handle, unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
return BIT256_GET(handle->buttons, id);
|
return BIT256_GET(handle->buttons[port], id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_mapper_poll(input_mapper_t *handle)
|
void input_mapper_poll(input_mapper_t *handle)
|
||||||
@ -92,7 +88,8 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
int i, j;
|
int i, j;
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
retro_bits_t current_input;
|
retro_bits_t current_input;
|
||||||
unsigned device = settings->uints.input_libretro_device[handle->port];
|
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
|
||||||
|
unsigned device = 0;
|
||||||
unsigned current_button_value;
|
unsigned current_button_value;
|
||||||
unsigned remap_button;
|
unsigned remap_button;
|
||||||
bool key_event[RARCH_CUSTOM_BIND_LIST_END];
|
bool key_event[RARCH_CUSTOM_BIND_LIST_END];
|
||||||
@ -100,18 +97,19 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
bool menu_is_alive = menu_driver_is_alive();
|
bool menu_is_alive = menu_driver_is_alive();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
device &= RETRO_DEVICE_MASK;
|
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
#ifdef HAVE_MENU
|
||||||
if (menu_is_alive)
|
if (menu_is_alive)
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memset(handle->keys, 0, sizeof(handle->keys));
|
memset(handle->keys, 0, sizeof(handle->keys));
|
||||||
i = 0;
|
|
||||||
if (device == RETRO_DEVICE_KEYBOARD)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
device = settings->uints.input_libretro_device[i];
|
||||||
|
device &= RETRO_DEVICE_MASK;
|
||||||
|
|
||||||
|
if (device == RETRO_DEVICE_KEYBOARD)
|
||||||
{
|
{
|
||||||
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
for (j = 0; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
||||||
{
|
{
|
||||||
@ -140,24 +138,21 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (device == RETRO_DEVICE_JOYPAD)
|
||||||
if (device == RETRO_DEVICE_JOYPAD)
|
|
||||||
{
|
|
||||||
input_keys_pressed(settings, ¤t_input);
|
|
||||||
BIT256_CLEAR_ALL(handle->buttons);
|
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
|
||||||
{
|
{
|
||||||
/* this loop iterates on all users and all buttons, and checks if a pressed button
|
/* this loop iterates on all users and all buttons, and checks if a pressed button
|
||||||
is assigned to any other button than the default one, then it sets the bit on the
|
is assigned to any other button than the default one, then it sets the bit on the
|
||||||
mapper input bitmap, later on the original input is cleared in input_state */
|
mapper input bitmap, later on the original input is cleared in input_state */
|
||||||
|
BIT256_CLEAR_ALL(handle->buttons[i]);
|
||||||
|
input_get_state_for_port(settings, i, ¤t_input);
|
||||||
|
|
||||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
||||||
{
|
{
|
||||||
current_button_value = BIT256_GET(current_input, j);
|
current_button_value = BIT256_GET(current_input, j);
|
||||||
remap_button = settings->uints.input_remap_ids[i][j];
|
remap_button = settings->uints.input_remap_ids[i][j];
|
||||||
if (current_button_value == 1 && j != remap_button &&
|
if (current_button_value == 1 && j != remap_button &&
|
||||||
remap_button != RARCH_UNMAPPED)
|
remap_button != RARCH_UNMAPPED)
|
||||||
BIT256_SET(handle->buttons, remap_button);
|
BIT256_SET(handle->buttons[i], remap_button);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
/* --CURRENTLY NOT IMPLEMENTED--
|
/* --CURRENTLY NOT IMPLEMENTED--
|
||||||
@ -167,44 +162,13 @@ void input_mapper_poll(input_mapper_t *handle)
|
|||||||
stick input in input_state in input_driver.c */
|
stick input in input_state in input_driver.c */
|
||||||
|
|
||||||
for (j = RARCH_FIRST_CUSTOM_BIND; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
for (j = RARCH_FIRST_CUSTOM_BIND; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
||||||
{
|
{ }
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (device == RETRO_DEVICE_ANALOG)
|
|
||||||
{
|
|
||||||
input_keys_pressed(settings, ¤t_input);
|
|
||||||
BIT256_CLEAR_ALL(handle->buttons);
|
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
|
||||||
{
|
|
||||||
/* this loop iterates on all users and all buttons, and checks if a pressed button
|
|
||||||
is assigned to any other button than the default one, then it sets the bit on the
|
|
||||||
mapper input bitmap, later on the original input is cleared in input_state */
|
|
||||||
|
|
||||||
for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++)
|
|
||||||
{
|
|
||||||
current_button_value = BIT256_GET(current_input, j);
|
|
||||||
remap_button = settings->uints.input_remap_ids[i][j];
|
|
||||||
if (current_button_value == 1 && j != remap_button &&
|
|
||||||
remap_button != RARCH_UNMAPPED)
|
|
||||||
BIT256_SET(handle->buttons, remap_button);
|
|
||||||
}
|
|
||||||
#if 0
|
|
||||||
/* --CURRENTLY NOT IMPLEMENTED--
|
|
||||||
this loop should iterate on all users and all analog stick axes and if the axes are
|
|
||||||
moved and is assigned to a button or another stick, it should set the bit on the
|
|
||||||
mapper input bitmap. Once implemented we should make sure to clear the original analog
|
|
||||||
stick input in input_state in input_driver.c */
|
|
||||||
|
|
||||||
for (j = RARCH_FIRST_CUSTOM_BIND; j < RARCH_CUSTOM_BIND_LIST_END; j++)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void input_mapper_state(
|
void input_mapper_state(
|
||||||
@ -221,7 +185,7 @@ void input_mapper_state(
|
|||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
if (input_mapper_button_pressed(handle, id))
|
if (input_mapper_button_pressed(handle, port, id))
|
||||||
*ret = 1;
|
*ret = 1;
|
||||||
break;
|
break;
|
||||||
case RETRO_DEVICE_KEYBOARD:
|
case RETRO_DEVICE_KEYBOARD:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user