[giimote commit] r192 - in trunk: GiiMote Help/GiiMote Help

0 views
Skip to first unread message

codesite...@google.com

unread,
Mar 7, 2009, 1:51:36 AM3/7/09
to gii...@googlegroups.com
Author: leif902
Date: Fri Mar 6 22:50:54 2009
New Revision: 192

Added:
trunk/GiiMote/Drums.h
Modified:
trunk/GiiMote/Definitions.gml
trunk/GiiMote/GMButtons.h
trunk/GiiMote/GiiMote.cpp
trunk/GiiMote/GiiMote.h
trunk/GiiMote/GiiMote.vcproj
trunk/GiiMote/Guitar.h
trunk/GiiMote/Orientation.h
trunk/Help/GiiMote Help/GiiMote.htm
trunk/Help/GiiMote Help/GiiMoteIndex.hhk

Log:
Added support for the drum set extension

Modified: trunk/GiiMote/Definitions.gml
==============================================================================
--- trunk/GiiMote/Definitions.gml (original)
+++ trunk/GiiMote/Definitions.gml Fri Mar 6 22:50:54 2009
@@ -34,19 +34,24 @@
const wm_c = 19
const wm_z = 20

-// Guitar Specific Buttons
+// General Instruments
const wm_blue = 21
const wm_green = 22
const wm_orange = 23
const wm_red = 24
const wm_yellow = 25
-const wm_touch_blue = 28
-const wm_touch_green = 29;
-const wm_touch_orange = 30;
-const wm_touch_red = 31;
-const wm_touch_yellow = 32;
+
+// Guitar Specific Buttons
const wm_strum_down = 26
const wm_strum_up = 27
+const wm_touch_blue = 28
+const wm_touch_green = 29
+const wm_touch_orange = 30
+const wm_touch_red = 31
+const wm_touch_yellow = 32
+
+// Drum Specific
+const wm_pedal = 33

// Balance Board Sensors
const bb_btmleft = 0
@@ -127,6 +132,14 @@
function wm_connected():real
function wm_disconnect():real
function wm_disconnect_all();
+function wm_drum_check_button(wm_button:real):real
+function wm_drum_direction():real
+function wm_drum_get_velocity(wm_button:real):real
+function wm_drum_pressure():real
+function wm_drum_rawx():real
+function wm_drum_rawy():real
+function wm_drum_xpos():real
+function wm_drum_ypos():real
function wm_exists():real
function wm_num_exists():real
function wm_find_all():real

