예제 #1
0
/*
 * InitMouse - initialize the mouse
 */
void InitMouse( void )
{
    USHORT          events;

    if( !EditFlags.UseMouse ) {
        return;
    }

    if( MouOpen( 0L, &mouseHandle ) != 0 ) {
        EditFlags.UseMouse = FALSE;
        return;
    }
    events = 0x007f;
    if( MouSetEventMask( &events, mouseHandle ) != 0 ) {
        events = 0x001f;
        if( MouSetEventMask( &events, mouseHandle ) == 0 ) {
            mouseHasTwoButtons = TRUE;
        }
    }

    SetMousePosition( WindMaxWidth / 2 - 1, WindMaxHeight / 2 - 1 );
    SetMouseSpeed( MouseSpeed );
    PollMouse( &MouseStatus, &MouseRow, &MouseCol );

} /* InitMouse */
예제 #2
0
파일: dospeg.cpp 프로젝트: garyqinyu/abv
void PegIdleFunction(void)
{
    PollTime();

    #ifdef PEG_MOUSE_SUPPORT
    PollMouse();
    #endif

    #ifndef __WATCOMC__
    PollKeyboard();
    #endif
}
예제 #3
0
파일: Input.cpp 프로젝트: Vavassor/meteor
void Input::PollKeyboardAndMouse()
{
	// set controller to defaults before polling
	Controller& controller = controllers[0];

	for(int i = 0; i < NUM_BUTTONS; ++i)
		controller.buttons[i] = false;

	controller.leftAnalog[0] = controller.rightAnalog[0] = 0.0f;
	controller.leftAnalog[1] = controller.rightAnalog[1] = 0.0f;
	controller.leftTrigger = controller.rightTrigger = 0.0f;

	// poll keyboard and mouse buttons
	char keys[256];
	PollKeyboard(keys);

	bool buttonsPressed[NUM_BUTTONS];
	for(int i = 0; i < NUM_BUTTONS; ++i)
		buttonsPressed[i] = GET_KEY_STATE(keyBindings[i], keys);

	bool mappingsPressed[NUM_MAPPINGS];
	for(int i = 0; i < NUM_MAPPINGS; ++i)
		mappingsPressed[i] = GET_KEY_STATE(keyBindings[NUM_BUTTONS + i], keys);

	// update controller and buttons with polled values
	for(int i = 0; i < NUM_BUTTONS; ++i)
		controller.buttons[i] = buttonsPressed[i];

	if(mappingsPressed[L_TRIGGER]) controller.leftTrigger = 1.0f;
	if(mappingsPressed[R_TRIGGER]) controller.rightTrigger = 1.0f;

	float dx = 0.0f, dy = 0.0f;
	if(mappingsPressed[A_LEFT])  dx -= 1.0f;
	if(mappingsPressed[A_RIGHT]) dx += 1.0f;
	if(mappingsPressed[A_UP])    dy += 1.0f;
	if(mappingsPressed[A_DOWN])  dy -= 1.0f;

	float magnitude = sqrt(dx * dx + dy * dy);
	if(magnitude > 0.0f)
	{
		controller.leftAnalog[0] = dx / magnitude;
		controller.leftAnalog[1] = dy / magnitude;
	}

	PollMouse(&controller);
}
예제 #4
0
void CD3DApp::Loop(void (*loopFunction)())
{
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));
	while (msg.message != WM_QUIT) {
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg); }
		else {
			if (m_bPaused)
				Sleep(80);
			else {
				CalculateTime(); 
				PollKeyboard();
				PollMouse();

				loopFunction();
			}
		}
	}
}
예제 #5
0
파일: main.cpp 프로젝트: qpHalcy0n/Mooball
int main(int argc, char** argv)
{

	int dw = GetScreenWidth();
	int dh = GetScreenHeight();

	vec3 icp = {0.0F, 4.0F, 8.0F};
	vec3 icl = {0.0F, 0.0F, 0.0F};
	vec3 icu = {0.0F, 1.0F, 0.0F};
	g_globalCam.SetCamera(icp, icl, icu);
	g_globalCam.SetPerspective(65.0F, dw / (float)dh, 0.1F, 1000.0F);



	// Query extension base //
	CreateAppWindow("Mooball", dw, dh, 32, false);
	initExtensions();
	InitKeys();

	srand(time(NULL));

	// Query Device capabilities //
	if(!ValidateDevice())
	{
		DestroyAppWindow();
		return 0;
	}
	g_pTexInterface = new CTextureInterface;
	g_pShaderInterface = new CShaderInterface;
	g_lightManager = new CLightManager;
	g_bMSAA = (quickINI::Instance()->getValueAsInt("msaa") > 0) && (g_pTexInterface->GetMaxMSAA() > 0);
	g_bVSYNC = quickINI::Instance()->getValueAsInt("vsync") > 0;

//	g_model.Load( "Media/Models/Pokeball.3ds" );
	CModelObject* pMdl = new COBJModel;
	std::string err = pMdl->LoadModel("sponza.obj", "Media/Models/");

	// Initialize CG Runtime and shaders //
	init_cg();

	// Turn vsync on //
	if( EXT_VSYNC && g_bVSYNC )
	{
        #ifdef WIN32
            wglSwapIntervalEXT(1);
        #else
            glXSwapIntervalSGI(1);
        #endif
	}

	// Create offscreen targets and depth configurations //
	init_render_targets();

	// Added 8/4/10 - Keeps Mooball from hogging
	// the input focus while it's minimized.
//	HWND windowHandle = GetFocus();

	while(running)
	{
		if(QueryQuitMsg())
			running = false;

		else
		{
			if(!g_bDebugMode)
			{
				UpdateScene();
				PollKeys();
				PollMouse();
			}
			RenderScene();
			FlipBuffers();
		}

	}

	// Fall through to destruction //
	DestroyAppWindow();

	delete g_lightManager;
	delete g_pTexInterface;
	delete g_pShaderInterface;

	return 0;
}