MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / fromString

Method fromString

Sources/nCine/Input/IInputManager.cpp:42–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 }
41
42 void JoystickGuid::fromString(StringView string)
43 {
44 if (string.empty()) {
45 fromType(JoystickGuidType::Unknown);
46 } else if (string == "default"_s) {
47 fromType(JoystickGuidType::Default);
48 } else if (string == "hidapi"_s) {
49 fromType(JoystickGuidType::Hidapi);
50 } else if (string == "xinput"_s) {
51 fromType(JoystickGuidType::Xinput);
52 } else {
53 if (string.size() != sizeof(data) * 2) {
54 fromType(JoystickGuidType::Unknown);
55 } else {
56 char component[3];
57 component[2] = '\0';
58 for (uint32_t i = 0, j = 0; i < sizeof(data); i++) {
59 component[0] = string[j++];
60 component[1] = string[j++];
61 data[i] = (std::uint8_t)std::strtoul(component, nullptr, 16);
62 }
63 }
64 }
65 }
66
67 bool JoystickGuid::isValid() const
68 {

Callers 1

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected