-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a keyboard listener and __init__ files
- Loading branch information
1 parent
aea441b
commit 69e1178
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Dora Node for sending arrow data. | ||
|
||
This node send DATA that is specified within the environemnt variable or from `--data` argument. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
|
||
# Define the path to the README file relative to the package directory | ||
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md") | ||
|
||
# Read the content of the README file | ||
try: | ||
with open(readme_path, "r", encoding="utf-8") as f: | ||
__doc__ = f.read() | ||
except FileNotFoundError: | ||
__doc__ = "README file not found." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from pynput import keyboard | ||
from pynput.keyboard import Key, Events | ||
import pyarrow as pa | ||
from dora import Node | ||
|
||
|
||
node = Node() | ||
|
||
|
||
with keyboard.Events() as events: | ||
while True: | ||
event = events.get(1.0) | ||
if event is not None and isinstance(event, Events.Press): | ||
if hasattr(event.key, "char"): | ||
if event.key.char == "w": | ||
node.send_output("move", pa.array([-0.02, 0, 0, 0, 0, 0])) | ||
elif event.key.char == "s": | ||
node.send_output("move", pa.array([0.02, 0, 0, 0, 0, 0])) | ||
elif event.key.char == "d": | ||
node.send_output("move", pa.array([0, 0.02, 0, 0, 0, 0])) | ||
elif event.key.char == "a": | ||
node.send_output("move", pa.array([0, -0.02, 0, 0, 0, 0])) | ||
elif event.key.char == "e": | ||
node.send_output("move", pa.array([0, 0, 0.02, 0, 0, 0])) | ||
elif event.key.char == "q": | ||
node.send_output("move", pa.array([0, 0, -0.02, 0, 0, 0])) | ||
elif event.key.char == "t": | ||
node.send_output("claw", pa.array([0])) | ||
elif event.key.char == "r": | ||
node.send_output("claw", pa.array([100])) | ||
elif event.key == Key.up: | ||
node.send_output("move", pa.array([0, 0, 0, 0, 0.2, 0])) | ||
elif event.key == Key.down: | ||
node.send_output("move", pa.array([0, 0, 0, 0, -0.2, 0])) | ||
elif event.key == Key.left: | ||
node.send_output("move", pa.array([0, 0, 0, 0.2, 0, 0])) | ||
elif event.key == Key.right: | ||
node.send_output("move", pa.array([0, 0, 0, -0.2, 0, 0])) | ||
|
||
# if event is not None and isinstance(event, Events.Release): | ||
# node.send_output("move", pa.array([0.0, 0, 0, 0, 0, 0])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[tool.poetry] | ||
name = "keyboard-listener" | ||
version = "0.3.5" | ||
authors = [ | ||
"Haixuan Xavier Tao <[email protected]>", | ||
"Enzo Le Van <[email protected]>", | ||
] | ||
description = "Dora keyboard-listener" | ||
license = "MIT License" | ||
homepage = "https://github.com/dora-rs/dora.git" | ||
documentation = "https://github.com/dora-rs/dora/blob/main/node-hub/keyboard-listener/README.md" | ||
readme = "README.md" | ||
packages = [{ include = "keyboard_listener" }] | ||
|
||
[tool.poetry.dependencies] | ||
dora-rs = "0.3.5" | ||
numpy = "< 2.0.0" | ||
pyarrow = ">= 5.0.0" | ||
pynput = "^1.7.6" | ||
|
||
[tool.poetry.scripts] | ||
keyboard-listener = "keyboard_listener.main:main" | ||
|
||
[build-system] | ||
requires = ["poetry-core>=1.8.0"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
[project] | ||
readme = "README.md" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
|
||
# Define the path to the README file relative to the package directory | ||
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md") | ||
|
||
# Read the content of the README file | ||
try: | ||
with open(readme_path, "r", encoding="utf-8") as f: | ||
__doc__ = f.read() | ||
except FileNotFoundError: | ||
__doc__ = "README file not found." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import os | ||
|
||
# Define the path to the README file relative to the package directory | ||
readme_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "README.md") | ||
|
||
# Read the content of the README file | ||
try: | ||
with open(readme_path, "r", encoding="utf-8") as f: | ||
__doc__ = f.read() | ||
except FileNotFoundError: | ||
__doc__ = "README file not found." |