Setup project with SMX linked.
This commit is contained in:
parent
60e84d3f80
commit
5979eddc21
@ -1,27 +1,19 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include "SMX.h"
|
#include "SMX.h"
|
||||||
#include <memory>
|
#define OLC_PGE_APPLICATION
|
||||||
#include <string>
|
#include "olcPixelGameEngine.h"
|
||||||
using namespace std;
|
using namespace olc;
|
||||||
|
|
||||||
class InputSample
|
class SMX_PGE : public olc::PixelGameEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputSample()
|
SMX_PGE()
|
||||||
{
|
{
|
||||||
// Set a logging callback. This can be called before SMX_Start.
|
sAppName = "Example";
|
||||||
// SMX_SetLogCallback( SMXLogCallback );
|
|
||||||
|
|
||||||
// Start scanning. The update callback will be called when devices connect or
|
|
||||||
// disconnect or panels are pressed or released. This callback will be called
|
|
||||||
// from a thread.
|
|
||||||
SMX_Start( SMXStateChangedCallback, this );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser)
|
static void SMXStateChangedCallback(int pad, SMXUpdateCallbackReason reason, void *pUser)
|
||||||
{
|
{
|
||||||
InputSample *pSelf = (InputSample *) pUser;
|
SMX_PGE *pSelf = (SMX_PGE*) pUser;
|
||||||
pSelf->SMXStateChanged( pad, reason );
|
pSelf->SMXStateChanged( pad, reason );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,76 +28,30 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int iPanelToLight = 0;
|
public:
|
||||||
void SetLights()
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
string sLightsData;
|
SMX_Start( SMXStateChangedCallback, this );
|
||||||
auto addColor = [&sLightsData](uint8_t r, uint8_t g, uint8_t b)
|
// Called once at the start, so create things here
|
||||||
{
|
return true;
|
||||||
sLightsData.append( 1, r );
|
|
||||||
sLightsData.append( 1, g );
|
|
||||||
sLightsData.append( 1, b );
|
|
||||||
};
|
|
||||||
for( int iPad = 0; iPad < 2; ++iPad )
|
|
||||||
{
|
|
||||||
for( int iPanel = 0; iPanel < 9; ++iPanel )
|
|
||||||
{
|
|
||||||
bool bLight = iPanel == iPanelToLight && iPad == 0;
|
|
||||||
if( !bLight )
|
|
||||||
{
|
|
||||||
// We're not lighting this panel, so append black for the 4x4 and 3x3 lights.
|
|
||||||
for( int iLED = 0; iLED < 25; ++iLED )
|
|
||||||
addColor( 0, 0, 0 );
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append light data for the outer 4x4 grid of lights.
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
addColor( 0xFF, 0, 0 );
|
{
|
||||||
addColor( 0xFF, 0, 0 );
|
// called once per frame
|
||||||
addColor( 0xFF, 0, 0 );
|
for (int x = 0; x < ScreenWidth(); x++)
|
||||||
addColor( 0xFF, 0, 0 );
|
for (int y = 0; y < ScreenHeight(); y++)
|
||||||
addColor( 0, 0xFF, 0 );
|
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255));
|
||||||
addColor( 0, 0xFF, 0 );
|
return true;
|
||||||
addColor( 0, 0xFF, 0 );
|
|
||||||
addColor( 0, 0xFF, 0 );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0xFF, 0xFF, 0 );
|
|
||||||
addColor( 0xFF, 0xFF, 0 );
|
|
||||||
addColor( 0xFF, 0xFF, 0 );
|
|
||||||
addColor( 0xFF, 0xFF, 0 );
|
|
||||||
|
|
||||||
// Append light data for the inner 3x3 grid of lights, if present. These
|
|
||||||
// are ignored if the platform doesn't have them.
|
|
||||||
addColor( 0xFF, 0, 0 );
|
|
||||||
addColor( 0xFF, 0, 0 );
|
|
||||||
addColor( 0xFF, 0, 0 );
|
|
||||||
addColor( 0, 0xFF, 0 );
|
|
||||||
addColor( 0, 0xFF, 0 );
|
|
||||||
addColor( 0, 0xFF, 0 );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
addColor( 0, 0, 0xFF );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SMX_SetLights2( sLightsData.data(), sLightsData.size() );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
InputSample demo;
|
SMX_PGE demo;
|
||||||
|
if (demo.Construct(256, 240, 4, 4))
|
||||||
// Loop forever for this sample.
|
demo.Start();
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
Sleep(500);
|
|
||||||
demo.SetLights();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,20 +14,20 @@
|
|||||||
<ProjectGuid>{8861D665-FD49-4EFD-92C3-F4B8548AFD23}</ProjectGuid>
|
<ProjectGuid>{8861D665-FD49-4EFD-92C3-F4B8548AFD23}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>SMXSample</RootNamespace>
|
<RootNamespace>SMXSample</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
<ProjectName>SMXSample</ProjectName>
|
<ProjectName>SMXSample</ProjectName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@ -62,6 +62,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -80,6 +81,7 @@
|
|||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
<DisableSpecificWarnings>4063;4100;4127;4201;4244;4275;4355;4505;4512;4702;4786;4996;4996;4005;4018;4389;4389;4800;4592;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\sdk</AdditionalIncludeDirectories>
|
||||||
|
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
@ -97,6 +99,9 @@
|
|||||||
<Project>{c5fc0823-9896-4b7c-bfe1-b60db671a462}</Project>
|
<Project>{c5fc0823-9896-4b7c-bfe1-b60db671a462}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="olcPixelGameEngine.h" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
@ -5,10 +5,18 @@
|
|||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{4453342b-4238-49ad-8412-9602572b054a}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="SMXSample.cpp">
|
<ClCompile Include="SMXSample.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="olcPixelGameEngine.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
6695
sample/olcPixelGameEngine.h
Normal file
6695
sample/olcPixelGameEngine.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -45,19 +45,19 @@
|
|||||||
<ProjectGuid>{C5FC0823-9896-4B7C-BFE1-B60DB671A462}</ProjectGuid>
|
<ProjectGuid>{C5FC0823-9896-4B7C-BFE1-B60DB671A462}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
<RootNamespace>SMX</RootNamespace>
|
<RootNamespace>SMX</RootNamespace>
|
||||||
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v141</PlatformToolset>
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <stdexcept>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace SMX;
|
using namespace SMX;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user