2015-08-19 11:12:54 -04:00
|
|
|
//This file must compile on ALL PLATFORMS. Be very careful what you put in here.
|
|
|
|
|
#include "HAL/HAL.hpp"
|
2015-09-27 14:09:17 -04:00
|
|
|
#include "FRC_NetworkCommunication/FRCComm.h"
|
2015-11-15 14:49:50 -08:00
|
|
|
#include <cstring>
|
2015-08-19 11:12:54 -04:00
|
|
|
|
2015-11-26 00:08:32 -08:00
|
|
|
extern "C" {
|
|
|
|
|
|
2015-08-19 11:12:54 -04:00
|
|
|
int HALGetControlWord(HALControlWord *data)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getControlWord((ControlWord_t*) data);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-15 21:24:03 -08:00
|
|
|
void HALSetNewDataSem(MULTIWAIT_ID sem)
|
2015-08-19 11:12:54 -04:00
|
|
|
{
|
2015-11-15 21:24:03 -08:00
|
|
|
setNewDataSem(sem->native_handle());
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetAllianceStation(enum HALAllianceStationID *allianceStation)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getAllianceStation((AllianceStationID_t*) allianceStation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickAxes(uint8_t joystickNum, HALJoystickAxes *axes)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getJoystickAxes(joystickNum, (JoystickAxes_t*) axes, kMaxJoystickAxes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickPOVs(uint8_t joystickNum, HALJoystickPOVs *povs)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getJoystickPOVs(joystickNum, (JoystickPOV_t*) povs, kMaxJoystickPOVs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickButtons(uint8_t joystickNum, HALJoystickButtons *buttons)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getJoystickButtons(joystickNum, &buttons->buttons, &buttons->count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickDescriptor(uint8_t joystickNum, HALJoystickDescriptor *desc)
|
|
|
|
|
{
|
2016-01-14 21:49:50 -08:00
|
|
|
desc->isXbox = 0;
|
|
|
|
|
desc->type = -1;
|
|
|
|
|
desc->name[0] = '\0';
|
|
|
|
|
desc->axisCount = 0;
|
|
|
|
|
desc->buttonCount = 0;
|
|
|
|
|
desc->povCount = 0;
|
2015-08-19 11:12:54 -04:00
|
|
|
return FRC_NetworkCommunication_getJoystickDesc(joystickNum, &desc->isXbox, &desc->type, (char *)(&desc->name),
|
|
|
|
|
&desc->axisCount, (uint8_t *)&desc->axisTypes, &desc->buttonCount, &desc->povCount);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickIsXbox(uint8_t joystickNum)
|
|
|
|
|
{
|
|
|
|
|
HALJoystickDescriptor joystickDesc;
|
|
|
|
|
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
return joystickDesc.isXbox;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetJoystickType(uint8_t joystickNum)
|
|
|
|
|
{
|
|
|
|
|
HALJoystickDescriptor joystickDesc;
|
|
|
|
|
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
return joystickDesc.type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-15 14:49:50 -08:00
|
|
|
char* HALGetJoystickName(uint8_t joystickNum)
|
2015-08-19 11:12:54 -04:00
|
|
|
{
|
|
|
|
|
HALJoystickDescriptor joystickDesc;
|
|
|
|
|
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
|
|
|
|
{
|
2015-11-15 14:49:50 -08:00
|
|
|
char* name = (char*)std::malloc(1);
|
|
|
|
|
name[0] = '\0';
|
|
|
|
|
return name;
|
2015-08-19 11:12:54 -04:00
|
|
|
} else
|
|
|
|
|
{
|
2015-11-15 14:49:50 -08:00
|
|
|
size_t len = std::strlen(joystickDesc.name);
|
|
|
|
|
char* name = (char*)std::malloc(len+1);
|
|
|
|
|
std::strcpy(name, joystickDesc.name);
|
|
|
|
|
return name;
|
2015-08-19 11:12:54 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 00:03:55 -08:00
|
|
|
int HALGetJoystickAxisType(uint8_t joystickNum, uint8_t axis)
|
2015-08-19 11:12:54 -04:00
|
|
|
{
|
|
|
|
|
HALJoystickDescriptor joystickDesc;
|
|
|
|
|
if(HALGetJoystickDescriptor(joystickNum, &joystickDesc)<0)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
return joystickDesc.axisTypes[axis];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALSetJoystickOutputs(uint8_t joystickNum, uint32_t outputs, uint16_t leftRumble, uint16_t rightRumble)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_setJoystickOutputs(joystickNum, outputs, leftRumble, rightRumble);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int HALGetMatchTime(float *matchTime)
|
|
|
|
|
{
|
|
|
|
|
return FRC_NetworkCommunication_getMatchTime(matchTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALNetworkCommunicationObserveUserProgramStarting(void)
|
|
|
|
|
{
|
|
|
|
|
FRC_NetworkCommunication_observeUserProgramStarting();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALNetworkCommunicationObserveUserProgramDisabled(void)
|
|
|
|
|
{
|
|
|
|
|
FRC_NetworkCommunication_observeUserProgramDisabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALNetworkCommunicationObserveUserProgramAutonomous(void)
|
|
|
|
|
{
|
|
|
|
|
FRC_NetworkCommunication_observeUserProgramAutonomous();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALNetworkCommunicationObserveUserProgramTeleop(void)
|
|
|
|
|
{
|
|
|
|
|
FRC_NetworkCommunication_observeUserProgramTeleop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void HALNetworkCommunicationObserveUserProgramTest(void)
|
|
|
|
|
{
|
|
|
|
|
FRC_NetworkCommunication_observeUserProgramTest();
|
|
|
|
|
}
|
2015-11-26 00:08:32 -08:00
|
|
|
|
|
|
|
|
} // extern "C"
|