MCPcopy Create free account
hub / github.com/beefytech/Beef / GetState

Method GetState

BeefySysLib/platform/win/DInputManager.cpp:100–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100String DInputDevice::GetState()
101{
102 DIJOYSTATE2 joyState = { 0 };
103 HRESULT result = mDirectInputDevice->Poll();
104 if (FAILED(result))
105 {
106 result = mDirectInputDevice->Acquire();
107 while (result == DIERR_INPUTLOST)
108 result = mDirectInputDevice->Acquire();
109 }
110
111 result = mDirectInputDevice->GetDeviceState(sizeof(joyState), &joyState);
112
113 String str;
114 if (!FAILED(result))
115 {
116 if (joyState.lX != 0)
117 str += StrFormat("X\t%d\n", joyState.lX);
118 if (joyState.lY != 0)
119 str += StrFormat("Y\t%d\n", joyState.lY);
120 if (joyState.lZ != 0)
121 str += StrFormat("Z\t%d\n", joyState.lZ);
122
123 //str += StrFormat("X\t%d\nY\t%d\nZ\t%d\n", joyState.lX, joyState.lY, joyState.lZ);
124
125 for (int i = 0; i < 128; i++)
126 {
127 if (joyState.rgbButtons[i] != 0)
128 {
129 str += StrFormat("Btn\t%d\n", i);
130 }
131 }
132 }
133 else
134 {
135 str += "!FAILED";
136 }
137
138 return str;
139}

Callers 1

Calls 1

AcquireMethod · 0.80

Tested by

no test coverage detected