From c2635d2498968159ae94158f4b1f32b2823aa853 Mon Sep 17 00:00:00 2001 From: "Stephen A. Imhoff" Date: Tue, 14 Dec 2021 18:44:13 +0000 Subject: [PATCH 1/5] makepanda: Add rpmversion for packaging. Closes #1220 --- makepanda/makepackage.py | 12 ++++++++---- makepanda/makepanda.py | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index f9e534ca52..6671b38eba 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -276,7 +276,7 @@ def MakeDebugSymbolArchive(zipname, dirname): zip.close() -def MakeInstallerLinux(version, debversion=None, rpmrelease=1, runtime=False, +def MakeInstallerLinux(version, debversion=None, rpmversion=None, rpmrelease=1, runtime=False, python_versions=[], **kwargs): outputdir = GetOutputDir() @@ -302,6 +302,8 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1, runtime=False, major_version = '.'.join(version.split('.')[:2]) if not debversion: debversion = version + if not rpmversion: + rpmversion = version # Clean and set up a directory to install Panda3D into oscmd("rm -rf targetroot data.tar.gz control.tar.gz panda3d.spec") @@ -461,16 +463,16 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1, runtime=False, txt += "/usr/bin/%s\n" % (base) # Write out the spec file. - txt = txt.replace("VERSION", version) + txt = txt.replace("VERSION", rpmversion) txt = txt.replace("RPMRELEASE", str(rpmrelease)) txt = txt.replace("PANDASOURCE", pandasource) WriteFile("panda3d.spec", txt) oscmd("fakeroot rpmbuild --define '_rpmdir "+pandasource+"' --buildroot '"+os.path.abspath("targetroot")+"' -bb panda3d.spec") if runtime: - oscmd("mv "+arch+"/panda3d-runtime-"+version+"-"+rpmrelease+"."+arch+".rpm .") + oscmd("mv "+arch+"/panda3d-runtime-"+rpmversion+"-"+rpmrelease+"."+arch+".rpm .") else: - oscmd("mv "+arch+"/panda3d-"+version+"-"+rpmrelease+"."+arch+".rpm .") + oscmd("mv "+arch+"/panda3d-"+rpmversion+"-"+rpmrelease+"."+arch+".rpm .") oscmd("rm -rf "+arch, True) else: @@ -1130,6 +1132,7 @@ if __name__ == "__main__": parser = OptionParser() parser.add_option('', '--version', dest='version', help='Panda3D version number (default: %s)' % (version), default=version) parser.add_option('', '--debversion', dest='debversion', help='Version number for .deb file', default=None) + parser.add_option('', '--rpmversion', dest='rpmversion', help='Version number for .rpm file', default=None) parser.add_option('', '--rpmrelease', dest='rpmrelease', help='Release number for .rpm file', default='1') parser.add_option('', '--outputdir', dest='outputdir', help='Makepanda\'s output directory (default: built)', default='built') parser.add_option('', '--verbose', dest='verbose', help='Enable verbose output', action='store_true', default=False) @@ -1167,6 +1170,7 @@ if __name__ == "__main__": optimize=GetOptimize(), compressor=options.compressor, debversion=options.debversion, + rpmversion=options.rpmversion, rpmrelease=options.rpmrelease, runtime=options.runtime, python_versions=ReadPythonVersionInfoFile(), diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 9af51e0832..2075bb213a 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -56,6 +56,7 @@ DISTRIBUTOR="" VERSION=None DEBVERSION=None WHLVERSION=None +RPMVERSION=None RPMRELEASE="1" GIT_COMMIT=None P3DSUFFIX=None @@ -171,7 +172,7 @@ def usage(problem): def parseopts(args): global INSTALLER,WHEEL,RUNTESTS,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL - global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION + global DEBVERSION,WHLVERSION,RPMVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER global COPY_PYTHON @@ -185,7 +186,7 @@ def parseopts(args): "help","distributor=","verbose","runtime","osxtarget=","tests", "optimize=","everything","nothing","installer","wheel","rtdist","nocolor", "version=","lzma","no-python","threads=","outputdir=","override=", - "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=", + "static","host=","debversion=","rpmversion=","rpmrelease=","p3dsuffix=","rtdist-version=", "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl", "universal", "target=", "arch=", "git-commit=", "no-copy-python", "cggl-incdir=", "cggl-libdir=", @@ -236,6 +237,7 @@ def parseopts(args): elif (option=="--static"): SetLinkAllStatic(True) elif (option=="--host"): HOST_URL=value elif (option=="--debversion"): DEBVERSION=value + elif (option=="--rpmversion"): RPMVERSION=value elif (option=="--rpmrelease"): RPMRELEASE=value elif (option=="--git-commit"): GIT_COMMIT=value elif (option=="--p3dsuffix"): P3DSUFFIX=value @@ -426,6 +428,9 @@ if RUNTIME or RTDIST: if DEBVERSION is None: DEBVERSION = VERSION +if RPMVERSION is None: + RPMVERSION = VERSION + MAJOR_VERSION = '.'.join(VERSION.split('.')[:2]) if P3DSUFFIX is None: @@ -7186,7 +7191,7 @@ if INSTALLER: MakeInstaller(version=VERSION, outputdir=GetOutputDir(), optimize=GetOptimize(), compressor=COMPRESSOR, - debversion=DEBVERSION, rpmrelease=RPMRELEASE, + debversion=DEBVERSION, rpmversion=RPMVERSION, rpmrelease=RPMRELEASE, runtime=RUNTIME, python_versions=python_versions) if WHEEL: From 987f2f036b7d5b0e02a7ed8a2ff0f1029ae0d048 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Dec 2021 12:29:03 +0100 Subject: [PATCH 2/5] makepanda: Fix clang crash on macOS when compiling Objective-C++ code --- makepanda/makepanda.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 2075bb213a..9e8186fd78 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -1602,14 +1602,17 @@ def CompileCxx(obj,src,opts): # Needed by both Python, Panda, Eigen, all of which break aliasing rules. cmd += " -fno-strict-aliasing" - if optlevel >= 3: - cmd += " -ffast-math -fno-stack-protector" - if optlevel == 3: - # Fast math is nice, but we'd like to see NaN in dev builds. - cmd += " -fno-finite-math-only" + # Certain clang versions crash when passing these math flags while + # compiling Objective-C++ code + if not src.endswith(".m") and not src.endswith(".mm"): + if optlevel >= 3: + cmd += " -ffast-math -fno-stack-protector" + if optlevel == 3: + # Fast math is nice, but we'd like to see NaN in dev builds. + cmd += " -fno-finite-math-only" - # Make sure this is off to avoid GCC/Eigen bug (see GitHub #228) - cmd += " -fno-unsafe-math-optimizations" + # Make sure this is off to avoid GCC/Eigen bug (see GitHub #228) + cmd += " -fno-unsafe-math-optimizations" if (optlevel==1): cmd += " -ggdb -D_DEBUG" if (optlevel==2): cmd += " -O1 -D_DEBUG" From c38d582f8c6b4c6b32fd0c441e60847b2fe348b2 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Dec 2021 12:21:37 +0100 Subject: [PATCH 3/5] showbase: Add `base.clock` alias for `globalClock` Mirrors eefcae7b05aef7628b691d8601f8d7d9d0916cb3 on master --- direct/src/showbase/ShowBase.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 5efe908ecd..79d4dad10a 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -383,18 +383,21 @@ class ShowBase(DirectObject.DirectObject): # Get a pointer to Panda's global ClockObject, used for # synchronizing events between Python and C. - globalClock = ClockObject.getGlobalClock() + clock = ClockObject.getGlobalClock() + + #: This is the global :class:`~panda3d.core.ClockObject`. + self.clock = clock # Since we have already started up a TaskManager, and probably # a number of tasks; and since the TaskManager had to use the # TrueClock to tell time until this moment, make sure the # globalClock object is exactly in sync with the TrueClock. trueClock = TrueClock.getGlobalPtr() - globalClock.setRealTime(trueClock.getShortTime()) - globalClock.tick() + clock.setRealTime(trueClock.getShortTime()) + clock.tick() - # Now we can make the TaskManager start using the new globalClock. - taskMgr.globalClock = globalClock + # Now we can make the TaskManager start using the new clock. + taskMgr.globalClock = clock # client CPU affinity is determined by, in order: # - client-cpu-affinity-mask config @@ -443,7 +446,7 @@ class ShowBase(DirectObject.DirectObject): builtins.ostream = Notify.out() builtins.directNotify = directNotify builtins.giveNotify = giveNotify - builtins.globalClock = globalClock + builtins.globalClock = clock builtins.vfs = vfs builtins.cpMgr = ConfigPageManager.getGlobalPtr() builtins.cvMgr = ConfigVariableManager.getGlobalPtr() From 8b197618440edf7c6dc9a2726ac970300b4bf8bd Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Dec 2021 12:23:20 +0100 Subject: [PATCH 4/5] device: Add spam output for raw windows device --- panda/src/device/winRawInputDevice.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/panda/src/device/winRawInputDevice.cxx b/panda/src/device/winRawInputDevice.cxx index 1370561852..7345406ebb 100644 --- a/panda/src/device/winRawInputDevice.cxx +++ b/panda/src/device/winRawInputDevice.cxx @@ -663,6 +663,13 @@ process_report(PCHAR ptr, size_t size) { if (status == HIDP_STATUS_SUCCESS) { for (ULONG di = 0; di < count; ++di) { if (data[di].DataIndex != _hat_data_index) { + if (device_cat.is_spam()) { + device_cat.spam() + << "Read RawValue " << data[di].RawValue + << " for DataIndex " << data[di].DataIndex + << " from raw device " << _path << "\n"; + } + if (data[di].DataIndex >= _indices.size()) { if (device_cat.is_debug()) { device_cat.debug() From f01399bba875929d0f25c460c290f584f0f81608 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 26 Dec 2021 12:22:39 +0100 Subject: [PATCH 5/5] device: Correct axis mappings for FrSky RC controller on Windows See #1218 --- panda/src/device/winRawInputDevice.cxx | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/panda/src/device/winRawInputDevice.cxx b/panda/src/device/winRawInputDevice.cxx index 7345406ebb..6bcb2ebf9b 100644 --- a/panda/src/device/winRawInputDevice.cxx +++ b/panda/src/device/winRawInputDevice.cxx @@ -38,6 +38,9 @@ enum QuirkBits : int { // Axes on the right stick are swapped, using x for y and vice versa. QB_right_axes_swapped = 64, + + // Using an RC (drone) controller as a gamepad instead of a flight stick + QB_rc_controller = 128, }; // Some nonstandard gamepads have different button mappings. @@ -85,6 +88,10 @@ static const struct DeviceMapping { {0x2563, 0x0523, InputDevice::DeviceClass::gamepad, QB_rstick_from_z | QB_no_analog_triggers, {"face_y", "face_b", "face_a", "face_x", "lshoulder", "rshoulder", "ltrigger", "rtrigger", "back", "start", "lstick", "rstick"} }, + // FrSky Simulator + {0x0483, 0x5720, InputDevice::DeviceClass::gamepad, QB_rc_controller, + {0} + }, {0}, }; @@ -434,7 +441,11 @@ on_arrival(HANDLE handle, const RID_DEVICE_INFO &info, std::string name) { switch (usage) { case HID_USAGE_GENERIC_X: if (_device_class == DeviceClass::gamepad) { - axis = Axis::left_x; + if (quirks & QB_rc_controller) { + axis = Axis::right_x; + } else { + axis = Axis::left_x; + } } else if (_device_class == DeviceClass::flight_stick) { axis = Axis::roll; } else { @@ -443,8 +454,12 @@ on_arrival(HANDLE handle, const RID_DEVICE_INFO &info, std::string name) { break; case HID_USAGE_GENERIC_Y: if (_device_class == DeviceClass::gamepad) { - axis = Axis::left_y; - swap(cap.LogicalMin, cap.LogicalMax); + if (quirks & QB_rc_controller) { + axis = Axis::right_y; + } else { + axis = Axis::left_y; + swap(cap.LogicalMin, cap.LogicalMax); + } } else if (_device_class == DeviceClass::flight_stick) { axis = Axis::pitch; } else { @@ -461,6 +476,8 @@ on_arrival(HANDLE handle, const RID_DEVICE_INFO &info, std::string name) { } else { axis = InputDevice::Axis::right_x; } + } else if (quirks & QB_rc_controller) { + axis = InputDevice::Axis::left_y; } else if ((quirks & QB_no_analog_triggers) == 0) { axis = Axis::left_trigger; } @@ -483,6 +500,8 @@ on_arrival(HANDLE handle, const RID_DEVICE_INFO &info, std::string name) { if ((quirks & QB_no_analog_triggers) == 0) { axis = Axis::left_trigger; } + } else if (quirks & QB_rc_controller) { + axis = Axis::left_x; } else { axis = Axis::right_x; }