Added: trunk/GiiMote/Drums.h
==============================================================================
--- (empty file)
+++ trunk/GiiMote/Drums.h Fri Mar 6 22:50:54 2009
@@ -0,0 +1,274 @@
+// Drums.h - Contains functions that deal with the drum extension.
+// Copyright 2008 Sam Whited
+//
+// This file is part of GiiMote.
+//
+// GiiMote is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as
published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// GiiMote is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
License
+// along with GiiMote. If not, see <http://www.gnu.org/licenses/>.
+
+/// <summary>Checks the state of a button or head</summary>
+/// <param name="key_code">
+/// The button or head to check
+/// <list type="bullet">
+/// <listheader>
+/// <term>Key Code</term>
+/// <description>Button</description>
+/// </listheader>
+/// <item>
+/// <term>btnBlue</term>
+/// <description>Blue head</description>
+/// </item>
+/// <item>
+/// <term>btnRed</term>
+/// <description>Red head</description>
+/// </item>
+/// <item>
+/// <term>btnYellow</term>
+/// <description>Yellow head</description>
+/// </item>
+/// <item>
+/// <term>btnGreen</term>
+/// <description>Green head</description>
+/// </item>
+/// <item>
+/// <term>btnOrange</term>
+/// <description>Orange head</description>
+/// </item>
+/// <item>
+/// <term>btnPedal</term>
+/// <description>Pedal</description>
+/// </item>
+/// <item>
+/// <term>btnMinus</term>
+/// <description>Minus button</description>
+/// </item>
+/// <item>
+/// <term>btnPlus</term>
+/// <description>Plus button</description>
+/// </item>
+/// </list>
+/// </param>
+/// <returns>Button pressed</returns>
+double wm_drum_check_button(double key_code)
+{
+ bool is_pressed = 0;
+ switch ((int)key_code)
+ {
+ case btnBlue:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Blue;
+ break;
+ case btnRed:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Red;
+ break;
+ case btnYellow:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Yellow;
+ break;
+ case btnGreen:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Green;
+ break;
+ case btnOrange:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Orange;
+ break;
+ case btnMinus:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Minus;
+ break;
+ case btnPlus:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Plus;
+ break;
+ case btnPedal:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Pedal;
+ break;
+ default:
+ is_pressed = false;
+ break;
+ }
+
+ return ((double)is_pressed);
+}
+
+/// <summary>Gets the velocity with which the drum head or pedal was
hit</summary>
+/// <remarks>Domain: (soft) [0,6] (hard)</remarks>
+/// <param name="key_code">
+/// The head or pedal to check
+/// <list type="bullet">
+/// <listheader>
+/// <term>Key Code</term>
+/// <description>Button</description>
+/// </listheader>
+/// <item>
+/// <term>btnBlue</term>
+/// <description>Blue head</description>
+/// </item>
+/// <item>
+/// <term>btnRed</term>
+/// <description>Red head</description>
+/// </item>
+/// <item>
+/// <term>btnYellow</term>
+/// <description>Yellow head</description>
+/// </item>
+/// <item>
+/// <term>btnGreen</term>
+/// <description>Green head</description>
+/// </item>
+/// <item>
+/// <term>btnOrange</term>
+/// <description>Orange head</description>
+/// </item>
+/// <item>
+/// <term>btnPedal</term>
+/// <description>Pedal</description>
+/// </item>
+/// </list>
+/// </param>
+/// <returns>Button pressed</returns>
+double wm_drum_get_velocity(double key_code)
+{
+ int is_pressed = 0;
+ switch ((int)key_code)
+ {
+ case btnBlue:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.BlueVelocity;
+ break;
+ case btnRed:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.RedVelocity;
+ break;
+ case btnYellow:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.YellowVelocity;
+ break;
+ case btnGreen:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.GreenVelocity;
+ break;
+ case btnOrange:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.OrangeVelocity;
+ break;
+ case btnPedal:
+ is_pressed =
GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.PedalVelocity;
+ break;
+ default:
+ is_pressed = false;
+ break;
+ }
+
+ return ((double)is_pressed);
+}
+
+/// <summary>Normalized joystick position</summary>
+/// <remarks>Domain: [-0.5,0.5]</remarks>
+/// <returns>The normalized X-position of the joystick</returns>
+double wm_drum_xpos()
+{
+ double xx;
+ try
+ {
+ xx =
(double)GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Joystick.X;
+ }
+ catch(...)
+ {
+ return ( -1 );
+ }
+ if ( System::Math::Abs(xx) <
(GiiMote::gm->joystick_dead_zone[GiiMote::gm->wmIndex]) )
+ {
+ xx = 0;
+ }
+ return ( xx );
+}
+
+/// <summary>Normalized joystick position</summary>
+/// <remarks>Domain: [-0.5,0.5]</remarks>
+/// <returns>The normalized Y-position of the joystick</returns>
+double wm_drum_ypos()
+{
+ double yy;
+ try
+ {
+ yy =
(double)GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.Joystick.Y;
+ }
+ catch(...)
+ {
+ return ( -1 );
+ }
+ if ( System::Math::Abs(yy) <
(GiiMote::gm->joystick_dead_zone[GiiMote::gm->wmIndex]) )
+ {
+ yy = 0;
+ }
+ return ( yy );
+}
+
+/// <summary>Joystick direction</summary>
+/// <returns>The direction of the joystick in degrees</returns>
+double wm_drum_direction()
+{
+ double xx = wm_drum_xpos();
+ double yy = wm_drum_ypos();
+ if (xx == -1 || yy == -1)
+ {
+ return ( -1 );
+ }
+ else
+ {
+ return ( joystick_direction(xx,yy) );
+ }
+}
+
+/// <summary>Joystick pressure</summary>
+/// <returns>The pressure on the joystick</returns>
+double wm_drum_pressure()
+{
+ double xx = wm_drum_xpos();
+ double yy = wm_drum_ypos();
+ if (xx == -1 || yy == -1)
+ {
+ return ( -1 );
+ }
+ else
+ {
+ return ( joystick_pressure(xx,yy) );
+ }
+}
+
+/// <summary>Raw joystick X-position</summary>
+/// <remarks>Domain: [0,255]</remarks>
+/// <returns>Raw joystick X-position</returns>
+double wm_drum_rawx()
+{
+ double rawX;
+ try
+ {
+ rawX =
(double)GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.RawJoystick.X;
+ }
+ catch(...)
+ {
+ return ( -1 );
+ }
+
+ return ( rawX );
+}
+
+/// <summary>Raw joystick Y-position</summary>
+/// <remarks>Domain: [0,255]</remarks>
+/// <returns>Raw joystick Y-position</returns>
+double wm_drum_rawy()
+{
+ double rawY;
+ try
+ {
+ rawY =
(double)GiiMote::gm->wc[GiiMote::gm->wmIndex]->WiimoteState->DrumsState.RawJoystick.Y;
+ }
+ catch(...)
+ {
+ return ( -1 );
+ }
+
+ return ( rawY );
+}

