Example #1
0
bool Input::HandleMessage(HWND _HWND, UINT _Message, WPARAM _WParam, LPARAM _LParam)
{
	//printf("Message %i 0x%x.\n", _Message, _Message);

	switch(_Message)
	{
		// Keyboard Input.
		//										If it's not already down.
		case WM_SYSKEYDOWN:		
		case WM_KEYDOWN:	if(!Input::m_KeyStates[GetKeyCode(_LParam)])	Input::OnKeyDown((Key)GetKeyCode(_LParam));	return true;
		case WM_SYSKEYUP:		
		case WM_KEYUP:														Input::OnKeyUp((Key)GetKeyCode(_LParam));	return true;
		case WM_MOUSEMOVE:		Input::OnMouseMove(short2(GetMouseXParam(_LParam), GetMouseYParam(_LParam)));			return true;

		// Mouse Input.
		// Down.
		case WM_LBUTTONDOWN:	Input::OnMouseBtnDown(MouseBtn::Left);													return true;
		case WM_RBUTTONDOWN:	Input::OnMouseBtnDown(MouseBtn::Right);													return true;
		case WM_MBUTTONDOWN:	Input::OnMouseBtnDown(MouseBtn::Middle);												return true;
		case WM_XBUTTONDOWN:	if(GetMouseXButton(_WParam) == 1)	Input::OnMouseBtnDown(MouseBtn::Btn4);
								else								Input::OnMouseBtnDown(MouseBtn::Btn5);				return true;
		// Up.
		case WM_LBUTTONUP:		Input::OnMouseBtnUp(MouseBtn::Left);													return true;
		case WM_RBUTTONUP:		Input::OnMouseBtnUp(MouseBtn::Right);													return true;
		case WM_MBUTTONUP:		Input::OnMouseBtnUp(MouseBtn::Middle);													return true;
		case WM_XBUTTONUP:		if(GetMouseXButton(_WParam) == 1)	Input::OnMouseBtnUp(MouseBtn::Btn4);
								else								Input::OnMouseBtnUp(MouseBtn::Btn5);				return true;
	}

	return false;
}
Example #2
0
void TestTwine009Compare_ToTwine()
{
	BEGIN_TEST_METHOD( "TestTwine009Compare_ToTwine" )
	
	twine empty1;
	twine empty2;
	twine short1 = "Something Short";
	twine short2 = "Something Short";
	twine long1 = "Something A Bit Longer that Will cause us to allocate memory";
	twine long2 = "Something A Bit Longer that Will cause us to allocate memory";

	// Ensure that everything has different data pointers:
	ASSERT_NOTEQUALS( empty1(), empty2(), "empty1 and empty2 point to the same memory");
	ASSERT_NOTEQUALS( short1(), short2(), "short1 and short2 point to the same memory");
	ASSERT_NOTEQUALS( long1(), long2(), "long1 and long2 point to the same memory");

	ASSERT_EQUALS( 0, empty1.compare( empty2 ), "empty1.compare( empty2 ) != 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( short1 ), "empty1.compare( short1 ) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( short2 ), "empty1.compare( short2 ) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( long1 ), "empty1.compare( long1) == 0");
	ASSERT_NOTEQUALS( 0, empty1.compare( long2 ), "empty1.compare( long2) == 0");

	ASSERT_EQUALS( 0, short1.compare( short2 ), "short1.compare( short2 ) != 0");
	ASSERT_NOTEQUALS( 0, short1.compare( empty1 ), "short1.compare( empty1 ) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( empty2), "short1.compare( empty2) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( long1 ), "short1.compare( long1) == 0");
	ASSERT_NOTEQUALS( 0, short1.compare( long2 ), "short1.compare( long2) == 0");
	
	ASSERT_EQUALS( 0, long1.compare( long2 ), "long1.compare( long2 ) != 0");
	ASSERT_NOTEQUALS( 0, long1.compare( empty1 ), "long1.compare( empty1 ) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( empty2), "long1.compare( empty2) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( short1 ), "long1.compare( short1) == 0");
	ASSERT_NOTEQUALS( 0, long1.compare( short2 ), "long1.compare( short2) == 0");

	END_TEST_METHOD
}