diff -x svn -Nuar src/pommed/pommed/conffile.c pommed/pommed/conffile.c --- src/pommed/pommed/conffile.c 2006-12-25 15:41:52.000000000 +0100 +++ pommed/pommed/conffile.c 2006-12-25 15:40:18.000000000 +0100 @@ -49,6 +49,7 @@ static cfg_opt_t general_opts[] = { CFG_INT("fnmode", 1, CFGF_NONE), + CFG_INT("applemouseemu", 0, CFGF_NONE), CFG_END() }; @@ -149,6 +150,7 @@ printf("pommed configuration:\n"); printf(" + General settings:\n"); printf(" fnmode: %d\n", general_cfg.fnmode); + printf(" applemouseemu: %d\n", general_cfg.applemouseemu); printf(" + ATI X1600 backlight control:\n"); printf(" initial level: %d\n", lcd_x1600_cfg.init); printf(" step: %d\n", lcd_x1600_cfg.step); @@ -196,6 +198,7 @@ /* Set up config values validation */ /* general */ cfg_set_validate_func(cfg, "general|fnmode", config_validate_positive_integer); + cfg_set_validate_func(cfg, "general|applemouseemu", config_validate_positive_integer); /* lcd_x1600 */ cfg_set_validate_func(cfg, "lcd_x1600|step", config_validate_positive_integer); /* lcd_gma950 */ @@ -239,6 +242,7 @@ /* Fill up the structs */ sec = cfg_getsec(cfg, "general"); general_cfg.fnmode = cfg_getint(sec, "fnmode"); + general_cfg.applemouseemu = cfg_getint(sec, "applemouseemu"); sec = cfg_getsec(cfg, "lcd_x1600"); lcd_x1600_cfg.init = cfg_getint(sec, "init"); diff -x svn -Nuar src/pommed/pommed/conffile.h pommed/pommed/conffile.h --- src/pommed/pommed/conffile.h 2006-12-25 15:41:52.000000000 +0100 +++ pommed/pommed/conffile.h 2006-12-25 15:40:18.000000000 +0100 @@ -7,6 +7,7 @@ struct _general_cfg { int fnmode; + int applemouseemu; }; struct _lcd_x1600_cfg { diff -x svn -Nuar src/pommed/pommed/pommed.c pommed/pommed/pommed.c --- src/pommed/pommed/pommed.c 2006-12-25 15:41:52.000000000 +0100 +++ pommed/pommed/pommed.c 2006-12-25 15:40:18.000000000 +0100 @@ -171,6 +171,45 @@ fclose(fp); } +void +kbd_set_applemouseemu(void) +{ + FILE *fp; + + if (general_cfg.applemouseemu == 1) { + + fp = fopen(KBD_APPLEMOUSEEMU_FILE, "a"); + if (fp == NULL) + { + logmsg(LOG_INFO, "Could not open %s: %s", KBD_APPLEMOUSEEMU_FILE, strerror(errno)); + return; + } + + fprintf(fp, "%d", general_cfg.applemouseemu); + fclose(fp); + + + fp = fopen(KBD_APPLEMOUSE2_FILE, "a"); + if (fp == NULL) + { + logmsg(LOG_INFO, "Could not open %s: %s", KBD_APPLEMOUSE2_FILE, strerror(errno)); + return; + } + + fprintf(fp, "%d", KBD_LEFTAPPLE); + fclose(fp); + + fp = fopen(KBD_APPLEMOUSE3_FILE, "a"); + if (fp == NULL) + { + logmsg(LOG_INFO, "Could not open %s: %s", KBD_APPLEMOUSE3_FILE, strerror(errno)); + return; + } + + fprintf(fp, "%d", KBD_RIGHTAPPLE); + fclose(fp); + } +} static machine_type check_machine_smbios(void) @@ -362,6 +401,8 @@ } kbd_set_fnmode(); + kbd_set_applemouseemu(); + kbd_backlight_init(); ret = audio_init(); @@ -430,6 +471,7 @@ * just resumed from sleep */ kbd_set_fnmode(); + kbd_set_applemouseemu(); reopen = 0; } diff -x svn -Nuar src/pommed/pommed/pommed.h pommed/pommed/pommed.h --- src/pommed/pommed/pommed.h 2006-12-25 15:41:52.000000000 +0100 +++ pommed/pommed/pommed.h 2006-12-25 15:40:18.000000000 +0100 @@ -23,6 +23,8 @@ void kbd_set_fnmode(void); +void +kbd_set_applemouseemu(void); typedef enum { @@ -50,6 +52,11 @@ #define CONFFILE "/etc/pommed.conf" #define KBD_FNMODE_FILE "/sys/module/usbhid/parameters/pb_fnmode" +#define KBD_APPLEMOUSEEMU_FILE "/proc/sys/dev/mac_hid/mouse_button_emulation" +#define KBD_APPLEMOUSE2_FILE "/proc/sys/dev/mac_hid/mouse_button2_keycode" +#define KBD_APPLEMOUSE3_FILE "/proc/sys/dev/mac_hid/mouse_button3_keycode" +#define KBD_LEFTAPPLE 125 // Left Apple key +#define KBD_RIGHTAPPLE 126 // Right Apple key #define STEP_UP 1 #define STEP_DOWN -1 diff -x svn -Nuar src/pommed/pommed.conf pommed/pommed.conf --- src/pommed/pommed.conf 2006-12-25 15:41:54.000000000 +0100 +++ pommed/pommed.conf 2006-12-25 15:40:18.000000000 +0100 @@ -7,6 +7,10 @@ # fnmode: functions keys first (no need to use fn) or last # Value is either 1 or 2, effect is hardware-dependent fnmode = 1 + # applemouseemu: using the left apple key as the middle mouse + # button and the right apple key as the right mouse button + # Value is either 0 for off and 1 for on + applemouseemu = 1 } # ATI X1600 backlight control (MacBook Pro)