Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control Codes in keyboard_layout_us not supported #106

Closed
bborncr opened this issue Nov 9, 2022 · 4 comments
Closed

Control Codes in keyboard_layout_us not supported #106

bborncr opened this issue Nov 9, 2022 · 4 comments

Comments

@bborncr
Copy link

bborncr commented Nov 9, 2022

Is there a reason that control codes besides LF (\n) are zeroed out in keyboard_layout_us.py?

For example, changing b"\x00" # CR \r to b"\xa8" # CR \r on line 48 allows \r to be used instead of \n

Now \r can be used to to send ascii art to a chat without breaking every line into separate messages:

ascii_art2 = \
"```           ___\r"\
"     |     | |\r"\
"    / \    | |\r"\
"   |--o|===|-|\r"\
"   |---|   | |\r"\
"  /     \  | |\r"\
" |       | | |\r"\
" |       |=| |\r"\
" |       | | |\r"\
" |_______| |_|\r"\
"  |@| |@|  | |\r"\
"___________|_|_\r```"\

The result:
image

@dhalbert
Copy link
Collaborator

dhalbert commented Nov 9, 2022

The ASCII_TO_KEYCODE table in keyboard_layout_us.py is meant to map to physical keys. I looked up keycode \xa8, and it's something obscure. Did you mean \x28?

Assuming you meant \xa8, what chat system are you using that uses \xa8 as a non-breaking newline?

@bborncr
Copy link
Author

bborncr commented Nov 9, 2022

\0xa8 is SHIFT+LF (SHIFT+0x28) which I always understood was \r (a carriage return without a LF). But looking it up the actual ASCII code for \r is 15 (0x0f). ENTER is being send for \n, and I'm just doing a SHIFT+ENTER for \r. So maybe what I'm doing is just a hack?

@dhalbert
Copy link
Collaborator

dhalbert commented Nov 9, 2022

SHIFT+LF is a convention for non-breaking newline, but it doesn't really have anything to do with CR (\r). You could send a line of the image and then kbd.send(Keycode.SHIFT, Keycode.ENTER), then another line, etc So, yes, it is a kind of a hack 🙂 .

If I were coding this up, I might make a list or tuple of the lines of the art, without \r in them. Then write() each one, one at a time, followed by the kbd.send() I gave above.

@bborncr
Copy link
Author

bborncr commented Nov 9, 2022

Understood! Thanks!

@bborncr bborncr closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants