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

Keyboard #659

Open
wants to merge 11 commits into
base: dev/0.8
Choose a base branch
from
Open

Keyboard #659

wants to merge 11 commits into from

Conversation

SirEndii
Copy link
Member

@SirEndii SirEndii commented Sep 23, 2024

  • Please check if the PR fulfills these requirements
  • The commit message are well described
  • Docs have been added / updated
  • All changes have fully been tested
  • What kind of change does this PR introduce? (Bug fix, feature, ...)
    Feature

  • What is the new behavior (if this is a feature change)?
    Added the keyboard item. An item which can be linked to a computer. A user can now right click the item to unlock their mouse, they can now freely type while the typed characters are send to the linked computer. Will also be a module for the smart glasses.

  • Does this PR introduce a breaking change? (What changes might users need to make in their scripts due to this PR?)
    No

  • Other information:

@SirEndii SirEndii self-assigned this Sep 23, 2024
@SirEndii SirEndii added enhancement New feature or request 1.19x labels Sep 23, 2024
@SirEndii SirEndii added this to the 0.8r milestone Sep 23, 2024
@SirEndii SirEndii changed the title [IntelligenceModding/Advanced-Peripherals-Features#59] Keyboard item and simple screen to unlock the mouse Keyboard Sep 23, 2024
@SirEndii
Copy link
Member Author

So the keyboard works now
I can bound it to a computer, right click it in the air and start typing. Every key stroke, key presses and releases are synced to the terminal

I now want to remove JEI from the keyboard screen and place a little info text at the top

The last thing I need to do is to implement this as a smart glasses module

…dule keybind. I will see what I will do with the hotkey module or if I will create a new Keybind

I've created two new nbt tags to bind the module to the glasses to sync that to the container, I am not sure if there is maybe a better way, but it works
@SirEndii
Copy link
Member Author

I think everything is done now. Mouse and keyboard events are working, I got the little info text rendered, JEI does not render anymore and everything works fine as a glasses module

@SirEndii SirEndii marked this pull request as ready for review September 30, 2024 10:21
Copy link
Collaborator

@zyxkad zyxkad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just have some detail need to deal with

float textX = (screenWidth / 2f - minecraft.font.width(text) * scale / 2f) / scale;
minecraft.font.drawShadow(poseStack, text, textX, 1, 0xFFFFFF);

// Prevents JEI/REI/EMI from rendering. Maybe not the best way, but it works for now.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind explain a bit what are you doing here to prevent them render? Or I mean I want to know if this won't disable other mods that decides to constant render something on the screen, such as inventory hud+

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have actually no clue if it also disables other ui addon stuff
So I just render an empty string on the far lower right and jei thinks it does not have space to render
There is maybe a better way, maybe using the JEI API


@Override
public boolean charTyped(char ch, int modifiers) {
if (ch >= 32 && ch <= 126 || ch >= 160 && ch <= 255) { // printable chars in byte range
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASCII char has a maximum value of 0x7f (127) btw, not 0xff or 255, above 0x7f will be considers as a two or more bytes UTF8

Copy link
Member Author

@SirEndii SirEndii Oct 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything below charTyped is borrowed from CCs screen itself, so I don't know why squid did what 😅

clipboard = SharedConstants.filterText(clipboard);
if (!clipboard.isEmpty()) {
// Clip to 512 characters and queue the event
if (clipboard.length() > 512) clipboard = clipboard.substring(0, 512);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we better clip before check anything should we not?

@SirEndii
Copy link
Member Author

Sorry to annoy you @SquidDev, just asking you because of #650 (comment)

I used a piece of the TerminalWidget implementation for our keyboard screen. Just asking if this is okay
See
https://github.com/IntelligenceModding/AdvancedPeripherals/pull/659/files#diff-6374267185184dd9bdd6868cb47752c688a105088d0063d0c5bf7992b4e10ec9R19

And maybe you can answer the two comments related to that from zyxkad

@SquidDev
Copy link
Contributor

It might be easier to copy what NoTermComputerScreen does, and just create a Terminal but never render it. Plethora's keyboard UI actually just subclasses NoTermComputerScreen directly.

@SirEndii
Copy link
Member Author

It might be easier to copy what NoTermComputerScreen does, and just create a Terminal but never render it. Plethora's keyboard UI actually just subclasses NoTermComputerScreen directly.

Thank you, I didn't see that
That would be simpler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.19x enhancement New feature or request
Projects
Status: Needs testing/review
Development

Successfully merging this pull request may close these issues.

3 participants