WiinScale: simple reads a connected balance board and displays measured weight.

This commit is contained in:
2018-07-14 17:08:18 +02:00
parent 5ae11c5d2d
commit a8173d4bcb
11 changed files with 596 additions and 14 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "wiiuse"]
path = wiiuse
url = https://github.com/rpavlik/wiiuse

View File

@@ -4,17 +4,114 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WiinScale", "WiinScale\WiinScale.csproj", "{99B4734E-3694-4A4A-BE02-D2FD41F01260}"
ProjectSection(ProjectDependencies) = postProject
{484414BA-B088-3E2A-A367-7BCC762462BF} = {484414BA-B088-3E2A-A367-7BCC762462BF}
{6D610BDA-9461-4B15-9409-8187063624FB} = {6D610BDA-9461-4B15-9409-8187063624FB}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wiiuse", "wiiuse\build\src\wiiuse.vcxproj", "{484414BA-B088-3E2A-A367-7BCC762462BF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wiiuseexample", "wiiuse\build\example\wiiuseexample.vcxproj", "{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wiiuse_board", "wiiuse_board\wiiuse_board.vcxproj", "{6D610BDA-9461-4B15-9409-8187063624FB}"
ProjectSection(ProjectDependencies) = postProject
{484414BA-B088-3E2A-A367-7BCC762462BF} = {484414BA-B088-3E2A-A367-7BCC762462BF}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
MinSizeRel|Any CPU = MinSizeRel|Any CPU
MinSizeRel|x64 = MinSizeRel|x64
MinSizeRel|x86 = MinSizeRel|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
RelWithDebInfo|Any CPU = RelWithDebInfo|Any CPU
RelWithDebInfo|x64 = RelWithDebInfo|x64
RelWithDebInfo|x86 = RelWithDebInfo|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|x64.ActiveCfg = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|x64.Build.0 = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|x86.ActiveCfg = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Debug|x86.Build.0 = Debug|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|Any CPU.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|Any CPU.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|x64.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|x64.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|x86.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.MinSizeRel|x86.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|Any CPU.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|x64.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|x64.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|x86.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.Release|x86.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|x86.ActiveCfg = Release|Any CPU
{99B4734E-3694-4A4A-BE02-D2FD41F01260}.RelWithDebInfo|x86.Build.0 = Release|Any CPU
{484414BA-B088-3E2A-A367-7BCC762462BF}.Debug|Any CPU.ActiveCfg = Debug|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Debug|x64.ActiveCfg = Debug|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Debug|x64.Build.0 = Debug|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Debug|x86.ActiveCfg = Debug|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Release|Any CPU.ActiveCfg = Release|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Release|x64.ActiveCfg = Release|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Release|x64.Build.0 = Release|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.Release|x86.ActiveCfg = Release|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{484414BA-B088-3E2A-A367-7BCC762462BF}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Debug|Any CPU.ActiveCfg = Debug|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Debug|x64.ActiveCfg = Debug|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Debug|x64.Build.0 = Debug|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Debug|x86.ActiveCfg = Debug|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.MinSizeRel|Any CPU.ActiveCfg = MinSizeRel|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Release|Any CPU.ActiveCfg = Release|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Release|x64.ActiveCfg = Release|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Release|x64.Build.0 = Release|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.Release|x86.ActiveCfg = Release|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.RelWithDebInfo|Any CPU.ActiveCfg = RelWithDebInfo|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{94D4B5E8-5C1D-3C85-B30B-744E9931A8BF}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.Debug|Any CPU.ActiveCfg = Debug|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.Debug|x64.ActiveCfg = Debug|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.Debug|x64.Build.0 = Debug|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.Debug|x86.ActiveCfg = Debug|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.Debug|x86.Build.0 = Debug|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|Any CPU.ActiveCfg = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|Any CPU.Build.0 = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|x64.ActiveCfg = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|x64.Build.0 = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|x86.ActiveCfg = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.MinSizeRel|x86.Build.0 = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.Release|Any CPU.ActiveCfg = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.Release|x64.ActiveCfg = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.Release|x64.Build.0 = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.Release|x86.ActiveCfg = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.Release|x86.Build.0 = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|Any CPU.ActiveCfg = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|Any CPU.Build.0 = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|x64.Build.0 = Release|x64
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{6D610BDA-9461-4B15-9409-8187063624FB}.RelWithDebInfo|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@@ -28,12 +28,75 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.ConnectionStatus = new System.Windows.Forms.Label();
this.Weight = new System.Windows.Forms.Label();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// ConnectionStatus
//
this.ConnectionStatus.Dock = System.Windows.Forms.DockStyle.Fill;
this.ConnectionStatus.Location = new System.Drawing.Point(0, 0);
this.ConnectionStatus.Name = "ConnectionStatus";
this.ConnectionStatus.Size = new System.Drawing.Size(421, 25);
this.ConnectionStatus.TabIndex = 0;
this.ConnectionStatus.Text = "...";
//
// Weight
//
this.Weight.Dock = System.Windows.Forms.DockStyle.Fill;
this.Weight.Font = new System.Drawing.Font("Microsoft Sans Serif", 32F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Weight.Location = new System.Drawing.Point(0, 0);
this.Weight.Name = "Weight";
this.Weight.Size = new System.Drawing.Size(421, 248);
this.Weight.TabIndex = 1;
this.Weight.Text = "...";
this.Weight.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.IsSplitterFixed = true;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.ConnectionStatus);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.Weight);
this.splitContainer1.Size = new System.Drawing.Size(421, 277);
this.splitContainer1.SplitterDistance = 25;
this.splitContainer1.TabIndex = 2;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Text = "Form1";
this.ClientSize = new System.Drawing.Size(421, 277);
this.Controls.Add(this.splitContainer1);
this.Name = "Form1";
this.Text = "WiinScale";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label ConnectionStatus;
private System.Windows.Forms.Label Weight;
private System.Windows.Forms.SplitContainer splitContainer1;
}
}

