<?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>NASKIT &#187; Xperia</title>
	<atom:link href="http://naskit.com/category/xperia/feed/" rel="self" type="application/rss+xml" />
	<link>http://naskit.com</link>
	<description>AndroidとかUnityとか</description>
	<lastBuildDate>Sun, 29 Jan 2012 16:57:20 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Xperiaのタッチパネルはノープレッシャー</title>
		<link>http://naskit.com/2010/04/09/xperia%e3%81%ae%e3%82%bf%e3%83%83%e3%83%81%e3%83%91%e3%83%8d%e3%83%ab%e3%81%af%e3%83%8e%e3%83%bc%e3%83%97%e3%83%ac%e3%83%83%e3%82%b7%e3%83%a3%e3%83%bc/</link>
		<comments>http://naskit.com/2010/04/09/xperia%e3%81%ae%e3%82%bf%e3%83%83%e3%83%81%e3%83%91%e3%83%8d%e3%83%ab%e3%81%af%e3%83%8e%e3%83%bc%e3%83%97%e3%83%ac%e3%83%83%e3%82%b7%e3%83%a3%e3%83%bc/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 18:11:18 +0000</pubDate>
		<dc:creator>saikoro</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[HT-03A]]></category>
		<category><![CDATA[Xperia]]></category>

		<guid isPermaLink="false">http://naskit.com/?p=314</guid>
		<description><![CDATA[再びXperiaネタ
タッチパネルの圧力取得について]]></description>
			<content:encoded><![CDATA[<p><script type="text/javascript"><!--
google_ad_client = "pub-6892715802145135";
/* 468x15, 作成済み 09/11/01 */
google_ad_slot = "8121608277";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p><p>DoCoMoの<strong>ニュータイプ</strong>、Xperiaのタッチパネルについてである。</p>
<p>Androidのタッチパネルではタッチした強さを取得できる。<br />
はずなんだ。</p>
<p>取得方法は<br />
onTouchEvent(MotionEvent event) 内の <strong><a href="http://developer.android.com/reference/android/view/MotionEvent.html#getPressure()" target="_blank">getPressure() メソッド</a></strong>で0.0から1.0の値が取得できるはず。<br />
少なくともHT-03Aでは取得できていたが、Xperiaでは常に1.0が返ってくるようだ。</p>
<p>こんなコードを書いてしらべた。</p>
<pre class="brush: java; title: ; notranslate">
// package略
// import略

public class Main extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        int a = event.getAction();
        String act = &quot;&quot;;
        if (a == MotionEvent.ACTION_CANCEL) {
            act = &quot;ACTION_CANCEL&quot;;
        }
        if (a == MotionEvent.ACTION_DOWN) {
            act = &quot;ACTION_DOWN&quot;;
        }
        if (a == MotionEvent.ACTION_MOVE) {
            act = &quot;ACTION_MOVE&quot;;
        }
        if (a == MotionEvent.ACTION_OUTSIDE) {
            act = &quot;ACTION_OUTSIDE&quot;;
        }
        if (a == MotionEvent.ACTION_UP) {
            act = &quot;ACTION_UP&quot;;
        }
        ((TextView)findViewById(R.id.touch_action)).setText(act);
        ((TextView)findViewById(R.id.touch_x)).setText(&quot;&quot;+event.getX());
        ((TextView)findViewById(R.id.touch_y)).setText(&quot;&quot;+event.getY());
        int size = event.getHistorySize();

        String histPress = &quot; size=&quot; + size;
        for (int i = 0;i &lt; size;i++) {
            if (i &gt; 1) break;
            histPress = histPress + &quot;,&quot; + event.getHistoricalPressure(i);
        }
        ((TextView)findViewById(R.id.touch_pressure)).setText(histPress);

        String histSize = &quot; size=&quot; + size;
        for (int i = 0;i &lt; size;i++) {
            if (i &gt; 1) break;
            histSize = histSize + &quot;,&quot; + event.getHistoricalSize(i);
        }
        ((TextView)findViewById(R.id.touch_size)).setText(histSize);

        return true;
    }
}

// layout/main.xml
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    android:orientation=&quot;vertical&quot;
    android:layout_width=&quot;fill_parent&quot;
    android:layout_height=&quot;fill_parent&quot;
    &gt;
    &lt;TextView
        android:layout_width=&quot;fill_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:text=&quot;@string/title&quot;/&gt;

    &lt;LinearLayout
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;MotionEvent.getX()=&quot; /&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:id=&quot;@+id/touch_x&quot;
            android:text=&quot;0&quot; /&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;MotionEvent.getY()=&quot; /&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;0&quot;
            android:id=&quot;@+id/touch_y&quot; /&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;MotionEvent.getSize()=&quot; /&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;0&quot;
            android:id=&quot;@+id/touch_size&quot; /&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;MotionEvent.getPressure()=&quot; /&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;0&quot;
            android:id=&quot;@+id/touch_pressure&quot; /&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:orientation=&quot;horizontal&quot;&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;MotionEvent.getAction()=&quot; /&gt;
        &lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:id=&quot;@+id/touch_action&quot; /&gt;
    &lt;/LinearLayout&gt;

&lt;/LinearLayout&gt;
</pre>
<p><a href="http://naskit.com/wp-content/uploads/xperia_pressure_ss01.png"><img src="http://naskit.com/wp-content/uploads/xperia_pressure_ss01-200x300.png" alt="" title="xperia_pressure_ss01" width="200" height="300" class="size-medium wp-image-324" /></a><a href="http://naskit.com/wp-content/uploads/xperia_pressure_ss02.png"><img src="http://naskit.com/wp-content/uploads/xperia_pressure_ss02-200x300.png" alt="" title="xperia_pressure_ss02" width="200" height="300" class="alignright size-medium wp-image-325" /></a></p>
<p>同様にタッチした範囲もgetSize()で取得できるのだが、Xperiaは常に0.0を返すのであった。<br />
これは機種依存なのかもしれない。<br />
マルチタッチをサポートしてたらタッチした範囲は求められそうだが、Xperiaのタッチパネルには<a href="http://japanese.engadget.com/2010/03/29/xperia-x10/" target="_blank">こんな情報</a>もあり、機種的に取得ができないのかもしれん。</p>
<p>幅広い端末をサポートするなら、タッチパネルのプレッシャーを測り知ろうとしてはならぬのかもしれない。<br />
Xperiaを猛烈に強くタッチしても｢私にプレッシャーをかけるパイロットとは・・・」などとは言ってくれなさそうである。</p>
<p>はたしてXperia君はAndroidOS2.X にアップデートして真のニュータイプになれるのであろうか。</p>
<div class="plus-one-wrap"><g:plusone size="medium" href="http://naskit.com/2010/04/09/xperia%e3%81%ae%e3%82%bf%e3%83%83%e3%83%81%e3%83%91%e3%83%8d%e3%83%ab%e3%81%af%e3%83%8e%e3%83%bc%e3%83%97%e3%83%ac%e3%83%83%e3%82%b7%e3%83%a3%e3%83%bc/"></g:plusone></div>]]></content:encoded>
			<wfw:commentRss>http://naskit.com/2010/04/09/xperia%e3%81%ae%e3%82%bf%e3%83%83%e3%83%81%e3%83%91%e3%83%8d%e3%83%ab%e3%81%af%e3%83%8e%e3%83%bc%e3%83%97%e3%83%ac%e3%83%83%e3%82%b7%e3%83%a3%e3%83%bc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

