Trackpad button separate mapping

This commit is contained in:
NepEgor 2022-05-09 22:45:17 +06:00
parent fce58b6f6d
commit 3204dbe371
3 changed files with 53 additions and 8 deletions

View File

@ -17,8 +17,6 @@ namespace InputMapper
{
START,
SELECT,
TRACKPAD_LEFT,
TRACKPAD_RIGHT,
BUMPER_LEFT,
BUMPER_RIGHT,
HOME,
@ -26,6 +24,8 @@ namespace InputMapper
GRIP_B,
GRIP_X,
GRIP_Y,
TRACKPAD_LEFT,
TRACKPAD_RIGHT,
};
extern uint16_t button_map[];

View File

@ -50,8 +50,6 @@ namespace InputMapper
{
USB_Device::START,
USB_Device::SELECT,
USB_Device::FACE_B,
USB_Device::FACE_X,
USB_Device::BUMPER_LEFT,
USB_Device::BUMPER_RIGHT,
USB_Device::HOME,
@ -61,6 +59,18 @@ namespace InputMapper
USB_Device::JOYSTICK_LEFT,
};
uint16_t button_tp_map[2][2] =
{
{
USB_Device::FACE_B,
USB_Device::JOYSTICK_LEFT,
},
{
USB_Device::FACE_X,
USB_Device::JOYSTICK_RIGHT,
}
};
uint16_t dpad_left_map[] =
{
USB_Device::DPAD_UP,
@ -133,6 +143,18 @@ namespace InputMapper
}
}
for (uint8_t id = 0; id < 2; ++id)
{
for (uint8_t c = 0; c < num_controls; ++c)
{
auto search = xinput_counter.find(button_tp_map[id][c]);
if (search == xinput_counter.end())
{
xinput_counter.insert(std::make_pair(button_tp_map[id][c], 0));
}
}
}
for (uint8_t d = 0; d < 2; ++d)
{
for (uint8_t i = 0; i < 4; ++i)
@ -272,8 +294,31 @@ namespace InputMapper
}
void mapButton(HardwareButtons button, bool value)
{
modifyCounter(button_map[button], value);
{
uint8_t id;
switch (button)
{
case HardwareButtons::TRACKPAD_LEFT:
id = 0;
break;
case HardwareButtons::TRACKPAD_RIGHT:
id = 1;
break;
default:
modifyCounter(button_map[button], value);
return;
}
for (uint8_t c = 0; c < num_controls; ++c)
{
if (tcontrols[id][c]->getTouching() > TouchControl::CT_NONE || !value)
{
modifyCounter(button_tp_map[id][c], value);
}
}
}
void sendReport()

View File

@ -9,8 +9,6 @@ const uint8_t pin_button[] =
{
PB12, 0, // START
PB13, 0, // SELECT
PC15, 0, // TRACKPAD_LEFT
PB3, 1, // TRACKPAD_RIGHT
PA2, 0, // BUMPER_LEFT
PA8, 1, // BUMPER_RIGHT
PB1, 0, // HOME
@ -18,6 +16,8 @@ const uint8_t pin_button[] =
PB15, 1, // GRIP_B
PA4, 0, // GRIP_X
PA3, 0, // GRIP_Y
PC15, 0, // TRACKPAD_LEFT
PB3, 1, // TRACKPAD_RIGHT
};
uint8_t button_state[sizeof(pin_button) / 2] = {0};