diff --git a/BACKERS.md b/BACKERS.md index b86afc0e71..8c6cd2e965 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -22,6 +22,7 @@ This is a list of all the people who are contributing financially to Panda3D. I ![Benefactors](https://opencollective.com/panda3d/tiers/benefactor.svg?avatarHeight=48&width=600) * Sam Edwards +* Max Voss ## Backers diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 041c2fc40a..5b15316d18 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -829,9 +829,11 @@ class ShowBase(DirectObject.DirectObject): win.requestProperties(props) mainWindow = False - if self.win == None: + if self.win is None: mainWindow = True self.win = win + if hasattr(self, 'bufferViewer'): + self.bufferViewer.win = win self.winList.append(win) diff --git a/panda/src/device/evdevInputDevice.cxx b/panda/src/device/evdevInputDevice.cxx index fc89b5a5a4..69d2979f7f 100644 --- a/panda/src/device/evdevInputDevice.cxx +++ b/panda/src/device/evdevInputDevice.cxx @@ -65,6 +65,12 @@ enum QuirkBits { // Axes on the right stick are swapped, using x for y and vice versa. QB_right_axes_swapped = 64, + + // Has no trigger axes. + QB_no_analog_triggers = 128, + + // Alternate button mapping. + QB_alt_button_mapping = 256, }; static const struct DeviceMapping { @@ -85,10 +91,14 @@ static const struct DeviceMapping { {0x28de, 0x1142, InputDevice::DeviceClass::unknown, QB_steam_controller}, // Jess Tech Colour Rumble Pad {0x0f30, 0x0111, InputDevice::DeviceClass::gamepad, QB_rstick_from_z | QB_right_axes_swapped}, - // SPEED Link SL-6535-SBK-01 - {0x0079, 0x0006, InputDevice::DeviceClass::gamepad, 0}, + // Trust GXT 24 + {0x0079, 0x0006, InputDevice::DeviceClass::gamepad, QB_no_analog_triggers | QB_alt_button_mapping}, // 8bitdo N30 Pro Controller {0x2dc8, 0x9001, InputDevice::DeviceClass::gamepad, QB_rstick_from_z}, + // Generic gamepad + {0x0810, 0x0001, InputDevice::DeviceClass::gamepad, QB_no_analog_triggers | QB_alt_button_mapping | QB_rstick_from_z | QB_right_axes_swapped}, + // Generic gamepad without sticks + {0x0810, 0xe501, InputDevice::DeviceClass::gamepad, QB_no_analog_triggers | QB_alt_button_mapping}, // 3Dconnexion Space Traveller 3D Mouse {0x046d, 0xc623, InputDevice::DeviceClass::spatial_mouse, 0}, // 3Dconnexion Space Pilot 3D Mouse @@ -497,8 +507,10 @@ init_device() { axis = InputDevice::Axis::right_x; } } else if (_device_class == DeviceClass::gamepad) { - axis = InputDevice::Axis::left_trigger; - have_analog_triggers = true; + if ((quirks & QB_no_analog_triggers) == 0) { + axis = InputDevice::Axis::left_trigger; + have_analog_triggers = true; + } } else if (_device_class == DeviceClass::spatial_mouse) { axis = InputDevice::Axis::z; } else { @@ -527,8 +539,13 @@ init_device() { axis = InputDevice::Axis::right_y; } } else if (_device_class == DeviceClass::gamepad) { - axis = InputDevice::Axis::right_trigger; - have_analog_triggers = true; + if ((quirks & QB_no_analog_triggers) == 0) { + axis = InputDevice::Axis::right_trigger; + have_analog_triggers = true; + } else { + // Special weird case for Trust GXT 24 + axis = InputDevice::Axis::right_y; + } } else { axis = InputDevice::Axis::yaw; } @@ -548,8 +565,10 @@ init_device() { break; case ABS_GAS: if (_device_class == DeviceClass::gamepad) { - axis = InputDevice::Axis::right_trigger; - have_analog_triggers = true; + if ((quirks & QB_no_analog_triggers) == 0) { + axis = InputDevice::Axis::right_trigger; + have_analog_triggers = true; + } } else { axis = InputDevice::Axis::accelerator; } @@ -974,6 +993,26 @@ map_button(int code, DeviceClass device_class, int quirks) { // BTN_THUMB and BTN_THUMB2 detect touching the touchpads. return ButtonHandle::none(); + } else if (device_class == DeviceClass::gamepad && + (quirks & QB_alt_button_mapping) != 0) { + static const ButtonHandle mapping[] = { + GamepadButton::face_y(), + GamepadButton::face_b(), + GamepadButton::face_a(), + GamepadButton::face_x(), + GamepadButton::lshoulder(), + GamepadButton::rshoulder(), + GamepadButton::ltrigger(), + GamepadButton::rtrigger(), + GamepadButton::back(), + GamepadButton::start(), + GamepadButton::lstick(), + GamepadButton::rstick(), + }; + if ((code & 0xf) < 12) { + return mapping[code & 0xf]; + } + } else if (device_class == DeviceClass::gamepad) { // Based on "Jess Tech Colour Rumble Pad" static const ButtonHandle mapping[] = { diff --git a/panda/src/mathutil/perlinNoise2.cxx b/panda/src/mathutil/perlinNoise2.cxx index ef187beb9c..1dc576e08a 100644 --- a/panda/src/mathutil/perlinNoise2.cxx +++ b/panda/src/mathutil/perlinNoise2.cxx @@ -19,6 +19,9 @@ */ double PerlinNoise2:: noise(const LVecBase2d &value) const { + // If this triggers, you passed in 0 for table_size. + nassertr(!_index.empty(), make_nan(0.0)); + // Convert the vector to our local coordinate space. LVecBase2d vec = _input_xform.xform_point(value); @@ -41,9 +44,13 @@ noise(const LVecBase2d &value) const { double v = fade(y); // Hash coordinates of the 4 square corners (A, B, A + 1, and B + 1) + nassertr(X >= 0 && X + 1 < _index.size(), make_nan(0.0)); int A = _index[X] + Y; int B = _index[X + 1] + Y; + nassertr(A >= 0 && A + 1 < _index.size(), make_nan(0.0)); + nassertr(B >= 0 && B + 1 < _index.size(), make_nan(0.0)); + // and add blended results from 4 corners of square. double result = lerp(v, lerp(u, grad(_index[A], x, y),