react-native-earl-gamepad 0.7.0 → 0.7.2
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/README.md +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,6 +151,24 @@ export function DebugScreen() {
|
|
|
151
151
|

|
|
152
152
|

|
|
153
153
|
|
|
154
|
+
## Demo
|
|
155
|
+
|
|
156
|
+
https://github.com/user-attachments/assets/6b073b65-9585-4168-8c2c-7ef06a7cf03a
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
https://github.com/user-attachments/assets/b5a9d422-b143-4887-9a64-fb41edee731f
|
|
160
|
+
|
|
161
|
+
## Example
|
|
162
|
+
### Basic Game Showcasing `react-native-earl-gamepad`
|
|
163
|
+
[Github Repository Basic Game](https://github.com/Swif7ify/react-native-earl-gamepad-example)
|
|
164
|
+
```sh
|
|
165
|
+
# external repo
|
|
166
|
+
git clone https://github.com/Swif7ify/react-native-earl-gamepad-example
|
|
167
|
+
cd react-native-earl-gamepad-example
|
|
168
|
+
npm install
|
|
169
|
+
npx expo start
|
|
170
|
+
```
|
|
171
|
+
|
|
154
172
|
## API
|
|
155
173
|
|
|
156
174
|
### `GamepadBridge` props
|
|
@@ -208,6 +226,13 @@ Button names map to the standard gamepad layout (`a`, `b`, `x`, `y`, `lb`, `rb`,
|
|
|
208
226
|
- Axis values below the deadzone are coerced to `0`. Adjust `axisThreshold` if you need more sensitivity.
|
|
209
227
|
- LT/RT expose analog values via `buttonValues.lt` and `buttonValues.rt`.
|
|
210
228
|
|
|
229
|
+
## Performance tips
|
|
230
|
+
|
|
231
|
+
- For movement/game loops in your app, prefer `requestAnimationFrame` over `setInterval` to avoid jitter from timer drift.
|
|
232
|
+
- Skip game loop work when no controller is connected (use `onStatus` or the hook’s `info.connected`).
|
|
233
|
+
- If you need to lower CPU/GPU cost, you can poll at a fixed interval inside your app logic (e.g., 45–60 fps) while the bridge keeps its internal rAF poll for accurate state.
|
|
234
|
+
- Avoid remounting the bridge; mount once near the root and let `enabled` toggle collection if you must pause.
|
|
235
|
+
|
|
211
236
|
## Patterns
|
|
212
237
|
|
|
213
238
|
- **Single place to render**: put the bridge near the root (e.g., inside your `App` provider layer) and consume state anywhere via `useGamepad`.
|