Modified: trunk/GiiMote/GMButtons.h
==============================================================================
--- trunk/GiiMote/GMButtons.h (original)
+++ trunk/GiiMote/GMButtons.h Fri Mar 6 22:50:54 2009
@@ -1,5 +1,5 @@
// GMButtons.h - Contains information on the buttons and triggers
-// used by the Wii Remote and Expansions.
+// used by the Wii Remote and expansions.
// Copyright 2007 Sam Whited
//
// This file is part of GiiMote.

Modified: trunk/GiiMote/GiiMote.cpp
==============================================================================
--- trunk/GiiMote/GiiMote.cpp (original)
+++ trunk/GiiMote/GiiMote.cpp Fri Mar 6 22:50:54 2009
@@ -30,6 +30,7 @@
#include "Orientation.h"
#include "IR.h"
#include "Guitar.h"
+#include "Drums.h"
#include "Nunchuck.h"
#include "Classic.h"
#include "BalanceBoard.h"

Modified: trunk/GiiMote/GiiMote.h
==============================================================================
--- trunk/GiiMote/GiiMote.h (original)
+++ trunk/GiiMote/GiiMote.h Fri Mar 6 22:50:54 2009
@@ -29,7 +29,7 @@
const int extNone = 0;
const int extUnknown = -1;

-// Wii Remote specific buttons:
+// General Wii Remote buttons
const int btnA = 0;
const int btnB = 1;
const int btnUp = 2;
@@ -50,6 +50,7 @@
const int btnZL = 15;
const int btnZR = 16;

+// Joysticks
const int joyL = 0;
const int joyR = 1;

@@ -57,12 +58,14 @@
const int btnC = 19;
const int btnZ = 20;

-// Guitar Specific
+// General Instruments
const int btnBlue = 21;
const int btnGreen = 22;
const int btnOrange = 23;
const int btnRed = 24;
const int btnYellow = 25;
+
+// Guitar Specific
const int btnStrumDown = 26;
const int btnStrumUp = 27;
const int btnTouchBlue = 28;
@@ -71,6 +74,9 @@
const int btnTouchRed = 31;
const int btnTouchYellow = 32;

+// Drum Specific
+const int btnPedal = 33;
+
// Balance Board Sensors
const int btmLeft = 0;
const int btmRight = 1;
@@ -168,6 +174,7 @@

// Buttons
exp double wm_guitar_check_button(double key_code);
+ exp double wm_drum_check_button(double key_code);
exp double wm_nunchuck_check_button(double key_code);
exp double wm_classic_check_button(double key_code);
exp double wm_check_button(double key_code);
@@ -211,6 +218,14 @@
exp double wm_guitar_rawx();
exp double wm_guitar_rawy();

+ // Joysticks (Drum)
+ exp double wm_drum_xpos();
+ exp double wm_drum_ypos();
+ exp double wm_drum_direction();
+ exp double wm_drum_pressure();
+ exp double wm_drum_rawx();
+ exp double wm_drum_rawy();
+
// Triggers (General)
exp double wm_set_trigger_dead_zone(double val);
exp double wm_get_trigger_dead_zone();
@@ -222,6 +237,9 @@
// Whammy Bar (Guitar)
exp double wm_guitar_whammybar_pos();
exp double wm_guitar_whammybar_rawpos();
+
+ // Drum
+ exp double wm_drum_get_velocity(double key_code);

