mirror of
https://github.com/love2d/love.git
synced 2026-08-28 18:26:55 +02:00
Properly initialize variables + fix changes.txt
This commit is contained in:
+2
-2
@@ -29,8 +29,8 @@ Released: N/A
|
|||||||
* Added Joystick:hasSensor.
|
* Added Joystick:hasSensor.
|
||||||
* Added Joystick:isSensorEnabled and Joystick:setSensorEnabled.
|
* Added Joystick:isSensorEnabled and Joystick:setSensorEnabled.
|
||||||
* Added Joystick:getSensorData.
|
* Added Joystick:getSensorData.
|
||||||
* Added Joystick:getDeviceBatteryPercent and Joystick:getDevicePowerState, these expose how charged batteries in a controller are and if they're charging
|
* Added Joystick:getPowerInfo which exposes infomation about batteries in a controller are and if they're charging.
|
||||||
* Added Joystick:getConnectionState which indicates if a joystick is connected wired or wireless
|
* Added Joystick:getConnectionState which indicates if a joystick is connected wired or wireless.
|
||||||
* Added new Gamepad API buttons: "misc1", "paddle1", "paddle2", "paddle3", "paddle4". and "touchpad".
|
* Added new Gamepad API buttons: "misc1", "paddle1", "paddle2", "paddle3", "paddle4". and "touchpad".
|
||||||
* Added World:getFixturesInArea().
|
* Added World:getFixturesInArea().
|
||||||
* Added support for saving .exr image files via ImageData:encode.
|
* Added support for saving .exr image files via ImageData:encode.
|
||||||
|
|||||||
@@ -465,9 +465,12 @@ void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion)
|
|||||||
Joystick::PowerType Joystick::getPowerInfo(int& batteryPercent) const
|
Joystick::PowerType Joystick::getPowerInfo(int& batteryPercent) const
|
||||||
{
|
{
|
||||||
// Gets the battery state of a joystick/gamepad
|
// Gets the battery state of a joystick/gamepad
|
||||||
Joystick::PowerType powerState;
|
Joystick::PowerType powerState = Joystick::PowerType::POWER_UNKNOWN;
|
||||||
SDL_PowerState batteryState;
|
SDL_PowerState batteryState;
|
||||||
|
|
||||||
|
if (!isConnected())
|
||||||
|
return powerState;
|
||||||
|
|
||||||
batteryState = SDL_GetJoystickPowerInfo(joyhandle, &batteryPercent);
|
batteryState = SDL_GetJoystickPowerInfo(joyhandle, &batteryPercent);
|
||||||
|
|
||||||
getConstant(batteryState, powerState);
|
getConstant(batteryState, powerState);
|
||||||
@@ -477,9 +480,12 @@ Joystick::PowerType Joystick::getPowerInfo(int& batteryPercent) const
|
|||||||
Joystick::ConnectionType Joystick::getConnectionState() const
|
Joystick::ConnectionType Joystick::getConnectionState() const
|
||||||
{
|
{
|
||||||
// Gets the connection state of a joystick/gamepad (wired / wireless etc)
|
// Gets the connection state of a joystick/gamepad (wired / wireless etc)
|
||||||
Joystick::ConnectionType connectionState;
|
Joystick::ConnectionType connectionState = Joystick::ConnectionType::CONNECTION_UNKNOWN;
|
||||||
SDL_JoystickConnectionState sdlConnectionState;
|
SDL_JoystickConnectionState sdlConnectionState;
|
||||||
|
|
||||||
|
if (!isConnected())
|
||||||
|
return connectionState;
|
||||||
|
|
||||||
sdlConnectionState = SDL_GetJoystickConnectionState(joyhandle);
|
sdlConnectionState = SDL_GetJoystickConnectionState(joyhandle);
|
||||||
|
|
||||||
getConstant(sdlConnectionState, connectionState);
|
getConstant(sdlConnectionState, connectionState);
|
||||||
|
|||||||
Reference in New Issue
Block a user