View File

@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System;
namespace WiinScale
{
@@ -15,6 +10,45 @@ namespace WiinScale
public Form1()
{
InitializeComponent();
Task.Run(() =>
{
int connected = 0;
while (connected == 0)
{
ConnectionStatus.BeginInvoke((Action)(() => {
ConnectionStatus.Text = "Connecting...";
}));
while ((connected = WiiUseBoard.Init()) == 0)
System.Threading.Thread.Sleep(500);
ConnectionStatus.BeginInvoke((Action)(() => {
ConnectionStatus.Text = "Connected";
}));
float weight, x, y;
while ((connected = WiiUseBoard.Read(out weight, out x, out y)) != 0)
{
Weight.BeginInvoke((Action)(() => {
Weight.Text = string.Format("{0:00.00} Kg", weight);
}));
System.Threading.Thread.Sleep(50);
}
WiiUseBoard.Shutdown();
}
});
}
}
public static class WiiUseBoard
{
[DllImport("wiiuse_board.dll", EntryPoint = "wiiuse_board_init")]
public extern static int Init();
[DllImport("wiiuse_board.dll", EntryPoint = "wiiuse_board_read")]
public extern static int Read(out float weight, out float x, out float y);
[DllImport("wiiuse_board.dll", EntryPoint = "wiiuse_board_shutdown")]
public extern static void Shutdown();
}
}