////////////////////////////////////////////
// Accelerometers and IR

Modified: trunk/GiiMote/GiiMote.vcproj
==============================================================================
--- trunk/GiiMote/GiiMote.vcproj (original)
+++ trunk/GiiMote/GiiMote.vcproj Fri Mar 6 22:50:54 2009
@@ -268,7 +268,7 @@
/>
<AssemblyReference
RelativePath="..\WiimoteLib\WiimoteLib.dll"
- AssemblyName="WiimoteLib, Version=1.6.0.0, processorArchitecture=MSIL"
+ AssemblyName="WiimoteLib, Version=1.7.0.0, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
@@ -387,6 +387,10 @@
</File>
<File
RelativePath=".\Classic.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Drums.h"
>
</File>
<File

Modified: trunk/GiiMote/Guitar.h
==============================================================================
--- trunk/GiiMote/Guitar.h (original)
+++ trunk/GiiMote/Guitar.h Fri Mar 6 22:50:54 2009
@@ -1,5 +1,5 @@
-// Guitar.h - Contains functions that deal with the Guitar extension.
-// Copyright 2007 Sam Whited
+// Guitar.h - Contains functions that deal with the guitar extension.
+// Copyright 2008 Sam Whited
//
// This file is part of GiiMote.
//

Modified: trunk/GiiMote/Orientation.h
==============================================================================
--- trunk/GiiMote/Orientation.h (original)
+++ trunk/GiiMote/Orientation.h Fri Mar 6 22:50:54 2009
@@ -1,5 +1,5 @@
// Orientation.h - Contains functions for getting data from the Wii Remote
and expansions
-// accelerometers.
+// accelerometers.
// Copyright 2007 Sam Whited
//
// This file is part of GiiMote.

