예제 #1
0
int ProcessButtonBinding(Binding *b, ButtonSum *sum, int value) {
	if (value < b->deadZone || !value) return 0;

	if (config.turboKeyHack == 1){ // send a tabulator keypress to emulator
		//printf("%x\n", b->command);
		if (b->command == 0x11){ // L3 button
			static unsigned int LastCheck = 0;
			unsigned int t = timeGetTime();
			if (t - LastCheck < 300) return 0;
			QueueKeyEvent(VK_TAB, KEYPRESS);
			LastCheck = t;
		}
	}

	int sensitivity = b->sensitivity;
	if (sensitivity < 0) {
		sensitivity = -sensitivity;
		value = (1 << 16) - value;
	}
	if (value < 0) return 0;

	/* Note:  Value ranges of FULLY_DOWN, and sensitivity of
	 *  BASE_SENSITIVITY corresponds to an axis/button being exactly fully down.
	 *  Math in next line takes care of those two conditions, rounding as necessary.
	 *  Done using __int64s because overflows will occur when
	 *  sensitivity > BASE_SENSITIVITY and/or value > FULLY_DOWN.  Latter only happens
	 *  for relative axis.
	 */
	int force = (int)((((sensitivity*(255 * (__int64)value)) + BASE_SENSITIVITY / 2) / BASE_SENSITIVITY + FULLY_DOWN / 2) / FULLY_DOWN);
	AddForce(sum, b->command, force);

	return 1;
}
예제 #2
0
void WindowsKeyboard::UpdateKey(int vkey, int state) {
	if (vkey > 7 && vkey < 256) {
		int newState = state * FULLY_DOWN;
		if (newState != physicalControlState[vkey]) {
			// Check for alt-F4 to avoid toggling skip mode incorrectly.
			if (vkey != VK_F4 || !(physicalControlState[VK_MENU] || physicalControlState[VK_RMENU] || physicalControlState[VK_LMENU])) {
				int event = KEYPRESS;
				if (!newState) event = KEYRELEASE;
				QueueKeyEvent(vkey, event);
			}
		}
		physicalControlState[vkey] = newState;
	}
}
예제 #3
0
inline void ReleaseModifierKeys() {
	QueueKeyEvent(VK_SHIFT, KEYRELEASE);
	QueueKeyEvent(VK_MENU, KEYRELEASE);
	QueueKeyEvent(VK_CONTROL, KEYRELEASE);
}