1 |
cedk 08/03/29 22:35:12 |
2 |
|
3 |
Added: chuck-1.2.1.1-hid-smc.patch |
4 |
Log: |
5 |
Version bump |
6 |
(Portage version: 2.1.4.4) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 media-sound/chuck/files/chuck-1.2.1.1-hid-smc.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/chuck/files/chuck-1.2.1.1-hid-smc.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-sound/chuck/files/chuck-1.2.1.1-hid-smc.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: chuck-1.2.1.1-hid-smc.patch |
15 |
=================================================================== |
16 |
diff -ru chuck-1.2.1.1~/src/util_hid.cpp chuck-1.2.1.1/src/util_hid.cpp |
17 |
--- chuck-1.2.1.1~/src/util_hid.cpp 2008-03-29 23:24:21.000000000 +0100 |
18 |
+++ chuck-1.2.1.1/src/util_hid.cpp 2008-03-29 23:24:54.000000000 +0100 |
19 |
@@ -7175,14 +7175,139 @@ |
20 |
int WiiRemote_send( const HidMsg * msg ){ return -1; } |
21 |
const char * WiiRemote_name( int wr ){ return NULL; } |
22 |
|
23 |
+#define SYSFS_TILTSENSOR_FILE "/sys/devices/platform/applesmc/position" |
24 |
+#define TILTSENSOR_BUF_LEN 32 |
25 |
+ |
26 |
+static struct t_TiltSensor_data |
27 |
+{ |
28 |
+ union |
29 |
+ { |
30 |
+ struct t_macbook |
31 |
+ { |
32 |
+ int x; |
33 |
+ int y; |
34 |
+ int z; |
35 |
+ } macbook; |
36 |
+ } data; |
37 |
+ int dataType; |
38 |
+ int detected; |
39 |
+ int refcount; |
40 |
+ |
41 |
+ t_TiltSensor_data() |
42 |
+ { |
43 |
+ refcount = 0; |
44 |
+ dataType = -1; |
45 |
+ detected = 0; |
46 |
+ } |
47 |
+ |
48 |
+} TiltSensor_data; |
49 |
+enum |
50 |
+{ |
51 |
+ linuxAppleSMCMacBookDataType |
52 |
+}; |
53 |
+static int TiltSensor_detect() |
54 |
+{ |
55 |
+ int fd; |
56 |
+ |
57 |
+ fd = open(SYSFS_TILTSENSOR_FILE, O_RDONLY); |
58 |
+ |
59 |
+ if (fd > 0) |
60 |
+ { |
61 |
+ TiltSensor_data.dataType = linuxAppleSMCMacBookDataType; |
62 |
+ TiltSensor_data.detected = 1; |
63 |
+ close(fd); |
64 |
+ return 1; |
65 |
+ } |
66 |
+ |
67 |
+ TiltSensor_data.detected = -1; |
68 |
+ |
69 |
+ return 0; |
70 |
+} |
71 |
+ |
72 |
+static int TiltSensor_do_read() |
73 |
+{ |
74 |
+ |
75 |
+ switch(TiltSensor_data.dataType) |
76 |
+ { |
77 |
+ case linuxAppleSMCMacBookDataType: |
78 |
+ char buf[TILTSENSOR_BUF_LEN]; |
79 |
+ int ret, fd; |
80 |
+ fd = open(SYSFS_TILTSENSOR_FILE, O_RDONLY); |
81 |
+ |
82 |
+ if (fd < 0) { |
83 |
+ return -1; |
84 |
+ } |
85 |
+ ret = read(fd, buf, TILTSENSOR_BUF_LEN); |
86 |
+ if (ret < 0) { |
87 |
+ close(fd); |
88 |
+ return -1; |
89 |
+ } |
90 |
+ if (sscanf(buf, "(%d,%d,%d)\n", &TiltSensor_data.data.macbook.x, &TiltSensor_data.data.macbook.y, &TiltSensor_data.data.macbook.z) != 3) { |
91 |
+ close(fd); |
92 |
+ return -1; |
93 |
+ } |
94 |
+ close(fd); |
95 |
+ break; |
96 |
+ default: |
97 |
+ return 0; |
98 |
+ } |
99 |
+ return 1; |
100 |
+} |
101 |
void TiltSensor_init(){} |
102 |
void TiltSensor_quit(){} |
103 |
void TiltSensor_probe(){} |
104 |
-int TiltSensor_count(){ return 0; } |
105 |
-int TiltSensor_open( int ts ){ return -1; } |
106 |
-int TiltSensor_close( int ts ){ return -1; } |
107 |
-int TiltSensor_read( int ts, int type, int num, HidMsg * msg ){ return -1; } |
108 |
-const char * TiltSensor_name( int ts ){ return NULL; } |
109 |
+int TiltSensor_count() |
110 |
+{ |
111 |
+ if(TiltSensor_data.detected == 0) |
112 |
+ TiltSensor_detect(); |
113 |
+ |
114 |
+ if(TiltSensor_data.detected == -1) |
115 |
+ return 0; |
116 |
+ else if(TiltSensor_data.detected == 1) |
117 |
+ return 1; |
118 |
+ |
119 |
+ return 0; |
120 |
+} |
121 |
+int TiltSensor_open( int ts ) |
122 |
+{ |
123 |
+ if(TiltSensor_data.detected == 0) |
124 |
+ TiltSensor_detect(); |
125 |
+ |
126 |
+ if(TiltSensor_data.detected == -1) |
127 |
+ return -1; |
128 |
+ |
129 |
+ TiltSensor_data.refcount++; |
130 |
+ |
131 |
+ return 0; |
132 |
+} |
133 |
+int TiltSensor_close( int ts ) |
134 |
+{ |
135 |
+ TiltSensor_data.refcount--; |
136 |
+ |
137 |
+ return 0; |
138 |
+} |
139 |
+int TiltSensor_read( int ts, int type, int num, HidMsg * msg ) |
140 |
+{ |
141 |
+ |
142 |
+ if(TiltSensor_data.detected == -1) |
143 |
+ return -1; |
144 |
+ |
145 |
+ if(!TiltSensor_do_read()) |
146 |
+ return -1; |
147 |
+ |
148 |
+ if(TiltSensor_data.dataType == linuxAppleSMCMacBookDataType) |
149 |
+ { |
150 |
+ msg->idata[0] = TiltSensor_data.data.macbook.x; |
151 |
+ msg->idata[1] = TiltSensor_data.data.macbook.y; |
152 |
+ msg->idata[2] = TiltSensor_data.data.macbook.z; |
153 |
+ } |
154 |
+ |
155 |
+ return 0; |
156 |
+} |
157 |
+const char * TiltSensor_name( int ts ) |
158 |
+{ |
159 |
+ return "Apple Sudden Motion Sensor"; |
160 |
+} |
161 |
|
162 |
|
163 |
#endif |
164 |
Only in chuck-1.2.1.1/src: util_hid.cpp.orig |
165 |
|
166 |
|
167 |
|
168 |
-- |
169 |
gentoo-commits@l.g.o mailing list |