Try MICRO_PIP fixes via opencode
This commit is contained in:
@@ -251,9 +251,11 @@ extern char ** environ;
|
||||
# endif
|
||||
|
||||
# ifdef MICRO_PIP
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# elif defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# else
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# endif
|
||||
|
||||
# ifdef CC_GCC
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "pibase.h"
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
|
||||
# include "piincludes.h"
|
||||
|
||||
@@ -47,6 +47,30 @@ public:
|
||||
|
||||
static __PIInit_Initializer__ __piinit_initializer__;
|
||||
|
||||
#ifdef MICRO_PIP
|
||||
#ifndef PIINIT_MICRO_STUB_DEFINED
|
||||
#define PIINIT_MICRO_STUB_DEFINED
|
||||
|
||||
int __PIInit_Initializer__::count_ = 0;
|
||||
PIInit * __PIInit_Initializer__::__instance__ = nullptr;
|
||||
|
||||
__PIInit_Initializer__::__PIInit_Initializer__() {
|
||||
count_++;
|
||||
if (count_ > 1) return;
|
||||
__instance__ = nullptr;
|
||||
}
|
||||
|
||||
__PIInit_Initializer__::~__PIInit_Initializer__() {
|
||||
count_--;
|
||||
if (count_ > 0) return;
|
||||
if (__instance__ != nullptr) {
|
||||
__instance__ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
class PIP_EXPORT PIInit {
|
||||
friend class __PIInit_Initializer__;
|
||||
@@ -88,5 +112,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIINIT_H
|
||||
|
||||
@@ -41,7 +41,11 @@ template<typename... Args>
|
||||
class Function: public FunctionBase {
|
||||
public:
|
||||
uint formatHash() override {
|
||||
#if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static uint ret = PIConstChars(typeid(std::function<void(Args...)>).name()).hash();
|
||||
#else
|
||||
static uint ret = 0;
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
std::function<bool(Args...)> func;
|
||||
|
||||
@@ -7,12 +7,21 @@
|
||||
# include "pifile.h"
|
||||
# include "piiostream.h"
|
||||
|
||||
# include <fcntl.h>
|
||||
# include <linux/input-event-codes.h>
|
||||
# include <linux/input.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/time.h>
|
||||
# include <unistd.h>
|
||||
# ifdef LINUX
|
||||
# include <fcntl.h>
|
||||
# include <linux/input-event-codes.h>
|
||||
# include <linux/input.h>
|
||||
# include <sys/ioctl.h>
|
||||
# include <sys/time.h>
|
||||
# include <unistd.h>
|
||||
# else
|
||||
// Stubs for embedded/non-Linux builds
|
||||
# define EV_SYN 0
|
||||
# define EV_KEY 1
|
||||
# define EV_REL 2
|
||||
# define EV_ABS 3
|
||||
# define EVIOCGABS(_v) 0
|
||||
# endif
|
||||
#else
|
||||
// clang-format off
|
||||
# undef _WIN32_WINNT
|
||||
@@ -395,6 +404,7 @@ PIVector<PIHIDeviceInfo> PIHIDevice::allDevices(bool try_open) {
|
||||
ullong bits = readFile(hd_i.path + file).toULLong(16);
|
||||
// piCout<< PICoutManipulators::Bin << abs;
|
||||
if (bits > 0) {
|
||||
#ifdef LINUX
|
||||
int fd = ::open(dev.path.dataAscii(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
// piCout << "Warning: can`t open" << dev.path << errorString();
|
||||
@@ -419,6 +429,19 @@ PIVector<PIHIDeviceInfo> PIHIDevice::allDevices(bool try_open) {
|
||||
}
|
||||
}
|
||||
if (fd >= 0) ::close(fd);
|
||||
#else
|
||||
// Stub implementation for non-Linux builds
|
||||
PIHIDeviceInfo::AxisInfo ai;
|
||||
ai.is_relative = is_relative;
|
||||
ai.min = 0;
|
||||
ai.max = 1024;
|
||||
for (int bit = 0; bit < 64; ++bit) {
|
||||
if (checkBit(bits, bit, PIString::fromNumber(bit))) {
|
||||
ai.data_index = bit;
|
||||
ret << ai;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
@@ -55,8 +55,21 @@ void piUSleep(int usecs) {
|
||||
# ifdef FREERTOS
|
||||
vTaskDelay(usecs / 1000 / portTICK_PERIOD_MS);
|
||||
# else
|
||||
# ifdef MICRO_PIP
|
||||
if (usecs > 0) {
|
||||
struct timeval start;
|
||||
gettimeofday(&start, nullptr);
|
||||
long long elapsed = 0;
|
||||
while (elapsed < usecs) {
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
elapsed = (now.tv_sec - start.tv_sec) * 1000000LL + (now.tv_usec - start.tv_usec);
|
||||
}
|
||||
}
|
||||
# else
|
||||
usecs -= PISystemTests::usleep_offset_us;
|
||||
if (usecs > 0) usleep(usecs);
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -55,12 +55,16 @@ public:
|
||||
}
|
||||
#ifdef MICRO_PIP
|
||||
PIString typeName() const final {
|
||||
static PIString ret(PIVariant(T()).typeName());
|
||||
static PIString ret(PIVariant::fromValue<T>(T()).typeName());
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
PIString typeName() const final {
|
||||
#if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
static PIString ret(typeid(T).name());
|
||||
#else
|
||||
static PIString ret("unknown");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user