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

Add support for user apps to capture raw mouse data and mouse support to Castle Frankenstein #93

Merged
merged 1 commit into from
Feb 25, 2023

Conversation

tinkeros
Copy link
Contributor

This adds a new kernel function MouseRaw which can be used to switch between the mouse sending data to the window manager and the mouse accumulating raw data for a user application to process instead.

When MouseRaw(TRUE) is called it is up to a user application to read the raw data stored in mouse_hard and to clear the accumulated data with MouseRawReset once it has saved it. If a cursor is desired, it is up to the user application to draw one. No mouse data is sent to the window manager for other applications until MouseRaw(FALSE) is called.

This also adds mouse support code to CastleFrankenstein to demonstrate how to integrate this feature into a user application. Now you can turn with the mouse and shoot with the left mouse button. The m key toggles mouse capture. The +/- keys increase and decrease the mouse sensitivity.

Copy link
Collaborator

@y4my4my4m y4my4my4m left a comment

Choose a reason for hiding this comment

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

I find it strange that MouseRaw had to be added to the Kernel, but I admit I did not find any other way to get the raw data either.

LGTM but I rather wait for @TomAwezome 's review before a merge.

@y4my4my4m y4my4my4m linked an issue Jan 26, 2023 that may be closed by this pull request
@tinkeros
Copy link
Contributor Author

Unfortunately the kernel takes all the mouse data on converts it to a positional screen coordinate which is clamped to the limits of the screen. So if you try to intercept it outside the kernel you eventually wouldn't be able to turn in a game because once the kernel thinks your mouse is at the edge of the screen it won't let you go farther in that direction. See MouseHardSetPos which is called immediately after the mouse data packet is parsed here

@y4my4my4m y4my4my4m self-requested a review January 27, 2023 05:49
Copy link
Collaborator

@Midnoclose Midnoclose left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@doodayev doodayev left a comment

Choose a reason for hiding this comment

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

From what I've seen and understand it looks good.
And from what I've tested, the results are excellent. I've run this on vmware with the Limine bootloader and Castle Frankenstein runs so smoothly in comparison to the arrow-keys controls.
The only "downside" is that the game is almost trivially easy now but that just means that more complex enemies and AI can be developed in the future now that the player is no longer bottle-necked by bad controls.
Thank you very much for these changes!

Copy link
Collaborator

@y4my4my4m y4my4my4m left a comment

Choose a reason for hiding this comment

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

LGTM!

@tinkeros
Copy link
Contributor Author

From what I've seen and understand it looks good. And from what I've tested, the results are excellent. I've run this on vmware with the Limine bootloader and Castle Frankenstein runs so smoothly in comparison to the arrow-keys controls. The only "downside" is that the game is almost trivially easy now but that just means that more complex enemies and AI can be developed in the future now that the player is no longer bottle-necked by bad controls. Thank you very much for these changes!

I thought the same thing about the game being too easy. That is what caused me to go off on a tangent and make what I called Castle Frankenstein 2.0. There's a Zeal port that works with this patch if you want to try it out just grab CF2.ZC

Copy link
Collaborator

@xslendix xslendix left a comment

Choose a reason for hiding this comment

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

LGTM.

@mintsuki mintsuki self-requested a review February 19, 2023 02:24
Copy link
Collaborator

@mintsuki mintsuki left a comment

Choose a reason for hiding this comment

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

LGTM

@tinkeros
Copy link
Contributor Author

I'm not sure if anyone is waiting for me on this, but on my screen it says merging is blocked and "The base branch restricts merging to authorized users." I would click merge if I could, but if anyone wants it merged someone else will have to click it.

@y4my4my4m
Copy link
Collaborator

@tinkeros yes, Tom will get it fixed soon.

@y4my4my4m y4my4my4m merged commit e65f27c into Zeal-Operating-System:master Feb 25, 2023
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

Successfully merging this pull request may close these issues.

Add mouse aim to CastleFrankenstein.
6 participants