--- orig/pbbuttonsd.conf.5 2005-04-03 11:00:25.000000000 +0200
+++ mod/pbbuttonsd.conf.5 2005-04-25 16:01:30.435208760 +0200
@@ -13,7 +13,7 @@
.\" along with this program; see the file COPYING. If not, write to
.\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.\"
-.TH PBBUTTONSD.CONF 5 "April 3, 2005"
+.TH PBBUTTONSD.CONF 5 "April 25, 2005"
.\" Please update the above date whenever this man page is modified.
.\"
.\" Some roff macros, for reference:
@@ -66,8 +66,15 @@
defined as follows.
.PP
The key definition could have multiple parts. The first is the keycode as it
-could be found in ..include/linux/input.h. This keycode must be there
-otherwise the built-in default value will be used.
+can be found in ..include/linux/input.h. This keycode must be there or one
+of the virtual keycodes, otherwise the built-in default value will be used.
+.PP
+Currently, the virtual keycodes that are defined are
+.ad l
+.in +17
+.ti -17
+pmupowerbutton - the power button on Mac Mini, new PowerBooks and maybe other machines.
+.br
.PP
The other parts are the optional modifiers that could be combined with the
keycode to trigger the certain function. The \fIshift\fR, \fIalt\fR and
--- orig/src/config_manager.c 2005-04-04 18:38:15.000000000 +0200
+++ mod/src/config_manager.c 2005-04-25 15:41:35.766560699 +0200
@@ -334,7 +334,7 @@
decode_key_and_modifier(char *arg, int *key, int *mod)
{
char *tag;
- int k;
+ int k, i;
*mod = 0; *key = 0;
tag = strtok(arg, "+\n");
@@ -348,6 +348,9 @@
*mod |= MOD_ALT;
else if (!strncmp("ctrl", tag, 4))
*mod |= MOD_CTRL;
+ for (i=0; i < VIRTUAL_KEY_NUM; i++)
+ if (!strcmp(virtual_key_names[i], tag))
+ *key = VIRTUAL_KEY_START + i;
} else
*key = k;
tag = strtok(0, "+\n");
--- orig/src/input_manager.c 2005-04-04 18:41:41.000000000 +0200
+++ mod/src/input_manager.c 2005-04-25 15:41:23.030692378 +0200
@@ -26,6 +26,12 @@
#include "init.h"
#include "input_manager.h"
+char * virtual_key_names[VIRTUAL_KEY_NUM] =
+ {
+ "pmupowerbutton",
+ };
+
+
/* --- private module data structure of the input manager --- */
struct moddata_inputmanager {
--- orig/src/input_manager.h 2005-03-21 11:12:34.000000000 +0100
+++ mod/src/input_manager.h 2005-04-25 15:43:11.965566077 +0200
@@ -41,6 +41,13 @@
#define MOD_ALTCTRL 6
#define MOD_SHIFTALTCTRL 7
+/* virtual keys and their names */
+#define VIRTUAL_KEY_START 1000
+#define VIRTUAL_KEY_POWERBUTTON 0
+#define VIRTUAL_KEY_NUM 1
+
+extern char * virtual_key_names[VIRTUAL_KEY_NUM];
+
#define BITS_PER_LONG (sizeof(long) * 8)
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define OFF(x) ((x)%BITS_PER_LONG)
--- orig/src/module_pmac.c 2005-04-04 18:30:39.000000000 +0200
+++ mod/src/module_pmac.c 2005-04-25 15:44:12.557939599 +0200
@@ -480,6 +480,11 @@
{
unsigned char intr[16];
int n;
+ struct tagitem taglist[] = {{ TAG_KEYCODE, VIRTUAL_KEY_START + VIRTUAL_KEY_POWERBUTTON },
+ { TAG_KEYREPEAT, 0 },
+ { TAG_MODIFIER, 0 },
+ { TAG_END, 0 }};
+ static int powerbutton_old = 0;
#if defined(DEBUG) && PMUINTR
int i;
#endif
@@ -489,6 +494,16 @@
if (n < 3 || intr[2] < 1 || intr[2] > 2)
break;
call_script ("/sbin/cardctl %s %d", "eject", intr[2]-1);
+ break;
+ /* FIXME: use some appropriate structures to parse the interrupt */
+ case 0x40:
+ if (n < 2) break;
+ if ((intr[1] & PMU_ENV_PBTN_PRESSED) != powerbutton_old) {
+ taglist[1].data = (intr[1] & PMU_ENV_PBTN_PRESSED) ? 1 : 0;
+ powerbutton_old = intr[1] & PMU_ENV_PBTN_PRESSED;
+ process_queue (KBDQUEUE, taglist);
+ }
+ break;
}
#if defined(DEBUG) && PMUINTR
printf ("\nPMU interrupt: ");
--- orig/src/module_pmac.h 2005-04-01 11:29:50.000000000 +0200
+++ mod/src/module_pmac.h 2005-04-25 15:12:20.696706750 +0200
@@ -57,6 +57,9 @@
#ifndef PMU_ENV_BATTERY_PRESENT
#define PMU_ENV_BATTERY_PRESENT 0x10
#endif
+#ifndef PMU_ENV_PBTN_PRESSED
+#define PMU_ENV_PBTN_PRESSED 0x08
+#endif
#define LMU_ADDR 0x42