Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add device configuration #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export interface From {
simultaneous?: SimultaneousFrom[];
simultaneous_options?: SimultaneousOptions;
modifiers?: Modifiers;
pointing_button?: string;
}

export interface Modifiers {
Expand Down Expand Up @@ -131,6 +132,34 @@ export interface MouseKey {
horizontal_wheel?: number;
}

export interface Device {
disable_built_in_keyboard_if_exists: boolean,
fn_function_keys: Pick<Manipulator, "to" | "from">[],
game_pad_swap_sticks: boolean,
identifiers: {
is_game_pad: boolean,
is_keyboard: boolean,
is_pointing_device: boolean,
product_id: number,
vendor_id: number
},
ignore: boolean,
manipulate_caps_lock_led: boolean,
mouse_flip_horizontal_wheel: boolean,
mouse_flip_vertical_wheel: boolean,
mouse_flip_x: boolean,
mouse_flip_y: boolean,
mouse_swap_wheels: boolean,
mouse_swap_xy: boolean,
simple_modifications: Pick<Manipulator, "to" | "from">[],
treat_as_built_in_keyboard: boolean
}

export interface DeviceOptions {
reverseVWheel?: boolean,
reverseHWheel?: boolean
}

export interface SoftwareFunction {
iokit_power_management_sleep_system?: {};
}
Expand Down
27 changes: 26 additions & 1 deletion utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { To, KeyCode, Manipulator, KarabinerRules } from "./types";
import { To, KeyCode, Manipulator, KarabinerRules, Device, DeviceOptions } from "./types";

/**
* Custom way to describe a command in a layer
Expand Down Expand Up @@ -149,6 +149,31 @@ function generateSubLayerVariableName(key: KeyCode) {
return `hyper_sublayer_${key}`;
}

export function createDeviceConfiguration(productId: number, vendorId: number, options?: DeviceOptions): Device {
return {
disable_built_in_keyboard_if_exists: false,
fn_function_keys: [],
game_pad_swap_sticks: false,
identifiers: {
is_game_pad: false,
is_keyboard: false,
is_pointing_device: true,
product_id: productId,
vendor_id: vendorId
},
ignore: false,
manipulate_caps_lock_led: false,
mouse_flip_horizontal_wheel: options?.reverseHWheel ?? false,
mouse_flip_vertical_wheel: options?.reverseVWheel ?? false,
mouse_flip_x: false,
mouse_flip_y: false,
mouse_swap_wheels: false,
mouse_swap_xy: false,
simple_modifications: [],
treat_as_built_in_keyboard: false
};
}

/**
* Shortcut for "open" shell command
*/
Expand Down