{"id":46084110,"url":"https://github.com/ctoth/mechanoreceptor","last_synced_at":"2026-03-01T16:17:42.481Z","repository":{"id":256665997,"uuid":"846981390","full_name":"ctoth/mechanoreceptor","owner":"ctoth","description":"Standardized game input from keyboard, mouse, gamepad, and touch","archived":false,"fork":false,"pushed_at":"2024-09-24T04:14:24.000Z","size":353,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T18:27:40.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctoth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T14:06:58.000Z","updated_at":"2024-09-22T19:31:39.000Z","dependencies_parsed_at":"2024-09-12T10:09:36.973Z","dependency_job_id":"ecb57f1f-5bc9-48ab-b91f-08d5e74e858b","html_url":"https://github.com/ctoth/mechanoreceptor","commit_stats":null,"previous_names":["ctoth/mechanoreceptor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ctoth/mechanoreceptor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctoth%2Fmechanoreceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctoth%2Fmechanoreceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctoth%2Fmechanoreceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctoth%2Fmechanoreceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctoth","download_url":"https://codeload.github.com/ctoth/mechanoreceptor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctoth%2Fmechanoreceptor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T15:41:30.362Z","status":"ssl_error","status_checked_at":"2026-03-01T15:37:07.343Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-03-01T16:17:41.887Z","updated_at":"2026-03-01T16:17:42.468Z","avatar_url":"https://github.com/ctoth.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mechanoreceptor: Advanced Browser-Based Game Input Library\n\nMechanoreceptor is a powerful and flexible TypeScript library designed to handle various input methods for browser-based games. It provides a unified interface for keyboard, mouse, touch, and gamepad inputs, making it easier for game developers to create responsive and intuitive controls for their games.\n\n## Features\n\n- Support for multiple input sources: keyboard, mouse, touch, and gamepad\n- Flexible input mapping system with context-based configurations\n- Combo detection for complex input sequences\n- Input buffering for timing-sensitive inputs\n- Throttling and debouncing for optimized performance\n- Gamepad vibration support for compatible devices\n- Easy integration with existing game engines and frameworks\n- Written in TypeScript for type safety and better developer experience\n\n## Installation\n\nYou can install Mechanoreceptor using npm:\n\n```bash\nnpm install mechanoreceptor\n```\n\nOr using yarn:\n\n```bash\nyarn add mechanoreceptor\n```\n\n## Basic Usage\n\nHere's a quick example of how to use Mechanoreceptor in your project:\n\n```typescript\nimport {\n  KeyboardSource,\n  MouseSource,\n  TouchSource,\n  GamepadSource,\n  MappingConfigManager,\n  InputMapper\n} from 'mechanoreceptor';\n\n// Create instances of input sources\nconst keyboardSource = new KeyboardSource();\nconst mouseSource = new MouseSource();\nconst touchSource = new TouchSource();\nconst gamepadSource = new GamepadSource();\n\n// Create a mapping configuration manager\nconst mappingManager = new MappingConfigManager();\n\n// Load your input mappings\nconst mappings = [\n  { contextId: 'gameplay', actionId: 'jump', inputType: 'keyboard', inputCode: 'Space' },\n  { contextId: 'gameplay', actionId: 'shoot', inputType: 'mouse', inputCode: 0 },\n];\nmappingManager.loadMappings(JSON.stringify(mappings));\n\n// Create an input mapper\nconst inputMapper = new InputMapper(\n  mappingManager,\n  keyboardSource,\n  mouseSource,\n  touchSource,\n  gamepadSource\n);\n\n// Initialize input sources\nkeyboardSource.initialize();\nmouseSource.initialize();\ntouchSource.initialize();\ngamepadSource.initialize();\n\n// Set the current context\ninputMapper.setContext('gameplay');\n\n// In your game loop\nfunction gameLoop() {\n  // Update input state\n  inputMapper.update();\n\n  // Get triggered actions\n  const actions = inputMapper.mapInput();\n\n  // Handle actions in your game\n  actions.forEach(action =\u003e {\n    switch (action) {\n      case 'jump':\n        // Handle jump action\n        break;\n      case 'shoot':\n        // Handle shoot action\n        break;\n    }\n  });\n\n  // Continue with your game logic\n  requestAnimationFrame(gameLoop);\n}\n\n// Start the game loop\ngameLoop();\n```\n\n## Advanced Features\n\n### Combo System\n\nMechanoreceptor supports complex input combinations:\n\n```typescript\nconst hadoukenCombo = {\n  id: 'hadouken',\n  sequence: [\n    { inputType: 'keyboard', inputCode: 'ArrowDown' },\n    { inputType: 'keyboard', inputCode: 'ArrowRight' },\n    { inputType: 'keyboard', inputCode: 'KeyP' }\n  ],\n  maxTimeWindow: 500\n};\n\ninputMapper.addCombo(hadoukenCombo);\n```\n\n### Input Buffering\n\nYou can access recent inputs for more complex game mechanics:\n\n```typescript\nconst recentInputs = inputMapper.getRecentInputs(500); // Get inputs from last 500ms\n```\n\n### Gamepad Vibration\n\nFor gamepads that support haptic feedback:\n\n```typescript\ngamepadSource.vibrate(0, 200, 0.5, 0.8); // Vibrate gamepad 0 for 200ms\n```\n\n### Context-Based Input Mapping\n\nMechanoreceptor allows you to define different input mappings for various game contexts:\n\n```typescript\nconst menuMappings = [\n  { contextId: 'menu', actionId: 'select', inputType: 'keyboard', inputCode: 'Enter' },\n  { contextId: 'menu', actionId: 'back', inputType: 'keyboard', inputCode: 'Escape' },\n];\n\nconst gameplayMappings = [\n  { contextId: 'gameplay', actionId: 'jump', inputType: 'keyboard', inputCode: 'Space' },\n  { contextId: 'gameplay', actionId: 'attack', inputType: 'mouse', inputCode: 0 },\n];\n\nmappingManager.loadMappings(JSON.stringify([...menuMappings, ...gameplayMappings]));\n\n// Switch context when transitioning from menu to gameplay\ninputMapper.setContext('gameplay');\n```\n\n### Mouse Input with Throttling and Debouncing\n\nMechanoreceptor optimizes mouse input handling:\n\n```typescript\nconst mouseSource = new MouseSource(16, 100); // 16ms throttle, 100ms debounce\nmouseSource.initialize();\n\n// In your game loop\nconst mousePosition = mouseSource.getPosition();\nconst isLeftButtonPressed = mouseSource.isButtonPressed(0);\n```\n\n### Touch Input for Mobile Devices\n\nSupport touch-based input for mobile gaming:\n\n```typescript\nconst touchSource = new TouchSource();\ntouchSource.initialize();\n\n// In your game loop\nif (touchSource.isTouching()) {\n  const touches = touchSource.getTouches();\n  // Handle touch input\n}\n```\n\n## Performance Optimization\n\nMechanoreceptor includes built-in performance optimizations:\n\n- Mouse move events are throttled and debounced for smooth performance.\n- Gamepad state is polled at a fixed interval to balance responsiveness and efficiency.\n- Input buffering allows for timing-sensitive inputs without compromising performance.\n\n## Documentation\n\nTo generate the documentation, run:\n\n```bash\nnpm run docs\n```\n\nThis will create a `docs` folder with the generated documentation. Open `docs/index.html` in your browser to view it.\n\n## Contributing\n\nWe welcome contributions to Mechanoreceptor! Please see our [Contributing Guide](CONTRIBUTING.md) for more details on how to get started.\n\n## License\n\nMechanoreceptor is released under the MIT License. See the [LICENSE](LICENSE) file for more details.\n\n## Support\n\nIf you encounter any issues or have questions, please file an issue on our [GitHub issue tracker](https://github.com/yourusername/mechanoreceptor/issues).\n\nHappy gaming!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctoth%2Fmechanoreceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctoth%2Fmechanoreceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctoth%2Fmechanoreceptor/lists"}