-rw-r--r-- | library/custom-sharp.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/custom-sharp.h b/library/custom-sharp.h index 3dab34f..3936875 100644 --- a/library/custom-sharp.h +++ b/library/custom-sharp.h | |||
@@ -1,97 +1,98 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QPE_NEED_CALIBRATION | ||
21 | #define QPE_OWNAPM | 22 | #define QPE_OWNAPM |
22 | #define QPE_HAVE_TOGGLELIGHT | 23 | #define QPE_HAVE_TOGGLELIGHT |
23 | #define QPE_NOCIBAUD | 24 | #define QPE_NOCIBAUD |
24 | #define QPE_STARTMENU | 25 | #define QPE_STARTMENU |
25 | #include <asm/sharp_apm.h> | 26 | #include <asm/sharp_apm.h> |
26 | #ifndef APM_IOC_BATTERY_BACK_CHK | 27 | #ifndef APM_IOC_BATTERY_BACK_CHK |
27 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) | 28 | #define APM_IOC_BATTERY_BACK_CHK _IO(APM_IOC_MAGIC, 32) |
28 | #endif | 29 | #endif |
29 | #ifndef APM_IOC_BATTERY_MAIN_CHK | 30 | #ifndef APM_IOC_BATTERY_MAIN_CHK |
30 | #define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) | 31 | #define APM_IOC_BATTERY_MAIN_CHK _IO(APM_IOC_MAGIC, 33) |
31 | #endif | 32 | #endif |
32 | 33 | ||
33 | #include <unistd.h> | 34 | #include <unistd.h> |
34 | #include <stdio.h> | 35 | #include <stdio.h> |
35 | #include <signal.h> | 36 | #include <signal.h> |
36 | #include <fcntl.h> | 37 | #include <fcntl.h> |
37 | #include <sys/ioctl.h> | 38 | #include <sys/ioctl.h> |
38 | 39 | ||
39 | 40 | ||
40 | #include <sys/ioctl.h> | 41 | #include <sys/ioctl.h> |
41 | #include <asm/sharp_char.h> | 42 | #include <asm/sharp_char.h> |
42 | 43 | ||
43 | #define QPE_HAVE_MEMALERTER | 44 | #define QPE_HAVE_MEMALERTER |
44 | 45 | ||
45 | #define QPE_MEMALERTER_IMPL \ | 46 | #define QPE_MEMALERTER_IMPL \ |
46 | static void sig_handler(int sig) \ | 47 | static void sig_handler(int sig) \ |
47 | { \ | 48 | { \ |
48 | switch (sig) { \ | 49 | switch (sig) { \ |
49 | case SIGHUP: \ | 50 | case SIGHUP: \ |
50 | memstate = VeryLow; \ | 51 | memstate = VeryLow; \ |
51 | break; \ | 52 | break; \ |
52 | case SIGUSR1: \ | 53 | case SIGUSR1: \ |
53 | memstate = Normal; \ | 54 | memstate = Normal; \ |
54 | break; \ | 55 | break; \ |
55 | case SIGUSR2: \ | 56 | case SIGUSR2: \ |
56 | memstate = Low; \ | 57 | memstate = Low; \ |
57 | break; \ | 58 | break; \ |
58 | } \ | 59 | } \ |
59 | } \ | 60 | } \ |
60 | static void initMemalerter() \ | 61 | static void initMemalerter() \ |
61 | { \ | 62 | { \ |
62 | struct sigaction sa; \ | 63 | struct sigaction sa; \ |
63 | memset(&sa, '\0', sizeof sa); \ | 64 | memset(&sa, '\0', sizeof sa); \ |
64 | sa.sa_handler = sig_handler; \ | 65 | sa.sa_handler = sig_handler; \ |
65 | sa.sa_flags = SA_RESTART; \ | 66 | sa.sa_flags = SA_RESTART; \ |
66 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ | 67 | if (sigaction(SIGHUP, &sa, NULL) < 0) { \ |
67 | return; \ | 68 | return; \ |
68 | } \ | 69 | } \ |
69 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ | 70 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { \ |
70 | return; \ | 71 | return; \ |
71 | } \ | 72 | } \ |
72 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ | 73 | if (sigaction(SIGUSR2, &sa, NULL) < 0) { \ |
73 | return; \ | 74 | return; \ |
74 | } \ | 75 | } \ |
75 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ | 76 | FILE *fo = fopen("/proc/sys/vm/freepg_signal_proc", "w"); \ |
76 | \ | 77 | \ |
77 | if (!fo) \ | 78 | if (!fo) \ |
78 | return; \ | 79 | return; \ |
79 | fprintf(fo, "qpe\n"); \ | 80 | fprintf(fo, "qpe\n"); \ |
80 | fclose(fo); \ | 81 | fclose(fo); \ |
81 | } | 82 | } |
82 | 83 | ||
83 | #define QPE_INITIAL_NUMLOCK_STATE \ | 84 | #define QPE_INITIAL_NUMLOCK_STATE \ |
84 | { \ | 85 | { \ |
85 | bool numLock = FALSE; \ | 86 | bool numLock = FALSE; \ |
86 | sharp_kbdctl_modifstat st; \ | 87 | sharp_kbdctl_modifstat st; \ |
87 | int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ | 88 | int dev = ::open("/dev/sharp_kbdctl", O_RDWR); \ |
88 | if( dev >= 0 ) { \ | 89 | if( dev >= 0 ) { \ |
89 | memset(&st, 0, sizeof(st)); \ | 90 | memset(&st, 0, sizeof(st)); \ |
90 | st.which = 3; \ | 91 | st.which = 3; \ |
91 | int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ | 92 | int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st); \ |
92 | if( !ret ) \ | 93 | if( !ret ) \ |
93 | numLock = (bool)st.stat; \ | 94 | numLock = (bool)st.stat; \ |
94 | ::close(dev); \ | 95 | ::close(dev); \ |
95 | } \ | 96 | } \ |
96 | return numLock; \ | 97 | return numLock; \ |
97 | } | 98 | } |