Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
fix: #57 remove button/coordinate union to allow clicks to have coord…
Browse files Browse the repository at this point in the history
…inate data associated with them when present.
  • Loading branch information
JoshSnider committed Apr 11, 2018
1 parent 89fe7b4 commit d62361f
Show file tree
Hide file tree
Showing 6 changed files with 1,035 additions and 1,015 deletions.
10 changes: 6 additions & 4 deletions Tests/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ void handle_transaction_complete(void* context, interactive_session session, con
transaction_data data = transactionItr->second;
switch (data.type)
{
case input_type_button:
case input_type_click:
case input_type_key:
Logger::WriteMessage((std::string("Executing button press for participant: ") + data.participantName).c_str());

// Look for a cooldown metadata property and tigger it if it exists.
Expand Down Expand Up @@ -286,9 +287,10 @@ void handle_input(void* context, interactive_session session, const interactive_

switch (input->type)
{
case input_type_button:
case input_type_click:
case input_type_key:
{
if (input->buttonData.action == interactive_button_action::down)
if (input->buttonData.action == interactive_button_action_down)
{
// This requries a transaction. Store relevant data.
transaction_data data;
Expand All @@ -308,7 +310,7 @@ void handle_input(void* context, interactive_session session, const interactive_
}
break;
}
case input_type_coordinate:
case input_type_move:
{
Logger::WriteMessage((std::string("MOVEMENT on ") + input->control.id).c_str());
Logger::WriteMessage(("X:\t" + std::to_string(input->coordinateData.x)).c_str());
Expand Down
Binary file modified samples/InteractiveSample/InteractiveSample.cpp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEvent
err = interactive_register_input_handler(session, [](void* context, interactive_session session, const interactive_input* input)
{
std::map<std::string, std::string>& controlsByTransaction = *(std::map <std::string, std::string>*)context;
if (input_type_button == input->type && interactive_button_action::down == input->buttonData.action)
if ((input_type_key == input->type || input_type_click == input->type) && interactive_button_action_down == input->buttonData.action)
{
// Capture the transaction on button down to deduct sparks
controlsByTransaction[input->transactionId] = input->control.id;
Expand Down
2 changes: 1 addition & 1 deletion samples/InteractiveXboxSample/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void Game::Initialize(IUnknown* window)
err = interactive_register_input_handler(m_interactiveSession, [](void* context, interactive_session session, const interactive_input* input)
{
Game* game = (Game*)context;
if (input_type_button == input->type && interactive_button_action::down == input->buttonData.action)
if ((input_type_key == input->type || input_type_click == input->type) && interactive_button_action_down == input->buttonData.action)
{
// Capture the transaction on button down to deduct sparks
int err = interactive_capture_transaction(session, input->transactionId);
Expand Down
30 changes: 14 additions & 16 deletions source/interactivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,17 @@ extern "C" {
};

enum interactive_input_type
{
input_type_button,
input_type_coordinate,
{
input_type_key,
input_type_click,
input_type_move,
input_type_custom
};

enum interactive_button_action
{
up,
down
interactive_button_action_up,
interactive_button_action_down
};

struct interactive_input
Expand All @@ -123,18 +124,15 @@ extern "C" {
size_t jsonDataLength;
const char* transactionId;
size_t transactionIdLength;
union
struct buttonData
{
interactive_button_action action;
} buttonData;
struct coordinateData
{
struct buttonData
{
interactive_button_action action;
} buttonData;
struct coordinateData
{
float x;
float y;
} coordinateData;
};
float x;
float y;
} coordinateData;
};

struct interactive_group : public interactive_object
Expand Down
Loading

0 comments on commit d62361f

Please sign in to comment.