📄 aiptek.c
字号:
s = "lens"; break; default: s = "unknown"; break; } return snprintf(buf, PAGE_SIZE, "%s\n", s);}static ssize_tstore_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (strcmp(buf, "mouse") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_MOUSE_MODE; } else if (strcmp(buf, "eraser") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_ERASER_MODE; } else if (strcmp(buf, "pencil") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_PENCIL_MODE; } else if (strcmp(buf, "pen") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_PEN_MODE; } else if (strcmp(buf, "brush") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_BRUSH_MODE; } else if (strcmp(buf, "airbrush") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_AIRBRUSH_MODE; } else if (strcmp(buf, "lens") == 0) { aiptek->newSetting.toolMode = AIPTEK_TOOL_BUTTON_LENS_MODE; } return count;}static DEVICE_ATTR(tool_mode, S_IRUGO | S_IWUGO, show_tabletToolMode, store_tabletToolMode);/*********************************************************************** * support routines for the 'xtilt' file. Note that this file * both displays current setting and allows reprogramming. */static ssize_t show_tabletXtilt(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (aiptek->curSetting.xTilt == AIPTEK_TILT_DISABLE) { return snprintf(buf, PAGE_SIZE, "disable\n"); } else { return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.xTilt); }}static ssize_tstore_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); int x; if (aiptek == NULL) return 0; if (strcmp(buf, "disable") == 0) { aiptek->newSetting.xTilt = AIPTEK_TILT_DISABLE; } else { x = (int)simple_strtol(buf, NULL, 10); if (x >= AIPTEK_TILT_MIN && x <= AIPTEK_TILT_MAX) { aiptek->newSetting.xTilt = x; } } return count;}static DEVICE_ATTR(xtilt, S_IRUGO | S_IWUGO, show_tabletXtilt, store_tabletXtilt);/*********************************************************************** * support routines for the 'ytilt' file. Note that this file * both displays current setting and allows reprogramming. */static ssize_t show_tabletYtilt(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (aiptek->curSetting.yTilt == AIPTEK_TILT_DISABLE) { return snprintf(buf, PAGE_SIZE, "disable\n"); } else { return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.yTilt); }}static ssize_tstore_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); int y; if (aiptek == NULL) return 0; if (strcmp(buf, "disable") == 0) { aiptek->newSetting.yTilt = AIPTEK_TILT_DISABLE; } else { y = (int)simple_strtol(buf, NULL, 10); if (y >= AIPTEK_TILT_MIN && y <= AIPTEK_TILT_MAX) { aiptek->newSetting.yTilt = y; } } return count;}static DEVICE_ATTR(ytilt, S_IRUGO | S_IWUGO, show_tabletYtilt, store_tabletYtilt);/*********************************************************************** * support routines for the 'jitter' file. Note that this file * both displays current setting and allows reprogramming. */static ssize_t show_tabletJitterDelay(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.jitterDelay);}static ssize_tstore_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; aiptek->newSetting.jitterDelay = (int)simple_strtol(buf, NULL, 10); return count;}static DEVICE_ATTR(jitter, S_IRUGO | S_IWUGO, show_tabletJitterDelay, store_tabletJitterDelay);/*********************************************************************** * support routines for the 'delay' file. Note that this file * both displays current setting and allows reprogramming. */static ssize_t show_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; return snprintf(buf, PAGE_SIZE, "%d\n", aiptek->curSetting.programmableDelay);}static ssize_tstore_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; aiptek->newSetting.programmableDelay = (int)simple_strtol(buf, NULL, 10); return count;}static DEVICE_ATTR(delay, S_IRUGO | S_IWUGO, show_tabletProgrammableDelay, store_tabletProgrammableDelay);/*********************************************************************** * support routines for the 'input_path' file. Note that this file * only displays current setting. */static ssize_t show_tabletInputDevice(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; return snprintf(buf, PAGE_SIZE, "/dev/input/%s\n", aiptek->features.inputPath);}static DEVICE_ATTR(input_path, S_IRUGO, show_tabletInputDevice, NULL);/*********************************************************************** * support routines for the 'event_count' file. Note that this file * only displays current setting. */static ssize_t show_tabletEventsReceived(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; return snprintf(buf, PAGE_SIZE, "%ld\n", aiptek->eventCount);}static DEVICE_ATTR(event_count, S_IRUGO, show_tabletEventsReceived, NULL);/*********************************************************************** * support routines for the 'diagnostic' file. Note that this file * only displays current setting. */static ssize_t show_tabletDiagnosticMessage(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); char *retMsg; if (aiptek == NULL) return 0; switch (aiptek->diagnostic) { case AIPTEK_DIAGNOSTIC_NA: retMsg = "no errors\n"; break; case AIPTEK_DIAGNOSTIC_SENDING_RELATIVE_IN_ABSOLUTE: retMsg = "Error: receiving relative reports\n"; break; case AIPTEK_DIAGNOSTIC_SENDING_ABSOLUTE_IN_RELATIVE: retMsg = "Error: receiving absolute reports\n"; break; case AIPTEK_DIAGNOSTIC_TOOL_DISALLOWED: if (aiptek->curSetting.pointerMode == AIPTEK_POINTER_ONLY_MOUSE_MODE) { retMsg = "Error: receiving stylus reports\n"; } else { retMsg = "Error: receiving mouse reports\n"; } break; default: return 0; } return snprintf(buf, PAGE_SIZE, retMsg);}static DEVICE_ATTR(diagnostic, S_IRUGO, show_tabletDiagnosticMessage, NULL);/*********************************************************************** * support routines for the 'stylus_upper' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); char *s; if (aiptek == NULL) return 0; switch (aiptek->curSetting.stylusButtonUpper) { case AIPTEK_STYLUS_UPPER_BUTTON: s = "upper"; break; case AIPTEK_STYLUS_LOWER_BUTTON: s = "lower"; break; default: s = "unknown"; break; } return snprintf(buf, PAGE_SIZE, "%s\n", s);}static ssize_tstore_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (strcmp(buf, "upper") == 0) { aiptek->newSetting.stylusButtonUpper = AIPTEK_STYLUS_UPPER_BUTTON; } else if (strcmp(buf, "lower") == 0) { aiptek->newSetting.stylusButtonUpper = AIPTEK_STYLUS_LOWER_BUTTON; } return count;}static DEVICE_ATTR(stylus_upper, S_IRUGO | S_IWUGO, show_tabletStylusUpper, store_tabletStylusUpper);/*********************************************************************** * support routines for the 'stylus_lower' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletStylusLower(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); char *s; if (aiptek == NULL) return 0; switch (aiptek->curSetting.stylusButtonLower) { case AIPTEK_STYLUS_UPPER_BUTTON: s = "upper"; break; case AIPTEK_STYLUS_LOWER_BUTTON: s = "lower"; break; default: s = "unknown"; break; } return snprintf(buf, PAGE_SIZE, "%s\n", s);}static ssize_tstore_tabletStylusLower(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (strcmp(buf, "upper") == 0) { aiptek->newSetting.stylusButtonLower = AIPTEK_STYLUS_UPPER_BUTTON; } else if (strcmp(buf, "lower") == 0) { aiptek->newSetting.stylusButtonLower = AIPTEK_STYLUS_LOWER_BUTTON; } return count;}static DEVICE_ATTR(stylus_lower, S_IRUGO | S_IWUGO, show_tabletStylusLower, store_tabletStylusLower);/*********************************************************************** * support routines for the 'mouse_left' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute *attr, char *buf){ struct aiptek *aiptek = dev_get_drvdata(dev); char *s; if (aiptek == NULL) return 0; switch (aiptek->curSetting.mouseButtonLeft) { case AIPTEK_MOUSE_LEFT_BUTTON: s = "left"; break; case AIPTEK_MOUSE_MIDDLE_BUTTON: s = "middle"; break; case AIPTEK_MOUSE_RIGHT_BUTTON: s = "right"; break; default: s = "unknown"; break; } return snprintf(buf, PAGE_SIZE, "%s\n", s);}static ssize_tstore_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){ struct aiptek *aiptek = dev_get_drvdata(dev); if (aiptek == NULL) return 0; if (strcmp(buf, "left") == 0) { aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_LEFT_BUTTON; } else if (strcmp(buf, "middle") == 0) { aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_MIDDLE_BUTTON; } else if (strcmp(buf, "right") == 0) { aiptek->newSetting.mouseButtonLeft = AIPTEK_MOUSE_RIGHT_BUTTON; } return count;}static DEVICE_ATTR(mouse_left, S_IRUGO | S_IWUGO, show_tabletMouseLeft, store_tabletMouseLeft);/***********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -