Added Clamp function to general.c Now clamps all final joystick values to be from 0 - 32767 (2^15 - 1). Output from the 3ds was giving a strange range on the values, even though the code expected it to be in the range -128 to 128. Was more like -146 to 146 on the c-stick, and -170 to 170 on the circle pad. This may remove some of the resolution of the sticks, but increase compatability with programs.
30 lines
486 B
C
30 lines
486 B
C
#include "wireless.h"
|
|
|
|
#include "general.h"
|
|
|
|
void error(const char *functionName) {
|
|
char errorMsg[92];
|
|
ZeroMemory(errorMsg, 92);
|
|
|
|
sprintf(errorMsg, "Call to %s returned error %d!", (char *)functionName, WSAGetLastError());
|
|
|
|
MessageBox(NULL, errorMsg, "socketIndication", MB_OK);
|
|
|
|
closesocket(client);
|
|
closesocket(listener);
|
|
WSACleanup();
|
|
|
|
exit(0);
|
|
}
|
|
|
|
int clamp (int val, int min, int max) {
|
|
if (val < min) {
|
|
return min;
|
|
}
|
|
|
|
if (val > max) {
|
|
return max;
|
|
}
|
|
|
|
return val;
|
|
}
|