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

📄 mac_keyb.c

📁 Linux内核源代码 为压缩文件 是<<Linux内核>>一书中的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	 * XXX: Add mouse button 2+3 fake codes here if mouse open.	 *	Keep track of 'button' states here as we only send	 *	single up/down events!	 *	Really messy; might need to check if keyboard is in	 *	VC_RAW mode.	 *	Might also want to know how many buttons need to be emulated.	 *	-> hide this as function in arch/m68k/mac ?	 */	if (adb_emulate_buttons	    && (keycode == adb_button2_keycode		|| keycode == adb_button3_keycode)	    && (adb_mouse_interrupt_hook || console_loglevel == 10)) {		int button;		/* faked ADB packet */		static unsigned char data[4] = { 0, 0x80, 0x80, 0x80 };		button = keycode == adb_button2_keycode? 2: 3;		if (data[button] != up_flag) {			/* send a fake mouse packet */			data[button] = up_flag;			if (console_loglevel >= 8)				printk("fake mouse event: %x %x %x\n",				       data[1], data[2], data[3]);			if (adb_mouse_interrupt_hook)				adb_mouse_interrupt_hook(data, 4);		}		return;	}#endif /* CONFIG_ADBMOUSE */	if (kbd->kbdmode != VC_RAW) {		if (!up_flag && !dont_repeat[keycode]) {			last_keycode = keycode;			repeat_timer.expires = jiffies + (repeat? HZ/15: HZ/2);			add_timer(&repeat_timer);		}		/*		 * adb kludge!! Imitate pc caps lock behaviour by		 * generating an up/down event for each time caps		 * is pressed/released. Also, makes sure that the		 * LED are handled.  atong@uiuc.edu		 */		 switch (keycode) {		 /*case 0xb9:*/		 case 0x39:			handle_scancode(0x39, 1);			handle_scancode(0x39, 0);		 	tasklet_schedule(&keyboard_tasklet);		 	return;		 case 0x47:		 /*case 0xc7:*/		 	tasklet_schedule(&keyboard_tasklet);		 	break;		 }	}	handle_scancode(keycode, !up_flag);	tasklet_schedule(&keyboard_tasklet);}static voidkbd_repeat(unsigned long xxx){	unsigned long flags;	save_flags(flags);	cli();	input_keycode(last_keycode, 1);	restore_flags(flags);}static void mac_put_queue(int ch){	extern struct tty_driver console_driver;	struct tty_struct *tty;	tty = console_driver.table? console_driver.table[fg_console]: NULL;	wake_up(&keypress_wait);	if (tty) {		tty_insert_flip_char(tty, ch, 0);		con_schedule_flip(tty);	}}#ifdef CONFIG_ADBMOUSEstatic voidmouse_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll){  /* [ACA:23-Mar-97] Three button mouse support.  This is designed to     function with MkLinux DR-2.1 style X servers.  It only works with     three-button mice that conform to Apple's multi-button mouse     protocol. */  /*    The X server for MkLinux DR2.1 uses the following unused keycodes to    read the mouse:    0x7e  This indicates that the next two keycodes should be interpreted          as mouse information.  The first following byte's high bit          represents the state of the left button.  The lower seven bits          represent the x-axis acceleration.  The lower seven bits of the          second byte represent y-axis acceleration.    0x3f  The x server interprets this keycode as a middle button          release.    0xbf  The x server interprets this keycode as a middle button          depress.    0x40  The x server interprets this keycode as a right button          release.    0xc0  The x server interprets this keycode as a right button          depress.    NOTES: There should be a better way of handling mice in the X server.    The MOUSE_ESCAPE code (0x7e) should be followed by three bytes instead    of two.  The three mouse buttons should then, in the X server, be read    as the high-bits of all three bytes.  The x and y motions can still be    in the first two bytes.  Maybe I'll do this...  */  /*    Handler 1 -- 100cpi original Apple mouse protocol.    Handler 2 -- 200cpi original Apple mouse protocol.    For Apple's standard one-button mouse protocol the data array will    contain the following values:                BITS    COMMENTS    data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd.    data[1] = bxxx xxxx First button and x-axis motion.    data[2] = byyy yyyy Second button and y-axis motion.    Handler 4 -- Apple Extended mouse protocol.    For Apple's 3-button mouse protocol the data array will contain the    following values:		BITS    COMMENTS    data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd.    data[1] = bxxx xxxx Left button and x-axis motion.    data[2] = byyy yyyy Second button and y-axis motion.    data[3] = byyy bxxx Third button and fourth button.  Y is additional	      high bits of y-axis motion.  XY is additional	      high bits of x-axis motion.    MacAlly 2-button mouse protocol.    For MacAlly 2-button mouse protocol the data array will contain the    following values:		BITS    COMMENTS    data[0] = dddd 1100 ADB command: Talk, register 0, for device dddd.    data[1] = bxxx xxxx Left button and x-axis motion.    data[2] = byyy yyyy Right button and y-axis motion.    data[3] = ???? ???? unknown    data[4] = ???? ???? unknown  */	struct kbd_struct *kbd;	/* If it's a trackpad, we alias the second button to the first.	   NOTE: Apple sends an ADB flush command to the trackpad when	         the first (the real) button is released. We could do		 this here using async flush requests.	*/	switch (adb_mouse_kinds[(data[0]>>4) & 0xf])	{	    case ADBMOUSE_TRACKPAD:		data[1] = (data[1] & 0x7f) | ((data[1] & data[2]) & 0x80);		data[2] = data[2] | 0x80;		break;	    case ADBMOUSE_MICROSPEED:		data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7);		data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6);		data[3] = (data[3] & 0x77) | ((data[3] & 0x04) << 5)			| (data[3] & 0x08);		break;	    case ADBMOUSE_TRACKBALLPRO:		data[1] = (data[1] & 0x7f) | (((data[3] & 0x04) << 5)			& ((data[3] & 0x08) << 4));		data[2] = (data[2] & 0x7f) | ((data[3] & 0x01) << 7);		data[3] = (data[3] & 0x77) | ((data[3] & 0x02) << 6);		break;	    case ADBMOUSE_MS_A3:		data[1] = (data[1] & 0x7f) | ((data[3] & 0x01) << 7);		data[2] = (data[2] & 0x7f) | ((data[3] & 0x02) << 6);		data[3] = ((data[3] & 0x04) << 5);		break;            case ADBMOUSE_MACALLY2:		data[3] = (data[2] & 0x80) ? 0x80 : 0x00;		data[2] |= 0x80;  /* Right button is mapped as button 3 */		nb=4;                break;	}	if (adb_mouse_interrupt_hook)		adb_mouse_interrupt_hook(data, nb);	kbd = kbd_table + fg_console;	/* Only send mouse codes when keyboard is in raw mode. */	if (kbd->kbdmode == VC_RAW) {		static unsigned char uch_ButtonStateSecond = 0x80;		unsigned char uchButtonSecond;		/* Send first button, second button and movement. */		mac_put_queue(0x7e);		mac_put_queue(data[1]);		mac_put_queue(data[2]);		/* [ACA: Are there any two-button ADB mice that use handler 1 or 2?] */		/* Store the button state. */		uchButtonSecond = (data[2] & 0x80);		/* Send second button. */		if (uchButtonSecond != uch_ButtonStateSecond) {			mac_put_queue(0x3f | uchButtonSecond);			uch_ButtonStateSecond = uchButtonSecond;		}		/* Macintosh 3-button mouse (handler 4). */		if (nb >= 4) {			static unsigned char uch_ButtonStateThird = 0x80;			unsigned char uchButtonThird;			/* Store the button state for speed. */			uchButtonThird = (data[3] & 0x80);			/* Send third button. */			if (uchButtonThird != uch_ButtonStateThird) {				mac_put_queue(0x40 | uchButtonThird);				uch_ButtonStateThird = uchButtonThird;			}		}	}}#endif /* CONFIG_ADBMOUSE */static voidbuttons_input(unsigned char *data, int nb, struct pt_regs *regs, int autopoll){#ifdef CONFIG_PMAC_BACKLIGHT	int backlight = get_backlight_level();	/*	 * XXX: Where is the contrast control for the passive?	 *  -- Cort	 */	/* Ignore data from register other than 0 */	if ((data[0] & 0x3) || (nb < 2))		return;	switch (data[1]) {	case 0x8:		/* mute */		break;	case 0x7:		/* contrast decrease */		break;	case 0x6:		/* contrast increase */		break;	case 0xa:		/* brightness decrease */		if (backlight < 0)			break;		if (backlight > BACKLIGHT_OFF)			set_backlight_level(backlight-1);		else			set_backlight_level(BACKLIGHT_OFF);		break;	case 0x9:		/* brightness increase */		if (backlight < 0)			break;		if (backlight < BACKLIGHT_MAX)			set_backlight_level(backlight+1);		else 			set_backlight_level(BACKLIGHT_MAX);		break;	}#endif /* CONFIG_PMAC_BACKLIGHT */}/* Map led flags as defined in kbd_kern.h to bits for Apple keyboard. */static unsigned char mac_ledmap[8] = {    0,		/* none */    4,		/* scroll lock */    1,		/* num lock */    5,		/* scroll + num lock */    2,		/* caps lock */    6,		/* caps + scroll lock */    3,		/* caps + num lock */    7,		/* caps + num + scroll lock */};static struct adb_request led_request;static int leds_pending[16];static int pending_devs[16];static int pending_led_start=0;static int pending_led_end=0;static void real_mackbd_leds(unsigned char leds, int device){    if (led_request.complete) {	adb_request(&led_request, leds_done, 0, 3,		    ADB_WRITEREG(device, KEYB_LEDREG), 0xff,		    ~mac_ledmap[leds]);    } else {	if (!(leds_pending[device] & 0x100)) {	    pending_devs[pending_led_end] = device;	    pending_led_end++;	    pending_led_end = (pending_led_end < 16) ? pending_led_end : 0;	}	leds_pending[device] = leds | 0x100;    }}void mackbd_leds(unsigned char leds){    int i;    for(i = 0; i < keyboard_ids.nids; i++)	real_mackbd_leds(leds,keyboard_ids.id[i]);}static void leds_done(struct adb_request *req){    int leds,device;    if (pending_led_start != pending_led_end) {	device = pending_devs[pending_led_start];	leds = leds_pending[device] & 0xff;	leds_pending[device] = 0;	pending_led_start++;	pending_led_start = (pending_led_start < 16) ? pending_led_start : 0;	real_mackbd_leds(leds,device);    }}void __init mackbd_init_hw(void){

⌨️ 快捷键说明

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