瀏覽代碼

Fix build option MOUSEKEY_ENABLE.

tags/v1.9
tmk 11 年之前
父節點
當前提交
5b00cf3f02
共有 4 個檔案被更改,包括 34 行新增18 行删除
  1. 11
    1
      common/keyboard.c
  2. 21
    15
      common/mousekey.c
  3. 1
    1
      keyboard/hhkb/config.h
  4. 1
    1
      keyboard/hhkb/config_vusb.h

+ 11
- 1
common/keyboard.c 查看文件

host_system_send(0); host_system_send(0);
host_consumer_send(0); host_consumer_send(0);


#ifdef MOUSEKEY_ENABLE
mousekey_clear(); mousekey_clear();
mousekey_send(); mousekey_send();
#endif
} }


static void clear_keyboard_but_mods(void) static void clear_keyboard_but_mods(void)
host_system_send(0); host_system_send(0);
host_consumer_send(0); host_consumer_send(0);


#ifdef MOUSEKEY_ENABLE
mousekey_clear(); mousekey_clear();
mousekey_send(); mousekey_send();
#endif
} }


static void layer_switch_on(uint8_t code) static void layer_switch_on(uint8_t code)
host_send_keyboard_report(); host_send_keyboard_report();
} }
else if IS_MOUSEKEY(code) { else if IS_MOUSEKEY(code) {
#ifdef MOUSEKEY_ENABLE
mousekey_on(code); mousekey_on(code);
mousekey_send(); mousekey_send();
#endif
} }
else if IS_CONSUMER(code) { else if IS_CONSUMER(code) {
uint16_t usage = 0; uint16_t usage = 0;
host_send_keyboard_report(); host_send_keyboard_report();
} }
else if IS_MOUSEKEY(code) { else if IS_MOUSEKEY(code) {
#ifdef MOUSEKEY_ENABLE
mousekey_off(code); mousekey_off(code);
mousekey_send(); mousekey_send();
#endif
} }
else if IS_CONSUMER(code) { else if IS_CONSUMER(code) {
host_consumer_send(0x0000); host_consumer_send(0x0000);
case KEY_UP: case KEY_UP:
case MOD_UP: case MOD_UP:
unregister_code(code); unregister_code(code);
// no key registered? mousekey, mediakey, systemkey
// TODO: no key registered? mousekey, mediakey, systemkey
if (!host_has_anykey()) if (!host_has_anykey())
NEXT(IDLE); NEXT(IDLE);
break; break;
} }
} }


#ifdef MOUSEKEY_ENABLE
// mousekey repeat & acceleration // mousekey repeat & acceleration
mousekey_task(); mousekey_task();
#endif


// FAIL SAFE: clear all key if no key down // FAIL SAFE: clear all key if no key down
if (matrix_change) { if (matrix_change) {

+ 21
- 15
common/mousekey.c 查看文件

* see wikipedia http://en.wikipedia.org/wiki/Mouse_keys * see wikipedia http://en.wikipedia.org/wiki/Mouse_keys
*/ */
#ifndef MOUSEKEY_DELAY_TIME #ifndef MOUSEKEY_DELAY_TIME
# define MOUSEKEY_DELAY_TIME 20
# define MOUSEKEY_DELAY_TIME 100
#endif #endif


#define MOUSEKEY_MOVE_INIT 5 #define MOUSEKEY_MOVE_INIT 5


static inline uint8_t move_unit(void) static inline uint8_t move_unit(void)
{ {
uint16_t unit = 5 + mousekey_repeat*4;
uint16_t unit = MOUSEKEY_MOVE_INIT + MOUSEKEY_MOVE_ACCEL * mousekey_repeat;
return (unit > 63 ? 63 : unit); return (unit > 63 ? 63 : unit);
} }


static inline uint8_t wheel_unit(void)
{
uint16_t unit = MOUSEKEY_WHEEL_INIT + MOUSEKEY_WHEEL_ACCEL * mousekey_repeat;
return (unit > 15 ? 15 : unit);
}

void mousekey_task(void) void mousekey_task(void)
{ {
if (timer_elapsed(last_timer) < MOUSEKEY_DELAY_TIME) if (timer_elapsed(last_timer) < MOUSEKEY_DELAY_TIME)
report.y *= 0.7; report.y *= 0.7;
} }


if (report.v > 0) report.v = move_unit();
if (report.v < 0) report.v = move_unit() * -1;
if (report.h > 0) report.h = move_unit();
if (report.h < 0) report.h = move_unit() * -1;
if (report.v > 0) report.v = wheel_unit();
if (report.v < 0) report.v = wheel_unit() * -1;
if (report.h > 0) report.h = wheel_unit();
if (report.h < 0) report.h = wheel_unit() * -1;


mousekey_send(); mousekey_send();
} }


void mousekey_off(uint8_t code) void mousekey_off(uint8_t code)
{ {
if (code == KC_MS_UP && report.y < 0) report.y = 0;
else if (code == KC_MS_DOWN && report.y > 0) report.y = 0;
else if (code == KC_MS_LEFT && report.x < 0) report.x = 0;
else if (code == KC_MS_RIGHT && report.x > 0) report.x = 0;
if (code == KC_MS_UP && report.y < 0) report.y = 0;
else if (code == KC_MS_DOWN && report.y > 0) report.y = 0;
else if (code == KC_MS_LEFT && report.x < 0) report.x = 0;
else if (code == KC_MS_RIGHT && report.x > 0) report.x = 0;
else if (code == KC_MS_WH_UP && report.v > 0) report.v = 0; else if (code == KC_MS_WH_UP && report.v > 0) report.v = 0;
else if (code == KC_MS_WH_DOWN && report.v < 0) report.v = 0; else if (code == KC_MS_WH_DOWN && report.v < 0) report.v = 0;
else if (code == KC_MS_WH_LEFT && report.h < 0) report.h = 0; else if (code == KC_MS_WH_LEFT && report.h < 0) report.h = 0;
else if (code == KC_MS_WH_RIGHT && report.h > 0) report.h = 0; else if (code == KC_MS_WH_RIGHT && report.h > 0) report.h = 0;
else if (code == KC_MS_BTN1) report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) report.buttons &= ~MOUSE_BTN5;
else if (code == KC_MS_BTN1) report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) report.buttons &= ~MOUSE_BTN5;


if (report.x == 0 && report.y == 0 && report.v == 0 && report.h == 0) if (report.x == 0 && report.y == 0 && report.v == 0 && report.h == 0)
mousekey_repeat = 0; mousekey_repeat = 0;

+ 1
- 1
keyboard/hhkb/config.h 查看文件



/* mouse keys */ /* mouse keys */
#ifdef MOUSEKEY_ENABLE #ifdef MOUSEKEY_ENABLE
# define MOUSEKEY_DELAY_TIME 192
# define MOUSEKEY_DELAY_TIME 100
#endif #endif





+ 1
- 1
keyboard/hhkb/config_vusb.h 查看文件



/* mouse keys */ /* mouse keys */
#ifdef MOUSEKEY_ENABLE #ifdef MOUSEKEY_ENABLE
# define MOUSEKEY_DELAY_TIME 255
# define MOUSEKEY_DELAY_TIME 100
#endif #endif





Loading…
取消
儲存