Access mouse and keyboard input in ACS

Moderator: GZDoom Developers

Posts: 44
Joined: Fri Dec 05, 2003 5:35 am

Access mouse and keyboard input in ACS

Post by Jonathan »

Here's a fun one. I would very much appreciate a proper way to get mouse and keyboard "events" from within ACS. This is something that came up while all those ACS mini-games were being made a while back (I made Pacman), but I had been thinking about it for a little while longer than that.

Beyond controlling ACS mini-games, keyboard input would be nice for doing things like consoles and keypads into which the player can type. I think RTC-3057 already allows this somewhat, so it'd be nice to see it in Zdoom proper. Mouse input would would be great for a lot of things, but my own aim would be to build an rpg style menu/inventory system, system-shock 2 style, or something similar.

What you'd need:
StartMouseHandling() and StopMouseHandling()
Two inbuilt functions which would instruct Zdoom to (possibly?) suspend normal mouse handling, pass mouse events to ACS for the duration, and display the mouse cursor.

A method to set the mouse cursor graphic. I guess this would most likely follow the conventions of current HUD message display.

Event handlers / callbacks
You need some way to setup handlers for events within ACS. You could have predefined functions such as MouseClicked(int x, int y, int button) which would be implemented by the script editor and detected and called by Zdoom if they existed. Or you could have a method to register scripts by number at runtime, with a function such as RegisterMouseEventHandler(int scriptnum, int EVENT_TYPE). A good event set would seem to be: moved, clicked, pressed and released.

General interrogation functions
A few generic functions to get info from the mouse, whether within a handler or not. GetMouseX, GetMouseY, GetMouseButtonState.

Keyboard input
I imagine this would be similar to the above. I don't think it necessarily be a good idea to disable the games own keyboard handling by default (and obviously some keys, such as escape, would always work). As well as getting keypress events, it would be useful to have a generic method to access the state of any key via its scancode.

Anyway, that's about all I can think of right now. Obviously I'm aware implementing this wouldn't be a trivial undertaking, and I don't expect to see it done any time soon, but I think it would be a very nice extension if it was done.
User avatar
Posts: 1616
Joined: Wed Feb 09, 2005 3:09 pm

Post by Belial »

Excellent idea. SS2 styled inventory/stat system implementation in a mod would really expand ZDoom's TC capabilities.
User avatar
Posts: 863
Joined: Sun Aug 29, 2004 6:15 am
Location: Sydney, Australia

Post by Sir_Alien »

I second everything! This is something I would love to use in my project. It could also be used for oldschool sierra style conversation.
User avatar
Bio Hazard
Posts: 4019
Joined: Fri Aug 15, 2003 8:15 pm
Location: ferret ~/C/ZDL $

Post by Bio Hazard »

I personally would doeverything the same way windows does it with messages.

Code: Select all

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){
		case IN_MOUSECLICK:return 0;
		case IN_MOUSEMOVE:return 0;
		case IN_KEYDOWN:Keys[(int)wParam]=TRUE;return 0;
		case IN_KEYUP:Keys[(int)wParam]=FALSE;return 0;
		default:return DefWindowProc(hWnd,message,wParam,lParam);
But of course it would be quite difficult to implement all this, but it doesn't hurt to ask :)

Return to “Closed Feature Suggestions [GZDoom]”