Fix multiple definition errors.

This commit is contained in:
2025-03-18 00:21:23 -04:00
parent 326ab4c8d8
commit 0c4d012627
2 changed files with 19 additions and 18 deletions

View File

@@ -64,21 +64,21 @@ namespace jstick {
/// This event is fired when a new joystick device is detected.
// TODO: Call JoystickConnected for each device found on library runtime start.
Event<int> JoystickConnected;
static Event<int> JoystickConnected;
/// This event is fired when a joystick device is unplugged or otherwise dropped.
Event<int> JoystickDisconnected;
static Event<int> JoystickDisconnected;
/// This event is fired when a joystick button is pressed.
Event<XBoxButton> ButtonPressed;
static Event<XBoxButton> ButtonPressed;
/// This event is fired when a xbox button is pressed.
Event<XBoxButton> ButtonReleased;
Event<Vector2> LeftThumbstickMoved;
Event<Vector2> RightThumbstickMoved;
Event<Vector2> DPadMoved;
Event<short> LeftTriggerMoved;
Event<short> RightTriggerMoved;
static Event<XBoxButton> ButtonReleased;
static Event<Vector2> LeftThumbstickMoved;
static Event<Vector2> RightThumbstickMoved;
static Event<Vector2> DPadMoved;
static Event<short> LeftTriggerMoved;
static Event<short> RightTriggerMoved;
//Event<int, JoystickAxis> AxisMoved;
@@ -97,14 +97,7 @@ namespace jstick {
int Connect(int hwid = 0);
bool Disconnect(int hwid = 0);
ControllerType GetDeviceTypeFromName(const std::string& name)
{
if (name == "Microsoft X-Box 360 pad")
return ControllerType::XBox;
return ControllerType::Unknown;
}
ControllerType GetDeviceTypeFromName(const std::string& name);
std::string GetDeviceName(int hwid = 0);
int NumJoysticksDetected();
void JoystickServiceUpdate();

View File

@@ -191,7 +191,7 @@ void jstick::ReadEventLoop() {
while (read_event(js_handle, &event) == 0) {
switch (event.type) {
case JS_EVENT_BUTTON:
ProcessButtonEvent(event.number, event.value ? true : false);
ProcessButtonEvent(event.number, event.value != 0);
break;
case JS_EVENT_AXIS:
ProcessAxisEvent(event.number, event.value);
@@ -238,3 +238,11 @@ float jstick::GetLeftTriggerNormalized() {
float jstick::GetRightTriggerNormalized() {
return r_trigger / short_range;
}
jstick::ControllerType jstick::GetDeviceTypeFromName(const std::string &name) {
if (name == "Microsoft X-Box 360 pad")
return ControllerType::XBox;
return ControllerType::Unknown;
}