static gboolean yui_gl_hide_cursor(GtkWidget * widget, GdkEventMotion * event, gpointer user_data) { if (PerGetId(padbits) == PERMOUSE) { int x = event->x; int y = event->y; double speed = g_key_file_get_double(keyfile, "General", "MouseSpeed", NULL); PerMouseMove(padbits, speed * (x - oldx), -speed * (y - oldy)); oldx = x; oldy = y; } if (beforehiding == 0) { gdk_window_set_cursor(widget->window, NULL); g_timeout_add(1000, gonna_hide, widget); } beforehiding = 2; return FALSE; }
void PollKeys(void) { u32 i; DWORD i2; DWORD size=8; DIDEVICEOBJECTDATA didod[8]; HRESULT hr; for (i = 0; i < numpads; i++) { if (paddevice[i].lpDIDevice == NULL) continue; hr = IDirectInputDevice8_Poll(paddevice[i].lpDIDevice); if (FAILED(hr)) { if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { // Make sure device is acquired while(IDirectInputDevice8_Acquire(paddevice[i].lpDIDevice) == DIERR_INPUTLOST) {} continue; } } size = 8; // Poll events if (FAILED(IDirectInputDevice8_GetDeviceData(paddevice[i].lpDIDevice, sizeof(DIDEVICEOBJECTDATA), didod, &size, 0))) { if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { // Make sure device is acquired while(IDirectInputDevice8_Acquire(paddevice[i].lpDIDevice) == DIERR_INPUTLOST) {} continue; } } if (size == 0) continue; switch (paddevice[i].type) { case TYPE_KEYBOARD: // This probably could be optimized for (i2 = 0; i2 < size; i2++) { if (didod[i2].dwData & 0x80) PerKeyDown(didod[i2].dwOfs); else PerKeyUp(didod[i2].dwOfs); } break; case TYPE_JOYSTICK: { // This probably could be optimized for (i2 = 0; i2 < size; i2++) { // X Axis if (didod[i2].dwOfs == DIJOFS_X) { if (didod[i2].dwData < 0x3FFF) { PerKeyDown(PAD_DIR_AXISLEFT); PerKeyUp(PAD_DIR_AXISRIGHT); } else if (didod[i2].dwData > 0xBFFF) { PerKeyDown(PAD_DIR_AXISRIGHT); PerKeyUp(PAD_DIR_AXISLEFT); } else { PerKeyUp(PAD_DIR_AXISLEFT); PerKeyUp(PAD_DIR_AXISRIGHT); } } // Y Axis else if (didod[i2].dwOfs == DIJOFS_Y) { if (didod[i2].dwData < 0x3FFF) { PerKeyDown(PAD_DIR_AXISUP); PerKeyUp(PAD_DIR_AXISDOWN); } else if (didod[i2].dwData > 0xBFFF) { PerKeyDown(PAD_DIR_AXISDOWN); PerKeyUp(PAD_DIR_AXISUP); } else { PerKeyUp(PAD_DIR_AXISUP); PerKeyUp(PAD_DIR_AXISDOWN); } } else if (didod[i2].dwOfs == DIJOFS_POV(0)) { // POV Center if (LOWORD(didod[i2].dwData) == 0xFFFF) { PerKeyUp(PAD_DIR_POVUP); PerKeyUp(PAD_DIR_POVRIGHT); PerKeyUp(PAD_DIR_POVDOWN); PerKeyUp(PAD_DIR_POVLEFT); } // POV Up else if (didod[i2].dwData < 4500) { PerKeyDown(PAD_DIR_POVUP); PerKeyUp(PAD_DIR_POVRIGHT); PerKeyUp(PAD_DIR_POVLEFT); } // POV Up-right else if (didod[i2].dwData < 9000) { PerKeyDown(PAD_DIR_POVUP); PerKeyDown(PAD_DIR_POVRIGHT); } // POV Right else if (didod[i2].dwData < 13500) { PerKeyDown(PAD_DIR_POVRIGHT); PerKeyUp(PAD_DIR_POVDOWN); PerKeyUp(PAD_DIR_POVUP); } // POV Right-down else if (didod[i2].dwData < 18000) { PerKeyDown(PAD_DIR_POVRIGHT); PerKeyDown(PAD_DIR_POVDOWN); } // POV Down else if (didod[i2].dwData < 22500) { PerKeyDown(PAD_DIR_POVDOWN); PerKeyUp(PAD_DIR_POVLEFT); PerKeyUp(PAD_DIR_POVRIGHT); } // POV Down-left else if (didod[i2].dwData < 27000) { PerKeyDown(PAD_DIR_POVDOWN); PerKeyDown(PAD_DIR_POVLEFT); } // POV Left else if (didod[i2].dwData < 31500) { PerKeyDown(PAD_DIR_POVLEFT); PerKeyUp(PAD_DIR_POVUP); PerKeyUp(PAD_DIR_POVDOWN); } // POV Left-up else if (didod[i2].dwData < 36000) { PerKeyDown(PAD_DIR_POVLEFT); PerKeyDown(PAD_DIR_POVUP); } } else if (didod[i2].dwOfs >= DIJOFS_BUTTON(0) && didod[i2].dwOfs <= DIJOFS_BUTTON(127)) { if (didod[i2].dwData & 0x80) PerKeyDown(didod[i2].dwOfs); else PerKeyUp(didod[i2].dwOfs); } } break; } case TYPE_MOUSE: for (i2 = 0; i2 < size; i2++) { if (didod[i2].dwOfs == DIMOFS_X) // X Axis PerMouseMove((PerMouse_struct *)pad[i], (s32)didod[i2].dwData, 0); else if (didod[i2].dwOfs == DIMOFS_Y) // Y Axis PerMouseMove((PerMouse_struct *)pad[i], 0, 0-(s32)didod[i2].dwData); else if (didod[i2].dwOfs >= DIMOFS_BUTTON0 && didod[i2].dwOfs <= DIMOFS_BUTTON7) { // Mouse Buttons if (didod[i2].dwData & 0x80) PerKeyDown(didod[i2].dwOfs-DIMOFS_BUTTON0); else PerKeyUp(didod[i2].dwOfs-DIMOFS_BUTTON0); } } break; default: break; } } }