[solved] Having trouble with the mouse wheel (ClanLib)

Started by
4 comments, last by jonahrowley 18 years ago
This has been driving me nuts, and google has not resulted in any success. I am using ClanLib for my graphics and input, and I'm having trouble specifically getting access to the mouse wheel. What I want, is when the mouse wheel is scrolled up, that it scrolls my chat buffer up, and vice versa when going down. I already confirmed those specific actions work, and that the problem relies entirely in how I check if the mouse wheel moved.
if(CL_Mouse::get_keycode(CL_MOUSE_WHEEL_UP))
{
	CHAT_BUFFER_OFFSET -= 1;
}
If it helps, the keys.h that is part of clanlib has a few mouse specific defines
#define CL_MOUSE_LEFT 0
#define CL_MOUSE_RIGHT 1
#define CL_MOUSE_MIDDLE 2
#define CL_MOUSE_WHEEL_UP 3
#define CL_MOUSE_WHEEL_DOWN 4
#define CL_MOUSE_XBUTTON1 5
#define CL_MOUSE_XBUTTON2 6
When I replace the keycode check with any other mouse keycode, they all work except for CL_MOUSE_WHEEL_UP and CL_MOUSE_WHEEL_DOWN. So I must be doing something wrong, and I have been unable to google anything up. Anyone that knows what I'm doing wrong? [Edited by - Necrosis on April 1, 2006 6:31:36 PM]
Advertisement
Have you tried any other methods for recieving input from the mouse wheel?

Dave
I know of no other way to recieve mouse inputs, and it doesnt seem to be documented very well (or at least not well enough for me to find). Some of the gamedev searches had various solutions relating to windows event stuff, but the thing is, my ClanLib application contains no windows code at all so I wouldnt know how to implement that, or if I can at all.

I have no objection to using an extra library just for getting the mouse wheel input, but searching for such a library has been less than satisfactory. I came across something called ConLib that claimed it could do it, but had NO documentation and I couldnt make heads or tails of the comments, so I removed it. I'm more than happy to use whatever gets the job done :)

Edit: My target platform is Windows 2000/XP
I use the signals and slots mechanism for input. It really does make things easy, especially since as soon as the CL_Slot objects go out of scope, they get disconnected. Clanlib does all kinds of cool stuff with scope. Just hook CL_Mouse::sig_key_down() to a slot that takes a single const CL_InputEvent& argument and look at the argument's id member variable. Its value will be the same as the macros you posted.
OMG, cant believe I managed to implement what you said. I was lucky and already had a slot for key that existed (from example code from my last clanlib project) that I didnt use. I copied it, renamed a new function, switched get_keyboard() to get_mouse(), and my mouse wheel works now! Thank you, if it helps anyone else, this is what my code looks like for it.

// up in my init sectionCL_Slot slot_mouse_input_up = (window.get_ic()->get_mouse()).sig_key_up().connect(this, &GAMEPROTOTYPE::on_mouse_input_up);void on_mouse_input_up(const CL_InputEvent &key){	switch(key.id)	{	case CL_MOUSE_WHEEL_UP:		CHAT_BUFFER_OFFSET--;		break;	case CL_MOUSE_WHEEL_DOWN:		CHAT_BUFFER_OFFSET++;		break;	}}

I would switch all my input the signal/slot. It's just a lot cleaner, when you call keep_alive, input events get pumped, and stuff gets updated via callbacks. When your objects get deleted or go out of scope, they clean up their own handlers automatically. Very clean, no millions of checks for input all over the place in your code.

This topic is closed to new replies.

Advertisement