120
WiinScale/Form1.resx Normal file
View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -1,8 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WiinScale
{

View File

@@ -14,7 +14,7 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
@@ -24,7 +24,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
@@ -54,6 +54,9 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

1
wiiuse Submodule

Submodule wiiuse added at 53c5ca618a

64
wiiuse_board/main.c Normal file
View File

@@ -0,0 +1,64 @@
#include "wiiuse.h"
#define MAX_WIIMOTES 5
static wiimote** wiimotes;
static int board;
__declspec(dllexport) int wiiuse_board_init()
{
wiimotes = wiiuse_init(MAX_WIIMOTES);
int count = wiiuse_find(wiimotes, MAX_WIIMOTES, 5);
count = wiiuse_connect(wiimotes, count);
board = -1;
for (int i = 0; i < count; i++)
if (board == -1 && wiimotes[i]->exp.type == EXP_WII_BOARD)
board = i;
else
wiiuse_disconnect(wiimotes[i]);
if (board == -1)
wiiuse_cleanup(wiimotes, MAX_WIIMOTES);
return board != -1;
}
__declspec(dllexport) int wiiuse_board_read(float* weight, float* x, float* y)
{
int read = 0;
if (board != -1)
{
while (wiiuse_poll(wiimotes, MAX_WIIMOTES))
{
switch (wiimotes[board]->event)
{
case WIIUSE_EVENT:
{
struct wii_board_t* wb = (wii_board_t*)&wiimotes[board]->exp.wb;
*weight = wb->tl + wb->tr + wb->bl + wb->br;
*x = ((wb->tr + wb->br) / *weight) * 2 - 1;
*y = ((wb->tl + wb->tr) / *weight) * 2 - 1;
read++;
break;
}
case WIIUSE_WII_BOARD_CTRL_REMOVED:
case WIIUSE_DISCONNECT:
case WIIUSE_UNEXPECTED_DISCONNECT:
{
return 0;
break;
}
}
}
}
return read;
}
__declspec(dllexport) void wiiuse_board_shutdown()
{
if (board != -1 && wiimotes[board]->state == WIIMOTE_STATE_CONNECTED)
wiiuse_disconnect(wiimotes[board]);
wiiuse_cleanup(wiimotes, MAX_WIIMOTES);
wiimotes = 0;
board = -1;
}

View File

@@ -0,0 +1,176 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6D610BDA-9461-4B15-9409-8187063624FB}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>wiiuse_board</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;WIIUSE_BOARD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Daniel\Documents\WiinScale\wiiuse\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\wiiuse\build\src\debug</AdditionalLibraryDirectories>
<AdditionalDependencies>wiiuse_debug.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy $(OutputPath)\$(TargetFileName) $(SolutionDir)\WiinScale\bin\Debug
xcopy $(OutputPath)\$(TargetFileName) $(SolutionDir)\WiinScale\bin\Release
xcopy $(SolutionDir)\wiiuse\build\src\debug\wiiuse_debug.dll $(SolutionDir)\WiinScale\bin\Debug
xcopy $(SolutionDir)\wiiuse\build\src\release\wiiuse.dll $(SolutionDir)\WiinScale\bin\Release</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;WIIUSE_BOARD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Daniel\Documents\WiinScale\wiiuse\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)\wiiuse\build\src\debug</AdditionalLibraryDirectories>
<AdditionalDependencies>wiiuse_debug.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /Y $(OutputPath)$(TargetFileName) $(SolutionDir)WiinScale\bin\Debug
xcopy /Y $(SolutionDir)wiiuse\build\src\debug\wiiuse_debug.dll $(SolutionDir)WiinScale\bin\Debug</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;WIIUSE_BOARD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Daniel\Documents\WiinScale\wiiuse\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)\wiiuse\build\src\debug</AdditionalLibraryDirectories>
<AdditionalDependencies>wiiuse.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;WIIUSE_BOARD_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Daniel\Documents\WiinScale\wiiuse\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)\wiiuse\build\src\release</AdditionalLibraryDirectories>
<AdditionalDependencies>wiiuse.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>xcopy /Y $(OutputPath)$(TargetFileName) $(SolutionDir)\WiinScale\bin\Release
xcopy /Y $(SolutionDir)\wiiuse\build\src\release\wiiuse.dll $(SolutionDir)\WiinScale\bin\Release</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="main.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>