@renegades/react-native-tickle 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +352 -0
- package/Tickle.podspec +29 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +126 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/tickle/Tickle.kt +71 -0
- package/android/src/main/java/com/margelo/nitro/tickle/TicklePackage.kt +22 -0
- package/ios/Tickle.swift +185 -0
- package/ios/TickleUtils.swift +404 -0
- package/lib/module/Tickle.nitro.js +4 -0
- package/lib/module/Tickle.nitro.js.map +1 -0
- package/lib/module/index.js +254 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/Tickle.nitro.d.ts +63 -0
- package/lib/typescript/src/Tickle.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +148 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JHapticCurve.hpp +87 -0
- package/nitrogen/generated/android/c++/JHapticCurveControlPoint.hpp +61 -0
- package/nitrogen/generated/android/c++/JHapticEvent.hpp +94 -0
- package/nitrogen/generated/android/c++/JHapticEventParameter.hpp +62 -0
- package/nitrogen/generated/android/c++/JHapticEventType.hpp +58 -0
- package/nitrogen/generated/android/c++/JHapticImpactStyle.hpp +67 -0
- package/nitrogen/generated/android/c++/JHapticNotificationType.hpp +61 -0
- package/nitrogen/generated/android/c++/JHapticParameterType.hpp +58 -0
- package/nitrogen/generated/android/c++/JHybridTickleSpec.cpp +162 -0
- package/nitrogen/generated/android/c++/JHybridTickleSpec.hpp +79 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticCurve.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticCurveControlPoint.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEvent.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEventParameter.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticEventType.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticImpactStyle.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticNotificationType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HapticParameterType.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/HybridTickleSpec.kt +109 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/tickle/tickleOnLoad.kt +35 -0
- package/nitrogen/generated/android/tickle+autolinking.cmake +81 -0
- package/nitrogen/generated/android/tickle+autolinking.gradle +27 -0
- package/nitrogen/generated/android/tickleOnLoad.cpp +44 -0
- package/nitrogen/generated/android/tickleOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/Tickle+autolinking.rb +60 -0
- package/nitrogen/generated/ios/Tickle-Swift-Cxx-Bridge.cpp +33 -0
- package/nitrogen/generated/ios/Tickle-Swift-Cxx-Bridge.hpp +139 -0
- package/nitrogen/generated/ios/Tickle-Swift-Cxx-Umbrella.hpp +70 -0
- package/nitrogen/generated/ios/TickleAutolinking.mm +33 -0
- package/nitrogen/generated/ios/TickleAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridTickleSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridTickleSpecSwift.hpp +185 -0
- package/nitrogen/generated/ios/swift/HapticCurve.swift +46 -0
- package/nitrogen/generated/ios/swift/HapticCurveControlPoint.swift +35 -0
- package/nitrogen/generated/ios/swift/HapticEvent.swift +57 -0
- package/nitrogen/generated/ios/swift/HapticEventParameter.swift +35 -0
- package/nitrogen/generated/ios/swift/HapticEventType.swift +40 -0
- package/nitrogen/generated/ios/swift/HapticImpactStyle.swift +52 -0
- package/nitrogen/generated/ios/swift/HapticNotificationType.swift +44 -0
- package/nitrogen/generated/ios/swift/HapticParameterType.swift +40 -0
- package/nitrogen/generated/ios/swift/HybridTickleSpec.swift +69 -0
- package/nitrogen/generated/ios/swift/HybridTickleSpec_cxx.swift +282 -0
- package/nitrogen/generated/shared/c++/HapticCurve.hpp +96 -0
- package/nitrogen/generated/shared/c++/HapticCurveControlPoint.hpp +87 -0
- package/nitrogen/generated/shared/c++/HapticEvent.hpp +101 -0
- package/nitrogen/generated/shared/c++/HapticEventParameter.hpp +88 -0
- package/nitrogen/generated/shared/c++/HapticEventType.hpp +76 -0
- package/nitrogen/generated/shared/c++/HapticImpactStyle.hpp +88 -0
- package/nitrogen/generated/shared/c++/HapticNotificationType.hpp +80 -0
- package/nitrogen/generated/shared/c++/HapticParameterType.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridTickleSpec.cpp +34 -0
- package/nitrogen/generated/shared/c++/HybridTickleSpec.hpp +87 -0
- package/package.json +179 -0
- package/react-native.config.js +8 -0
- package/src/Tickle.nitro.ts +84 -0
- package/src/index.tsx +306 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticEvent.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticEvent.hpp"
|
|
12
|
+
|
|
13
|
+
#include "HapticEventParameter.hpp"
|
|
14
|
+
#include "HapticEventType.hpp"
|
|
15
|
+
#include "HapticParameterType.hpp"
|
|
16
|
+
#include "JHapticEventParameter.hpp"
|
|
17
|
+
#include "JHapticEventType.hpp"
|
|
18
|
+
#include "JHapticParameterType.hpp"
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::tickle {
|
|
23
|
+
|
|
24
|
+
using namespace facebook;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The C++ JNI bridge between the C++ struct "HapticEvent" and the the Kotlin data class "HapticEvent".
|
|
28
|
+
*/
|
|
29
|
+
struct JHapticEvent final: public jni::JavaClass<JHapticEvent> {
|
|
30
|
+
public:
|
|
31
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticEvent;";
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* Convert this Java/Kotlin-based struct to the C++ struct HapticEvent by copying all values to C++.
|
|
36
|
+
*/
|
|
37
|
+
[[maybe_unused]]
|
|
38
|
+
[[nodiscard]]
|
|
39
|
+
HapticEvent toCpp() const {
|
|
40
|
+
static const auto clazz = javaClassStatic();
|
|
41
|
+
static const auto fieldType = clazz->getField<JHapticEventType>("type");
|
|
42
|
+
jni::local_ref<JHapticEventType> type = this->getFieldValue(fieldType);
|
|
43
|
+
static const auto fieldParameters = clazz->getField<jni::JArrayClass<JHapticEventParameter>>("parameters");
|
|
44
|
+
jni::local_ref<jni::JArrayClass<JHapticEventParameter>> parameters = this->getFieldValue(fieldParameters);
|
|
45
|
+
static const auto fieldRelativeTime = clazz->getField<double>("relativeTime");
|
|
46
|
+
double relativeTime = this->getFieldValue(fieldRelativeTime);
|
|
47
|
+
static const auto fieldDuration = clazz->getField<jni::JDouble>("duration");
|
|
48
|
+
jni::local_ref<jni::JDouble> duration = this->getFieldValue(fieldDuration);
|
|
49
|
+
return HapticEvent(
|
|
50
|
+
type->toCpp(),
|
|
51
|
+
[&]() {
|
|
52
|
+
size_t __size = parameters->size();
|
|
53
|
+
std::vector<HapticEventParameter> __vector;
|
|
54
|
+
__vector.reserve(__size);
|
|
55
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
56
|
+
auto __element = parameters->getElement(__i);
|
|
57
|
+
__vector.push_back(__element->toCpp());
|
|
58
|
+
}
|
|
59
|
+
return __vector;
|
|
60
|
+
}(),
|
|
61
|
+
relativeTime,
|
|
62
|
+
duration != nullptr ? std::make_optional(duration->value()) : std::nullopt
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
/**
|
|
68
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
69
|
+
*/
|
|
70
|
+
[[maybe_unused]]
|
|
71
|
+
static jni::local_ref<JHapticEvent::javaobject> fromCpp(const HapticEvent& value) {
|
|
72
|
+
using JSignature = JHapticEvent(jni::alias_ref<JHapticEventType>, jni::alias_ref<jni::JArrayClass<JHapticEventParameter>>, double, jni::alias_ref<jni::JDouble>);
|
|
73
|
+
static const auto clazz = javaClassStatic();
|
|
74
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
75
|
+
return create(
|
|
76
|
+
clazz,
|
|
77
|
+
JHapticEventType::fromCpp(value.type),
|
|
78
|
+
[&]() {
|
|
79
|
+
size_t __size = value.parameters.size();
|
|
80
|
+
jni::local_ref<jni::JArrayClass<JHapticEventParameter>> __array = jni::JArrayClass<JHapticEventParameter>::newArray(__size);
|
|
81
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
82
|
+
const auto& __element = value.parameters[__i];
|
|
83
|
+
auto __elementJni = JHapticEventParameter::fromCpp(__element);
|
|
84
|
+
__array->setElement(__i, *__elementJni);
|
|
85
|
+
}
|
|
86
|
+
return __array;
|
|
87
|
+
}(),
|
|
88
|
+
value.relativeTime,
|
|
89
|
+
value.duration.has_value() ? jni::JDouble::valueOf(value.duration.value()) : nullptr
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticEventParameter.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticEventParameter.hpp"
|
|
12
|
+
|
|
13
|
+
#include "HapticParameterType.hpp"
|
|
14
|
+
#include "JHapticParameterType.hpp"
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::tickle {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "HapticEventParameter" and the the Kotlin data class "HapticEventParameter".
|
|
22
|
+
*/
|
|
23
|
+
struct JHapticEventParameter final: public jni::JavaClass<JHapticEventParameter> {
|
|
24
|
+
public:
|
|
25
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticEventParameter;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct HapticEventParameter by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
HapticEventParameter toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldType = clazz->getField<JHapticParameterType>("type");
|
|
36
|
+
jni::local_ref<JHapticParameterType> type = this->getFieldValue(fieldType);
|
|
37
|
+
static const auto fieldValue = clazz->getField<double>("value");
|
|
38
|
+
double value = this->getFieldValue(fieldValue);
|
|
39
|
+
return HapticEventParameter(
|
|
40
|
+
type->toCpp(),
|
|
41
|
+
value
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
/**
|
|
47
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
48
|
+
*/
|
|
49
|
+
[[maybe_unused]]
|
|
50
|
+
static jni::local_ref<JHapticEventParameter::javaobject> fromCpp(const HapticEventParameter& value) {
|
|
51
|
+
using JSignature = JHapticEventParameter(jni::alias_ref<JHapticParameterType>, double);
|
|
52
|
+
static const auto clazz = javaClassStatic();
|
|
53
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
54
|
+
return create(
|
|
55
|
+
clazz,
|
|
56
|
+
JHapticParameterType::fromCpp(value.type),
|
|
57
|
+
value.value
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticEventType.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticEventType.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::tickle {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "HapticEventType" and the the Kotlin enum "HapticEventType".
|
|
19
|
+
*/
|
|
20
|
+
struct JHapticEventType final: public jni::JavaClass<JHapticEventType> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticEventType;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum HapticEventType.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
HapticEventType toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<HapticEventType>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JHapticEventType> fromCpp(HapticEventType value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case HapticEventType::TRANSIENT:
|
|
46
|
+
static const auto fieldTRANSIENT = clazz->getStaticField<JHapticEventType>("TRANSIENT");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldTRANSIENT);
|
|
48
|
+
case HapticEventType::CONTINUOUS:
|
|
49
|
+
static const auto fieldCONTINUOUS = clazz->getStaticField<JHapticEventType>("CONTINUOUS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldCONTINUOUS);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticImpactStyle.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticImpactStyle.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::tickle {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "HapticImpactStyle" and the the Kotlin enum "HapticImpactStyle".
|
|
19
|
+
*/
|
|
20
|
+
struct JHapticImpactStyle final: public jni::JavaClass<JHapticImpactStyle> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticImpactStyle;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum HapticImpactStyle.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
HapticImpactStyle toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<HapticImpactStyle>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JHapticImpactStyle> fromCpp(HapticImpactStyle value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case HapticImpactStyle::RIGID:
|
|
46
|
+
static const auto fieldRIGID = clazz->getStaticField<JHapticImpactStyle>("RIGID");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldRIGID);
|
|
48
|
+
case HapticImpactStyle::HEAVY:
|
|
49
|
+
static const auto fieldHEAVY = clazz->getStaticField<JHapticImpactStyle>("HEAVY");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldHEAVY);
|
|
51
|
+
case HapticImpactStyle::MEDIUM:
|
|
52
|
+
static const auto fieldMEDIUM = clazz->getStaticField<JHapticImpactStyle>("MEDIUM");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldMEDIUM);
|
|
54
|
+
case HapticImpactStyle::LIGHT:
|
|
55
|
+
static const auto fieldLIGHT = clazz->getStaticField<JHapticImpactStyle>("LIGHT");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldLIGHT);
|
|
57
|
+
case HapticImpactStyle::SOFT:
|
|
58
|
+
static const auto fieldSOFT = clazz->getStaticField<JHapticImpactStyle>("SOFT");
|
|
59
|
+
return clazz->getStaticFieldValue(fieldSOFT);
|
|
60
|
+
default:
|
|
61
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
62
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticNotificationType.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticNotificationType.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::tickle {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "HapticNotificationType" and the the Kotlin enum "HapticNotificationType".
|
|
19
|
+
*/
|
|
20
|
+
struct JHapticNotificationType final: public jni::JavaClass<JHapticNotificationType> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticNotificationType;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum HapticNotificationType.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
HapticNotificationType toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<HapticNotificationType>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JHapticNotificationType> fromCpp(HapticNotificationType value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case HapticNotificationType::ERROR:
|
|
46
|
+
static const auto fieldERROR = clazz->getStaticField<JHapticNotificationType>("ERROR");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldERROR);
|
|
48
|
+
case HapticNotificationType::SUCCESS:
|
|
49
|
+
static const auto fieldSUCCESS = clazz->getStaticField<JHapticNotificationType>("SUCCESS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldSUCCESS);
|
|
51
|
+
case HapticNotificationType::WARNING:
|
|
52
|
+
static const auto fieldWARNING = clazz->getStaticField<JHapticNotificationType>("WARNING");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldWARNING);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHapticParameterType.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "HapticParameterType.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::tickle {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "HapticParameterType" and the the Kotlin enum "HapticParameterType".
|
|
19
|
+
*/
|
|
20
|
+
struct JHapticParameterType final: public jni::JavaClass<JHapticParameterType> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HapticParameterType;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum HapticParameterType.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
HapticParameterType toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<HapticParameterType>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JHapticParameterType> fromCpp(HapticParameterType value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case HapticParameterType::INTENSITY:
|
|
46
|
+
static const auto fieldINTENSITY = clazz->getStaticField<JHapticParameterType>("INTENSITY");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldINTENSITY);
|
|
48
|
+
case HapticParameterType::SHARPNESS:
|
|
49
|
+
static const auto fieldSHARPNESS = clazz->getStaticField<JHapticParameterType>("SHARPNESS");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldSHARPNESS);
|
|
51
|
+
default:
|
|
52
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
53
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridTickleSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridTickleSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `HapticEvent` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::tickle { struct HapticEvent; }
|
|
12
|
+
// Forward declaration of `HapticEventType` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::tickle { enum class HapticEventType; }
|
|
14
|
+
// Forward declaration of `HapticEventParameter` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::tickle { struct HapticEventParameter; }
|
|
16
|
+
// Forward declaration of `HapticParameterType` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::tickle { enum class HapticParameterType; }
|
|
18
|
+
// Forward declaration of `HapticCurve` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::tickle { struct HapticCurve; }
|
|
20
|
+
// Forward declaration of `HapticCurveControlPoint` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::tickle { struct HapticCurveControlPoint; }
|
|
22
|
+
// Forward declaration of `HapticImpactStyle` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::tickle { enum class HapticImpactStyle; }
|
|
24
|
+
// Forward declaration of `HapticNotificationType` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::tickle { enum class HapticNotificationType; }
|
|
26
|
+
|
|
27
|
+
#include "HapticEvent.hpp"
|
|
28
|
+
#include <vector>
|
|
29
|
+
#include "JHapticEvent.hpp"
|
|
30
|
+
#include "HapticEventType.hpp"
|
|
31
|
+
#include "JHapticEventType.hpp"
|
|
32
|
+
#include "HapticEventParameter.hpp"
|
|
33
|
+
#include "JHapticEventParameter.hpp"
|
|
34
|
+
#include "HapticParameterType.hpp"
|
|
35
|
+
#include "JHapticParameterType.hpp"
|
|
36
|
+
#include <optional>
|
|
37
|
+
#include "HapticCurve.hpp"
|
|
38
|
+
#include "JHapticCurve.hpp"
|
|
39
|
+
#include "HapticCurveControlPoint.hpp"
|
|
40
|
+
#include "JHapticCurveControlPoint.hpp"
|
|
41
|
+
#include <string>
|
|
42
|
+
#include "HapticImpactStyle.hpp"
|
|
43
|
+
#include "JHapticImpactStyle.hpp"
|
|
44
|
+
#include "HapticNotificationType.hpp"
|
|
45
|
+
#include "JHapticNotificationType.hpp"
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro::tickle {
|
|
48
|
+
|
|
49
|
+
jni::local_ref<JHybridTickleSpec::jhybriddata> JHybridTickleSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
50
|
+
return makeCxxInstance(jThis);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void JHybridTickleSpec::registerNatives() {
|
|
54
|
+
registerHybrid({
|
|
55
|
+
makeNativeMethod("initHybrid", JHybridTickleSpec::initHybrid),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
size_t JHybridTickleSpec::getExternalMemorySize() noexcept {
|
|
60
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
61
|
+
return method(_javaPart);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
bool JHybridTickleSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
65
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridTickleSpec>(other)) {
|
|
66
|
+
return _javaPart == otherCast->_javaPart;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
void JHybridTickleSpec::dispose() noexcept {
|
|
72
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
73
|
+
method(_javaPart);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
std::string JHybridTickleSpec::toString() {
|
|
77
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
78
|
+
auto javaString = method(_javaPart);
|
|
79
|
+
return javaString->toStdString();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Properties
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
// Methods
|
|
86
|
+
void JHybridTickleSpec::startHaptic(const std::vector<HapticEvent>& events, const std::vector<HapticCurve>& curves) {
|
|
87
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JHapticEvent>> /* events */, jni::alias_ref<jni::JArrayClass<JHapticCurve>> /* curves */)>("startHaptic");
|
|
88
|
+
method(_javaPart, [&]() {
|
|
89
|
+
size_t __size = events.size();
|
|
90
|
+
jni::local_ref<jni::JArrayClass<JHapticEvent>> __array = jni::JArrayClass<JHapticEvent>::newArray(__size);
|
|
91
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
92
|
+
const auto& __element = events[__i];
|
|
93
|
+
auto __elementJni = JHapticEvent::fromCpp(__element);
|
|
94
|
+
__array->setElement(__i, *__elementJni);
|
|
95
|
+
}
|
|
96
|
+
return __array;
|
|
97
|
+
}(), [&]() {
|
|
98
|
+
size_t __size = curves.size();
|
|
99
|
+
jni::local_ref<jni::JArrayClass<JHapticCurve>> __array = jni::JArrayClass<JHapticCurve>::newArray(__size);
|
|
100
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
101
|
+
const auto& __element = curves[__i];
|
|
102
|
+
auto __elementJni = JHapticCurve::fromCpp(__element);
|
|
103
|
+
__array->setElement(__i, *__elementJni);
|
|
104
|
+
}
|
|
105
|
+
return __array;
|
|
106
|
+
}());
|
|
107
|
+
}
|
|
108
|
+
void JHybridTickleSpec::stopAllHaptics() {
|
|
109
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stopAllHaptics");
|
|
110
|
+
method(_javaPart);
|
|
111
|
+
}
|
|
112
|
+
void JHybridTickleSpec::initializeEngine() {
|
|
113
|
+
static const auto method = javaClassStatic()->getMethod<void()>("initializeEngine");
|
|
114
|
+
method(_javaPart);
|
|
115
|
+
}
|
|
116
|
+
void JHybridTickleSpec::destroyEngine() {
|
|
117
|
+
static const auto method = javaClassStatic()->getMethod<void()>("destroyEngine");
|
|
118
|
+
method(_javaPart);
|
|
119
|
+
}
|
|
120
|
+
void JHybridTickleSpec::createContinuousPlayer(const std::string& playerId, double initialIntensity, double initialSharpness) {
|
|
121
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* playerId */, double /* initialIntensity */, double /* initialSharpness */)>("createContinuousPlayer");
|
|
122
|
+
method(_javaPart, jni::make_jstring(playerId), initialIntensity, initialSharpness);
|
|
123
|
+
}
|
|
124
|
+
void JHybridTickleSpec::startContinuousPlayer(const std::string& playerId) {
|
|
125
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* playerId */)>("startContinuousPlayer");
|
|
126
|
+
method(_javaPart, jni::make_jstring(playerId));
|
|
127
|
+
}
|
|
128
|
+
void JHybridTickleSpec::updateContinuousPlayer(const std::string& playerId, double intensityControl, double sharpnessControl) {
|
|
129
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* playerId */, double /* intensityControl */, double /* sharpnessControl */)>("updateContinuousPlayer");
|
|
130
|
+
method(_javaPart, jni::make_jstring(playerId), intensityControl, sharpnessControl);
|
|
131
|
+
}
|
|
132
|
+
void JHybridTickleSpec::stopContinuousPlayer(const std::string& playerId) {
|
|
133
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* playerId */)>("stopContinuousPlayer");
|
|
134
|
+
method(_javaPart, jni::make_jstring(playerId));
|
|
135
|
+
}
|
|
136
|
+
void JHybridTickleSpec::destroyContinuousPlayer(const std::string& playerId) {
|
|
137
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* playerId */)>("destroyContinuousPlayer");
|
|
138
|
+
method(_javaPart, jni::make_jstring(playerId));
|
|
139
|
+
}
|
|
140
|
+
void JHybridTickleSpec::setHapticsEnabled(bool enabled) {
|
|
141
|
+
static const auto method = javaClassStatic()->getMethod<void(jboolean /* enabled */)>("setHapticsEnabled");
|
|
142
|
+
method(_javaPart, enabled);
|
|
143
|
+
}
|
|
144
|
+
bool JHybridTickleSpec::getHapticsEnabled() {
|
|
145
|
+
static const auto method = javaClassStatic()->getMethod<jboolean()>("getHapticsEnabled");
|
|
146
|
+
auto __result = method(_javaPart);
|
|
147
|
+
return static_cast<bool>(__result);
|
|
148
|
+
}
|
|
149
|
+
void JHybridTickleSpec::triggerImpact(HapticImpactStyle style) {
|
|
150
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHapticImpactStyle> /* style */)>("triggerImpact");
|
|
151
|
+
method(_javaPart, JHapticImpactStyle::fromCpp(style));
|
|
152
|
+
}
|
|
153
|
+
void JHybridTickleSpec::triggerNotification(HapticNotificationType type) {
|
|
154
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHapticNotificationType> /* type */)>("triggerNotification");
|
|
155
|
+
method(_javaPart, JHapticNotificationType::fromCpp(type));
|
|
156
|
+
}
|
|
157
|
+
void JHybridTickleSpec::triggerSelection() {
|
|
158
|
+
static const auto method = javaClassStatic()->getMethod<void()>("triggerSelection");
|
|
159
|
+
method(_javaPart);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
} // namespace margelo::nitro::tickle
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridTickleSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridTickleSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::tickle {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridTickleSpec: public jni::HybridClass<JHybridTickleSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridTickleSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/tickle/HybridTickleSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridTickleSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridTickleSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridTickleSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
+
void dispose() noexcept override;
|
|
45
|
+
std::string toString() override;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline const jni::global_ref<JHybridTickleSpec::javaobject>& getJavaPart() const noexcept {
|
|
49
|
+
return _javaPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
void startHaptic(const std::vector<HapticEvent>& events, const std::vector<HapticCurve>& curves) override;
|
|
59
|
+
void stopAllHaptics() override;
|
|
60
|
+
void initializeEngine() override;
|
|
61
|
+
void destroyEngine() override;
|
|
62
|
+
void createContinuousPlayer(const std::string& playerId, double initialIntensity, double initialSharpness) override;
|
|
63
|
+
void startContinuousPlayer(const std::string& playerId) override;
|
|
64
|
+
void updateContinuousPlayer(const std::string& playerId, double intensityControl, double sharpnessControl) override;
|
|
65
|
+
void stopContinuousPlayer(const std::string& playerId) override;
|
|
66
|
+
void destroyContinuousPlayer(const std::string& playerId) override;
|
|
67
|
+
void setHapticsEnabled(bool enabled) override;
|
|
68
|
+
bool getHapticsEnabled() override;
|
|
69
|
+
void triggerImpact(HapticImpactStyle style) override;
|
|
70
|
+
void triggerNotification(HapticNotificationType type) override;
|
|
71
|
+
void triggerSelection() override;
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
friend HybridBase;
|
|
75
|
+
using HybridBase::HybridBase;
|
|
76
|
+
jni::global_ref<JHybridTickleSpec::javaobject> _javaPart;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro::tickle
|