1
Index: uswsusp-0.8/splash.c
2
===================================================================
3
--- uswsusp-0.8.orig/splash.c 2007-12-31 19:50:12.000000000 +0100
4
+++ uswsusp-0.8/splash.c 2008-07-15 16:52:51.000000000 +0200
14
+#include <linux/input.h>
15
+#include <sys/types.h>
16
+#include <sys/types.h>
17
+#include <sys/stat.h>
20
#include "bootsplash.h"
22
#include "fbsplash_funcs.h"
25
+#define INPUT_PATH "/dev/input/by-path"
26
+#define MAX_INPUT_FD 8
28
+ int fds[MAX_INPUT_FD];
34
* dummy functions in case if no splash system was found or
35
* bootsplashing is disabled
38
static char key_pressed(void)
41
- if (read(0, &c, 1) == 0)
43
+ struct input_event ev;
44
+ struct timeval timeout = {0, 0};
47
+ if (!input_fds.count)
50
+ active = -1; /* GCC STFU */
52
+ for (i = 0; i < input_fds.count; i++)
53
+ FD_SET(input_fds.fds[i], &fds);
55
+ err = select(input_fds.highest + 1, &fds, NULL, NULL, &timeout);
64
+ /* Get only the fist active fd */
65
+ for (i = 0; i < input_fds.count; i++) {
66
+ if (FD_ISSET(input_fds.fds[i], &fds)) {
67
+ active = input_fds.fds[i];
72
+ while ((err = read(active, &ev, sizeof(struct input_event))) != -1) {
73
+ /* we only need key release events */
74
+ if (ev.type == EV_KEY && ev.value == 0)
81
static void restore_abort(struct termios *oldtrm)
83
tcsetattr(0, TCSANOW, oldtrm);
86
+static int open_input_fd(void)
91
+ char input_dev[PATH_MAX];
94
+ if (!(dir = opendir(INPUT_PATH))) {
95
+ perror("Cannot open input directory");
100
+ while ((it = readdir(dir))) {
101
+ if (i == MAX_INPUT_FD)
104
+ if (!strstr(it->d_name, "-event-kbd"))
107
+ sprintf(input_dev, "%s/%s", INPUT_PATH, it->d_name);
109
+ fd = open(input_dev, O_RDONLY|O_NONBLOCK);
111
+ perror("opening input fd");
114
+ input_fds.fds[i++] = fd;
116
+ if (fd > input_fds.highest)
117
+ input_fds.highest = fd;
120
+ if (!it && errno) {
121
+ perror("readdir()");
129
/* Tries to find a splash system and initializes interface functions */
130
void splash_prepare(struct splash *splash, int mode)
133
splash->restore_abort = restore_abort;
134
splash->key_pressed = key_pressed;
135
splash->set_caption = splash_dummy_set_caption;
137
+ if (open_input_fd())
138
+ fprintf(stderr, "Could not open keyboard input device\n");
143
Index: uswsusp-0.8/suspend.c
144
===================================================================
145
--- uswsusp-0.8.orig/suspend.c 2007-12-31 19:50:12.000000000 +0100
146
+++ uswsusp-0.8/suspend.c 2008-07-15 16:52:51.000000000 +0200
148
unsigned int nr_pages)
150
unsigned int m, writeout_rate;
151
- int ret, abort_possible;
152
+ int ret, abort_possible, key;
153
struct termios newtrm, savedtrm;
155
char message[SPLASH_GENERIC_MESSAGE_SIZE];
157
printf("\b\b\b\b%3d%%", nr_pages / m);
158
splash.progress(20 + (nr_pages / m) * 0.75);
160
- switch (splash.key_pressed()) {
161
+ while ((key = splash.key_pressed()) > 0) {
164
if (abort_possible) {
165
printf(" aborted!\n");
168
SHUTDOWN_METHOD_REBOOT;
176
} else if (shutdown_method == SHUTDOWN_METHOD_PLATFORM) {
177
int ret = platform_enter(snapshot_fd);
179
- suspend_error("pm_ops->enter failed, calling power_off.");
181
+ // suspend_error("pm_ops->enter failed, calling power_off.");
184
/* Signature is on disk, it is very dangerous to continue now.
185
Index: uswsusp-0.8/swsusp.h
186
===================================================================
187
--- uswsusp-0.8.orig/swsusp.h 2007-12-31 19:50:12.000000000 +0100
188
+++ uswsusp-0.8/swsusp.h 2008-07-15 16:52:51.000000000 +0200
191
#define SUSPEND_SWAPPINESS 100
193
-#define ABORT_KEY_CODE 127
194
+#define ABORT_KEY_CODE 14
195
#define ABORT_KEY_NAME "backspace"
196
-#define REBOOT_KEY_CODE 'r'
197
+#define REBOOT_KEY_CODE 19
198
#define REBOOT_KEY_NAME "r"