<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; Библиотека для Wii Remote]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=10279&amp;type=atom" />
	<updated>2015-01-19T08:51:26Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=10279</id>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90708#p90708" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kharlashkin пишет:</cite><blockquote><p>Нашлась такая - называется <a href="http://wiki.unity3d.com/index.php?title=UniWii">UniWii</a>, и вроде как намного проще функции, без сложных структур и прочего. Надо попробовать вызывать функции из неё - может так:<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><div class="codebox"><pre><code>Wiimote_start := DllCall(&quot;uniwii.dll\wiimote_start&quot;)
Wiimote_count := DllCall(&quot;uniwii.dll\wiimote_count&quot;, &quot;Cdecl Int&quot;)
Wiimote_rumble := DllCall(&quot;uniwii.dll\wiimote_rumble&quot;, &quot;Int&quot;, Wiimote_count, &quot;Float&quot;, 2)</code></pre></div></div></div></blockquote></div><p>Не взлетело...</p><p>Копаясь, нашел вот такой отзыв о wiiuse:<br /></p><div class="quotebox"><blockquote><p>if you will use multiple wiimotes, don&#039;t use wiiuse library. i am working on a stereo system with two wiimotes using wiiuse library but wiiuse made me crazy( it gives delayed ir tracking data ) and i decided to change my library wiiuse from wiiyourself</p></blockquote></div><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header"><strong>+</strong>&nbsp;мнение</div><div class="fancy_spoiler"><p>Кстати тестируя примеры для wiiuse из консоли на С и python, видел что связь между контроллером и ПК действительно &quot;не внушает доверия&quot; и довольно часто пропадают пакеты.</p></div></div><p>Исследую библиотеку <a href="http://wiiyourself.gl.tter.org/">wiiyourself</a>.</p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-19T08:51:26Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90708#p90708</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90601#p90601" />
			<content type="html"><![CDATA[<p>Предыстория: сегодня свалилось письмо в почту от мелокомягких как обычно с новостями и прочей лабудой. Пройдя по ссылке с <a href="http://blogs.msdn.com/b/rudevnews/archive/2014/12/23/10582615.aspx">конкурсом игр с поддержкой геймпада</a> и просмотрев пару уроков заинтересовался &quot;А есть ли библиотека для Unity под Wiimote?&quot;.<br />Нашлась такая - называется <a href="http://wiki.unity3d.com/index.php?title=UniWii">UniWii</a>, и вроде как намного проще функции, без сложных структур и прочего. Надо попробовать вызывать функции из неё - может так:<br /></p><div class="codebox"><pre><code>Wiimote_start := DllCall(&quot;uniwii.dll\wiimote_start&quot;)
Wiimote_count := DllCall(&quot;uniwii.dll\wiimote_count&quot;, &quot;Cdecl Int&quot;)
Wiimote_rumble := DllCall(&quot;uniwii.dll\wiimote_rumble&quot;, &quot;Int&quot;, Wiimote_count, &quot;Float&quot;, 2)</code></pre></div>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-16T13:48:06Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90601#p90601</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90548#p90548" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kharlashkin пишет:</cite><blockquote><p>1. Каким образом читать структуру expansion_t:<br /></p><div class="codebox"><pre><code>int     type
union {
   struct nunchuk_t   nunchuk
   struct classic_ctrl_t   classic
   struct guitar_hero_3_t   gh3
} </code></pre></div></blockquote></div><p>Сегодня открылись доки по <a href="http://www.autohotkey.net/~HotKeyIt/AutoHotkey/_Struct.htm">_Struct</a> (вчера было недоступно), там есть описание каким образом сделать с помощью этой библиотеки в union вставить внутрь структуры.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>Union	<br />Using {} you can create union, for example: <br />AHKVar:=&quot;{Int64 ContentsInt64,Double ContentsDouble,object},...</p><p>Struct	<br />Using struct{} you can create structures in union.</p></div></div><p>Так есть упоминание о вложении структур в структуры, но непонятно мне, кому понятно поделитесь примером с комментариями.<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>Same way you can have a structure in structure so you can call for example Label.NextLabel.NextLabel.JumpToLine</p></div></div><div class="quotebox"><cite>kharlashkin пишет:</cite><blockquote><p>2. Каким образом сделать вот это, я так понимаю нужно считать 18 байт:<br /></p><div class="codebox"><pre><code>
WCONST char wiimote_t::bdaddr_str[18]
readable bt address</code></pre></div></blockquote></div><p>С этим что поделать - не знаю.</p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-15T08:33:29Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90548#p90548</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90507#p90507" />
			<content type="html"><![CDATA[<p>Начал приводить в нормальный вид библиотеку (аналог Xinput), появилось несколько вопросов:<br />1. Каким образом читать структуру expansion_t:<br /></p><div class="codebox"><pre><code>int     type
union {
   struct nunchuk_t   nunchuk
   struct classic_ctrl_t   classic
   struct guitar_hero_3_t   gh3
} </code></pre></div><p>2. Каким образом сделать вот это, я так понимаю нужно считать 18 байт:<br /></p><div class="codebox"><pre><code>
WCONST char wiimote_t::bdaddr_str[18]
readable bt address</code></pre></div>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-14T11:34:18Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90507#p90507</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90505#p90505" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Как так нет? Читаем:<br /></p><div class="quotebox"><blockquote><p>Char 	An 8-bit integer, whose range is -128 (-0x80) to 127 (0x7F). An unsigned character (UChar) can be used with functions that expect a BYTE.</p></blockquote></div><p><em>8-bit integer</em> — это и есть размер, 8 бит = 1 байт.</p></blockquote></div><p>Точно. Спасибо!</p><p>Теперь если &quot;вернуться к нашим баранам&quot;, а именно к библиотеке Xinput от уважаемого Lexikos:<br />1. _XInput_hm - указатель на dll.<br />2. _XInput_GetState - указатель на функцию, при вызове которой получаем указатель на структуру XINPUT_STATE.<br />3. И соответственно считываем данные этой структуры и разбираем по байтово:<br /></p><div class="codebox"><pre><code>return {
    (Join,
        dwPacketNumber: NumGet(xiState,  0, &quot;UInt&quot;)
        wButtons:       NumGet(xiState,  4, &quot;UShort&quot;)
        bLeftTrigger:   NumGet(xiState,  6, &quot;UChar&quot;)
        bRightTrigger:  NumGet(xiState,  7, &quot;UChar&quot;)
        sThumbLX:       NumGet(xiState,  8, &quot;Short&quot;)
        sThumbLY:       NumGet(xiState, 10, &quot;Short&quot;)
        sThumbRX:       NumGet(xiState, 12, &quot;Short&quot;)
        sThumbRY:       NumGet(xiState, 14, &quot;Short&quot;)
    )}</code></pre></div><p>Если я правильно себе это представляют - то нужно делать по аналогии?</p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-14T10:31:57Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90505#p90505</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90504#p90504" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>kharlashkin пишет:</cite><blockquote><p>Заканчиваем оффтопить, а то сейчас teadrinker накажет <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p></blockquote></div><p>Сам себя?</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-14T10:31:51Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90504#p90504</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90501#p90501" />
			<content type="html"><![CDATA[<p>Как так нет? Читаем:<br /></p><div class="quotebox"><blockquote><p>Char 	An 8-bit integer, whose range is -128 (-0x80) to 127 (0x7F). An unsigned character (UChar) can be used with functions that expect a BYTE.</p></blockquote></div><p><em>8-bit integer</em> — это и есть размер, 8 бит = 1 байт.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-14T10:22:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90501#p90501</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90500#p90500" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Вообще-то <a href="http://ahkscript.org/docs/commands/DllCall.htm#types">есть</a>.</p></blockquote></div><p>Да ну эту &quot;табличку&quot;, я уже почти на память помню <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /> Но размеров то там нет. (т.е. UChar = 1, FLOAT = 4 и т.п.)</p><p>Заканчиваем оффтопить, а то сейчас teadrinker накажет <img src="//forum.script-coding.com/img/smilies/wink.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-14T10:19:40Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90500#p90500</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90499#p90499" />
			<content type="html"><![CDATA[<p>Ну, если этого хватит, то отлично.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-14T10:15:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90499#p90499</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90498#p90498" />
			<content type="html"><![CDATA[<p>Вообще-то <a href="http://ahkscript.org/docs/commands/DllCall.htm#types">есть</a>.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-14T10:14:24Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90498#p90498</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90497#p90497" />
			<content type="html"><![CDATA[<p>Таблички нет, но по каким-то конкретным типам могу подсказать.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-14T10:12:11Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90497#p90497</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90495#p90495" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>YMP пишет:</cite><blockquote><p>Есть ведь сишные определения этих структур, верно? Там типы понятные, размеры не проблема узнать. Зачем с Питоном путаться?</p></blockquote></div><p>Вот и спрашиваю табличку С-шных значений и AHK-соответсвий.</p><div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Так это от задачи зависит. Я могу привести пример для какой-либо функции из WinApi, если скажете, какая именно интересует.</p></blockquote></div><p>По WinAPI нашел очень много всего ещё на этапе копания по DllCall - <a href="https://github.com/jNizM/AHK_DllCall_WinAPI">AHK_DllCall_WinAPI</a><br />Но сходу не нашел структуру включающую в себя другую структуру (которая используется и в другом месте).</p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-14T10:03:25Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90495#p90495</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90493#p90493" />
			<content type="html"><![CDATA[<p>Есть ведь сишные определения этих структур, верно? Там типы понятные, размеры не проблема узнать. Зачем с Питоном путаться?</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2015-01-14T09:57:49Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90493#p90493</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90492#p90492" />
			<content type="html"><![CDATA[<p>Так это от задачи зависит. Я могу привести пример для какой-либо функции из WinApi, если скажете, какая именно интересует.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2015-01-14T09:54:28Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90492#p90492</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Библиотека для Wii Remote]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=90489#p90489" />
			<content type="html"><![CDATA[<p>Хотя наверное можно и не создавать дубликаты, а считать её непосредственно из dll.<br /></p><div class="codebox"><pre><code>_Wiiuse_hm                := DllCall(&quot;LoadLibrary&quot;, &quot;Str&quot;, dll)
_Wiimote                := DllCall(&quot;GetProcAddress&quot;, &quot;Ptr&quot;, _Wiiuse_hm, &quot;AStr&quot;, &quot;wiimote_t&quot;)

Wiimote()
{
    global _Wiimote
    
    VarSetCapacity(wiimote,78)    
    
    if ErrorLevel := DllCall(_Wiimote, &quot;UInt&quot;, &amp;wiimote)
        return 0

    return {
    (Join,
        unid:                NumGet(wiimote, 0, &quot;Int&quot;)
        bdaddr:                NumGet(wiimote, 4, &quot;Int*&quot;)
        bdaddr_Str:            NumGet(wiimote, 8, &quot;UChar&quot;)*16
        out_sock:            NumGet(wiimote, 27, &quot;Int&quot;)
        in_sock:            NumGet(wiimote, 31, &quot;Int&quot;)
        state:                NumGet(wiimote, 35, &quot;Int&quot;)
        leds:                NumGet(wiimote, 39, &quot;UChar&quot;)
        battery_level:        NumGet(wiimote, 40, &quot;Float&quot;)
        flags:                NumGet(wiimote, 42, &quot;Int&quot;)
        handshake_state:    NumGet(wiimote, 46, &quot;UChar&quot;)
        read_req:            NumGet(wiimote, 47, &quot;UInt*&quot;)
        accel_calib:        StrGet(wiimote, 50, &quot;Str&quot;)
        orient:                StrGet(wiimote, 53, &quot;Str&quot;)
        gforce:                StrGet(wiimote, 57, &quot;Str&quot;)
        ir:                    StrGet(wiimote, 59, &quot;Str&quot;)    
        btns:                NumGet(wiimote, 57, &quot;UShort&quot;)
        btns_held:            NumGet(wiimote, 57, &quot;UShort&quot;)
        btns_released:      NumGet(wiimote, 57, &quot;UShort&quot;)
        orient_threshold:   NumGet(wiimote, 57, &quot;Float&quot;)
        accel_threshold:    NumGet(wiimote, 35, &quot;Int&quot;)
        lstate:                StrGet(wiimote, 57, &quot;Str&quot;)
        event:                NumGet(wiimote, 27, &quot;Int&quot;)
        event_buf:            NumGet(wiimote, 8, &quot;UChar&quot;)*32
    )}
}</code></pre></div><p>Если такой вариант правильный. подскажите как правильно посчитать размеры (может есть табличка - а то разрозненными кусками по интурнету искать сложно)?</p>]]></content>
			<author>
				<name><![CDATA[kharlashkin]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=32183</uri>
			</author>
			<updated>2015-01-14T09:40:54Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=90489#p90489</id>
		</entry>
</feed>
