<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cyher.NET</title>
	<atom:link href="http://cyher.net/feed" rel="self" type="application/rss+xml" />
	<link>http://cyher.net</link>
	<description>Technology, Life, Code, OpenSource, *nix, Mac and iphone, Mobile development</description>
	<lastBuildDate>Wed, 16 Mar 2011 01:25:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>伪造?还是检测信用卡 cocoa, Objc实现</title>
		<link>http://cyher.net/apple/cocoa/credit-card-check</link>
		<comments>http://cyher.net/apple/cocoa/credit-card-check#comments</comments>
		<pubDate>Tue, 15 Mar 2011 15:33:38 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[cocoa]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637084</guid>
		<description><![CDATA[伪造? 还是去检测一张信用卡? 看完这个图, 相信很容易了解其中的数学算法. 原始链接:http://www.geekv5.com/archives/2859 英文原始链接:http://www.mint.com/blog/trends/credit-card-code-01202011/ 好了其实这个小知识还是很有趣的, 作为向geek前进的我们, 怎么能不知道这样的小trick. 看见这个，会想起什么？我们的思维真的会从伪造信用卡这个keywrod延伸到，卡片的生产，怎么把磁条信息录入，怎么去设这个陷阱让人踩了还不知道？ 至少我不是的。。我第一个想到的是如果我有一个iphone，我的iphone上有一个软件通过摄像头，对着一张信用卡来信用卡真伪识别。So cool? 其实这样的思维常常出现在每个人的脑海中，那些so cool的创意程序可能就在这瞬间的头脑风暴产生了。好吧，其实本不应该说这么多的。其实我是想鼓励自己，纸上得来终觉浅，绝知此事要躬行，just do it. 其实这个信用卡真伪的识别是基于，一个叫做Luhn 的算法 详细内容请移步 http://en.wikipedia.org/wiki/Luhn_algorithm 我对这个算法的描述就是: 从右倒左, 偶数位 * 2, 如果偶数大于10, 则个位+(十位/10) 把奇数位和刚刚得出的偶数位相加得出 sum sum如果能够mod 10 = 0 那就是正确的 这里给出C的code, wikipedia里面有java和pyhon的 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [...]]]></description>
			<content:encoded><![CDATA[<p>伪造? 还是去检测一张信用卡? 看完这个图, 相信很容易了解其中的数学算法.</p>
<p>原始链接:<a href="http://www.geekv5.com/archives/2859">http://www.geekv5.com/archives/2859</a></p>
<p>英文原始链接:<a href="http://www.mint.com/blog/trends/credit-card-code-01202011/">http://www.mint.com/blog/trends/credit-card-code-01202011/</a></p>
<p><a href="http://cyher.net/wp-content/uploads/2011/03/cc.jpg" rel="lightbox[637084]"><img class="aligncenter size-full wp-image-637085" title="How to Validate a Credit Card" src="http://cyher.net/wp-content/uploads/2011/03/cc.jpg" alt="" width="440" height="1206" /></a>好了其实这个小知识还是很有趣的, 作为向geek前进的我们, 怎么能不知道这样的小trick.</p>
<p>看见这个，会想起什么？我们的思维真的会从伪造信用卡这个keywrod延伸到，卡片的生产，怎么把磁条信息录入，怎么去设这个陷阱让人踩了还不知道？</p>
<p>至少我不是的。。我第一个想到的是如果我有一个iphone，我的iphone上有一个软件通过摄像头，对着一张信用卡来信用卡真伪识别。So cool? 其实这样的思维常常出现在每个人的脑海中，那些so cool的创意程序可能就在这瞬间的头脑风暴产生了。好吧，其实本不应该说这么多的。其实我是想鼓励自己，纸上得来终觉浅，绝知此事要躬行，just do it.</p>
<p>其实这个信用卡真伪的识别是基于，一个叫做Luhn 的算法 详细内容请移步<a href=" http://en.wikipedia.org/wiki/Luhn_algorithm"> http://en.wikipedia.org/wiki/Luhn_algorithm</a></p>
<p>我对这个算法的描述就是:</p>
<ul>
<li>从右倒左, 偶数位 * 2, 如果偶数大于10, 则个位+(十位/10)</li>
<li> 把奇数位和刚刚得出的偶数位相加得出 sum</li>
<li>sum如果能够mod 10 = 0 那就是正确的</li>
</ul>
<p>这里给出C的<a href="http://www.mathematik.uni-bielefeld.de/~sillke/codes/luhn-method">code</a>, wikipedia里面有java和pyhon的</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">The Luhn Mod<span style="color: #339933;">-</span><span style="color: #0000dd;">10</span> Method <span style="color: #009900;">&#40;</span>ISO <span style="color: #0000dd;">2894</span><span style="color: #339933;">/</span>ANSI <span style="color:#800080;">4.13</span><span style="color: #009900;">&#41;</span> involves a check digit in the
one<span style="color: #ff0000;">'s position.  The check digit is calculated starting at the right with
the digit immediately preceding the check digit (ten'</span>s digit<span style="color: #009900;">&#41;</span> and moving
toward the left<span style="color: #339933;">,</span> doubling every other digit.  <span style="color: #202020;">If</span> a doubled digit is greater
than nine<span style="color: #339933;">,</span> the two digits are added to together to obtain a single<span style="color: #339933;">-</span>digit
result.  <span style="color: #202020;">The</span> sum of all the resulting digits <span style="color: #009900;">&#40;</span>including those skipped<span style="color: #009900;">&#41;</span> is then
taken modulo with <span style="color: #0000dd;">10</span><span style="color: #339933;">,</span> to obtain the check digit.
&nbsp;
<span style="color: #202020;">Below</span><span style="color: #339933;">,</span> is untested code.
&nbsp;
<span style="color: #808080; font-style: italic;">/************************************************************************
*  LuhnMod10 - self-checking scheme for validating card account numbers
*  according to ISO 2894/ANSI 4.13.
*
*    Ex:  cardNumber = &quot;795102879015546&quot;
*         strlen(cardNumber) == 15
*         LuhnMod10(cardNumber, 14) == 6 == cardNumber[14]
*
************************************************************************/</span>
<span style="color: #993333;">int</span> LuhnMod10<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span> cardNumber<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> size<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">static</span> <span style="color: #993333;">int</span> table<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span><span style="color: #0000dd;">4</span><span style="color: #339933;">,</span><span style="color: #0000dd;">5</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span><span style="color: #339933;">,</span><span style="color: #0000dd;">8</span><span style="color: #339933;">,</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span><span style="color: #0000dd;">2</span><span style="color: #339933;">,</span><span style="color: #0000dd;">4</span><span style="color: #339933;">,</span><span style="color: #0000dd;">6</span><span style="color: #339933;">,</span><span style="color: #0000dd;">8</span><span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span><span style="color: #0000dd;">3</span><span style="color: #339933;">,</span><span style="color: #0000dd;">5</span><span style="color: #339933;">,</span><span style="color: #0000dd;">7</span><span style="color: #339933;">,</span><span style="color: #0000dd;">9</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #339933;">=</span>size<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> odd<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> sum<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>isdigit<span style="color: #009900;">&#40;</span>cardNumber<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      sum <span style="color: #339933;">+=</span> table<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>odd<span style="color: #339933;">=</span><span style="color: #0000dd;">1</span><span style="color: #339933;">-</span>odd<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span>cardNumber<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">-</span><span style="color: #ff0000;">'0'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  sum <span style="color: #339933;">%=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>sum <span style="color: #339933;">?</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">-</span>sum <span style="color: #339933;">:</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>               <span style="color: #808080; font-style: italic;">/* return the check digit */</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>站在巨人的肩膀是不是有一种很强大的感觉。好吧，我们既然要把要在iphone上实现，那首先需要一个Objective-C的代码. here is it ,从C代码修改过来并不是很难。</p>
<p>CheckCreditCard.h</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="objective-c" style="font-family:monospace;">#import 
&nbsp;
@interface CheckCreditCard : NSObject {
	IBOutlet NSTextField *ccNum;
	IBOutlet NSTextField *ccTrue;
&nbsp;
}
- (IBAction)checkIt:(id)sender;
@end</pre></td></tr></table></div>

<p>CheckCreditCard.m</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
</pre></td><td class="code"><pre class="objective-c" style="font-family:monospace;">//  CheckCreditCard.m
//  Verify Credit Card
//
//  Created by cyher on 11-3-8.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//
&nbsp;
#import &quot;CheckCreditCard.h&quot;
&nbsp;
@implementation CheckCreditCard
&nbsp;
- (id)init
{
	[super init];
	NSLog(@&quot;Init!&quot;);
	return self;
}
&nbsp;
- (IBAction)checkIt:(id)sender
{
	int sumTable[10][10] = {{0,1,2,3,4,5,6,7,8,9},{0,2,4,6,8,1,3,5,7,9}};
	int sum = 0, flip = 0;
&nbsp;
	NSString *string = [ccNum stringValue];
	NSLog(@&quot;ccNum = %@&quot;, string);
	if ([string length] == 0)
		return;
	for (int i = [string length] - 1; i &amp;gt;= 0; i--)
		sum +=
		sumTable[flip++ &amp;amp; 0x1][[string characterAtIndex:i] - '0'];
	NSLog(@&quot;sum = %d&quot;, sum);
	if (0 == (sum % 10)) {
		[ccTrue setStringValue:[NSString stringWithFormat
				       :@&quot;This is a real Credit Card!&quot;,
				       [string length]]];
	} else {
		[ccTrue setStringValue:[NSString stringWithFormat
					:@&quot;This is fake Credit Card!&quot;,
					[string length]]];
	}
&nbsp;
	return;
}
&nbsp;
@end</pre></td></tr></table></div>

<p>来我们看看在mac上的效果吧:</p>
<p><a href="http://cyher.net/wp-content/uploads/2011/03/fake.png" rel="lightbox[637084]"><img class="aligncenter size-full wp-image-637087" title="fake" src="http://cyher.net/wp-content/uploads/2011/03/fake.png" alt="" width="280" height="135" /></a></p>
<p>&nbsp;</p>
<p><a href="http://cyher.net/wp-content/uploads/2011/03/real.png" rel="lightbox[637084]"><img class="aligncenter size-full wp-image-637088" title="real" src="http://cyher.net/wp-content/uploads/2011/03/real.png" alt="" width="285" height="137" /></a></p>
<p>怎么样很简单吧， 如果我们能够调用goggle（google的图形识别程序，基于云计算）的API，我们能够从图片转换成数字。其实一个有意思的小软件就成了. 希望我们能运用生活中的小科技, 来改变我们的生活吧.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/apple/cocoa/credit-card-check/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用syerngy共享屏幕和键盘鼠标，超级KVM</title>
		<link>http://cyher.net/gnulinux/share-screen-and-keyboard-mouse-with-syerngy</link>
		<comments>http://cyher.net/gnulinux/share-screen-and-keyboard-mouse-with-syerngy#comments</comments>
		<pubDate>Sat, 12 Feb 2011 04:28:51 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[keyborad]]></category>
		<category><![CDATA[KVM]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mouse]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[键盘]]></category>
		<category><![CDATA[鼠标]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637073</guid>
		<description><![CDATA[自己在公司里写了个syerngy简单的介绍，觉得挺好的，就发上来了，英语不好，凑合看吧。这里介绍了ubuntu和windows互联，其实这个软件的特点就是多系统，windows，mac，linux都可以，如果有两台以上电脑很推荐此软件。 Would you want improve work efficiency? Do you dislike there is not only one mouse on your desk? Did you want share clipboard data between different OS, easily? If have YES in your answers, haha, let&#8217;s begin! Ok. Shortly, Synergy!! Synergy is a software. here is it&#8217;s website: http://synergy-foss.org/pm/projects/synergy/tabs/welcome STEP: On the Client Windows [...]]]></description>
			<content:encoded><![CDATA[<div>自己在公司里写了个syerngy简单的介绍，觉得挺好的，就发上来了，英语不好，凑合看吧。这里介绍了ubuntu和windows互联，其实这个软件的特点就是多系统，windows，mac，linux都可以，如果有两台以上电脑很推荐此软件。</div>
<div>Would you want improve work efficiency?</div>
<div>Do you dislike there is not only one mouse on your desk?</div>
<div>Did you want share clipboard data between different OS, easily?</div>
<div>If have YES in your answers, haha, let&#8217;s begin!</p>
<div>Ok. Shortly, Synergy!! Synergy is a software.</div>
</div>
<div>here is it&#8217;s website:</div>
<div><a href="http://synergy-foss.org/pm/projects/synergy/tabs/welcome">http://synergy-foss.org/pm/projects/synergy/tabs/welcome</a></div>
<div>STEP:</div>
<div>On the Client</div>
<div>Windows is a Client, So download this:</div>
<div><a href="http://synergy-plus.googlecode.com/files/synergy-plus-1.3.4-Windows-x64-r1.exe">http://synergy-plus.googlecode.com/files/synergy-plus-1.3.4-Windows-x64-r1.exe</a></div>
<blockquote></blockquote>
<div>Install this.</div>
<ol>
<li>choose “Use another computer&#8217;s shared keyboard and mouse [client]“</li>
<li>Type your <a href="http://cyher.net/tag/linux" class="st_tag internal_tag" rel="tag" title="标签 linux 下的日志">linux</a> pc&#8217;s host name, you can find it with this command “uname -n”</li>
<li>Press start.</li>
</ol>
<div>OK, That is all.</div>
<div><a href="http://cyher.net/wp-content/uploads/2011/02/153a6f65-a1e4-4215-83e1-3f4a379d4d6a.png" rel="lightbox[637073]"><img class="aligncenter size-full wp-image-637075" title="windows7" src="http://cyher.net/wp-content/uploads/2011/02/153a6f65-a1e4-4215-83e1-3f4a379d4d6a.png" alt="" width="466" height="361" /></a></div>
<div>On the Server</div>
<div>Follow these steps on the computer with the keyboard and mouse.</p>
<p>Install QuickSynergy:</p></div>
<div>In <a href="http://cyher.net/tag/ubuntu" class="st_tag internal_tag" rel="tag" title="标签 ubuntu 下的日志">Ubuntu</a> Software Center, search “QuickSynergy”.</div>
<div>Open it (under Applications &gt; Accessories)<br />
Under the &#8216;Share&#8217; tab enter the hostname or IP address of the Client machines in one of the directional boxes. The directional box you choose will determine which edge of the Host computer&#8217;s screen the mouse will “run off”.<br />
Click Execute<br />
Move the mouse to the edge of the Host screen &#8212; it should now appear on the client screen.</div>
<div><a href="http://cyher.net/wp-content/uploads/2011/02/Screenshot-1.png" rel="lightbox[637073]"><img class="aligncenter size-full wp-image-637076" title="ubuntu" src="http://cyher.net/wp-content/uploads/2011/02/Screenshot-1.png" alt="" width="323" height="294" /></a></div>
<div>OK ,Have fun&#8230;.</div>
<div></div>
<div>refer：</div>
<div><a href="https://help.ubuntu.com/community/SynergyHowto">https://help.ubuntu.com/community/SynergyHowto</a></div>
<div>延伸：想在win7上用的更爽就看看了</div>
<div><a href="http://n00tz.net/2010/01/quick-tip-synergy-on-windows-7/">http://n00tz.net/2010/01/quick-tip-synergy-on-windows-7/</a></div>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/share-screen-and-keyboard-mouse-with-syerngy/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android 手机电源管理实例 &#8211; milestone</title>
		<link>http://cyher.net/gnulinux/android/android-phone-powermanagement</link>
		<comments>http://cyher.net/gnulinux/android/android-phone-powermanagement#comments</comments>
		<pubDate>Sun, 25 Jul 2010 08:07:59 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[milestone]]></category>
		<category><![CDATA[power management]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637064</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[
<table id="wp-table-reloaded-id-1-no-1" class="wp-table-reloaded wp-table-reloaded-id-1">
<thead>
	<tr class="row-1 odd">
		<th class="column-1"></th><th class="column-2">MOTO Milestone (omap)</th><th class="column-3">HTC tattoo (msm7225)</th><th class="column-4">HTC Magic (msm7201A)</th><th class="column-5">某手机(保密)(msm7227)</th>
	</tr>
</thead>
<tbody>
	<tr class="row-2 even">
		<td class="column-1">开机过程</td><td class="column-2">200ma-1000ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5">200ma-500ma</td>
	</tr>
	<tr class="row-3 odd">
		<td class="column-1">HSDPA 联网</td><td class="column-2">700ma</td><td class="column-3"></td><td class="column-4">500ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-4 even">
		<td class="column-1">idle, 屏幕最暗, 黑色背景,键灯关</td><td class="column-2">44ma</td><td class="column-3">13ma</td><td class="column-4">33ma</td><td class="column-5">60ma</td>
	</tr>
	<tr class="row-5 odd">
		<td class="column-1">idle, 屏幕中等, 黑色背景,键灯关</td><td class="column-2">69ma</td><td class="column-3">64ma</td><td class="column-4">73ma</td><td class="column-5">88ma</td>
	</tr>
	<tr class="row-6 even">
		<td class="column-1">idle, 屏幕最亮, 黑色背景,键灯关</td><td class="column-2">104ma</td><td class="column-3">97ma</td><td class="column-4">135ma</td><td class="column-5">120ma</td>
	</tr>
	<tr class="row-7 odd">
		<td class="column-1">idle, 屏幕最暗, 动态桌面,键灯关</td><td class="column-2">330ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-8 even">
		<td class="column-1">idle, 屏幕中等, 动态桌面,键灯关</td><td class="column-2">350ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-9 odd">
		<td class="column-1">idle, 屏幕最亮, 动态桌面,键灯关</td><td class="column-2">450ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-10 even">
		<td class="column-1">idle, 屏幕最暗, 白背景,键灯关</td><td class="column-2">51ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-11 odd">
		<td class="column-1">idle, 屏幕中等, 白背景,键灯关</td><td class="column-2">92ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-12 even">
		<td class="column-1">idle, 屏幕最亮, 白背景,键灯关</td><td class="column-2">167ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-13 odd">
		<td class="column-1">照相机预览</td><td class="column-2">400ma-500ma(1G)<br />
325ma-350ma(550M)</td><td class="column-3">210ma-260ma</td><td class="column-4">295ma-334ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-14 even">
		<td class="column-1">录制音频(开屏)</td><td class="column-2">107ma-112ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-15 odd">
		<td class="column-1">录制音频(关屏)</td><td class="column-2">43ma-59ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-16 even">
		<td class="column-1">录制视频</td><td class="column-2">500ma-700ma(1G)<br />
427ma-558ma(550M)</td><td class="column-3">260ma-360ma</td><td class="column-4">360ma-390ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-17 odd">
		<td class="column-1">google maps(gps开)</td><td class="column-2">540ma-750ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-18 even">
		<td class="column-1">浏览网页(HSDPA)(有数据链接时)</td><td class="column-2">400ma-600ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-19 odd">
		<td class="column-1">浏览网页(EDGE)(有数据链接时)</td><td class="column-2">200ma-500ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-20 even">
		<td class="column-1">开屏,放mp3,耳机</td><td class="column-2">90ma-120ma</td><td class="column-3"></td><td class="column-4">168ma-220ma</td><td class="column-5">285ma</td>
	</tr>
	<tr class="row-21 odd">
		<td class="column-1">关屏, 放mp3,耳机</td><td class="column-2">30ma-50ma</td><td class="column-3"></td><td class="column-4">93ma-112ma</td><td class="column-5">210ma</td>
	</tr>
	<tr class="row-22 even">
		<td class="column-1">开屏, 放mp4,耳机(放自己拍摄的)</td><td class="column-2">250ma-300ma</td><td class="column-3"></td><td class="column-4">300ma-327ma</td><td class="column-5"></td>
	</tr>
	<tr class="row-23 odd">
		<td class="column-1">开启g-sensro和gps</td><td class="column-2">320ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-24 even">
		<td class="column-1">wifi扫描时</td><td class="column-2">150ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-25 odd">
		<td class="column-1">开led闪光灯(长亮)</td><td class="column-2">50ma(单独计算)</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-26 even">
		<td class="column-1">虚拟按键led</td><td class="column-2">20ma(单独计算)</td><td class="column-3">14ma</td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-27 odd">
		<td class="column-1">GSM通话(开接近)</td><td class="column-2">350ma-450ma</td><td class="column-3"></td><td class="column-4"></td><td class="column-5"></td>
	</tr>
	<tr class="row-28 even">
		<td class="column-1">suspend(关屏进入休眠)</td><td class="column-2">2ma</td><td class="column-3">1ma</td><td class="column-4">1ma</td><td class="column-5">2ma</td>
	</tr>
</tbody>
</table>

]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/android-phone-powermanagement/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>这样的房,这样的车,这样的女人(阿哈哈)</title>
		<link>http://cyher.net/webthings/%e8%bf%99%e6%a0%b7%e7%9a%84%e6%88%bf%e8%bf%99%e6%a0%b7%e7%9a%84%e8%bd%a6%e8%bf%99%e6%a0%b7%e7%9a%84%e5%a5%b3%e4%ba%ba%e9%98%bf%e5%93%88%e5%93%88</link>
		<comments>http://cyher.net/webthings/%e8%bf%99%e6%a0%b7%e7%9a%84%e6%88%bf%e8%bf%99%e6%a0%b7%e7%9a%84%e8%bd%a6%e8%bf%99%e6%a0%b7%e7%9a%84%e5%a5%b3%e4%ba%ba%e9%98%bf%e5%93%88%e5%93%88#comments</comments>
		<pubDate>Sat, 17 Jul 2010 13:34:17 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[网事如沙]]></category>
		<category><![CDATA[女人]]></category>
		<category><![CDATA[房]]></category>
		<category><![CDATA[车]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637060</guid>
		<description><![CDATA[x:  什么是房子, 什么是车, 连老爹的女人都霸占了. 1x: 住老爹的房, 坐老爹的车, 连泡妞都用老爹的钱 2x: 和别人拼房, 和别人拼车, 连女朋友都和别人拼. 3x: 开二手车, 住二手房, 连媳妇都是二手的. 4x: 开上新车了, 住上大房子了, 连媳妇都都不止一个了. 5x: 开不动车了, 上不动楼了, 连孩子都说我不是亲爹了. 6x: 给孩子买车, 给孩子买房, 连儿媳妇都要帮着去相了. 7x: 车坏了, 房拆了, 连给自己买个墓地都要排号了. 8x: 再也不需要车了, 也不需要房了,连自己是生是死都不重要了. 可以说真的是闲着没事干, 才写了这样的话. 是挺消极的, 但是&#8230;..改变,还是顺从?]]></description>
			<content:encoded><![CDATA[<h3>x:  什么是房子, 什么是车, 连老爹的女人都霸占了.</h3>
<h3>1x: 住老爹的房, 坐老爹的车, 连泡妞都用老爹的钱</h3>
<h3>2x: 和别人拼房, 和别人拼车, 连女朋友都和别人拼.</h3>
<h3>3x: 开二手车, 住二手房, 连媳妇都是二手的.</h3>
<h3>4x: 开上新车了, 住上大房子了, 连媳妇都都不止一个了.</h3>
<h3>5x: 开不动车了, 上不动楼了, 连孩子都说我不是亲爹了.</h3>
<h3>6x: 给孩子买车, 给孩子买房, 连儿媳妇都要帮着去相了.</h3>
<h3>7x: 车坏了, 房拆了, 连给自己买个墓地都要排号了.</h3>
<h3>8x: 再也不需要车了, 也不需要房了,连自己是生是死都不重要了.</h3>
<p>可以说真的是闲着没事干, 才写了这样的话. 是挺消极的, 但是&#8230;..改变,还是顺从?</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/webthings/%e8%bf%99%e6%a0%b7%e7%9a%84%e6%88%bf%e8%bf%99%e6%a0%b7%e7%9a%84%e8%bd%a6%e8%bf%99%e6%a0%b7%e7%9a%84%e5%a5%b3%e4%ba%ba%e9%98%bf%e5%93%88%e5%93%88/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>macbook pro ubuntu10.4 bcm无线网卡问题修复</title>
		<link>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver</link>
		<comments>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver#comments</comments>
		<pubDate>Sun, 02 May 2010 13:03:00 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[GNU/linux]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[macbook]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637057</guid>
		<description><![CDATA[话说虽然用了macbook pro成了apple fan但是也没有使我对linux的热情衰减， 这不刚刚把macbook pro上的9.10升级为10.4， 这回我相信ubuntu的自动升级能力，但是结果是，我不应该像要求mac os x一样要求 ubuntu。 有几个东西不能用了，但是那也无关紧要，最要命的使我的wireless的驱动没了，装不上了，靠。这个我受不了。找到了以下解决方法。 首先，说明一点，我的电脑是macbook pro 471，就是macbook pro 5,1. 本来是应该这样解决的 System-&#62;Administration-&#62;Hardware Drivers. Select the Broadcom STA options and click enable. 但是现在不行了。 1. 下载broadcom驱动源码，http://www.broadcom.com/support/802.11/linux_sta.php 2. 解压，然后找到 src/wl/sys/wl_linux.c 这个文件 3. 在 #include &#60;XX.h&#62;的下面一行加上下面的代码 #include &#60;﻿linux/sched.h&#62; 4. 编译源码  make 5.把新编译的driver放到lib中 sudo mv wl.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless 6. 更新依赖关系 sudo depmod -a 7. ok [...]]]></description>
			<content:encoded><![CDATA[<p>话说虽然用了macbook pro成了apple fan但是也没有使我对linux的热情衰减， 这不刚刚把macbook pro上的9.10升级为10.4， 这回我相信ubuntu的自动升级能力，但是结果是，我不应该像要求mac os x一样要求 <a href="http://cyher.net/tag/ubuntu" class="st_tag internal_tag" rel="tag" title="标签 ubuntu 下的日志">ubuntu</a>。 有几个东西不能用了，但是那也无关紧要，最要命的使我的wireless的驱动没了，装不上了，靠。这个我受不了。找到了以下解决方法。</p>
<p>首先，说明一点，我的电脑是macbook pro 471，就是macbook pro 5,1.</p>
<p>本来是应该这样<a href="https://help.ubuntu.com/community/MacBookPro5-1_5-2/Lucid#Wireless">解决</a>的</p>
<blockquote><p>System-&gt;Administration-&gt;Hardware Drivers. Select the Broadcom STA options and click enable.</p></blockquote>
<p>但是现在不行了。</p>
<p>1. 下载broadcom驱动源码，<a href="http://www.broadcom.com/support/802.11/linux_sta.php" target="_blank">http://www.broadcom.com/support/802.11/linux_sta.php</a></p>
<p>2. 解压，然后找到 src/wl/sys/wl_<a href="http://cyher.net/tag/linux" class="st_tag internal_tag" rel="tag" title="标签 linux 下的日志">linux</a>.c 这个文件</p>
<p>3. 在 #include &lt;XX.h&gt;的下面一行加上下面的代码</p>
<p><code>#include &lt;﻿linux/sched.h&gt;</code></p>
<p>4. 编译源码  make</p>
<p>5.把新编译的driver放到lib中</p>
<p><code>sudo mv wl.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless</code></p>
<p>6. 更新依赖关系</p>
<p><code>sudo depmod -a</code></p>
<p>7. ok 加入内核<br />
modprobe wl<br />
8. 如果编译报 没有include &lt;linux/sched.h&gt; 加入新的内核头文件。</p>
<p><code>sudo apt-get install linux-headers-$(uname -r)</code></p>
<p>到这里基本上就ok了 可以继续自由自在了，至于以后升级内核从新来一遍就ok</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/macbook-pro-ubuntu10-4-bcm-wireless-driver/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>android驱动之虚拟按键</title>
		<link>http://cyher.net/gnulinux/android/virualkey</link>
		<comments>http://cyher.net/gnulinux/android/virualkey#comments</comments>
		<pubDate>Mon, 22 Mar 2010 03:09:57 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[virualkey]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637050</guid>
		<description><![CDATA[1    背景 nexus one工业设计简洁，类似于iphone只有一个按键的设计，只有中间的一个轨迹球。但是android标准键盘是有 HOME，MENU，BACK，SEARCH等，但是同时要保持工业设计。nexus one是这样解决问题的，显示屏是800X480，但是在电容触摸屏是8xx*480的就是比800要大的地方就变成了虚拟按键，模拟了android标准按键。 2    方案 要实现，虚拟按键，在android里面是靠两层协助实现，底层要把虚拟按键在比显示屏多出的地方规定好虚拟按键的位置大小以及键值等，给上层一文件接口。上层java层启动一个服务来读取这一区域的按键响应，这样就是大体的架构。具体实现如下： 2.1    底层虚拟按键功能实现方案 简而言之，就是在内核中把虚拟按键的所有信息给上层给出，用什么方式？就是用sys文件系统的方式，sys文件系统的路径是约定好的所以代码如下实现。给出信息的协议格式是一段连续的字符串，每个按键有六项分别用冒号分割，按键按键之间也是用冒号分割，六项按顺序分别是： 键类型:键值:按键区域中心x坐标:按键区域中心y坐标:按键区域宽:按键区域高 arch/arm/mach-msm/board-mahimahi.c static ssize_t mahimahi_virtual_keys_show&#40;struct kobject *kobj, struct kobj_attribute *attr, char *buf&#41; &#123; if &#40;system_rev &#38;gt; 2&#41; &#123; /* center: x: back: 55, menu: 172, home: 298, search 412, y: 835 */ return sprintf&#40;buf, __stringify&#40;EV_KEY&#41; &#34;:&#34; __stringify&#40;KEY_BACK&#41; &#34;:55:835:90:55&#34; &#34;:&#34; __stringify&#40;EV_KEY&#41; &#34;:&#34; __stringify&#40;KEY_MENU&#41; &#34;:172:835:125:55&#34; [...]]]></description>
			<content:encoded><![CDATA[<h1>1    背景</h1>
<p>nexus one工业设计简洁，类似于iphone只有一个按键的设计，只有中间的一个轨迹球。但是android标准键盘是有 HOME，MENU，BACK，SEARCH等，但是同时要保持工业设计。nexus one是这样解决问题的，显示屏是800X480，但是在电容触摸屏是8xx*480的就是比800要大的地方就变成了虚拟按键，模拟了android标准按键。</p>
<h1>2    方案</h1>
<p>要实现，虚拟按键，在android里面是靠两层协助实现，底层要把虚拟按键在比显示屏多出的地方规定好虚拟按键的位置大小以及键值等，给上层一文件接口。上层java层启动一个服务来读取这一区域的按键响应，这样就是大体的架构。具体实现如下：</p>
<h3>2.1    底层虚拟按键功能实现方案</h3>
<p>简而言之，就是在内核中把虚拟按键的所有信息给上层给出，用什么方式？就是用sys文件系统的方式，sys文件系统的路径是约定好的所以代码如下实现。给出信息的协议格式是一段连续的字符串，每个按键有六项分别用冒号分割，按键按键之间也是用冒号分割，六项按顺序分别是：</p>
<p><code>键类型:键值:按键区域中心x坐标:按键区域中心y坐标:按键区域宽:按键区域高</code></p>
<p>arch/arm/mach-msm/board-mahimahi.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> ssize_t mahimahi_virtual_keys_show<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> kobject <span style="color: #339933;">*</span>kobj<span style="color: #339933;">,</span>
			       <span style="color: #993333;">struct</span> kobj_attribute <span style="color: #339933;">*</span>attr<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buf<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>system_rev <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/* center: x: back: 55, menu: 172, home: 298, search 412, y: 835 */</span>
		<span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span>
			__stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_BACK<span style="color: #009900;">&#41;</span>  <span style="color: #ff0000;">&quot;:55:835:90:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_MENU<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:172:835:125:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_HOME<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:298:835:115:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_SEARCH<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:412:835:95:55&quot;</span>
		   <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #808080; font-style: italic;">/* center: x: home: 55, menu: 185, back: 305, search 425, y: 835 */</span>
		<span style="color: #b1b100;">return</span> sprintf<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span>
			__stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_HOME<span style="color: #009900;">&#41;</span>  <span style="color: #ff0000;">&quot;:55:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_MENU<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:185:835:100:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_BACK<span style="color: #009900;">&#41;</span>   <span style="color: #ff0000;">&quot;:305:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>EV_KEY<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:&quot;</span> __stringify<span style="color: #009900;">&#40;</span>KEY_SEARCH<span style="color: #009900;">&#41;</span> <span style="color: #ff0000;">&quot;:425:835:70:55&quot;</span>
		   <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> kobj_attribute mahimahi_virtual_keys_attr <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	.<span style="color: #202020;">attr</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
		.<span style="color: #202020;">name</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;virtualkeys.synaptics-rmi-touchscreen&quot;</span><span style="color: #339933;">,</span>
		.<span style="color: #202020;">mode</span> <span style="color: #339933;">=</span> S_IRUGO<span style="color: #339933;">,</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	.<span style="color: #202020;">show</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_virtual_keys_show<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> attribute <span style="color: #339933;">*</span>mahimahi_properties_attrs<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_virtual_keys_attr.<span style="color: #202020;">attr</span><span style="color: #339933;">,</span>
	NULL
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> attribute_group mahimahi_properties_attr_group <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	.<span style="color: #202020;">attrs</span> <span style="color: #339933;">=</span> mahimahi_properties_attrs<span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> kobject <span style="color: #339933;">*</span>properties_kobj<span style="color: #339933;">;</span>
&nbsp;
properties_kobj <span style="color: #339933;">=</span> kobject_create_and_add<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;board_properties&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>properties_kobj<span style="color: #009900;">&#41;</span>
	ret <span style="color: #339933;">=</span> sysfs_create_group<span style="color: #009900;">&#40;</span>properties_kobj<span style="color: #339933;">,</span>
					 <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>mahimahi_properties_attr_group<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>properties_kobj <span style="color: #339933;">||</span> ret<span style="color: #009900;">&#41;</span>
	pr_err<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;failed to create board_properties<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>2.2    JAVA上层方案</h3>
<p>Java层主要是读取按键信息，然后经过一定的算法，来识别虚拟按键，基本不需要修改，但最好还是熟悉java层的架构这样出问题的时候利于定位<br />
frameworks/base/services/java/com/<a href="http://cyher.net/tag/android" class="st_tag internal_tag" rel="tag" title="标签 android 下的日志">android</a>/server/KeyInputQueue.java</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*这是虚拟按键的类里面包括了VirtualKey所用到的成员变量和按键定位方法*/</span>
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> VirtualKey <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> scancode<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> centerx<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> centery<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> width<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> height<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> hitLeft<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitTop<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitRight<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> hitBottom<span style="color: #339933;">;</span>
&nbsp;
        InputDevice lastDevice<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> lastKeycode<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">boolean</span> checkHit<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x, <span style="color: #000066; font-weight: bold;">int</span> y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>x <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> hitLeft <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> x <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> hitRight                     <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> y <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> hitTop <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> y <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> hitBottom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">void</span> computeHitRect<span style="color: #009900;">&#40;</span>InputDevice dev, <span style="color: #000066; font-weight: bold;">int</span> dw, <span style="color: #000066; font-weight: bold;">int</span> dh<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dev <span style="color: #339933;">==</span> lastDevice<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;computeHitRect for &quot;</span> <span style="color: #339933;">+</span> scancode
                    <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: dev=&quot;</span> <span style="color: #339933;">+</span> dev <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; absX=&quot;</span> <span style="color: #339933;">+</span> dev.<span style="color: #006633;">absX</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; absY=&quot;</span> <span style="color: #339933;">+</span> dev.<span style="color: #006633;">absY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            lastDevice <span style="color: #339933;">=</span> dev<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> minx <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absX</span>.<span style="color: #006633;">minValue</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> maxx <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absX</span>.<span style="color: #006633;">maxValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> halfw <span style="color: #339933;">=</span> width<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> left <span style="color: #339933;">=</span> centerx <span style="color: #339933;">-</span> halfw<span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> right <span style="color: #339933;">=</span> centerx <span style="color: #339933;">+</span> halfw<span style="color: #339933;">;</span>
            hitLeft <span style="color: #339933;">=</span> minx <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>left<span style="color: #339933;">*</span>maxx<span style="color: #339933;">-</span>minx<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            hitRight <span style="color: #339933;">=</span> minx <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>right<span style="color: #339933;">*</span>maxx<span style="color: #339933;">-</span>minx<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> miny <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absY</span>.<span style="color: #006633;">minValue</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> maxy <span style="color: #339933;">=</span> dev.<span style="color: #006633;">absY</span>.<span style="color: #006633;">maxValue</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> halfh <span style="color: #339933;">=</span> height<span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> top <span style="color: #339933;">=</span> centery <span style="color: #339933;">-</span> halfh<span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> bottom <span style="color: #339933;">=</span> centery <span style="color: #339933;">+</span> halfh<span style="color: #339933;">;</span>
            hitTop <span style="color: #339933;">=</span> miny <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>top<span style="color: #339933;">*</span>maxy<span style="color: #339933;">-</span>miny<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dh<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            hitBottom <span style="color: #339933;">=</span> miny <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>bottom<span style="color: #339933;">*</span>maxy<span style="color: #339933;">-</span>miny<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>dh<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/*以下就是与底层接口的函数，如果这个函数和底层接口正常，基本上虚拟按键就能够ok*/</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> readVirtualKeys<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> deviceName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">FileInputStream</span> fis <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileInputStream</span><span style="color: #009900;">&#40;</span>
                    <span style="color: #0000ff;">&quot;/sys/board_properties/virtualkeys.&quot;</span> <span style="color: #339933;">+</span> deviceName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*这里就是读取kernel给出信息的地方，也就是地层与上层接口的地方，所以整个实现的重点就是这里*/</span>
            <span style="color: #003399;">InputStreamReader</span> isr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>fis<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">BufferedReader</span> br <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span>isr, <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">String</span> str <span style="color: #339933;">=</span> br.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> it <span style="color: #339933;">=</span> str.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;***** VIRTUAL KEYS: &quot;</span> <span style="color: #339933;">+</span> it<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> N <span style="color: #339933;">=</span> it.<span style="color: #006633;">length</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span>N<span style="color: #339933;">;</span> i<span style="color: #339933;">+=</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #0000ff;">&quot;0x01&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Unknown virtual key type at elem #&quot;</span> <span style="color: #339933;">+</span> i
                                <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: &quot;</span> <span style="color: #339933;">+</span> it<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                        VirtualKey sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> VirtualKey<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">scancode</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">centerx</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">centery</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">width</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        sb.<span style="color: #006633;">height</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>it<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>DEBUG_VIRTUAL_KEYS<span style="color: #009900;">&#41;</span> Log.<span style="color: #006633;">v</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Virtual key &quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">scancode</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;: center=&quot;</span> <span style="color: #339933;">+</span> sb.<span style="color: #006633;">centerx</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;,&quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">centery</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; size=&quot;</span> <span style="color: #339933;">+</span> sb.<span style="color: #006633;">width</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;x&quot;</span>
                                <span style="color: #339933;">+</span> sb.<span style="color: #006633;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        mVirtualKeys.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sb<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NumberFormatException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Bad number at region &quot;</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; in: &quot;</span>
                                <span style="color: #339933;">+</span> str, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            br.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Log.<span style="color: #006633;">i</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;No virtual keys found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Log.<span style="color: #006633;">w</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Error reading virtual keys&quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<h3>2.3    总结</h3>
<p>方案基本上就是这样，主要是调试工作可能需要一段时间，还有如果要做虚拟按键，还需要硬件的支持（超过显示区域的触摸屏区域）。本代码基于android 2.1请根据实际情况修改</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/virualkey/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>真有蛋疼人&#8230;..</title>
		<link>http://cyher.net/useless_stuff/%e7%9c%9f%e6%9c%89%e8%9b%8b%e7%96%bc%e4%ba%ba</link>
		<comments>http://cyher.net/useless_stuff/%e7%9c%9f%e6%9c%89%e8%9b%8b%e7%96%bc%e4%ba%ba#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:57:02 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[/dev/null]]></category>
		<category><![CDATA[p民]]></category>
		<category><![CDATA[蛋疼]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637047</guid>
		<description><![CDATA[看来, 广大p民还是比较蛋疼的&#8230;..哪个姐妹有处理的? 赶紧去百姓网&#8230;..呵呵&#8230;.]]></description>
			<content:encoded><![CDATA[<p><a href="http://cyher.net/wp-content/uploads/2010/03/danteng.png" rel="lightbox[637047]"><img class="aligncenter size-full wp-image-637048" title="danteng" src="http://cyher.net/wp-content/uploads/2010/03/danteng.png" alt="" width="382" height="307" /></a>看来, 广大p民还是比较蛋疼的&#8230;..哪个姐妹有处理的? 赶紧去百姓网&#8230;..呵呵&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/useless_stuff/%e7%9c%9f%e6%9c%89%e8%9b%8b%e7%96%bc%e4%ba%ba/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>android驱动之jogball</title>
		<link>http://cyher.net/gnulinux/android/android-driver-jogball</link>
		<comments>http://cyher.net/gnulinux/android/android-driver-jogball#comments</comments>
		<pubDate>Tue, 16 Mar 2010 09:18:16 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637024</guid>
		<description><![CDATA[1 简介 JogBall是首款Android手机-HTC Dream上附带的类似轨迹球Trackball的滑轮，通过Jogball用户可以轻松的实现网页的翻页、地图翻 转等操作，这种在手机上增加轨迹球的方式可以取消传统的4维导航键，Jogball并非HTC公司的首例，早在HTC 3300(Dopod P800)就 实现了这项功能，轨迹球操作方式的加入可以实现像电脑上鼠标一样轻松操控。现在jogball基本上算是android手机的标准配置了。 2 框图&#38;架构 2.1 gpio_event子系统 Jogball驱动是由linux代码中的gpio_event子系统实现的。 由以下文件组成： driver/input/misc/gpio_event.c driver/input/misc/gpio_input.c driver/input/misc/gpio_output.c driver/input/misc/gpio_matrix.c driver/input/misc/gpio_axis.c gpio_event子系统是一个关于gpio的输入设备的通用代码，里面可以包含一般嵌入式设备中需要的键盘阵列和坐标有关的输入等。 2.2 Jogball架构 Jogball是归类于gpio_axis.c中的，是一个相对坐标系，判断电信号的高低来对坐标加或者减一定数值。具体细节在gpio_axis.c中 gpio_axis.c中的结构体初始化是在xxx-borad.c中的，基本架构就是这样，细节在下文叙述。 3 硬件描述 3.1 Jogball机械特性 Jogball是一个基于滚球滚动的输入设备，所以它机械特性也是比较重要，知道他的机械特性，便于我们理解驱动。 Jogball和以前的滚球鼠标比较相似，依靠滚轮的滚动来带动四周的圆柱体旋转。每个圆柱体端头都有一个磁铁，这个磁体铁从横断 面来看就是由N极的扇形和S极的扇形来组成一个圆周。这样当磁铁旋转的时候，N极和S极切换，使霍尔IC产生高低电平。 注意：在滚球旋转时，两个相对方向只有一个方向可以转动，这是为了减化软件编写的一个机械特性。 3.2 Jogball的电气特性 Jogball最重要的电特性就是这个霍尔IC， 霍尔元件的工作原理：所谓霍尔效应，是指磁场作用于载流金属导体、半导体中的载流子时，产生横向电位差的物理现 象。金属的霍尔效应是1879年被美 国物理学家霍尔发现的。当电流通过金属箔片时，若在垂直于电流的方向施加磁场，则金属箔片 两侧面会出现横向电位差。半导体中的霍尔效应比金属箔片中更为明 显，而铁磁金属在居里温度以下将呈现极强的霍尔效应。 所以jogball是旋转磁轴引起磁场的变幻，来产生高低电压的。从而根据机械特性就不难理解jogball的数字输入过程。 3.3 Jogball的原理图 其实jogball只是机械结构,原理图是hall ic的,有兴趣的人在这里下载 4 数据结构 struct hero_axis_info &#123; struct gpio_event_axis_info info; /*gpio_event_axis结构的信息*/ uint16_t [...]]]></description>
			<content:encoded><![CDATA[<h1><span style="color: #000000;">1 简介</span></h1>
<p>JogBall是首款Android手机-HTC Dream上附带的类似轨迹球Trackball的滑轮，通过Jogball用户可以轻松的实现网页的翻页、地图翻</p>
<p>转等操作，这种在手机上增加轨迹球的方式可以取消传统的4维导航键，Jogball并非HTC公司的首例，早在HTC 3300(Dopod P800)就</p>
<p>实现了这项功能，轨迹球操作方式的加入可以实现像电脑上鼠标一样轻松操控。现在jogball基本上算是android手机的标准配置了。</p>
<h1><span style="color: #000000;">2 框图&amp;架构</span></h1>
<p><span style="color: #000000;"><br />
</span></p>
<h3><span style="color: #000000;">2.1    gpio_event子系统</span></h3>
<p>Jogball驱动是由linux代码中的gpio_event子系统实现的。<br />
由以下文件组成：</p>
<ul>
<li> <a href="http://cyher.net/tag/driver" class="st_tag internal_tag" rel="tag" title="标签 driver 下的日志">driver</a>/input/misc/gpio_event.c</li>
<li> driver/input/misc/gpio_input.c</li>
<li> driver/input/misc/gpio_output.c</li>
<li> driver/input/misc/gpio_matrix.c</li>
<li> driver/input/misc/gpio_axis.c</li>
</ul>
<p>gpio_event子系统是一个关于gpio的输入设备的通用代码，里面可以包含一般嵌入式设备中需要的键盘阵列和坐标有关的输入等。</p>
<h3><span style="color: #000000;">2.2 Jogball架构</span></h3>
<p>Jogball是归类于gpio_axis.c中的，是一个相对坐标系，判断电信号的高低来对坐标加或者减一定数值。具体细节在gpio_axis.c中</p>
<p>gpio_axis.c中的结构体初始化是在xxx-borad.c中的，基本架构就是这样，细节在下文叙述。</p>
<h1><span style="color: #000000;">3 硬件描述</span></h1>
<p><span style="color: #000000;"><br />
</span></p>
<h3><span style="color: #000000;">3.1 Jogball机械特性</span></h3>
<p>Jogball是一个基于滚球滚动的输入设备，所以它机械特性也是比较重要，知道他的机械特性，便于我们理解驱动。<br />
Jogball和以前的滚球鼠标比较相似，依靠滚轮的滚动来带动四周的圆柱体旋转。每个圆柱体端头都有一个磁铁，这个磁体铁从横断</p>
<p>面来看就是由N极的扇形和S极的扇形来组成一个圆周。这样当磁铁旋转的时候，N极和S极切换，使霍尔IC产生高低电平。<br />
注意：在滚球旋转时，两个相对方向只有一个方向可以转动，这是为了减化软件编写的一个机械特性。</p>
<h3><span style="color: #000000;">3.2 Jogball的电气特性</span></h3>
<p>Jogball最重要的电特性就是这个霍尔IC，</p>
<blockquote><p>霍尔元件的工作原理：所谓霍尔效应，是指磁场作用于载流金属导体、半导体中的载流子时，产生横向电位差的物理现</p>
<p>象。金属的霍尔效应是1879年被美 国物理学家霍尔发现的。当电流通过金属箔片时，若在垂直于电流的方向施加磁场，则金属箔片</p>
<p>两侧面会出现横向电位差。半导体中的霍尔效应比金属箔片中更为明 显，而铁磁金属在居里温度以下将呈现极强的霍尔效应。</p></blockquote>
<p>所以jogball是旋转磁轴引起磁场的变幻，来产生高低电压的。从而根据机械特性就不难理解jogball的数字输入过程。</p>
<p>3.3 Jogball的原理图</p>
<p>其实jogball只是机械结构,原理图是hall ic的,有兴趣的人在<a href="http://www.datasheetarchive.com/pdf-datasheets/Datasheets-24/DSA-469829.pdf" target="_blank">这里下载</a></p>
<h1><span style="color: #000000;">4 数据结构</span></h1>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> hero_axis_info <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> gpio_event_axis_info info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio_event_axis结构的信息*/</span>
        <span style="color: #993333;">uint16_t</span> in_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*记录输入的高低电平信号*/</span>
        <span style="color: #993333;">uint16_t</span> out_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*记录输出的高低电平信号*/</span>
        <span style="color: #993333;">uint16_t</span> temp_state<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*临时存储高低电平*/</span>
        <span style="color: #993333;">uint16_t</span> threshold<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*门限值，超过这个值上报给input子系统*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #009900;">&#123;</span>
        <span style="color: #808080; font-style: italic;">/* initialize to gpio_event_axis_func */</span>
        <span style="color: #993333;">struct</span> gpio_event_info info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio_event信息*/</span>
        <span style="color: #993333;">uint8_t</span>  count<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio的数量*/</span>
        <span style="color: #993333;">uint8_t</span>  type<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* EV_REL or EV_ABS */</span>
        <span style="color: #993333;">uint16_t</span> code<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*输入键值类型*/</span>
        <span style="color: #993333;">uint16_t</span> decoded_size<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio 数组的大小*/</span>
        <span style="color: #993333;">uint16_t</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>map<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">uint16_t</span> in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*解析回调函数*/</span>
        <span style="color: #993333;">uint32_t</span> <span style="color: #339933;">*</span>gpio<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*gpio端口数组*/</span>
        <span style="color: #993333;">uint32_t</span> flags<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*调试标值*/</span>
        <span style="color: #993333;">uint32_t</span> enable_emc_protect_delay<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*保护间隔时间*/</span>
        <span style="color: #993333;">uint16_t</span> emc_gpio_state<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* 延时中用到gpio_state*/</span>
        atomic_t emc_disable_irqnum<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*延时中用到的屏蔽的中断号*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_info <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>func<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #808080; font-style: italic;">/*给gpio_event子系统中实现注册到内核中的回调函数*/</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> type<span style="color: #339933;">,</span>
        <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> code<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* out events */</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>name<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*名字*/</span>
        <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">**</span>info<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*gpio_event的结构指针*/</span>
        size_t info_count<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*注册到axis中的info 结构体的数量*/</span>
        <span style="color: #993333;">int</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>power<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #339933;">*</span>pdata<span style="color: #339933;">,</span> bool on<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*电源管理回调函数*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<h1><span style="color: #000000;">5 代码分析</span></h1>
<h3><span style="color: #000000;">5.1 通用代码</span></h3>
<p>driver/input/misc/gpio_event.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*gpio_event基本数据结构*/</span>
<span style="color: #993333;">struct</span> gpio_event <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">;</span>
        <span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> gpio_event_platform_data <span style="color: #339933;">*</span>info<span style="color: #339933;">;</span>
        <span style="color: #993333;">struct</span> early_suspend early_suspend<span style="color: #339933;">;</span>
        <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>state<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*注册给input的回调函数*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_input_event<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>dev<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> type<span style="color: #339933;">,</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> code<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> value<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*调用下层给的回调函数来实现具体的注册*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_event_call_all_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event <span style="color: #339933;">*</span>ip<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*电源管理*/</span>
<span style="color: #339933;">#ifdef CONFIG_HAS_EARLYSUSPEND</span>
<span style="color: #993333;">void</span> gpio_event_suspend<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> early_suspend <span style="color: #339933;">*</span>h<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">void</span> gpio_event_resume<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> early_suspend <span style="color: #339933;">*</span>h<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">#endif</span>
<span style="color: #808080; font-style: italic;">/*注册*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> __init gpio_event_probe<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> platform_device <span style="color: #339933;">*</span>pdev<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*注销*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> gpio_event_remove<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> platform_device <span style="color: #339933;">*</span>pdev<span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> platform_driver gpio_event_driver
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> __devinit gpio_event_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> __exit gpio_event_exit<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>gpio_event.c:主要是gpio_event子系统的框架</p>
<h3><span style="color: #000000;">5.2    soc代码</span></h3>
<p>driver/input/misc/gpio_axis.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">struct</span> gpio_axis_state <span style="color: #009900;">&#123;</span>
<span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">;</span><span style="color: #808080; font-style: italic;">/*input设备结构*/</span>
<span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*坐标系数据结构*/</span>
<span style="color: #993333;">uint32_t</span> pos<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*位置*/</span>
<span style="color: #993333;">struct</span> hrtimer emc_hrtimer_delay<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/* 延时时间*/</span>
atomic_t atomic_emc_hrtimer_is_run<span style="color: #339933;">;</span> <span style="color: #808080; font-style: italic;">/*延时的原子变量*/</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #808080; font-style: italic;">/*上报input数据*/</span>
<span style="color: #993333;">static</span> <span style="color: #993333;">void</span> gpio_event_update_axis<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_axis_state <span style="color: #339933;">*</span>as<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> report<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*时间处理函数*/</span>
<span style="color: #993333;">static</span> <span style="color: #000000; font-weight: bold;">enum</span> hrtimer_restart emc_progress_hrtimer_handler_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> hrtimer <span style="color: #339933;">*</span>timer<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*中断处理函数*/</span>
<span style="color: #993333;">static</span> irqreturn_t gpio_axis_irq_handler<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> irq<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>dev_id<span style="color: #009900;">&#41;</span>
<span style="color: #808080; font-style: italic;">/*给上层的注册回调函数*/</span>
<span style="color: #993333;">int</span> gpio_event_axis_func<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> input_dev <span style="color: #339933;">*</span>input_dev<span style="color: #339933;">,</span> <span style="color: #993333;">struct</span> gpio_event_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">**</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> func<span style="color: #009900;">&#41;</span></pre></div></div>

<h3><span style="color: #000000;">5.3    platform代码</span></h3>
<p>例如：/arch/arm/match-msm/board-72&#215;7.c</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">uint16_t</span> hero_axis_map<span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> gpio_event_axis_info <span style="color: #339933;">*</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">uint16_t</span> in<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">struct</span> hero_axis_info <span style="color: #339933;">*</span>ai <span style="color: #339933;">=</span> container_of<span style="color: #009900;">&#40;</span>info<span style="color: #339933;">,</span> <span style="color: #993333;">struct</span> hero_axis_info<span style="color: #339933;">,</span> info<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #993333;">uint16_t</span> out <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>out_state<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>nav_just_on<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jiffies <span style="color: #339933;">==</span> nav_on_jiffies <span style="color: #339933;">||</span> jiffies <span style="color: #339933;">==</span> nav_on_jiffies <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
                <span style="color: #b1b100;">goto</span> ignore<span style="color: #339933;">;</span>
        nav_just_on <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>in_state <span style="color: #339933;">^</span> in<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #808080; font-style: italic;">/*检测在方向1上有没有数值变化*/</span>
        out<span style="color: #339933;">--;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>n_state <span style="color: #339933;">^</span> in<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #808080; font-style: italic;">/*检测在方向1相对方向上有没有数值变化*/</span>
        out<span style="color: #339933;">++;</span>
ai<span style="color: #339933;">-&gt;;</span>out_state <span style="color: #339933;">=</span> out<span style="color: #339933;">;</span>
ignore<span style="color: #339933;">:</span>
        ai<span style="color: #339933;">-&gt;</span>in_state <span style="color: #339933;">=</span> in<span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">==</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">++;</span>
        ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-</span>out_state <span style="color: #339933;">==</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">--;</span>
        ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>abs<span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>out_state <span style="color: #339933;">-</span> ai<span style="color: #339933;">-&gt;;</span>temp_state<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> ai<span style="color: #339933;">-&gt;</span>threshold<span style="color: #009900;">&#41;</span>
        ai<span style="color: #339933;">-&gt;</span>temp_state <span style="color: #339933;">=</span> ai<span style="color: #339933;">-&gt;</span>out_state<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">return</span> ai<span style="color: #339933;">-&gt;</span>temp_state<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>以上函数，是最终的数据解析函数，也就是把硬件中读出来的数据，转化为实际的位置变化的函数。此函数主要做了差错控制，增加</p>
<p>了程序的鲁棒性和可订制性。</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> hero_axis_info hero_x_axis <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        .<span style="color: #202020;">threshold</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">info</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                .<span style="color: #202020;">info</span>.<span style="color: #202020;">func</span> <span style="color: #339933;">=</span> gpio_event_axis_func<span style="color: #339933;">,</span>
                .<span style="color: #202020;">count</span> <span style="color: #339933;">=</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_x_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">type</span> <span style="color: #339933;">=</span> EV_REL<span style="color: #339933;">,</span>
                .<span style="color: #202020;">code</span> <span style="color: #339933;">=</span> REL_X<span style="color: #339933;">,</span>
                .<span style="color: #202020;">decoded_size</span> <span style="color: #339933;">=</span> 1U <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_x_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">map</span> <span style="color: #339933;">=</span> hero_axis_map<span style="color: #339933;">,</span>
                .<span style="color: #202020;">gpio</span> <span style="color: #339933;">=</span> hero_x_axis_gpios<span style="color: #339933;">,</span>
                .<span style="color: #202020;">flags</span> <span style="color: #339933;">=</span> GPIOEAF_PRINT_UNKNOWN_DIRECTION <span style="color: #808080; font-style: italic;">/*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT */</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">enable_emc_protect_delay</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">*</span> NSEC_PER_MSEC<span style="color: #339933;">,</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>X轴上的info结构体的初始化</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">struct</span> hero_axis_info hero_y_axis <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        .<span style="color: #202020;">threshold</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">info</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
                .<span style="color: #202020;">info</span>.<span style="color: #202020;">func</span> <span style="color: #339933;">=</span> gpio_event_axis_func<span style="color: #339933;">,</span>
                .<span style="color: #202020;">count</span> <span style="color: #339933;">=</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_y_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">type</span> <span style="color: #339933;">=</span> EV_REL<span style="color: #339933;">,</span>
                .<span style="color: #202020;">code</span> <span style="color: #339933;">=</span> REL_Y<span style="color: #339933;">,</span>
                .<span style="color: #202020;">decoded_size</span> <span style="color: #339933;">=</span> 1U <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;&amp;</span>lt<span style="color: #339933;">;</span> ARRAY_SIZE<span style="color: #009900;">&#40;</span>hero_y_axis_gpios<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">map</span> <span style="color: #339933;">=</span> hero_axis_map<span style="color: #339933;">,</span>
                .<span style="color: #202020;">gpio</span> <span style="color: #339933;">=</span> hero_y_axis_gpios<span style="color: #339933;">,</span>
                .<span style="color: #202020;">flags</span> <span style="color: #339933;">=</span> GPIOEAF_PRINT_UNKNOWN_DIRECTION <span style="color: #808080; font-style: italic;">/*| GPIOEAF_PRINT_RAW | GPIOEAF_PRINT_EVENT  */</span><span style="color: #339933;">,</span>
                .<span style="color: #202020;">enable_emc_protect_delay</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">*</span> NSEC_PER_MSEC<span style="color: #339933;">,</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y轴上的info结构体的初始化</p>
<h1><span style="color: #000000;">6 备注</span></h1>
<p>在android的framework的代码中识别jogball设备是识别成鼠标的特性的，不仅有坐标还是由按键的，但是驱动中并没有axis中并没</p>
<p>有按键，所以在注册input设备的时候要加入按键的键值。如下代码：<br />
在drivers/input/misc/gpio_axis.c中的gpio_event_axis_func函数中</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">as<span style="color: #339933;">-&gt;</span>input_dev <span style="color: #339933;">=</span> input_dev<span style="color: #339933;">;</span>
as<span style="color: #339933;">-&gt;</span>info <span style="color: #339933;">=</span> ai<span style="color: #339933;">;</span>
&nbsp;
input_set_capability<span style="color: #009900;">&#40;</span>input_dev<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;</span>type<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;;</span>code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ai<span style="color: #339933;">-&gt;</span>type <span style="color: #339933;">==</span> EV_ABS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        input_set_abs_params<span style="color: #009900;">&#40;</span>input_dev<span style="color: #339933;">,</span> ai<span style="color: #339933;">-&gt;</span>code<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span>
        ai<span style="color: #339933;">-&gt;</span>decoded_size <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>input_set_capability(input_dev, ai->type, BT_MOUSE);</p>
<p>本文源码是基于hero手机kernel代码<br />
kernel_hero/arch/arm/mach-msm/board-hero.c<br />
下载地址 <a href="http://developer.htc.com/">http://developer.htc.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/gnulinux/android/android-driver-jogball/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>月经博文不看也罢</title>
		<link>http://cyher.net/useless_stuff/%e6%9c%88%e7%bb%8f%e5%8d%9a%e6%96%87%e4%b8%8d%e7%9c%8b%e4%b9%9f%e7%bd%a2</link>
		<comments>http://cyher.net/useless_stuff/%e6%9c%88%e7%bb%8f%e5%8d%9a%e6%96%87%e4%b8%8d%e7%9c%8b%e4%b9%9f%e7%bd%a2#comments</comments>
		<pubDate>Fri, 26 Feb 2010 07:40:48 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[/dev/null]]></category>
		<category><![CDATA[月经]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637021</guid>
		<description><![CDATA[什么叫月经博文? 呵呵，那就看下面吧。 在每个人的个人blog上总会有这样的文章： 好久没来这里了，觉得这一段过的很忙没有时间写blog，以后我会坚持写的 诸如此类。。。 我其实也想写这样的话但是，觉得自己写的也太多了，所以就不无志者长立志了。写本文就是上来冒个泡，别让人觉得我人间蒸发了，或者不在计算机行当工作了。过去的一年让我学会了很多，未来的一年我很期待。我有好多信息想分享到网上，也许是我太懒，但是不能在懒了，再懒下去我就OUT了。 纪念一下，很让人难忘的2009。。]]></description>
			<content:encoded><![CDATA[<p>什么叫月经博文? 呵呵，那就看下面吧。</p>
<p>在每个人的个人blog上总会有这样的文章：</p>
<blockquote><p>好久没来这里了，觉得这一段过的很忙没有时间写blog，以后我会坚持写的 诸如此类。。。</p></blockquote>
<p>我其实也想写这样的话但是，觉得自己写的也太多了，所以就不无志者长立志了。写本文就是上来冒个泡，别让人觉得我人间蒸发了，或者不在计算机行当工作了。过去的一年让我学会了很多，未来的一年我很期待。我有好多信息想分享到网上，也许是我太懒，但是不能在懒了，再懒下去我就OUT了。</p>
<p>纪念一下，很让人难忘的2009。。</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/useless_stuff/%e6%9c%88%e7%bb%8f%e5%8d%9a%e6%96%87%e4%b8%8d%e7%9c%8b%e4%b9%9f%e7%bd%a2/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>北有中关村, 南有华强北!</title>
		<link>http://cyher.net/useless_stuff/huaqiangbei</link>
		<comments>http://cyher.net/useless_stuff/huaqiangbei#comments</comments>
		<pubDate>Sun, 10 Jan 2010 13:49:48 +0000</pubDate>
		<dc:creator>cyher</dc:creator>
				<category><![CDATA[/dev/null]]></category>
		<category><![CDATA[华强北]]></category>
		<category><![CDATA[山寨]]></category>

		<guid isPermaLink="false">http://cyher.net/?p=637018</guid>
		<description><![CDATA[来深圳一段时间了, 今天有幸去了, 一直听说的华强北. 真是不愧那一句话, 北有中关村, 南有华强北. 这里好多电子市场, 注意是电子市场, 不是一般所说的电脑城, 或者是科技市场. 每座大楼里面1层和2层基本都是电子元件, 想要什么电子元件, 你一定可以找到, 电容论斤称的(开玩笑), 电阻, 二极管, 三极管什么的, 基本上你想找的芯片都能够找到, 我真希望我是个硬件, 自己买回去整个山寨机出来, 可惜了. 说起来深圳了, 一定要去看看水货手机和山寨机, 山寨机的那个强大, 都不用我多说的. 我偶然进了一个专门作电池的店, 里面有个牌子写着, 国产电池, 现场制作, 看完那一个寒阿&#8230;.一堆一堆的电池,都没有包装, 露着金属皮, 你要什么样就给你贴什么样的, 匆800毫安时到9800都有, 各种各样的形状, 现在可以理解山寨机的强大了. 一个专做iphone配件的, 里面有背壳, 面板, 主板, 电池, 只要你能想到的, 他基本都有, 他要是想,绝对能弄出来个iphone&#8230;&#8230;真是太&#8230;呵呵. 长见识了, 有机会的话一定带个深圳特产&#8211;山寨机回去&#8230;哈哈]]></description>
			<content:encoded><![CDATA[<p>来深圳一段时间了, 今天有幸去了, 一直听说的华强北. 真是不愧那一句话, 北有中关村, 南有华强北.</p>
<p>这里好多电子市场, 注意是电子市场, 不是一般所说的电脑城, 或者是科技市场. 每座大楼里面1层和2层基本都是电子元件, 想要什么电子元件, 你一定可以找到, 电容论斤称的(开玩笑), 电阻, 二极管, 三极管什么的, 基本上你想找的芯片都能够找到, 我真希望我是个硬件, 自己买回去整个山寨机出来, 可惜了. 说起来深圳了, 一定要去看看水货手机和山寨机, 山寨机的那个强大, 都不用我多说的. 我偶然进了一个专门作电池的店, 里面有个牌子写着, 国产电池, 现场制作, 看完那一个寒阿&#8230;.一堆一堆的电池,都没有包装, 露着金属皮, 你要什么样就给你贴什么样的, 匆800毫安时到9800都有, 各种各样的形状, 现在可以理解山寨机的强大了. 一个专做iphone配件的, 里面有背壳, 面板, 主板, 电池, 只要你能想到的, 他基本都有, 他要是想,绝对能弄出来个iphone&#8230;&#8230;真是太&#8230;呵呵.</p>
<p>长见识了, 有机会的话一定带个深圳特产&#8211;山寨机回去&#8230;哈哈</p>
]]></content:encoded>
			<wfw:commentRss>http://cyher.net/useless_stuff/huaqiangbei/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.924 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-05 16:09:09 -->

