aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/di__game__device_8cpp-source.html
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
committerneodarz <neodarz@neodarz.net>2018-08-11 20:21:34 +0200
commit0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch)
tree2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/di__game__device_8cpp-source.html
downloadnevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz
nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip
Initial commit
Diffstat (limited to 'docs/doxygen/nel/di__game__device_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/di__game__device_8cpp-source.html581
1 files changed, 581 insertions, 0 deletions
diff --git a/docs/doxygen/nel/di__game__device_8cpp-source.html b/docs/doxygen/nel/di__game__device_8cpp-source.html
new file mode 100644
index 00000000..0df70893
--- /dev/null
+++ b/docs/doxygen/nel/di__game__device_8cpp-source.html
@@ -0,0 +1,581 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>di_game_device.cpp</h1><a href="di__game__device_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001
+00007 <font class="comment">/* Copyright, 2000-2002 Nevrax Ltd.</font>
+00008 <font class="comment"> *</font>
+00009 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00010 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00011 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00012 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00013 <font class="comment"> * any later version.</font>
+00014 <font class="comment"></font>
+00015 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00018 <font class="comment"> * General Public License for more details.</font>
+00019 <font class="comment"></font>
+00020 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00021 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00022 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00023 <font class="comment"> * MA 02111-1307, USA.</font>
+00024 <font class="comment"> */</font>
+00025
+00026
+00027 <font class="preprocessor">#include "<a class="code" href="stdmisc_8h.html">stdmisc.h</a>"</font>
+00028 <font class="preprocessor">#include "<a class="code" href="di__game__device_8h.html">misc/di_game_device.h</a>"</font>
+00029 <font class="preprocessor">#include "<a class="code" href="game__device__events_8h.html">nel/misc/game_device_events.h</a>"</font>
+00030 <font class="preprocessor">#include &lt;stddef.h&gt;</font>
+00031 <font class="preprocessor">#include &lt;memory&gt;</font>
+00032 <font class="preprocessor">#include &lt;algorithm&gt;</font>
+00033
+00034 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00035 <font class="preprocessor"></font>
+00036 <font class="keyword">namespace </font>NLMISC
+00037 {
+00038
+00039 <font class="comment">//============================================================================</font>
+00040 CDIGameDevice::CDIGameDevice() : _Device(NULL)
+00041 {
+00042 ::memset(&amp;_CurrentState, 0, <font class="keyword">sizeof</font>(_CurrentState));
+00043 }
+00044
+00045 <font class="comment">//============================================================================</font>
+00046 CDIGameDevice::~CDIGameDevice()
+00047 {
+00048 <font class="keywordflow">if</font> (_Device)
+00049 {
+00050 _Device-&gt;Unacquire();
+00051 _Device-&gt;Release();
+00052 }
+00053 }
+00054
+00055 <font class="comment">//============================================================================</font>
+00056 CDIGameDevice *CDIGameDevice::createGameDevice(IDirectInput8 *di8,
+00057 HWND hwnd,
+00058 CDIEventEmitter *diEventEmitter,
+00059 <font class="keyword">const</font> CGameDeviceDesc &amp;desc,
+00060 REFGUID rguid) <font class="keywordflow">throw</font>(EDirectInput)
+00061 {
+00062 <a class="code" href="debug_8h.html#a6">nlassert</a>(diEventEmitter);
+00063 <a class="code" href="debug_8h.html#a6">nlassert</a>(di8);
+00064 std::auto_ptr&lt;CDIGameDevice&gt; dev(<font class="keyword">new</font> CDIGameDevice);
+00065 <font class="comment">//</font>
+00066
+00067 HRESULT <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = di8-&gt;CreateDevice(rguid, &amp;dev-&gt;_Device, NULL);
+00068 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK) <font class="keywordflow">throw</font> EDirectInputGameDeviceNotCreated();
+00069
+00070 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = dev-&gt;_Device-&gt;SetDataFormat(pJoyDataFormat);
+00071 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> == DI_OK);
+00072 <font class="comment">//</font>
+00073 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = dev-&gt;_Device-&gt;SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_EXCLUSIVE);
+00074 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK) <font class="keywordflow">throw</font> EDirectInputCooperativeLevelFailed();
+00075 <font class="comment">// </font>
+00076 <font class="comment">// </font>
+00077 dev-&gt;_Desc = desc;
+00078 dev-&gt;_EventEmitter = diEventEmitter;
+00079 dev-&gt;querryControls();
+00080 <font class="keywordflow">return</font> dev.release();
+00081 }
+00082
+00083 <font class="comment">//============================================================================</font>
+00084 <font class="keywordtype">void</font> CDIGameDevice::begin(CEventServer *server)
+00085 {
+00086 <a class="code" href="debug_8h.html#a6">nlassert</a>(_Device);
+00087 HRESULT <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>;
+00088 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = _Device-&gt;Poll();
+00089 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> == DIERR_INPUTLOST || <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> == DIERR_NOTACQUIRED)
+00090 {
+00091 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = _Device-&gt;Acquire();
+00092 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK) <font class="keywordflow">return</font>;
+00093 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = _Device-&gt;Poll();
+00094 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK) <font class="keywordflow">return</font>;
+00095 }
+00096
+00097 CDIJoyState newState;
+00098 <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = _Device-&gt;GetDeviceState(<font class="keyword">sizeof</font>(CDIJoyState), &amp;newState);
+00099 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK) <font class="keywordflow">return</font>;
+00100
+00101 <a class="code" href="types__nl_8h.html#a14">uint</a> k;
+00103 <font class="comment">// Axis //</font>
+00105 <font class="comment"> for (k = 0; k &lt; MaxNumAxis; ++k)</font>
+00106 {
+00107 CAxis &amp;axis = _Axis[k];
+00108 <font class="keywordflow">if</font> (axis.Present)
+00109 {
+00110
+00111 <font class="keywordflow">if</font> (((LONG *) &amp;newState)[k] != ((LONG *) &amp;_CurrentState)[k]) <font class="comment">// state changed ?</font>
+00112 {
+00113 <font class="comment">// update position</font>
+00114 axis.Value = 2.f * (((LONG *) &amp;newState)[k] - axis.Min) / (float) (axis.Max - axis.Min) - 1.f;
+00115 <font class="comment">// create event</font>
+00116 CGDAxisMoved *event = <font class="keyword">new</font> CGDAxisMoved((IGameDevice::TAxis) k, axis.Value, <font class="keyword">this</font>, _EventEmitter);
+00117 <font class="comment">// update state</font>
+00118 ((LONG *) &amp;_CurrentState)[k] = ((LONG *) &amp;newState)[k];
+00119 <font class="comment">//</font>
+00120 server-&gt;postEvent(event);
+00121 <font class="comment">//</font>
+00122 }
+00123 }
+00124 }
+00125
+00126
+00128 <font class="comment">// Buttons //</font>
+00130 <font class="comment"> for (k = 0; k &lt; _Buttons.size(); ++k)</font>
+00131 {
+00132 CButton &amp;bt = _Buttons[k];
+00133 <font class="keywordflow">if</font> ((newState.rgbButtons[k] &amp; 0x80) != (_CurrentState.rgbButtons[k] &amp; 0x80))
+00134 {
+00135 <font class="keywordtype">bool</font> pushed = (newState.rgbButtons[k] &amp; 0x80) != 0;
+00136 <font class="comment">// update the state of the button</font>
+00137 bt.Pushed = pushed;
+00138 CGDButton *event;
+00139 <font class="keywordflow">if</font> (pushed) event = <font class="keyword">new</font> CGDButtonDown(k, <font class="keyword">this</font>, _EventEmitter);
+00140 <font class="keywordflow">else</font> event = <font class="keyword">new</font> CGDButtonUp(k, <font class="keyword">this</font>, _EventEmitter);
+00141 <font class="comment">// update state </font>
+00142 _CurrentState.rgbButtons[k] = newState.rgbButtons[k];
+00143 server-&gt;postEvent(event);
+00144 }
+00145 }
+00146
+00148 <font class="comment">// Sliders //</font>
+00150 <font class="comment"> for (k = 0; k &lt; _Sliders.size(); ++k)</font>
+00151 {
+00152 CSlider &amp;sl = _Sliders[k];
+00153 <font class="keywordflow">if</font> (newState.rglSlider[k] != _CurrentState.rglSlider[k]) <font class="comment">// state changed ?</font>
+00154 {
+00155 <font class="comment">// update position</font>
+00156 sl.Pos = ( newState.rglSlider[k] - sl.Min) / (float) (sl.Max - sl.Min);
+00157 <font class="comment">// create event</font>
+00158 CGDSliderMoved *event = <font class="keyword">new</font> CGDSliderMoved(sl.Pos, k, <font class="keyword">this</font>, _EventEmitter);
+00159 <font class="comment">// update state</font>
+00160 _CurrentState.rglSlider[k] = newState.rglSlider[k];
+00161 <font class="comment">//</font>
+00162 server-&gt;postEvent(event);
+00163 }
+00164 }
+00165
+00167 <font class="comment">// POVs //</font>
+00169 <font class="comment"> for (k = 0; k &lt; _POVs.size(); ++k)</font>
+00170 {
+00171 CPOV &amp;pov = _POVs[k];
+00172 <font class="keywordflow">if</font> (newState.rgdwPOV[k] != _CurrentState.rgdwPOV[k]) <font class="comment">// state changed ?</font>
+00173 {
+00174 DWORD value = newState.rgdwPOV[k];
+00175
+00176 pov.Centered = (LOWORD(value) == 0xFFFF);
+00177 <font class="keywordflow">if</font> (!pov.Centered)
+00178 {
+00179 <font class="comment">// update position</font>
+00180 pov.Angle = value / 100.f;
+00181 }
+00182 <font class="comment">// create event</font>
+00183 CGDPOVChanged *event = <font class="keyword">new</font> CGDPOVChanged(pov.Centered, pov.Angle, k, <font class="keyword">this</font>, _EventEmitter);
+00184 <font class="comment">// update state</font>
+00185 _CurrentState.rgdwPOV[k] = newState.rgdwPOV[k];
+00186 <font class="comment">//</font>
+00187 server-&gt;postEvent(event);
+00188 }
+00189 }
+00190
+00191 }
+00192
+00193 <font class="comment">//============================================================================</font>
+00194 <font class="keywordtype">void</font> CDIGameDevice::poll(CInputDeviceServer *dev)
+00195 {
+00196 <font class="comment">// buffered datas not supported</font>
+00197 }
+00198
+00199 <font class="comment">//============================================================================</font>
+00200 <font class="keywordtype">void</font> CDIGameDevice::submit(IInputDeviceEvent *deviceEvent, CEventServer *server)
+00201 {
+00202 <font class="comment">// should never be called, buffered datas not supported</font>
+00203 <a class="code" href="debug_8h.html#a6">nlassert</a>(0);
+00204 }
+00205
+00206
+00207 <font class="comment">//============================================================================</font>
+00211 <font class="comment"></font><font class="keyword">static</font> <font class="keywordtype">void</font> BuildCtrlName(LPCDIDEVICEOBJECTINSTANCE lpddoi,
+00212 std::string &amp;destName,
+00213 <font class="keyword">const</font> <font class="keywordtype">char</font> *defaultName)
+00214 {
+00215 <font class="keywordflow">if</font> (lpddoi-&gt;dwSize &gt;= offsetof(DIDEVICEOBJECTINSTANCE, tszName) + <font class="keyword">sizeof</font>(TCHAR[MAX_PATH]))
+00216 {
+00217 destName = (::strcmp(<font class="stringliteral">"N/A"</font>, lpddoi-&gt;tszName) == 0) ? defaultName
+00218 : lpddoi-&gt;tszName;
+00219 }
+00220 <font class="keywordflow">else</font>
+00221 {
+00222 destName = defaultName;
+00223 }
+00224 }
+00225
+00226 <font class="comment">//============================================================================</font>
+00227 <font class="comment">// A callback to enumerate the controls of a device</font>
+00228 <font class="keyword">static</font> BOOL CALLBACK DIEnumDeviceObjectsCallback
+00229 (
+00230 LPCDIDEVICEOBJECTINSTANCE lpddoi,
+00231 LPVOID pvRef
+00232 )
+00233 {
+00234
+00235 CDIGameDevice *gd = (CDIGameDevice *) pvRef;
+00236 <font class="keywordflow">return</font> gd-&gt;processEnumObject(lpddoi);
+00237 }
+00238
+00239
+00240
+00241 <font class="comment">//=======================================================================</font>
+00242 <font class="comment">// get range for an axis</font>
+00243 <font class="keyword">static</font> HRESULT GetDIAxisRange(LPDIRECTINPUTDEVICE8 device, <a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a256">offset</a>, DWORD <a class="code" href="driver__opengl__extension__def_8h.html#a251">type</a>, <a class="code" href="types__nl_8h.html#a13">sint</a> &amp;<a class="code" href="bit__set_8cpp.html#a0">min</a>, <a class="code" href="types__nl_8h.html#a13">sint</a> &amp;max)
+00244 {
+00245 DIPROPRANGE diprg;
+00246 diprg.diph.dwSize = <font class="keyword">sizeof</font>(DIPROPRANGE);
+00247 diprg.diph.dwHeaderSize = <font class="keyword">sizeof</font>(DIPROPHEADER);
+00248 diprg.diph.dwHow = DIPH_BYOFFSET;
+00249 diprg.diph.dwObj = <a class="code" href="driver__opengl__extension__def_8h.html#a256">offset</a>;
+00250
+00251 <font class="comment">// Set the range for the axis</font>
+00252 HRESULT <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = device-&gt;GetProperty(DIPROP_RANGE, &amp;diprg.diph);
+00253
+00254 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> == DIERR_OBJECTNOTFOUND)
+00255 {
+00256 <font class="comment">// try from its ID</font>
+00257 diprg.diph.dwHow = DIPH_BYID;
+00258 diprg.diph.dwObj = <a class="code" href="driver__opengl__extension__def_8h.html#a251">type</a>;
+00259
+00260 <font class="comment">// Set the range for the axis</font>
+00261 HRESULT <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = device-&gt;GetProperty(DIPROP_RANGE, &amp;diprg.diph);
+00262 <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK)
+00263 {
+00264 <font class="comment">// setup default values ...</font>
+00265 <a class="code" href="bit__set_8cpp.html#a0">min</a> = 0;
+00266 max = 65535;
+00267 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>;
+00268 }
+00269 }
+00270 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> != DI_OK)
+00271 {
+00272 <a class="code" href="bit__set_8cpp.html#a0">min</a> = 0;
+00273 max = 65535;
+00274 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>;
+00275 }
+00276
+00277
+00278 <font class="comment">/* switch (r)</font>
+00279 <font class="comment"> {</font>
+00280 <font class="comment"> default:</font>
+00281 <font class="comment"> nlinfo("ok");</font>
+00282 <font class="comment"> break;</font>
+00283 <font class="comment"> case DIERR_INVALIDPARAM: </font>
+00284 <font class="comment"> nlinfo("invalid param");</font>
+00285 <font class="comment"> break;</font>
+00286 <font class="comment"> case DIERR_NOTEXCLUSIVEACQUIRED: </font>
+00287 <font class="comment"> nlinfo("DIERR_NOTEXCLUSIVEACQUIRED");</font>
+00288 <font class="comment"> break;</font>
+00289 <font class="comment"> case DIERR_NOTINITIALIZED: </font>
+00290 <font class="comment"> nlinfo("DIERR_NOTINITIALIZED");</font>
+00291 <font class="comment"> break;</font>
+00292 <font class="comment"> case DIERR_OBJECTNOTFOUND: </font>
+00293 <font class="comment"> nlinfo("DIERR_OBJECTNOTFOUND");</font>
+00294 <font class="comment"> break;</font>
+00295 <font class="comment"> case DIERR_UNSUPPORTED: </font>
+00296 <font class="comment"> nlinfo("DIERR_UNSUPPORTED");</font>
+00297 <font class="comment"> break;</font>
+00298 <font class="comment"> }*/</font>
+00299
+00300
+00301 <a class="code" href="bit__set_8cpp.html#a0">min</a> = (sint) diprg.lMin;
+00302 max = (sint) diprg.lMax;
+00303
+00304 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a>;
+00305 }
+00306
+00307 <font class="comment">//============================================================================</font>
+00308 BOOL CDIGameDevice::processEnumObject(LPCDIDEVICEOBJECTINSTANCE lpddoi)
+00309 {
+00310 <font class="comment">// the dwSize field gives us the size of the objects, and the available fields</font>
+00311 <font class="comment">// has this object the field guidType and dwOfs ?</font>
+00312 <font class="keywordflow">if</font> (lpddoi-&gt;dwSize &lt; offsetof(DIDEVICEOBJECTINSTANCE, dwOfs) + <font class="keyword">sizeof</font>(DWORD)) <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00313
+00314 <a class="code" href="types__nl_8h.html#a14">uint</a> ctrlType = (uint) lpddoi-&gt;dwType;
+00315
+00317 <font class="comment">// axis, we only support absolute ones //</font>
+00319 <font class="comment"></font>
+00320 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_XAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS) )
+00321 {
+00322 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[XAxis].Min, _Axis[XAxis].Max);
+00323 BuildCtrlName(lpddoi, _Axis[XAxis].Name, <font class="stringliteral">"X Axis"</font>);
+00324 _Axis[XAxis].Present = <font class="keyword">true</font>;
+00325 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00326 }
+00327 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_YAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS))
+00328 {
+00329 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[YAxis].Min, _Axis[YAxis].Max);
+00330 BuildCtrlName(lpddoi, _Axis[YAxis].Name, <font class="stringliteral">"Y Axis"</font>);
+00331 _Axis[YAxis].Present = <font class="keyword">true</font>;
+00332 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00333 }
+00334
+00335 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_ZAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS))
+00336 {
+00337 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[ZAxis].Min, _Axis[ZAxis].Max);
+00338 BuildCtrlName(lpddoi, _Axis[ZAxis].Name, <font class="stringliteral">"Z Axis"</font>);
+00339 _Axis[ZAxis].Present = <font class="keyword">true</font>;
+00340 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00341 }
+00342 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_RxAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS))
+00343 {
+00344 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[RXAxis].Min, _Axis[RXAxis].Max);
+00345 BuildCtrlName(lpddoi, _Axis[RXAxis].Name, <font class="stringliteral">"RX Axis"</font>);
+00346 _Axis[RXAxis].Present = <font class="keyword">true</font>;
+00347 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00348 }
+00349 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_RyAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS))
+00350 {
+00351 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[RYAxis].Min, _Axis[RYAxis].Max);
+00352 BuildCtrlName(lpddoi, _Axis[RYAxis].Name, <font class="stringliteral">"RY Axis"</font>);
+00353 _Axis[RYAxis].Present = <font class="keyword">true</font>;
+00354 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00355 }
+00356 <font class="keywordflow">if</font> (lpddoi-&gt;guidType == GUID_RzAxis &amp;&amp; (ctrlType &amp; DIDFT_ABSAXIS))
+00357 {
+00358 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Axis[RZAxis].Min, _Axis[RZAxis].Max);
+00359 BuildCtrlName(lpddoi, _Axis[RZAxis].Name, <font class="stringliteral">"RZ Axis"</font>);
+00360 _Axis[RZAxis].Present = <font class="keyword">true</font>;
+00361 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00362 }
+00363
+00364
+00365 <font class="comment">// has this object the field dwType ?</font>
+00366 <font class="keywordflow">if</font> (lpddoi-&gt;dwSize &lt; offsetof(DIDEVICEOBJECTINSTANCE, dwType) + <font class="keyword">sizeof</font>(DWORD)) <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00367
+00368
+00369 <a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a251">type</a> = lpddoi-&gt;dwType;
+00371 <font class="comment">// Buttons //</font>
+00373 <font class="comment"> if (type &amp; DIDFT_BUTTON)</font>
+00374 {
+00375 <font class="keywordflow">if</font> (_Buttons.size() &lt; MaxNumButtons)
+00376 {
+00377 _Buttons.push_back(CButton());
+00378 <a class="code" href="types__nl_8h.html#a14">uint</a> buttonIndex = _Buttons.size() - 1;
+00379 <font class="keywordtype">char</font> defaultButtonName[32];
+00380 <a class="code" href="namespaceNLMISC.html#a203">smprintf</a>(defaultButtonName, 32, <font class="stringliteral">"BUTTON %d"</font>, buttonIndex + 1);
+00381 BuildCtrlName(lpddoi, _Buttons[buttonIndex].Name, defaultButtonName);
+00382 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00383 }
+00384 }
+00385
+00387 <font class="comment">// Sliders //</font>
+00389 <font class="comment"> if (type &amp; DIDFT_ABSAXIS)</font>
+00390 {
+00391 <font class="keywordflow">if</font> (_Sliders.size() &lt; MaxNumSliders)
+00392 {
+00393 _Sliders.push_back(CSlider());
+00394 <a class="code" href="types__nl_8h.html#a14">uint</a> sliderIndex = _Sliders.size() - 1;
+00395 GetDIAxisRange(_Device, lpddoi-&gt;dwOfs, lpddoi-&gt;dwType, _Sliders[sliderIndex].Min, _Sliders[sliderIndex].Max);
+00396 <font class="keywordtype">char</font> defaultSliderName[32];
+00397 <a class="code" href="namespaceNLMISC.html#a203">smprintf</a>(defaultSliderName, 32, <font class="stringliteral">"SLIDER %d"</font>, sliderIndex + 1);
+00398 BuildCtrlName(lpddoi, _Sliders[sliderIndex].Name, defaultSliderName);
+00399 }
+00400 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00401 }
+00402
+00403
+00405 <font class="comment">// POVs //</font>
+00407 <font class="comment"> if (type &amp; DIDFT_POV)</font>
+00408 {
+00409 <font class="keywordflow">if</font> (_POVs.size() &lt; MaxNumPOVs)
+00410 {
+00411 _POVs.push_back(CPOV());
+00412 <a class="code" href="types__nl_8h.html#a14">uint</a> povIndex = _POVs.size() - 1;
+00413 <font class="keywordtype">char</font> defaultPOVName[16];
+00414 <a class="code" href="namespaceNLMISC.html#a203">smprintf</a>(defaultPOVName, 16, <font class="stringliteral">"POV %d"</font>, povIndex + 1);
+00415 BuildCtrlName(lpddoi, _POVs[povIndex].Name, defaultPOVName);
+00416 }
+00417 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00418 }
+00419
+00420 <font class="keywordflow">return</font> DIENUM_CONTINUE;
+00421 }
+00422
+00423 <font class="comment">//============================================================================</font>
+00424 <font class="keywordtype">void</font> CDIGameDevice::querryControls()
+00425 {
+00426 HRESULT <a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> = _Device-&gt;EnumObjects(&amp;DIEnumDeviceObjectsCallback, (LPVOID) <font class="keyword">this</font>, DIDFT_ALL);
+00427 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a262">r</a> == DI_OK);
+00428 }
+00429
+00430 <font class="comment">//============================================================================</font>
+00431 <font class="keywordtype">bool</font> CDIGameDevice::setBufferSize(<a class="code" href="types__nl_8h.html#a14">uint</a> size)
+00432 {
+00433 <font class="comment">// uisually not supported by this kind of devices</font>
+00434 <font class="keywordflow">return</font> <font class="keyword">false</font>;
+00435 }
+00436
+00437 <font class="comment">//============================================================================</font>
+00438 <a class="code" href="types__nl_8h.html#a14">uint</a> CDIGameDevice::getBufferSize()<font class="keyword"> const</font>
+00439 <font class="keyword"></font>{
+00440 <font class="comment">// uisually not supported by this kind of devices</font>
+00441 <font class="keywordflow">return</font> 0;
+00442 }
+00443
+00444 <font class="comment">//============================================================================</font>
+00445 <a class="code" href="types__nl_8h.html#a14">uint</a> CDIGameDevice::getNumButtons()<font class="keyword"> const</font>
+00446 <font class="keyword"></font>{
+00447 <font class="keywordflow">return</font> _Buttons.size();
+00448 }
+00449
+00450 <font class="comment">//============================================================================</font>
+00451 <font class="keywordtype">bool</font> CDIGameDevice::hasAxis(TAxis axis)<font class="keyword"> const</font>
+00452 <font class="keyword"></font>{
+00453 <a class="code" href="debug_8h.html#a6">nlassert</a>(axis &lt; MaxNumAxis);
+00454 <font class="keywordflow">return</font> _Axis[axis].Present;
+00455 }
+00456
+00457 <font class="comment">//============================================================================</font>
+00458 <a class="code" href="types__nl_8h.html#a14">uint</a> CDIGameDevice::getNumSliders()<font class="keyword"> const</font>
+00459 <font class="keyword"></font>{
+00460 <font class="keywordflow">return</font> _Sliders.size();
+00461 }
+00462
+00463 <font class="comment">//============================================================================</font>
+00464 <a class="code" href="types__nl_8h.html#a14">uint</a> CDIGameDevice::getNumPOV()<font class="keyword"> const </font>
+00465 <font class="keyword"></font>{
+00466 <font class="keywordflow">return</font> _POVs.size();
+00467 }
+00468 <font class="comment">//============================================================================</font>
+00469 <font class="keyword">const</font> <font class="keywordtype">char</font> *CDIGameDevice::getButtonName(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00470 <font class="keyword"></font>{
+00471 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _Buttons.size());
+00472 <font class="keywordflow">return</font> _Buttons[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Name.c_str();
+00473 }
+00474
+00475 <font class="comment">//============================================================================</font>
+00476 <font class="keyword">const</font> <font class="keywordtype">char</font> *CDIGameDevice::getAxisName(TAxis axis)<font class="keyword"> const</font>
+00477 <font class="keyword"></font>{
+00478 <a class="code" href="debug_8h.html#a6">nlassert</a>(axis &lt; MaxNumAxis);
+00479 <a class="code" href="debug_8h.html#a6">nlassert</a>(hasAxis(axis)); <font class="comment">// ! Not an axis of this device</font>
+00480 <font class="keywordflow">return</font> _Axis[axis].Name.c_str();
+00481 }
+00482
+00483 <font class="comment">//============================================================================</font>
+00484 <font class="keyword">const</font> <font class="keywordtype">char</font> *CDIGameDevice::getSliderName(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00485 <font class="keyword"></font>{
+00486 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _Sliders.size());
+00487 <font class="keywordflow">return</font> _Sliders[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Name.c_str();
+00488 }
+00489
+00490 <font class="comment">//============================================================================</font>
+00491 <font class="keyword">const</font> <font class="keywordtype">char</font> *CDIGameDevice::getPOVName(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00492 <font class="keyword"></font>{
+00493 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _POVs.size());
+00494 <font class="keywordflow">return</font> _POVs[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Name.c_str();
+00495 }
+00496
+00497 <font class="comment">//============================================================================</font>
+00498 <font class="keywordtype">bool</font> CDIGameDevice::getButtonState(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00499 <font class="keyword"></font>{
+00500 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _Buttons.size());
+00501 <font class="keywordflow">return</font> _Buttons[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Pushed;
+00502 }
+00503
+00504 <font class="comment">//============================================================================</font>
+00505 <font class="keywordtype">float</font> CDIGameDevice::getAxisValue(TAxis axis)<font class="keyword"> const</font>
+00506 <font class="keyword"></font>{
+00507 <a class="code" href="debug_8h.html#a6">nlassert</a>(axis &lt; MaxNumAxis);
+00508 <a class="code" href="debug_8h.html#a6">nlassert</a>(hasAxis(axis)); <font class="comment">// ! Not an axis of this device</font>
+00509 <font class="keywordflow">return</font> _Axis[axis].Value;
+00510 }
+00511
+00512 <font class="comment">//============================================================================</font>
+00513 <font class="keywordtype">float</font> CDIGameDevice::getSliderPos(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00514 <font class="keyword"></font>{
+00515 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _Sliders.size());
+00516 <font class="keywordflow">return</font> _Sliders[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Pos;
+00517 }
+00518
+00519 <font class="comment">//============================================================================</font>
+00520 <font class="keywordtype">float</font> CDIGameDevice::getPOVAngle(<a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>)<font class="keyword"> const</font>
+00521 <font class="keyword"></font>{
+00522 <a class="code" href="debug_8h.html#a6">nlassert</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a> &lt; _POVs.size());
+00523 <font class="keywordflow">return</font> _POVs[<a class="code" href="driver__opengl__extension__def_8h.html#a236">index</a>].Angle;
+00524 }
+00525
+00526
+00527
+00528 } <font class="comment">// NLMISC</font>
+00529
+00530
+00531 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>