コード例 #1
0
ファイル: keymap.c プロジェクト: 0xdec/qmk_firmware
uint32_t layer_state_set_user(uint32_t state) {
  current_layer_state = state;

  if (is_macro1_recording) {
    led_1_on();
    led_2_on();
    led_3_on();
    return state;
  }

  if (LAYER_ON(NUM)) {
    led_1_on();
  } else {
    led_1_off();
  }

  if (LAYER_ON(MAC)) {
    led_2_on();
  } else {
    led_2_off();
  }

  if (LAYER_ON(QWERTY)) {
    led_3_on();
  } else {
    led_3_off();
  }

  return state;
};
コード例 #2
0
ファイル: kbm2ctrl.c プロジェクト: Poopi/UsbXlater
void kbm2c_task(char force)
{
	static uint32_t lastReportTime;
	uint32_t nowTime = systick_1ms_cnt;

	if ((nowTime - lastReportTime) >= 10 || force != 0)
	{
		lastReportTime = nowTime;
		if ((nowTime - kbm2c_mouseTimestamp) > 21)
		{
			kbm2c_mouseTimestamp = nowTime;
			kbm2c_mouseData.x = 0;
			kbm2c_mouseData.y = 0;
		}
		else if ((nowTime - kbm2c_mouseTimestamp) > 13)
		{
			kbm2c_mouseTimestamp = nowTime;
			kbm2c_mouseData.x = (kbm2c_mouseData.x * (1.0d - kbm2c_config.mouse_filter));
			kbm2c_mouseData.y = (kbm2c_mouseData.y * (1.0d - kbm2c_config.mouse_filter));
			if (kbm2c_mouseData.x > kbm2c_config.mouse_decay) kbm2c_mouseData.x -= kbm2c_config.mouse_decay;
			else if (kbm2c_mouseData.x < -kbm2c_config.mouse_decay) kbm2c_mouseData.x += kbm2c_config.mouse_decay;
			if (kbm2c_mouseData.y > kbm2c_config.mouse_decay) kbm2c_mouseData.y -= kbm2c_config.mouse_decay;
			else if (kbm2c_mouseData.y < -kbm2c_config.mouse_decay) kbm2c_mouseData.y += kbm2c_config.mouse_decay;
		}

		dbgwdg_feed();
	}
	else {
		return;
	}

	// at this point, we should send a report

	memset(&ctrler_data, 0, sizeof(ctrler_data_t));

	if (KBM2C_CHECKKEY(KEYCODE_W, kbm2c_keyFlags)) {
		ctrler_data.left_y -= 127;
	}

	if (KBM2C_CHECKKEY(KEYCODE_S, kbm2c_keyFlags)) {
		ctrler_data.left_y += 127;
	}

	if (KBM2C_CHECKKEY(KEYCODE_A, kbm2c_keyFlags)) {
		ctrler_data.left_x -= 127;
	}

	if (KBM2C_CHECKKEY(KEYCODE_D, kbm2c_keyFlags)) {
		ctrler_data.left_x += 127;
	}

	if (KBM2C_CHECKMODKEY(KEYCODE_MOD_LEFT_ALT, kbm2c_keyFlags)) {
		kbm2c_rightGainIdx = 1;
		led_3_on();
	}
	else {
		kbm2c_rightGainIdx = 0;
		led_3_off();
	}

	ctrler_data.right_x = kbm2c_mouseData.x * 2;
	ctrler_data.right_y = kbm2c_mouseData.y * 2;

	if ((kbm2c_mouseData.btn & (1 << 0)) != 0) {
		ctrler_data.btnBits |= (1 << CTRLBTN_TRIGGER_RIGHT);
	}

	if ((kbm2c_mouseData.btn & (1 << 1)) != 0) {
		ctrler_data.btnBits |= (1 << CTRLBTN_TRIGGER_LEFT);
	}

	if ((kbm2c_mouseData.btn & (1 << 2)) != 0) {
		ctrler_data.btnBits |= (1 << CTRLBTN_R3);
	}

	if (kbm2c_mouseData.w > 3) {
		ctrler_data.btnBits |= (1 << CTRLBTN_DPAD_UP);
	}

	if (kbm2c_mouseData.w < -3) {
		ctrler_data.btnBits |= (1 << CTRLBTN_DPAD_DOWN);
	}

	if (kbm2c_mouseData.w > 0) {
		kbm2c_mouseData.w--;
	}
	else if (kbm2c_mouseData.w < 0) {
		kbm2c_mouseData.w++;
	}

	if (KBM2C_CHECKKEY(KEYCODE_R, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_SQR);
	}

	if (KBM2C_CHECKKEY(KEYCODE_C, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_CIR);
	}

	if (KBM2C_CHECKKEY(KEYCODE_Q, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_SELECT);
	}

	if (KBM2C_CHECKKEY(KEYCODE_G, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_BUMPER_LEFT);
	}

	if (KBM2C_CHECKKEY(KEYCODE_F, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_BUMPER_RIGHT);
	}

	if (KBM2C_CHECKKEY(KEYCODE_SPACE, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_X);
	}

	if (KBM2C_CHECKKEY(KEYCODE_1, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_TRI);
	}

	if (KBM2C_CHECKMODKEY(KEYCODE_MOD_LEFT_SHIFT, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_L3);
	}

	if (KBM2C_CHECKKEY(KEYCODE_2, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_DPAD_LEFT);
	}

	if (KBM2C_CHECKKEY(KEYCODE_3, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_DPAD_RIGHT);
	}

	if (KBM2C_CHECKKEY(KEYCODE_4, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_DPAD_UP);
	}

	if (KBM2C_CHECKKEY(KEYCODE_ESC, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_START);
	}

	if (KBM2C_CHECKKEY(KEYCODE_HOME, kbm2c_keyFlags)) {
		ctrler_data.btnBits |= (1 << CTRLBTN_HOME);
	}

	kbm2c_prepForPS4();
	ds4emu_report(ds4_outBuffer, ds4_outBufferLen);

	memcpy(kbm2c_keyFlagsPrev, kbm2c_keyFlags, KBM2C_KEYFLAGS_SIZE * sizeof(uint32_t));
}