Compare commits

...

3 Commits

@ -51,7 +51,8 @@ class Gyro
uint32_t time0;
uint32_t delay;
bool (*_Enabled)();
bool (*_EnabledCallback)();
bool enabled;
public:
@ -59,8 +60,10 @@ class Gyro
void init();
void setEnabledCallback(bool (*_Enabled)()) { this->_Enabled = _Enabled; }
bool Enabled() { return _Enabled(); }
void setEnabledCallback(bool (*_EnabledCallback)()) { this->_EnabledCallback = _EnabledCallback; }
void enable() { enabled = true; }
void disable() { enabled = false; }
bool Enabled() { return enabled && _EnabledCallback(); }
void setMappedId(uint8_t mapped_id) { this->mapped_id = mapped_id; }
uint8_t getMappedId() { return mapped_id; }

@ -45,7 +45,7 @@ Gyro::Gyro()
bind_to_x = BIND_X;
_Enabled = [] { return false; };
_EnabledCallback = [] { return false; };
}
void Gyro::init()

@ -13,6 +13,7 @@ namespace InputMapper
USB_Device device;
TouchMouseJoystick tjoystick_right;
TouchJoystick tjoystick_right_wheel;
TouchJoystick tjoystick_left;
TouchDpad tdpad_right;
TouchDpad tdpad_left;
@ -116,6 +117,12 @@ namespace InputMapper
pos_x = 31.25 * ppmX;
pos_y = (103.9 - 31.25) * ppmY;
tjoystick_right_wheel.init(pos_x, pos_y, pos_r, USB_Device::usb_joystick_x, USB_Device::usb_joystick_y, USB_Device::usb_joystick_r);
tjoystick_right_wheel.setDeadZoneInner(0);
tjoystick_right_wheel.setDeadZoneOuter(dead_zone_outer);
tjoystick_right_wheel.setMappedId(1);
dead_zone_outer = 10 * ppmX;
tjoystick_right.init(pos_x, pos_y, pos_r, USB_Device::usb_joystick_x, USB_Device::usb_joystick_y, USB_Device::usb_joystick_r);
@ -180,7 +187,7 @@ namespace InputMapper
gyro.setMappedId(1);
//gyro.setInvertX();
gyro.setInvertY();
gyro.setSensitivity(1.0f);
gyro.setSensitivity(0.75f);
gyro.setDeadzone(0);
gyro.setMinDelta(1000);
gyro.setBindToX(Gyro::BIND_XZ);
@ -328,6 +335,22 @@ namespace InputMapper
id = 1;
break;
case HardwareButtons::BUMPER_LEFT:
if (value)
{
tcontrols[1][0] = &tjoystick_right_wheel;
gyro.disable();
}
else
{
tcontrols[1][0] = &tjoystick_right;
gyro.enable();
}
modifyCounter(button_map[button], value);
return true;
default:
modifyCounter(button_map[button], value);
return true;

@ -9,21 +9,21 @@ const uint8_t pin_button[] =
{
PB12, 0, // START
PB13, 0, // SELECT
PA2, 0, // BUMPER_LEFT
PB5, 0, // BUMPER_LEFT
PA8, 1, // BUMPER_RIGHT
PB1, 0, // HOME
PB14, 1, // GRIP_A
PB15, 1, // GRIP_B
PA4, 0, // GRIP_X
PA3, 0, // GRIP_Y
PB4, 0, // GRIP_Y
PC15, 0, // TRACKPAD_LEFT
PB3, 1, // TRACKPAD_RIGHT
};
uint8_t button_state[sizeof(pin_button) / 2] = {0};
const uint8_t pin_trackpad_data[2] = {PB5, PB9};
const uint8_t pin_trackpad_clock[2] = {PB4, PB8};
const uint8_t pin_trackpad_data[2] = {PA2, PB9};
const uint8_t pin_trackpad_clock[2] = {PA3, PB8};
const uint8_t gyro_int = PC14;

Loading…
Cancel
Save