-
Notifications
You must be signed in to change notification settings - Fork 68
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
Conversation
There was a problem hiding this 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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this 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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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. |
@tinkeros yes, Tom will get it fixed soon. |
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.