I am trying to use SDL with the Raw Input API but whenever SDL sends me a keyboard input message, the msg it sends me is an invalid pointer and it gives me an access violation when I try to use it. I check to see if it's invalid for other kinds of events (like the events SDL sends me when the program starts up) and it's valid for those events. This is the code I have. My question is why is the msg an invalid pointer and is there any way I could get at it.

void CSystemEvent::TranslateEvent( SDL_Event *sysevent )
{
	switch( sysevent->type )
	{
	case SDL_QUIT:
		m_eventtype = ET_QUIT;
		break;
	case SDL_KEYDOWN:
		m_eventtype = ET_KEYDOWN;
		m_keypressed = sysevent->key.keysym.sym;

                ////////////////////////////////////////////////////
                // Here is where the msg is an invalid pointer
                ////////////////////////////////////////////////////

		input->InputRecieved( sysevent->syswm.msg->lParam );
		break;
	case SDL_KEYUP:
		m_eventtype = ET_KEYUP;
		m_keypressed = sysevent->key.keysym.sym;
		break;
	case SDL_MOUSEBUTTONDOWN:
		m_eventtype = ET_MOUSEDOWN;
		m_keypressed = sysevent->button.button;
		break;
	case SDL_MOUSEBUTTONUP:
		m_eventtype = ET_MOUSEUP;
		m_keypressed = sysevent->button.button;
		break;
	case SDL_MOUSEMOTION:
		m_eventtype = ET_MOUSEMOVE;
		m_position.x = sysevent->motion.x;
		m_position.y = sysevent->motion.y;
		break;
	}
}

If I have missed out any needed information just ask.

See the links in my post in your other thread on the same subject (getting WM_INPUT message).

Note that lParam has the handle to the RAWINPUT structure, not a pointer to it. To get the raw data, use the handle in the call to GetRawInputData.

link

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.