{"id":18675533,"url":"https://github.com/bithatch/linuxio4j","last_synced_at":"2025-04-12T02:11:53.188Z","repository":{"id":27139740,"uuid":"30608466","full_name":"bithatch/linuxio4j","owner":"bithatch","description":"Java Interface to parts of the Linux I/O system, specifically UInput and the Framebuffer.","archived":false,"fork":false,"pushed_at":"2020-12-08T22:08:47.000Z","size":251,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T02:11:47.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bithatch.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-02-10T18:51:55.000Z","updated_at":"2024-07-15T23:41:16.000Z","dependencies_parsed_at":"2022-08-31T16:12:03.319Z","dependency_job_id":null,"html_url":"https://github.com/bithatch/linuxio4j","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Flinuxio4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Flinuxio4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Flinuxio4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bithatch%2Flinuxio4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bithatch","download_url":"https://codeload.github.com/bithatch/linuxio4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248505928,"owners_count":21115354,"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":[],"created_at":"2024-11-07T09:25:20.706Z","updated_at":"2025-04-12T02:11:53.168Z","avatar_url":"https://github.com/bithatch.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# linuxio4j\n\nJava Interface to parts of the Linux I/O system, specifically UInput/Evdev and the Framebuffer.\n\n## Configuring your project\n\nThe library is available in Maven Central, so configure your project according to the\nbuild system you use. \n\nVersion 2.0 was released as Java 9 or higher only, but as from version 2.1-SNAPSHOT,\nJava 8 compatibility is restored through the use of a multi release jar (MRJAR). So for Java 9\nmodularity support, use anything from version 2.0. For Java 8, use any version except\nversion 2.0. Be aware though, that Java 8 compatibility may be completely removed at some\nfuture version.\n\n### Maven\n\n```xml\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003euk.co.bithatch\u003c/groupId\u003e\n\t\t\u003cartifactId\u003elinuxio4j\u003c/artifactId\u003e\n\t\t\u003cversion\u003e2.1\u003c/version\u003e\n\t\u003c/dependency\u003e\n```\n\nOr for the current development version (will be occasionally updated between releases).\n\n```xml\n\t\u003cdependency\u003e\n\t\t\u003cgroupId\u003euk.co.bithatch\u003c/groupId\u003e\n\t\t\u003cartifactId\u003elinuxio4j\u003c/artifactId\u003e\n\t\t\u003cversion\u003e2.1\u003c/version\u003e\n\t\u003c/dependency\u003e\n```\n\n## Try It\n\nYou can run the test application from the command line (requires Maven).\n\n```sh\nmvn compile exec:java\n```\n\nIf all is well, you'll see a simple menu.\n\n```\n1. FB List GraphicsDevice\n2. FB random colours (full speed)\n3. FB noise (direct to buffer)\n4. FB Test Card\n5. UINPUT Keyboard\n6. UINPUT Pointer\n7. UINPUT All\n8. UINPUT Virtual Device\n```\n\n## Usage\n\nTo integrate with your own project, here are some basics.\n\n### Framebuffer\n\nTo find all the frame buffer devices :-\n\n```java\nList\u003cFrameBuffer\u003e fbs = FrameBuffer.getFrameBuffers();\n```\n\nTo get the resolution of a buffer device :-\n\n```java\n\ttry(FrameBuffer fb = FrameBuffer.getFrameBuffer()) {\n\t\tint xres = fb.getVariableScreenInfo().xres;\n\t\tint yres = fb.getVariableScreenInfo().xres;\n\t\tSystem.out.println(\"The buffer is \" + xres + \" x \" + yres);\n\t}\n```\n\nTo write a whole screen of random noise directly to the display :-\n\n```java\n\ttry(FrameBuffer fb = FrameBuffer.getFrameBuffer()) {\n\t\n\t\t/* Get a whole page of random numbers */\n\t\tbyte[] rnd = new byte[fb.getVariableScreenInfo().yres * fb.getVariableScreenInfo().xres * Math.max(1, fb.getVariableScreenInfo().bits_per_pixel / 8)];\n\t\tnew Random().nextBytes(rnd);\n\t\t\n\t\t/* Write the noise */\n\t\tfb.getBuffer().put(rnd);\n\t}\n\t\n```\n\nTo get a `Graphics` to draw on :-\n\n```java\n\ttry(FrameBuffer fb = FrameBuffer.getFrameBuffer()) {\n\t\tGraphics2D g = fb.getGraphics();\n\t\tg.setColor(Color.RED);\n\t\tg.drawRect(100, 100, 400, 400);\n\t\tfb.commit();\n\t}\n\t\n```\n\n### UInput\n\nTo grab and read mouse events :-\n\n```java\n   try(InputDevice mouse = InputDevice.getFirstPointerDevice()) {\n\t\t mouse.open();\n        mouse.grab();\n        while (true) {\n\t\t\tEvent ev = mouse.nextEvent();\n\t\t\tif (ev == null) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tSystem.out.println(ev);\n\t\t}\n\t}\n```\n\nTo create a new virtual keyboard device and emit some keys :-\n\n```java\ntry (InputDevice dev = new InputDevice(\"LinuxIO Test\", (short) 0x1234, (short) 0x5678)) {\n\n\tdev.getCapabilities().put(\n\t\tType.EV_KEY, new LinkedHashSet\u003c\u003e(Arrays.asList(\n\t\t\tEventCode.KEY_H,\n\t\t\tEventCode.KEY_E, \n\t\t\tEventCode.KEY_L, \n\t\t\tEventCode.KEY_O, \n\t\t\tEventCode.KEY_W, \n\t\t\tEventCode.KEY_R, \n\t\t\tEventCode.KEY_D, \n\t\t\tEventCode.KEY_ENTER)));\n\tdev.open();\n\tdev.typeKeys(\n\t\tEventCode.KEY_H, EventCode.KEY_E, EventCode.KEY_L, EventCode.KEY_L, \tEventCode.KEY_O,\n\t\tEventCode.KEY_W, EventCode.KEY_O, EventCode.KEY_R, EventCode.KEY_L, EventCode.KEY_D,\n\t\tEventCode.KEY_ENTER);\n}\n```\n\nNon-blocking monitoring of multiple devices (internally a single thread is created).\n\n```java\n\n\t\tfor (InputDevice device : InputDevice.getAllPointerDevices()) {\n\t\t\tdevice.open();\n\t\t\tdevice.grab();\n\t\t\tInputController.getInstance().add(device, (d, e) -\u003e {\n\t\t\t\tSystem.err.println(d + \" = \" + e);\n\t\t\t});\n\t\t}\n```\n\n## History\n\n#### 2.1-SNAPSHOT\n\n * Added support for creating virtual devices.\n * Restored Java8 compatibility\n * `InputEventCode` renamed to `EventCode` and turned into an `enum`. More convenience methods for typing keys.\n * `UInputDevice` renamed to `InputDevice`.\n * `UInputController` renamed to `InputController`.\n * Added supported for properties and absolute value.\n \n#### 2.0\n\n * Modularised for Java9+ \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbithatch%2Flinuxio4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbithatch%2Flinuxio4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbithatch%2Flinuxio4j/lists"}