Example #1
0
static void handle_mouse_key_event(Key mappedKey, uint8_t keyState) {
    if (key_toggled_off(keyState)) {
	    if (mappedKey.keyCode & KEY_MOUSE_UP || mappedKey.keyCode & KEY_MOUSE_DOWN) {
		MouseWrapper.mouseActiveForCyclesY=0;
	    }
	    if (mappedKey.keyCode & KEY_MOUSE_LEFT || mappedKey.keyCode & KEY_MOUSE_RIGHT) {
		MouseWrapper.mouseActiveForCyclesX=0;
	    } 
    }

    if (!key_is_pressed(keyState))
        return;

    if (mappedKey.keyCode & KEY_MOUSE_UP) {
        MouseWrapper.move(0,-1);
    } else if (mappedKey.keyCode & KEY_MOUSE_DOWN) {
        MouseWrapper.move(0,1);
    }

    if (mappedKey.keyCode & KEY_MOUSE_LEFT) {
        MouseWrapper.move(-1,0);
    } else if (mappedKey.keyCode & KEY_MOUSE_RIGHT) {
        MouseWrapper.move(1,0);
    }
}
Example #2
0
static Key handleMouseKeys(Key mappedKey, byte row, byte col, uint8_t keyState) {
    if (mappedKey.flags != (SYNTHETIC | IS_MOUSE_KEY))
        return mappedKey;

    if (mappedKey.keyCode & KEY_MOUSE_BUTTON) {
        uint8_t button = mappedKey.keyCode & ~KEY_MOUSE_BUTTON;

        if (key_toggled_on(keyState)) {
            MouseWrapper.press_button(button);
        } else if (key_toggled_off(keyState)) {
            MouseWrapper.release_button(button);
        }
    } else if (!(mappedKey.keyCode & KEY_MOUSE_WARP)) {
        handle_mouse_key_event(mappedKey, keyState);
    } else if (key_toggled_on(keyState)) {
        if (mappedKey.keyCode & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) {
            // we don't pass in the left and up values because those are the
            // default, "no-op" conditionals
            MouseWrapper.warp( ((mappedKey.keyCode & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) |
                               ((mappedKey.keyCode & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) |
                               ((mappedKey.keyCode & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00) );
        }
    }

    return Key_NoKey;
}
Example #3
0
void handle_synthetic_key_event(uint8_t switchState, Key mappedKey) {
    if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) {
        handle_mouse_key_event(switchState, mappedKey);
    } else if (! (mappedKey.flags & IS_INTERNAL)
          && (mappedKey.rawKey == KEY_MOUSE_BTN_L
               || mappedKey.rawKey == KEY_MOUSE_BTN_M
               || mappedKey.rawKey == KEY_MOUSE_BTN_R)) {
        if (key_toggled_on (switchState)) {
            MouseWrapper.press_button(
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_L ?  KEY_MOUSE_BUTTON_LEFT   : 0x00) |
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_M ?  KEY_MOUSE_BUTTON_MIDDLE : 0x00) |
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_R ?  KEY_MOUSE_BUTTON_RIGHT  : 0x00) );
        } else if (key_toggled_off(switchState)) {
            MouseWrapper.release_button(
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_L ?  KEY_MOUSE_BUTTON_LEFT   : 0x00) |
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_M ?  KEY_MOUSE_BUTTON_MIDDLE : 0x00) |
                (mappedKey.rawKey ==  KEY_MOUSE_BTN_R ?  KEY_MOUSE_BUTTON_RIGHT  : 0x00) );
        }
    }


    else if (key_toggled_on(switchState)) {
        if (mappedKey.rawKey & KEY_MOUSE_WARP && mappedKey.flags & IS_MOUSE_KEY) {
            // we don't pass in the left and up values because those are the
            // default, "no-op" conditionals
            MouseWrapper.warp( ((mappedKey.rawKey & KEY_MOUSE_WARP_END) ? WARP_END : 0x00) |
                               ((mappedKey.rawKey & KEY_MOUSE_DOWN) ? WARP_DOWN : 0x00) |
                               ((mappedKey.rawKey & KEY_MOUSE_RIGHT) ? WARP_RIGHT : 0x00) );
        } else if (mappedKey.flags & IS_CONSUMER) {
            ConsumerControl.press(mappedKey.rawKey);
        } else if (mappedKey.flags & IS_INTERNAL) {
            if (mappedKey.rawKey == LED_TOGGLE) {
                LEDControl.next_mode();
            }
        } else if (mappedKey.flags & IS_SYSCTL) {
            SystemControl.press(mappedKey.rawKey);
        } else  if (mappedKey.flags & IS_MACRO) {
            if (mappedKey.rawKey == 1) {
                Serial.print("Keyboard.IO keyboard driver v0.00");
            }
        }

    }
}
Example #4
0
void handle_keymap_key_event(uint8_t switchState, Key keymapEntry) {
    if (keymapEntry.flags & MOMENTARY ) {
        if (key_toggled_on(switchState)) {
            if ( keymapEntry.rawKey == KEYMAP_NEXT) {
                temporary_keymap++;
            } else if ( keymapEntry.rawKey == KEYMAP_PREVIOUS) {
                temporary_keymap--;
            } else {
                temporary_keymap = keymapEntry.rawKey;
            }
        }
        if (key_toggled_off(switchState)) {
            temporary_keymap = primary_keymap;
        }

        // switch keymap and stay there
    } else if (key_toggled_on(switchState)) {
        temporary_keymap = primary_keymap = keymapEntry.rawKey;
        Storage.save_primary_keymap(primary_keymap);
    }
}