Exemple #1
0
/*************
 * DESCRIPTION: read an object consisting of
 *              triangles
 * INPUT:       pointer to chunk
 * OUTPUT:      -
 *************/
static void ParseTriObject(HANDLER_DATA *data, CHUNK *mainchunk)
{
	CHUNK chunk;

	do
	{
		BeginChunk(data, &chunk);
		switch (chunk.id)
		{
			case ID_POINTS:
				ParsePoints(data);
				break;
			case ID_FACES:
				ParseFaces(data, &chunk);
				break;
			case ID_MAPPINGCOORS:
				ParseMapping(data);
				break;
			case ID_TRANSMATRIX:
				ReadFloat(data, &data->transm[0], 12);
				data->transmatrix.m[0] = data->transm[0];
				data->transmatrix.m[1] = data->transm[1];
				data->transmatrix.m[2] = data->transm[2];
				data->transmatrix.m[4] = data->transm[3];
				data->transmatrix.m[5] = data->transm[4];
				data->transmatrix.m[6] = data->transm[5];
				data->transmatrix.m[8] = data->transm[6];
				data->transmatrix.m[9] = data->transm[7];
				data->transmatrix.m[10] = data->transm[8];
				data->transmatrix.m[12] = data->transm[9];
				data->transmatrix.m[13] = data->transm[10];
				data->transmatrix.m[14] = data->transm[11];
				break;
		}
		EndChunk(data, &chunk);
	}
	while (INCHUNK);
}
Exemple #2
0
std::tuple<GamepadMappings, std::string> GetMappings(const std::string& uuidString)
{
    GamepadMappings mappings;
#if defined(POMDOG_PLATFORM_LINUX)
    // NOTE: Please see this header
    // https://github.com/torvalds/linux/blob/4982327ff6755377a8a66e84113f496f3a6c53bc/include/uapi/linux/input-event-codes.h#L379-L398
    mappings.buttons = {{
        ButtonKind::A,
        ButtonKind::B,
        ButtonKind::X,
        ButtonKind::Y,
        ButtonKind::LeftShoulder,
        ButtonKind::RightShoulder,
        ButtonKind::LeftMenu,
        ButtonKind::RightMenu,
        ButtonKind::Guide,
        ButtonKind::LeftStick,
        ButtonKind::RightStick,
        ButtonKind::Extra1,
        ButtonKind::Extra2,
        ButtonKind::None,
        ButtonKind::None,
        ButtonKind::None,
    }};
#elif defined(POMDOG_PLATFORM_MACOSX)
    mappings.buttons = {{
        ButtonKind::A,
        ButtonKind::B,
        ButtonKind::X,
        ButtonKind::Y,
        ButtonKind::LeftShoulder,
        ButtonKind::RightShoulder,
        ButtonKind::LeftTrigger,
        ButtonKind::RightTrigger,
        ButtonKind::LeftMenu,
        ButtonKind::RightMenu,
        ButtonKind::LeftStick,
        ButtonKind::RightStick,
        ButtonKind::Guide,
        ButtonKind::Extra1,
        ButtonKind::Extra2,
        ButtonKind::None,
    }};
#else
    mappings.buttons = {{
        ButtonKind::A,
        ButtonKind::B,
        ButtonKind::X,
        ButtonKind::Y,
        ButtonKind::LeftShoulder,
        ButtonKind::RightShoulder,
        ButtonKind::LeftMenu,
        ButtonKind::RightMenu,
        ButtonKind::LeftStick,
        ButtonKind::RightStick,
        ButtonKind::Guide,
        ButtonKind::Extra1,
        ButtonKind::Extra2,
        ButtonKind::None,
        ButtonKind::None,
        ButtonKind::None,
    }};
#endif

    mappings.axes = {{
        AxisMapper{ ThumbStickKind::LeftStickX, ButtonKind::None, ButtonKind::None },
        AxisMapper{ ThumbStickKind::LeftStickY, ButtonKind::None, ButtonKind::None },
        AxisMapper{ ThumbStickKind::None, ButtonKind::LeftTrigger, ButtonKind::None },
        AxisMapper{ ThumbStickKind::RightStickX, ButtonKind::None, ButtonKind::None },
        AxisMapper{ ThumbStickKind::RightStickY, ButtonKind::None, ButtonKind::None },
        AxisMapper{ ThumbStickKind::None, ButtonKind::RightTrigger, ButtonKind::None },
    }};

    std::string deviceName;
    for (auto m : s_ControllerMappings) {
        if (m == nullptr) {
            break;
        }
        std::string s = m;
        if (StringHelper::HasPrefix(s, uuidString)) {
            // found
            std::fill(std::begin(mappings.buttons), std::end(mappings.buttons), ButtonKind::None);
            for (auto& axis : mappings.axes) {
                axis.thumbStick = ThumbStickKind::None;
                axis.positiveTrigger = ButtonKind::None;
                axis.negativeTrigger = ButtonKind::None;
            }
            ParseMapping(m, mappings, deviceName);
            break;
        }
    }
    return std::make_tuple(mappings, deviceName);
}