{"id":22111390,"url":"https://github.com/hebirobotics/matlabinput","last_synced_at":"2025-07-25T07:31:46.450Z","repository":{"id":65367700,"uuid":"79696461","full_name":"HebiRobotics/MatlabInput","owner":"HebiRobotics","description":"Library for getting keyboard and joystick input into MATLAB","archived":false,"fork":false,"pushed_at":"2023-01-20T15:19:06.000Z","size":87,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-02-28T20:26:09.524Z","etag":null,"topics":["java","matlab"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HebiRobotics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-22T05:41:10.000Z","updated_at":"2023-01-20T15:15:51.000Z","dependencies_parsed_at":"2023-02-12T03:00:31.228Z","dependency_job_id":null,"html_url":"https://github.com/HebiRobotics/MatlabInput","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HebiRobotics%2FMatlabInput","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HebiRobotics%2FMatlabInput/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HebiRobotics%2FMatlabInput/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HebiRobotics%2FMatlabInput/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HebiRobotics","download_url":"https://codeload.github.com/HebiRobotics/MatlabInput/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227540937,"owners_count":17785056,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["java","matlab"],"created_at":"2024-12-01T10:40:28.088Z","updated_at":"2024-12-01T10:40:29.508Z","avatar_url":"https://github.com/HebiRobotics.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MatlabInput\n\nMatlabInput allows MATLAB users to get input from keyboards and joysticks in a non-blocking manner. \n\n## Installation\n\n* Download the [latest release](https://github.com/HebiRobotics/MatlabInput/releases)\n* Extract the .zip file into a folder of your choice\n* Add the unzipped files to the [MATLAB path](http://www.mathworks.com/help/matlab/ref/path.html)\n\n## Warning: Problems when used with other Java libraries\n\nTypically the underlying Java libraries are loaded automatically at the first call. However, there is a limitation in MATLAB that prevents Java libraries to be loaded once any Java object is instantiated. Thus, if you are using other Java libraries, e.g., [HebiCam](https://github.com/HebiRobotics/HebiCam) or the [Hebi API](http://hebirobotics.com/matlab), you will need to pre-load the libraries manually before using them.\n\n```matlab\nHebiKeyboard.loadLibs();\n```\n\n## HebiKeyboard\n\nHebiKeyboard provides a way to get keyboard input in a non-blocking manner. The default driver is based on Java-AWT and requires focus on a MATLAB window, i.e., the console, an editor window, or a figure. Note that inputs from all keyboards are combined.\n\n### Usage\n\nThe 'read' method returns a snapshot of the current state of various standard and meta keys. Numbers and letters can be queried by indexing into a key vector. Meta keys are exposed directly as fields in the returned struct.\n\nDisplay a message whenever letter 'x' and the number '0' are pressed at the same time.\n\n```matlab\nkb = HebiKeyboard();\nwhile true\n    state = read(kb);\n    if all(state.keys('x0'))\n        disp('x and 0 are both pressed!')\n    end\n    pause(0.01);\nend\n```\n\nDisplay all pressed letters whenever shift is up\n\n```matlab\nkb = HebiKeyboard();\nwhile true\n    state = read(kb);\n    down = find(state.keys('a':'z')) + 'a';\n    if ~state.SHIFT\n        disp(char(down));\n    end\n    pause(0.01);\nend\n```\n\n### Driver Selection\n\nAlternatively, users can choose to use a 'native' driver (based on [JInput](https://github.com/jinput/jinput) binaries) that may support the selection of individual keyboards and may allow reading input when MATLAB is running in the background.\n\n| OS      | Requires Focus   | Selectable Keyboard |\n|---------|------------------|---------------------|\n| Windows | No               | No                  |\n| OSX     | No               | Yes                 |\n| Linux   | N/A (needs sudo) | N/A (needs sudo)    |\n\nNote that this is not the default behavior because of security concerns, e.g., displaying pressed keys while entering passwords into a browser window.\n\n```matlab\ndeviceId = 1;\nkb = HebiKeyboard('native', deviceId);\nstate = read(kb);\n```\n\n## HebiJoystick\n\nHebiJoystick is intended for people who don't have access to the [3D Animation Toolbox](https://www.mathworks.com/products/3d-animation.html) and serves as a drop-in replacement for [vrjoystick](https://www.mathworks.com/help/sl3d/vrjoystick.html).\n\n### Usage\n\nCreate a joystick and react to button presses.\n\n```matlab\njoy = HebiJoystick(1);\nwhile true\n  [axes, buttons, povs] = read(joy);\n  if any(buttons)\n    disp(['Pressed buttons: ' num2str(find(buttons))]);\n  end\n  pause(0.1);\nend\n```\n\nSee [vrjoystick](https://www.mathworks.com/help/sl3d/vrjoystick.html) documentation for more information.\n\n![comparison](https://github.com/HebiRobotics/MatlabInput/raw/resources/comparison.png)\n\n## Notes\n\n* There is a maximum number of events that can occur between reads. If reads don't happen frequently enough, the returned state may not match the real physical state.\n* On some operating systems going into sleep mode while executing a script that reads from the joystick may make MATLAB seem unresponsive. Ctrl-C works eventually, but it may take on the order of minutes to recover.\n* The number and behavior of joystick axes / buttons / povs may differ between operating systems\n\n## Building from source\n\nInstall [Apache Maven](http://maven.apache.org/install.html)\n\nBuild the default snapshot\n\n```bash\ngit clone https://github.com/HebiRobotics/MatlabInput.git\nmvn package\n```\n\nCreate a release\n\n```bash\nmvn package -DreleaseName=\"matlab-input-x.y\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebirobotics%2Fmatlabinput","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhebirobotics%2Fmatlabinput","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhebirobotics%2Fmatlabinput/lists"}