Modified: trunk/Help/GiiMote Help/GiiMote.htm
==============================================================================
--- trunk/Help/GiiMote Help/GiiMote.htm (original)
+++ trunk/Help/GiiMote Help/GiiMote.htm Fri Mar 6 22:50:54 2009
@@ -93,17 +93,25 @@
<tt><b><a
name="wm_nunchuck_check_button">wm_nunchuck_check_button(button)</a></b></tt>
Gets the status of the given button on the Nunchuck (if inserted).<br>
<tt><b><a
name="wm_guitar_check_button">wm_guitar_check_button(button)</a></b></tt>
- Gets the status of the given button on the Guitar (if inserted).<br>
+ Gets the status of the given button on the guitar (if inserted).<br>
+ <tt><b><a
name="wm_drum_check_button">wm_drum_check_button(button)</a></b></tt>
+ Gets the status of the given button, head, or pedal on the drum set (if
inserted).<br>
</blockquote>
<p>There is also an additional function for checking the pressure of L and
R on the classic controller:</p>
<blockquote>
<p><tt><b><a
name="wm_classic_trigger_pressure">wm_classic_trigger_pressure(trigger)</a></b></tt>
This function returns a value between 0.0 and 1.0 depending on the
amount the trigger is being pushed in with 1 being all the way in and 0
being released. You may define a &quot;dead zone&quot; for the function by
calling <a href="#wm_set_dead_zone">wm_set_dead_zone</a>.</p>
</blockquote>
-<p>And another for checking the pressure on the Whammy bar on the
Guitar:</p>
+<p>Another for checking the pressure on the Whammy bar on the Guitar:</p>
<blockquote>
<p><tt><b><a
name="wm_guitar_whammybar_pos">wm_guitar_whammybar_pos()</a></b></tt> The
position of the Guitar's whammy bar as a value between 0.0 and 1.0.</p>
</blockquote>
+
+<p>And another for checking the velocity with which the drum heads and
pedal on the drum set are hit:</p>
+<blockquote>
+ <p><tt><b><a
name="wm_drum_get_velocity">wm_drum_get_velocity(head)</a></b></tt> The
velocity with which the drum head or pedal was hit from 0.0 (hard) to 6.0
(soft).</p>
+</blockquote>
+
<p>
The following button key codes exist for use in any function that requires
a button (not all buttons are available on all controllers):</p>
<blockquote>
@@ -137,9 +145,10 @@
<tt><b><a name="wm_touch_yellow">wm_touch_yellow</a></b></tt><br>
<tt><b><a name="wm_strum_up">wm_strum_up</a></b></tt><br>
<tt><b><a name="wm_strum_down">wm_strum_down</a></b></tt><br>
+ <tt><b><a name="wm_pedal">wm_pedal</a></b></tt><br>
</blockquote>
<h2><a name="joystick">Joystick Positions</a></h2>
-<p>The Nunchuck, Classic Controller, and Guitar Controller both contain
one or more joysticks which can be utilized with the following
functions:</p>
+<p>The Nunchuck, Classic Controller, Guitar controller, and Drum set both
contain one or more joysticks which can be utilized with the following
functions:</p>
<blockquote>
<tt><b><a name="wm_nunchuck_xpos">wm_nunchuck_xpos()</a></b></tt> From
-0.5 (left) to 0.5 (right).<br>
<tt><b><a name="wm_nunchuck_ypos">wm_nunchuck_ypos()</a></b></tt><br>
@@ -153,6 +162,10 @@
<tt><b><a name="wm_guitar_ypos">wm_guitar_ypos()</a></b></tt><br>
<tt><b><a
name="wm_guitar_direction">wm_guitar_direction()</a></b></tt><br>
<tt><b><a name="wm_guitar_pressure">wm_guitar_pressure()</a></b></tt><br>
+ <tt><b><a name="wm_drum_xpos">wm_drum_xpos()</a></b></tt><br>
+ <tt><b><a name="wm_drum_ypos">wm_drum_ypos()</a></b></tt><br>
+ <tt><b><a name="wm_drum_direction">wm_drum_direction()</a></b></tt><br>
+ <tt><b><a name="wm_drum_pressure">wm_drum_pressure()</a></b></tt><br>
</blockquote>
<p>For the Classic Controller you must specify which joystick to check the
values of, for this the following constants are defined:</p>
<blockquote>
@@ -326,6 +339,8 @@
<tt><b><a name="wm_guitar_rawy">wm_guitar_rawy()</a></b></tt><br>
<tt><b><a
name="wm_guitar_whammybar_rawpos">wm_guitar_whammybar_rawpos()</a></b></tt><br>
<tt><b><a
name="wm_bb_get_sensor_raw">wm_bb_get_sensor_raw(sensor)</a></b></tt><br>
+ <tt><b><a name="wm_drum_rawx">wm_drum_rawx()</a></b></tt><br>
+ <tt><b><a name="wm_drum_rawy">wm_drum_rawy()</a></b></tt><br>
</blockquote>
<p>These functions are for advanced use only and return data that has not
been normalized.</p>


Modified: trunk/Help/GiiMote Help/GiiMoteIndex.hhk
==============================================================================
--- trunk/Help/GiiMote Help/GiiMoteIndex.hhk (original)
+++ trunk/Help/GiiMote Help/GiiMoteIndex.hhk Fri Mar 6 22:50:54 2009
@@ -302,6 +302,36 @@
<param name="Local" value="GiiMote.htm#setup">
</OBJECT>
<LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_check_button()">
+ <param name="Name" value="Buttons">
+ <param name="Local" value="GiiMote.htm#buttons">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_direction()">
+ <param name="Name" value="Joystick Positions">
+ <param name="Local" value="GiiMote.htm#joystick">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_get_velocity()">
+ <param name="Name" value="Buttons">
+ <param name="Local" value="GiiMote.htm#buttons">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_pressure()">
+ <param name="Name" value="Joystick Positions">
+ <param name="Local" value="GiiMote.htm#joystick">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_xpos()">
+ <param name="Name" value="Joystick Positions">
+ <param name="Local" value="GiiMote.htm#joystick">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
+ <param name="Name" value="wm_drum_ypos()">
+ <param name="Name" value="Joystick Positions">
+ <param name="Local" value="GiiMote.htm#joystick">
+ </OBJECT>
+ <LI> <OBJECT type="text/sitemap">
<param name="Name" value="wm_exists()">
<param name="Name" value="Setup">
<param name="Local" value="GiiMote.htm#setup">

Reply all
Reply to author
Forward
0 new messages