Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Memory Game 1.2 source code
  • Loading branch information
Alexandre Colucci committed Jan 8, 2019
0 parents commit ea2740d
Show file tree
Hide file tree
Showing 4,763 changed files with 570,614 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 9 additions & 0 deletions LICENSE
@@ -0,0 +1,9 @@
The MIT License

Copyright 2018 Corsair Memory, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 changes: 26 additions & 0 deletions README.md
@@ -0,0 +1,26 @@

`MemoryGame` is a sample plugin demonstrating the [Stream Deck SDK](https://developer.elgato.com/documentation/stream-deck/).


# Description

`MemoryGame` is a fullscreen plugin that lets you play a memory game.

Features:

- code written in C++
- cross-platform (macOS, Windows)
- fullscreen
- pre-configured profiles
- localized


# Installation

In the Release folder, you can find the file `com.elgato.memorygame.streamDeckPlugin`. If you double-click this file on your machine, Stream Deck will install the plugin.


# Source code

The Sources and Common folders contains the source code of the plugin.

Binary file added Release/com.elgato.memorygame.streamDeckPlugin
Binary file not shown.
153 changes: 153 additions & 0 deletions Sources/Common/EPLJSONUtils.h
@@ -0,0 +1,153 @@
//==============================================================================
/**
@file EPLJSONUtils.h
@brief Utility methods for JSON parser from N.Lohmann
https://github.com/nlohmann/json
@copyright (c) 2018, Corsair Memory, Inc.
This source code is licensed under the MIT-style license found in the LICENSE file.
**/
//==============================================================================

#pragma once

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------

#include "../Vendor/json/src/json.hpp"
using json = nlohmann::json;

class EPLJSONUtils
{

public:

//! Get object by name
static bool GetObjectByName(const json& inJSON, const std::string& inName, json& outObject)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return false;

// Check value is an array
if (!iter->is_object())
return false;

// Assign value
outObject = *iter;

return true;
}

//! Get array by name
static bool GetArrayByName(const json& inJSON, const std::string& inName, json& outArray)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return false;

// Check value is an array
if (!iter->is_array())
return false;

// Assign value
outArray = *iter;

return true;
}

//! Get string by name
static std::string GetStringByName(const json& inJSON, const std::string& inName, const std::string& defaultValue = "")
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return defaultValue;

// Check value is a string
if (!iter->is_string())
return defaultValue;

// Return value
return *iter;
}

//! Get string
static std::string GetString(const json& j, const std::string& defaultString = "")
{
// Check value is a string
if (!j.is_string())
return defaultString;

return j;
}

//! Get bool by name
static bool GetBoolByName(const json& inJSON, const std::string& inName, bool defaultValue = false)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return defaultValue;

// Check value is a bool
if (!iter->is_boolean())
return defaultValue;

// Return value
return *iter;
}

//! Get integer by name
static int GetIntByName(const json& inJSON, const std::string& inName, int defaultValue = 0)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return defaultValue;

// Check value is an integer
if (!iter->is_number_integer())
return defaultValue;

// Return value
return *iter;
}

//! Get unsigned integer by name
static unsigned int GetUnsignedIntByName(const json& inJSON, const std::string& inName, unsigned int defaultValue = 0)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return defaultValue;

// Check value is an unsigned integer
if (!iter->is_number_unsigned())
return defaultValue;

// Return value
return *iter;
}

//! Get float by name
static float GetFloatByName(const json& inJSON, const std::string& inName, float defaultValue = 0.0)
{
// Check desired value exists
json::const_iterator iter(inJSON.find(inName));
if (iter == inJSON.end())
return defaultValue;

// Check value is an integer
if (!iter->is_number_float() && !iter->is_number_integer())
return defaultValue;

// Return value
return *iter;
}
};
37 changes: 37 additions & 0 deletions Sources/Common/ESDBasePlugin.h
@@ -0,0 +1,37 @@
//==============================================================================
/**
@file ESDBasePlugin.h
@brief Plugin base class
@copyright (c) 2018, Corsair Memory, Inc.
This source code is licensed under the MIT-style license found in the LICENSE file.
**/
//==============================================================================

#pragma once

class ESDConnectionManager;

class ESDBasePlugin
{
public:
ESDBasePlugin() { }
virtual ~ESDBasePlugin() { }

void SetConnectionManager(ESDConnectionManager * inConnectionManager) { mConnectionManager = inConnectionManager; }

virtual void KeyDownForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID) = 0;
virtual void KeyUpForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID) = 0;

virtual void WillAppearForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID) = 0;
virtual void WillDisappearForAction(const std::string& inAction, const std::string& inContext, const json &inPayload, const std::string& inDeviceID) = 0;

virtual void DeviceDidConnect(const std::string& inDeviceID, const json &inDeviceInfo) = 0;
virtual void DeviceDidDisconnect(const std::string& inDeviceID) = 0;

protected:
ESDConnectionManager *mConnectionManager = nullptr;

};

0 comments on commit ea2740d

Please sign in to comment.