⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aiptek.c

📁 linux 内核源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
static ssize_t show_tabletToolMode(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(tool_mode_map,					aiptek->curSetting.toolMode));}static ssize_tstore_tabletToolMode(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_mode = map_str_to_val(tool_mode_map, buf, count);	if (new_mode == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.toolMode = new_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->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 (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->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 (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);	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);	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);	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);	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 '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);	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;	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 struct aiptek_map stylus_button_map[] = {	{ "upper",	AIPTEK_STYLUS_UPPER_BUTTON },	{ "lower",	AIPTEK_STYLUS_LOWER_BUTTON },	{ NULL,		AIPTEK_INVALID_VALUE }};static ssize_t show_tabletStylusUpper(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(stylus_button_map,					aiptek->curSetting.stylusButtonUpper));}static ssize_tstore_tabletStylusUpper(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_button = map_str_to_val(stylus_button_map, buf, count);	if (new_button == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.stylusButtonUpper = new_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);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(stylus_button_map,					aiptek->curSetting.stylusButtonLower));}static ssize_tstore_tabletStylusLower(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_button = map_str_to_val(stylus_button_map, buf, count);	if (new_button == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.stylusButtonLower = new_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 struct aiptek_map mouse_button_map[] = {	{ "left",	AIPTEK_MOUSE_LEFT_BUTTON },	{ "middle",	AIPTEK_MOUSE_MIDDLE_BUTTON },	{ "right",	AIPTEK_MOUSE_RIGHT_BUTTON },	{ NULL,		AIPTEK_INVALID_VALUE }};static ssize_t show_tabletMouseLeft(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(mouse_button_map,					aiptek->curSetting.mouseButtonLeft));}static ssize_tstore_tabletMouseLeft(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_button = map_str_to_val(mouse_button_map, buf, count);	if (new_button == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.mouseButtonLeft = new_button;	return count;}static DEVICE_ATTR(mouse_left,		   S_IRUGO | S_IWUGO,		   show_tabletMouseLeft, store_tabletMouseLeft);/*********************************************************************** * support routines for the 'mouse_middle' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(mouse_button_map,					aiptek->curSetting.mouseButtonMiddle));}static ssize_tstore_tabletMouseMiddle(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_button = map_str_to_val(mouse_button_map, buf, count);	if (new_button == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.mouseButtonMiddle = new_button;	return count;}static DEVICE_ATTR(mouse_middle,		   S_IRUGO | S_IWUGO,		   show_tabletMouseMiddle, store_tabletMouseMiddle);/*********************************************************************** * support routines for the 'mouse_right' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletMouseRight(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	return snprintf(buf, PAGE_SIZE, "%s\n",			map_val_to_str(mouse_button_map,					aiptek->curSetting.mouseButtonRight));}static ssize_tstore_tabletMouseRight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){	struct aiptek *aiptek = dev_get_drvdata(dev);	int new_button = map_str_to_val(mouse_button_map, buf, count);	if (new_button == AIPTEK_INVALID_VALUE)		return -EINVAL;	aiptek->newSetting.mouseButtonRight = new_button;	return count;}static DEVICE_ATTR(mouse_right,		   S_IRUGO | S_IWUGO,		   show_tabletMouseRight, store_tabletMouseRight);/*********************************************************************** * support routines for the 'wheel' file. Note that this file * both displays current setting and allows for setting changing. */static ssize_t show_tabletWheel(struct device *dev, struct device_attribute *attr, char *buf){	struct aiptek *aiptek = dev_get_drvdata(dev);	if (aiptek->curSetting.wheel == AIPTEK_WHEEL_DISABLE) {		return snprintf(buf, PAGE_SIZE, "disable\n");	} else {		return snprintf(buf, PAGE_SIZE, "%d\n",				aiptek->curSetting.wheel);	}}static ssize_tstore_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -