@makefully/engagefully 0.0.0-stage → 0.2.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.
@@ -0,0 +1,193 @@
1
+ import EventEmitter from 'events';
2
+
3
+ const
4
+ clampVector = function (v, deadzone) {
5
+ const
6
+ x = v.x,
7
+ y = v.y,
8
+ m = Math.sqrt(x * x + y * y);
9
+
10
+ if (m > 1) {
11
+ v.x *= 1 / m;
12
+ v.y *= 1 / m;
13
+ } else if (m < deadzone) {
14
+ v.x = 0;
15
+ v.y = 0;
16
+ } else {
17
+ const
18
+ span = 1 - deadzone;
19
+
20
+ v.x = (x - deadzone) / span;
21
+ v.y = (y - deadzone) / span;
22
+ }
23
+
24
+ return v;
25
+ },
26
+ updateGamepads = () => {
27
+ const
28
+ gamepads = [...window.navigator.getGamepads()];
29
+
30
+ for (let i = 0; i < gamepads.length; i++) {
31
+ const gamepad = gamepads[i];
32
+
33
+ if (gamepad) {
34
+ const standard = standardizedGamepads[gamepad.index];
35
+
36
+ if (!standard) { // set up initial values so events can be triggered later
37
+ standardizedGamepads[gamepad.index] = new Gamepad(gamepad);
38
+ } else {
39
+ standard.update(gamepad);
40
+ }
41
+ }
42
+ }
43
+
44
+ window.requestAnimationFrame(updateGamepads);
45
+ },
46
+ playEffectOptions = {
47
+ duration: 500,
48
+ startDelay: 0,
49
+ strongMagnitude: 1.0,
50
+ weakMagnitude: 1.0
51
+ },
52
+ controllers = {
53
+ a0: 'LeftStick',
54
+ a1: 'RightStick',
55
+ b0: 'AButton',
56
+ b1: 'BButton',
57
+ b2: 'XButton',
58
+ b3: 'YButton',
59
+ b4: 'LeftBumper',
60
+ b5: 'RightBumper',
61
+ b6: 'LeftTrigger',
62
+ b7: 'RightTrigger',
63
+ b8: 'BackButton',
64
+ b9: 'StartButton',
65
+ b10: 'LeftStickButton',
66
+ b11: 'RightStickButton',
67
+ b12: 'UpDPad',
68
+ b13: 'DownDPad',
69
+ b14: 'LeftDPad',
70
+ b15: 'RightDPad'
71
+ },
72
+ standardizedGamepads = [];
73
+
74
+ window.addEventListener("gamepadconnected", () => {
75
+ updateGamepads();
76
+ });
77
+
78
+ class Gamepad extends EventEmitter {
79
+ constructor (gamepad, id = '', deadzone = 0.1) {
80
+ super();
81
+
82
+ this.source = gamepad;
83
+ this.deadzone = deadzone;
84
+ this.axes = [];
85
+ for (let i = 0; i < (gamepad.axes.length >> 1); i++) {
86
+ this.axes.push(clampVector({
87
+ x: gamepad.axes[i * 2],
88
+ y: gamepad.axes[i * 2 + 1]
89
+ }, deadzone));
90
+ }
91
+ this.buttons = [];
92
+ for (let i = 0; i < gamepad.buttons.length; i++) {
93
+ this.buttons.push(gamepad.buttons[i].value);
94
+ }
95
+ this.id = id || `${gamepad.id} - ${gamepad.index}`; // Adding index to make it unique.
96
+ }
97
+
98
+ dualRumble (duration = 500, delay = 0, strong = 1.0, weak = 1.0) {
99
+ playEffectOptions.duration = duration;
100
+ playEffectOptions.startDelay = delay;
101
+ playEffectOptions.strongMagnitude = strong;
102
+ playEffectOptions.weakMagnitude = weak;
103
+ this.source.vibrationActuator.playEffect('dual-rumble', playEffectOptions);
104
+ }
105
+
106
+ update (gamepad) {
107
+ const
108
+ axes = this.axes,
109
+ buttons = this.buttons;
110
+
111
+ for (let i = 0; i < axes.length; i++) {
112
+ const
113
+ oldVector = axes[i],
114
+ newVector = clampVector({
115
+ x: gamepad.axes[i * 2],
116
+ y: gamepad.axes[i * 2 + 1]
117
+ }, this.deadzone);
118
+
119
+ if (oldVector.x !== newVector.x || oldVector.y !== newVector.y) {
120
+ const
121
+ x = newVector.x,
122
+ y = newVector.y;
123
+
124
+ oldVector.x = x;
125
+ oldVector.y = y;
126
+
127
+ this.emit('updated', {
128
+ control: controllers[`a${i}`],
129
+ device: this.id,
130
+ target: this,
131
+ type: 'Joystick',
132
+ x,
133
+ y
134
+ });
135
+ }
136
+ }
137
+
138
+ for (let i = 0; i < gamepad.buttons.length; i++) {
139
+ const
140
+ newButton = gamepad.buttons[i],
141
+ newValue = newButton.value,
142
+ oldButton = buttons[i];
143
+
144
+ if (newValue !== oldButton) {
145
+ buttons[i] = newValue;
146
+ this.emit('updated', {
147
+ control: controllers[`b${i}`],
148
+ device: this.id,
149
+ target: this,
150
+ type: 'Button',
151
+ value: newValue
152
+ });
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+ class GamepadDevice extends EventEmitter {
159
+ constructor () {
160
+ super();
161
+
162
+ this.eventHandlers = [];
163
+
164
+ window.addEventListener("gamepadconnected", () => {
165
+ this.updateGamepads();
166
+ });
167
+
168
+ this.updateGamepads();
169
+ }
170
+
171
+ updateGamepads () {
172
+ for (let i = 0; i < this.eventHandlers.length; i++) {
173
+ this.eventHandlers[i].gamepad.off('updated', this.eventHandlers[i].handler);
174
+ }
175
+ this.eventHandlers.length = 0;
176
+
177
+ for (let i = 0; i < standardizedGamepads.length; i++) {
178
+ const
179
+ handler = (event) => {
180
+ this.emit('updated', event);
181
+ };
182
+
183
+ standardizedGamepads[i].on('updated', handler);
184
+
185
+ this.eventHandlers.push({
186
+ gamepad: standardizedGamepads[i],
187
+ handler
188
+ })
189
+ }
190
+ }
191
+ };
192
+
193
+ export default GamepadDevice;
@@ -0,0 +1,28 @@
1
+ import EventEmitter from 'events';
2
+
3
+ class KeyboardDevice extends EventEmitter {
4
+ constructor (device = 'Keyboard') {
5
+ super();
6
+
7
+ window.addEventListener('keydown', (event) => {
8
+ this.emit('updated', {
9
+ control: event.code,
10
+ device,
11
+ event,
12
+ type: 'Button',
13
+ value: 1
14
+ });
15
+ });
16
+ window.addEventListener('keyup', (event) => {
17
+ this.emit('updated', {
18
+ control: event.code,
19
+ device,
20
+ event,
21
+ type: 'Button',
22
+ value: 0
23
+ });
24
+ });
25
+ }
26
+ }
27
+
28
+ export default KeyboardDevice;
@@ -0,0 +1,14 @@
1
+ import {BroadcastChannel} from 'broadcast-channel';
2
+ import EventEmitter from 'events';
3
+
4
+ class PageDevice extends EventEmitter {
5
+ constructor (device = 'PageDevice') {
6
+ super();
7
+ this.channel = new BroadcastChannel(device);
8
+ this.channel.addEventListener('message', (event) => {
9
+ this.emit('updated', event);
10
+ });
11
+ }
12
+ };
13
+
14
+ export default PageDevice;
@@ -0,0 +1,50 @@
1
+ import EventEmitter from 'events';
2
+
3
+ class PixiDevice extends EventEmitter {
4
+ constructor (target, device = 'PixiDevice') {
5
+ super();
6
+
7
+ this.pressed = 0;
8
+
9
+ target.on('pointerdown', (event) => {
10
+ this.pressed = 1;
11
+ this.emit('updated', {
12
+ control: 'Pointer',
13
+ device,
14
+ event,
15
+ target,
16
+ type: 'Pointer',
17
+ value: this.pressed,
18
+ x: event.x,
19
+ y: event.y
20
+ });
21
+ });
22
+ target.on('pointermove', (event) => {
23
+ this.emit('updated', {
24
+ control: 'Pointer',
25
+ device,
26
+ event,
27
+ target,
28
+ type: 'Pointer',
29
+ value: this.pressed,
30
+ x: event.x,
31
+ y: event.y
32
+ });
33
+ });
34
+ target.on(options?.up ?? 'pointerup', (event) => {
35
+ this.pressed = 0;
36
+ this.emit('updated', {
37
+ control: 'Pointer',
38
+ device,
39
+ event,
40
+ target,
41
+ type: 'Pointer',
42
+ value: this.pressed,
43
+ x: event.x,
44
+ y: event.y
45
+ });
46
+ });
47
+ }
48
+ }
49
+
50
+ export default PixiDevice;
@@ -0,0 +1,50 @@
1
+ import EventEmitter from 'events';
2
+
3
+ class PointerDevice extends EventEmitter {
4
+ constructor (target, device = 'PointerDevice') {
5
+ super();
6
+
7
+ this.pressed = 0;
8
+
9
+ target.addEventListener('pointerdown', (event) => {
10
+ this.pressed = 1;
11
+ this.emit('updated', {
12
+ control: 'Pointer',
13
+ device,
14
+ event,
15
+ target,
16
+ type: 'Pointer',
17
+ value: this.pressed,
18
+ x: event.x ?? event.pointer?.x,
19
+ y: event.y ?? event.pointer?.y
20
+ });
21
+ });
22
+ target.addEventListener('pointermove', (event) => {
23
+ this.emit('updated', {
24
+ control: 'Pointer',
25
+ device,
26
+ event,
27
+ target,
28
+ type: 'Pointer',
29
+ value: this.pressed,
30
+ x: event.x ?? event.pointer?.x,
31
+ y: event.y ?? event.pointer?.y
32
+ });
33
+ });
34
+ target.addEventListener('pointerup', (event) => {
35
+ this.pressed = 0;
36
+ this.emit('updated', {
37
+ control: 'Pointer',
38
+ device,
39
+ event,
40
+ target,
41
+ type: 'Pointer',
42
+ value: this.pressed,
43
+ x: event.x ?? event.pointer?.x,
44
+ y: event.y ?? event.pointer?.y
45
+ });
46
+ });
47
+ }
48
+ }
49
+
50
+ export default PointerDevice;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @namespace devices
3
+ * @memberof engagefully
4
+ */
5
+ import BLEDevice from './BLEDevice';
6
+ import FabricDevice from './FabricDevice';
7
+ import GamepadDevice from './GamepadDevice';
8
+ import KeyboardDevice from './KeyboardDevice';
9
+ import PageDevice from './PageDevice';
10
+ import PixiDevice from './PixiDevice';
11
+ import PointerDevice from './PointerDevice';
12
+
13
+ export default {
14
+ BLEDevice,
15
+ FabricDevice,
16
+ GamepadDevice,
17
+ KeyboardDevice,
18
+ PageDevice,
19
+ PixiDevice,
20
+ PointerDevice
21
+ };
22
+
@@ -0,0 +1,160 @@
1
+ {
2
+ "00002a7e-0000-1000-8000-00805f9b34fb": "aerobic_heart_rate_lower_limit",
3
+ "00002a84-0000-1000-8000-00805f9b34fb": "aerobic_heart_rate_upper_limit",
4
+ "00002a7f-0000-1000-8000-00805f9b34fb": "aerobic_threshold",
5
+ "00002a80-0000-1000-8000-00805f9b34fb": "age",
6
+ "00002a5a-0000-1000-8000-00805f9b34fb": "aggregate",
7
+ "00002a43-0000-1000-8000-00805f9b34fb": "alert_category_id",
8
+ "00002a42-0000-1000-8000-00805f9b34fb": "alert_category_id_bit_mask",
9
+ "00002a06-0000-1000-8000-00805f9b34fb": "alert_level",
10
+ "00002a44-0000-1000-8000-00805f9b34fb": "alert_notification_control_point",
11
+ "00002a3f-0000-1000-8000-00805f9b34fb": "alert_status",
12
+ "00002ab3-0000-1000-8000-00805f9b34fb": "altitude",
13
+ "00002a81-0000-1000-8000-00805f9b34fb": "anaerobic_heart_rate_lower_limit",
14
+ "00002a82-0000-1000-8000-00805f9b34fb": "anaerobic_heart_rate_upper_limit",
15
+ "00002a83-0000-1000-8000-00805f9b34fb": "anaerobic_threshold",
16
+ "00002a58-0000-1000-8000-00805f9b34fb": "analog",
17
+ "00002a73-0000-1000-8000-00805f9b34fb": "apparent_wind_direction",
18
+ "00002a72-0000-1000-8000-00805f9b34fb": "apparent_wind_speed",
19
+ "00002a01-0000-1000-8000-00805f9b34fb": "gap.appearance",
20
+ "00002aa3-0000-1000-8000-00805f9b34fb": "barometric_pressure_trend",
21
+ "00002a19-0000-1000-8000-00805f9b34fb": "battery_level",
22
+ "00002a49-0000-1000-8000-00805f9b34fb": "blood_pressure_feature",
23
+ "00002a35-0000-1000-8000-00805f9b34fb": "blood_pressure_measurement",
24
+ "00002a9b-0000-1000-8000-00805f9b34fb": "body_composition_feature",
25
+ "00002a9c-0000-1000-8000-00805f9b34fb": "body_composition_measurement",
26
+ "00002a38-0000-1000-8000-00805f9b34fb": "body_sensor_location",
27
+ "00002aa4-0000-1000-8000-00805f9b34fb": "bond_management_control_point",
28
+ "00002aa5-0000-1000-8000-00805f9b34fb": "bond_management_feature",
29
+ "00002a22-0000-1000-8000-00805f9b34fb": "boot_keyboard_input_report",
30
+ "00002a32-0000-1000-8000-00805f9b34fb": "boot_keyboard_output_report",
31
+ "00002a33-0000-1000-8000-00805f9b34fb": "boot_mouse_input_report",
32
+ "00002aa6-0000-1000-8000-00805f9b34fb": "gap.central_address_resolution_support",
33
+ "00002aa8-0000-1000-8000-00805f9b34fb": "cgm_feature",
34
+ "00002aa7-0000-1000-8000-00805f9b34fb": "cgm_measurement",
35
+ "00002aab-0000-1000-8000-00805f9b34fb": "cgm_session_run_time",
36
+ "00002aaa-0000-1000-8000-00805f9b34fb": "cgm_session_start_time",
37
+ "00002aac-0000-1000-8000-00805f9b34fb": "cgm_specific_ops_control_point",
38
+ "00002aa9-0000-1000-8000-00805f9b34fb": "cgm_status",
39
+ "00002a5c-0000-1000-8000-00805f9b34fb": "csc_feature",
40
+ "00002a5b-0000-1000-8000-00805f9b34fb": "csc_measurement",
41
+ "00002a2b-0000-1000-8000-00805f9b34fb": "current_time",
42
+ "00002a66-0000-1000-8000-00805f9b34fb": "cycling_power_control_point",
43
+ "00002a65-0000-1000-8000-00805f9b34fb": "cycling_power_feature",
44
+ "00002a63-0000-1000-8000-00805f9b34fb": "cycling_power_measurement",
45
+ "00002a64-0000-1000-8000-00805f9b34fb": "cycling_power_vector",
46
+ "00002a99-0000-1000-8000-00805f9b34fb": "database_change_increment",
47
+ "00002a85-0000-1000-8000-00805f9b34fb": "date_of_birth",
48
+ "00002a86-0000-1000-8000-00805f9b34fb": "date_of_threshold_assessment",
49
+ "00002a08-0000-1000-8000-00805f9b34fb": "date_time",
50
+ "00002a0a-0000-1000-8000-00805f9b34fb": "day_date_time",
51
+ "00002a09-0000-1000-8000-00805f9b34fb": "day_of_week",
52
+ "00002a7d-0000-1000-8000-00805f9b34fb": "descriptor_value_changed",
53
+ "00002a00-0000-1000-8000-00805f9b34fb": "gap.device_name",
54
+ "00002a7b-0000-1000-8000-00805f9b34fb": "dew_point",
55
+ "00002a56-0000-1000-8000-00805f9b34fb": "digital",
56
+ "00002a0d-0000-1000-8000-00805f9b34fb": "dst_offset",
57
+ "00002a6c-0000-1000-8000-00805f9b34fb": "elevation",
58
+ "00002a87-0000-1000-8000-00805f9b34fb": "email_address",
59
+ "00002a0c-0000-1000-8000-00805f9b34fb": "exact_time_256",
60
+ "00002a88-0000-1000-8000-00805f9b34fb": "fat_burn_heart_rate_lower_limit",
61
+ "00002a89-0000-1000-8000-00805f9b34fb": "fat_burn_heart_rate_upper_limit",
62
+ "00002a26-0000-1000-8000-00805f9b34fb": "firmware_revision_string",
63
+ "00002a8a-0000-1000-8000-00805f9b34fb": "first_name",
64
+ "00002a8b-0000-1000-8000-00805f9b34fb": "five_zone_heart_rate_limits",
65
+ "00002ab2-0000-1000-8000-00805f9b34fb": "floor_number",
66
+ "00002a8c-0000-1000-8000-00805f9b34fb": "gender",
67
+ "00002a51-0000-1000-8000-00805f9b34fb": "glucose_feature",
68
+ "00002a18-0000-1000-8000-00805f9b34fb": "glucose_measurement",
69
+ "00002a34-0000-1000-8000-00805f9b34fb": "glucose_measurement_context",
70
+ "00002a74-0000-1000-8000-00805f9b34fb": "gust_factor",
71
+ "00002a27-0000-1000-8000-00805f9b34fb": "hardware_revision_string",
72
+ "00002a39-0000-1000-8000-00805f9b34fb": "heart_rate_control_point",
73
+ "00002a8d-0000-1000-8000-00805f9b34fb": "heart_rate_max",
74
+ "00002a37-0000-1000-8000-00805f9b34fb": "heart_rate_measurement",
75
+ "00002a7a-0000-1000-8000-00805f9b34fb": "heat_index",
76
+ "00002a8e-0000-1000-8000-00805f9b34fb": "height",
77
+ "00002a4c-0000-1000-8000-00805f9b34fb": "hid_control_point",
78
+ "00002a4a-0000-1000-8000-00805f9b34fb": "hid_information",
79
+ "00002a8f-0000-1000-8000-00805f9b34fb": "hip_circumference",
80
+ "00002a6f-0000-1000-8000-00805f9b34fb": "humidity",
81
+ "00002aad-0000-1000-8000-00805f9b34fb": "indoor_positioning_configuration",
82
+ "00002a1e-0000-1000-8000-00805f9b34fb": "intermediate_temperature",
83
+ "00002a77-0000-1000-8000-00805f9b34fb": "irradiance",
84
+ "00002aa2-0000-1000-8000-00805f9b34fb": "language",
85
+ "00002a90-0000-1000-8000-00805f9b34fb": "last_name",
86
+ "00002aae-0000-1000-8000-00805f9b34fb": "latitude",
87
+ "00002a6b-0000-1000-8000-00805f9b34fb": "ln_control_point",
88
+ "00002a6a-0000-1000-8000-00805f9b34fb": "ln_feature",
89
+ "00002ab0-0000-1000-8000-00805f9b34fb": "local_north_coordinate",
90
+ "00002a0f-0000-1000-8000-00805f9b34fb": "local_time_information",
91
+ "00002a67-0000-1000-8000-00805f9b34fb": "location_and_speed",
92
+ "00002ab5-0000-1000-8000-00805f9b34fb": "location_name",
93
+ "00002aaf-0000-1000-8000-00805f9b34fb": "longitude",
94
+ "00002a2c-0000-1000-8000-00805f9b34fb": "magnetic_declination",
95
+ "00002aa0-0000-1000-8000-00805f9b34fb": "magnetic_flux_density_2D",
96
+ "00002aa1-0000-1000-8000-00805f9b34fb": "magnetic_flux_density_3D",
97
+ "00002a29-0000-1000-8000-00805f9b34fb": "manufacturer_name_string",
98
+ "00002a91-0000-1000-8000-00805f9b34fb": "maximum_recommended_heart_rate",
99
+ "00002a21-0000-1000-8000-00805f9b34fb": "measurement_interval",
100
+ "00002a24-0000-1000-8000-00805f9b34fb": "model_number_string",
101
+ "00002a68-0000-1000-8000-00805f9b34fb": "navigation",
102
+ "00002a46-0000-1000-8000-00805f9b34fb": "new_alert",
103
+ "00002a04-0000-1000-8000-00805f9b34fb": "gap.peripheral_preferred_connection_parameters",
104
+ "00002a02-0000-1000-8000-00805f9b34fb": "gap.peripheral_privacy_flag",
105
+ "00002a5f-0000-1000-8000-00805f9b34fb": "plx_continuous_measurement",
106
+ "00002a60-0000-1000-8000-00805f9b34fb": "plx_features",
107
+ "00002a5e-0000-1000-8000-00805f9b34fb": "plx_spot_check_measurement",
108
+ "00002a50-0000-1000-8000-00805f9b34fb": "pnp_id",
109
+ "00002a75-0000-1000-8000-00805f9b34fb": "pollen_concentration",
110
+ "00002a69-0000-1000-8000-00805f9b34fb": "position_quality",
111
+ "00002a6d-0000-1000-8000-00805f9b34fb": "pressure",
112
+ "00002a4e-0000-1000-8000-00805f9b34fb": "protocol_mode",
113
+ "00002a78-0000-1000-8000-00805f9b34fb": "rainfall",
114
+ "00002a03-0000-1000-8000-00805f9b34fb": "gap.reconnection_address",
115
+ "00002a52-0000-1000-8000-00805f9b34fb": "record_access_control_point",
116
+ "00002a14-0000-1000-8000-00805f9b34fb": "reference_time_information",
117
+ "00002a4d-0000-1000-8000-00805f9b34fb": "report",
118
+ "00002a4b-0000-1000-8000-00805f9b34fb": "report_map",
119
+ "00002a92-0000-1000-8000-00805f9b34fb": "resting_heart_rate",
120
+ "00002a40-0000-1000-8000-00805f9b34fb": "ringer_control_point",
121
+ "00002a41-0000-1000-8000-00805f9b34fb": "ringer_setting",
122
+ "00002a54-0000-1000-8000-00805f9b34fb": "rsc_feature",
123
+ "00002a53-0000-1000-8000-00805f9b34fb": "rsc_measurement",
124
+ "00002a55-0000-1000-8000-00805f9b34fb": "sc_control_point",
125
+ "00002a4f-0000-1000-8000-00805f9b34fb": "scan_interval_window",
126
+ "00002a31-0000-1000-8000-00805f9b34fb": "scan_refresh",
127
+ "00002a5d-0000-1000-8000-00805f9b34fb": "sensor_location",
128
+ "00002a25-0000-1000-8000-00805f9b34fb": "serial_number_string",
129
+ "00002a05-0000-1000-8000-00805f9b34fb": "gatt.service_changed",
130
+ "00002a28-0000-1000-8000-00805f9b34fb": "software_revision_string",
131
+ "00002a93-0000-1000-8000-00805f9b34fb": "sport_type_for_aerobic_and_anaerobic_thresholds",
132
+ "00002a47-0000-1000-8000-00805f9b34fb": "supported_new_alert_category",
133
+ "00002a48-0000-1000-8000-00805f9b34fb": "supported_unread_alert_category",
134
+ "00002a23-0000-1000-8000-00805f9b34fb": "system_id",
135
+ "00002a6e-0000-1000-8000-00805f9b34fb": "temperature",
136
+ "00002a1c-0000-1000-8000-00805f9b34fb": "temperature_measurement",
137
+ "00002a1d-0000-1000-8000-00805f9b34fb": "temperature_type",
138
+ "00002a94-0000-1000-8000-00805f9b34fb": "three_zone_heart_rate_limits",
139
+ "00002a12-0000-1000-8000-00805f9b34fb": "time_accuracy",
140
+ "00002a13-0000-1000-8000-00805f9b34fb": "time_source",
141
+ "00002a16-0000-1000-8000-00805f9b34fb": "time_update_control_point",
142
+ "00002a17-0000-1000-8000-00805f9b34fb": "time_update_state",
143
+ "00002a11-0000-1000-8000-00805f9b34fb": "time_with_dst",
144
+ "00002a0e-0000-1000-8000-00805f9b34fb": "time_zone",
145
+ "00002a71-0000-1000-8000-00805f9b34fb": "true_wind_direction",
146
+ "00002a70-0000-1000-8000-00805f9b34fb": "true_wind_speed",
147
+ "00002a95-0000-1000-8000-00805f9b34fb": "two_zone_heart_rate_limit",
148
+ "00002a07-0000-1000-8000-00805f9b34fb": "tx_power_level",
149
+ "00002ab4-0000-1000-8000-00805f9b34fb": "uncertainty",
150
+ "00002a45-0000-1000-8000-00805f9b34fb": "unread_alert_status",
151
+ "00002a9f-0000-1000-8000-00805f9b34fb": "user_control_point",
152
+ "00002a9a-0000-1000-8000-00805f9b34fb": "user_index",
153
+ "00002a76-0000-1000-8000-00805f9b34fb": "uv_index",
154
+ "00002a96-0000-1000-8000-00805f9b34fb": "vo2_max",
155
+ "00002a97-0000-1000-8000-00805f9b34fb": "waist_circumference",
156
+ "00002a98-0000-1000-8000-00805f9b34fb": "weight",
157
+ "00002a9d-0000-1000-8000-00805f9b34fb": "weight_measurement",
158
+ "00002a9e-0000-1000-8000-00805f9b34fb": "weight_scale_feature",
159
+ "00002a79-0000-1000-8000-00805f9b34fb": "wind_chill"
160
+ }
@@ -0,0 +1,12 @@
1
+ /* global TextDecoder */
2
+ export default {
3
+ "default": {
4
+ convert: (dataView) => dataView.byteLength ? dataView : null
5
+ },
6
+ "00002901-0000-1000-8000-00805f9b34fb": {
7
+ convert: (dataView) => new TextDecoder('utf-8').decode(dataView)
8
+ },
9
+ "00002904-0000-1000-8000-00805f9b34fb": {
10
+ convert: (dataView) => dataView.getUint8()
11
+ }
12
+ };
@@ -0,0 +1,96 @@
1
+ /* global TextDecoder */
2
+ export default [{ // 0x0
3
+ description: "Reserved For Future Use",
4
+ convert: (dataView) => dataView.byteLength ? dataView : null
5
+ }, { // 0x1
6
+ description: "Boolean",
7
+ convert: (dataView) => dataView.getInt8()
8
+ }, { // 0x2
9
+ description: "unsigned 2-bit integer",
10
+ convert: (dataView) => dataView.getUint8()
11
+ }, { // 0x3
12
+ description: "unsigned 4-bit integer",
13
+ convert: (dataView) => dataView.getUint8()
14
+ }, { // 0x4
15
+ description: "unsigned 8-bit integer",
16
+ convert: (dataView) => dataView.getUint8()
17
+ }, { // 0x5
18
+ description: "unsigned 12-bit integer",
19
+ convert: (dataView) => dataView.getUint16()
20
+ }, { // 0x6
21
+ description: "unsigned 16-bit integer",
22
+ convert: (dataView) => dataView.getUint16()
23
+ }, { // 0x7
24
+ description: "unsigned 24-bit integer",
25
+ convert: (dataView) => dataView.getUint32()
26
+ }, { // 0x8
27
+ description: "unsigned 32-bit integer",
28
+ convert: (dataView) => dataView.getUint32()
29
+ }, { // 0x9
30
+ description: "unsigned 48-bit integer",
31
+ convert: (dataView) => dataView.getBigUint64()
32
+ }, { // 0xA
33
+ description: "unsigned 64-bit integer",
34
+ convert: (dataView) => dataView.getBigUint64()
35
+ }, { // 0xB
36
+ description: "unsigned 128-bit integer",
37
+ convert: (dataView) => [dataView.getBigUint64(), dataView.getBigUint64(8)]
38
+ }, { // 0xC
39
+ description: "signed 8-bit integer",
40
+ convert: (dataView) => dataView.getInt8()
41
+ }, { // 0xD
42
+ description: "signed 12-bit integer",
43
+ convert: (dataView) => dataView.getInt16()
44
+ }, { // 0xE
45
+ description: "signed 16-bit integer",
46
+ convert: (dataView) => dataView.getInt16()
47
+ }, { // 0xF
48
+ description: "signed 24-bit integer",
49
+ convert: (dataView) => dataView.getInt32()
50
+ }, { // 0x10
51
+ description: "signed 32-bit integer",
52
+ convert: (dataView) => dataView.getInt32()
53
+ }, { // 0x11
54
+ description: "signed 48-bit integer",
55
+ convert: (dataView) => dataView.getBigInt64()
56
+ }, { // 0x12
57
+ description: "signed 64-bit integer",
58
+ convert: (dataView) => dataView.getBigInt64()
59
+ }, { // 0x13
60
+ description: "signed 128-bit integer",
61
+ convert: (dataView) => [dataView.getBigInt64(), dataView.getBigInt64(8)]
62
+ }, { // 0x14
63
+ description: "IEEE-754 32-bit floating point",
64
+ convert: (dataView) => dataView.getFloat32()
65
+ }, { // 0x15
66
+ description: "IEEE-754 64-bit floating point",
67
+ convert: (dataView) => dataView.getFloat64()
68
+ }, { // 0x16
69
+ description: "IEEE-11073 16-bit SFLOAT",
70
+ convert: (dataView) => dataView // TODO: Add conversion
71
+ }, { // 0x17
72
+ description: "IEEE-11073 32-bit FLOAT",
73
+ convert: (dataView) => dataView // TODO: Add conversion
74
+ }, { // 0x18
75
+ description: "IEEE-20601 format",
76
+ convert: (dataView) => dataView // TODO: Add conversion
77
+ }, { // 0x19
78
+ description: "UTF-8 string",
79
+ convert: (dataView) => {
80
+ const
81
+ decoder = new TextDecoder('utf-8');
82
+
83
+ return decoder.decode(dataView);
84
+ }
85
+ }, { // 0x1A
86
+ description: "UTF-16 string",
87
+ convert: (dataView) => {
88
+ const
89
+ decoder = new TextDecoder('utf-16');
90
+
91
+ return decoder.decode(dataView);
92
+ }
93
+ }, { // 0x1B
94
+ description: "Opaque Structure",
95
+ convert: (dataView) => dataView
96
+ }];
package/src/index.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @namespace engagefully
3
+ */
4
+ /* global window */
5
+ import Controller from './Controller';
6
+ import ActionMap from './ActionMap';
7
+ import actions from './actions';
8
+ import devices from './devices';
9
+ import { quantizeStick } from './utils/quantizeStick';
10
+ import { focusGate } from './utils/focusGate';
11
+
12
+ window.engagefully = {
13
+ Controller,
14
+ ActionMap,
15
+ actions,
16
+ devices,
17
+ quantizeStick,
18
+ focusGate
19
+ };
20
+
21
+ export {
22
+ Controller,
23
+ ActionMap,
24
+ actions,
25
+ devices,
26
+ quantizeStick,
27
+ focusGate
28
+ };