mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-24 13:53:36 +02:00
Catch up with SFML 3 API changes
This commit is contained in:
1 parent
330b423ee9
commit
5fb7d4a0a1
14 files changed
+265
-147
No files matched your search
@@ -30,6 +30,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Audio/Export.h>
|
#include <SFML/Audio/Export.h>
|
||||||
#include <SFML/Audio/Types.h>
|
#include <SFML/Audio/Types.h>
|
||||||
|
#include <SFML/Audio/SoundChannel.h>
|
||||||
#include <SFML/System/InputStream.h>
|
#include <SFML/System/InputStream.h>
|
||||||
#include <SFML/System/Time.h>
|
#include <SFML/System/Time.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -84,15 +85,22 @@ CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* str
|
|||||||
/// The assumed format of the audio samples is 16 bits signed integer
|
/// The assumed format of the audio samples is 16 bits signed integer
|
||||||
/// (int16_t).
|
/// (int16_t).
|
||||||
///
|
///
|
||||||
/// \param samples Pointer to the array of samples in memory
|
/// \param samples Pointer to the array of samples in memory
|
||||||
/// \param sampleCount Number of samples in the array
|
/// \param sampleCount Number of samples in the array
|
||||||
/// \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
|
/// \param channelCount Number of channels (1 = mono, 2 = stereo, ...)
|
||||||
/// \param sampleRate Sample rate (number of samples to play per second)
|
/// \param sampleRate Sample rate (number of samples to play per second)
|
||||||
|
/// \param channelMapData Pointer to the array of channel map data
|
||||||
|
/// \param channelMapSize Size of channel map data array
|
||||||
///
|
///
|
||||||
/// \return A new sfSoundBuffer object (NULL if failed)
|
/// \return A new sfSoundBuffer object (NULL if failed)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const int16_t* samples, uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate);
|
CSFML_AUDIO_API sfSoundBuffer* sfSoundBuffer_createFromSamples(const int16_t* samples,
|
||||||
|
uint64_t sampleCount,
|
||||||
|
unsigned int channelCount,
|
||||||
|
unsigned int sampleRate,
|
||||||
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create a new sound buffer by copying an existing one
|
/// \brief Create a new sound buffer by copying an existing one
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SFML - Simple and Fast Multimedia Library
|
||||||
|
// Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org)
|
||||||
|
//
|
||||||
|
// This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
//
|
||||||
|
// Permission is granted to anyone to use this software for any purpose,
|
||||||
|
// including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
// subject to the following restrictions:
|
||||||
|
//
|
||||||
|
// 1. The origin of this software must not be misrepresented;
|
||||||
|
// you must not claim that you wrote the original software.
|
||||||
|
// If you use this software in a product, an acknowledgment
|
||||||
|
// in the product documentation would be appreciated but is not required.
|
||||||
|
//
|
||||||
|
// 2. Altered source versions must be plainly marked as such,
|
||||||
|
// and must not be misrepresented as being the original software.
|
||||||
|
//
|
||||||
|
// 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SFML_SOUNDCHANNEL_H
|
||||||
|
#define SFML_SOUNDCHANNEL_H
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Types of sound channels that can be read/written from sound buffers/files
|
||||||
|
///
|
||||||
|
/// In multi-channel audio, each sound channel can be
|
||||||
|
/// assigned a position. The position of the channel is
|
||||||
|
/// used to determine where to place a sound when it
|
||||||
|
/// is spatialised. Assigning an incorrect sound channel
|
||||||
|
/// will result in multi-channel audio being positioned
|
||||||
|
/// incorrectly when using spatialisation.
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
sfSoundChannelUnspecified,
|
||||||
|
sfSoundChannelMono,
|
||||||
|
sfSoundChannelFrontLeft,
|
||||||
|
sfSoundChannelFrontRight,
|
||||||
|
sfSoundChannelFrontCenter,
|
||||||
|
sfSoundChannelFrontLeftOfCenter,
|
||||||
|
sfSoundChannelFrontRightOfCenter,
|
||||||
|
sfSoundChannelLowFrequencyEffects,
|
||||||
|
sfSoundChannelBackLeft,
|
||||||
|
sfSoundChannelBackRight,
|
||||||
|
sfSoundChannelBackCenter,
|
||||||
|
sfSoundChannelSideLeft,
|
||||||
|
sfSoundChannelSideRight,
|
||||||
|
sfSoundChannelTopCenter,
|
||||||
|
sfSoundChannelTopFrontLeft,
|
||||||
|
sfSoundChannelTopFrontRight,
|
||||||
|
sfSoundChannelTopFrontCenter,
|
||||||
|
sfSoundChannelTopBackLeft,
|
||||||
|
sfSoundChannelTopBackRight,
|
||||||
|
sfSoundChannelTopBackCenter
|
||||||
|
} sfSoundChannel;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SFML_SOUNDCHANNEL_H
|
||||||
@@ -115,25 +115,6 @@ CSFML_AUDIO_API unsigned int sfSoundRecorder_getSampleRate(const sfSoundRecorder
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
|
CSFML_AUDIO_API bool sfSoundRecorder_isAvailable(void);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
/// \brief Set the processing interval
|
|
||||||
///
|
|
||||||
/// The processing interval controls the period
|
|
||||||
/// between calls to the onProcessSamples function. You may
|
|
||||||
/// want to use a small interval if you want to process the
|
|
||||||
/// recorded data in real time, for example.
|
|
||||||
///
|
|
||||||
/// Note: this is only a hint, the actual period may vary.
|
|
||||||
/// So don't rely on this parameter to implement precise timing.
|
|
||||||
///
|
|
||||||
/// The default processing interval is 100 ms.
|
|
||||||
///
|
|
||||||
/// \param soundRecorder Sound recorder object
|
|
||||||
/// \param interval Processing interval
|
|
||||||
///
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Get a list of the names of all available audio capture devices
|
/// \brief Get a list of the names of all available audio capture devices
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -31,8 +31,10 @@
|
|||||||
#include <SFML/Audio/Export.h>
|
#include <SFML/Audio/Export.h>
|
||||||
#include <SFML/Audio/SoundStatus.h>
|
#include <SFML/Audio/SoundStatus.h>
|
||||||
#include <SFML/Audio/Types.h>
|
#include <SFML/Audio/Types.h>
|
||||||
|
#include <SFML/Audio/SoundChannel.h>
|
||||||
#include <SFML/System/Time.h>
|
#include <SFML/System/Time.h>
|
||||||
#include <SFML/System/Vector3.h>
|
#include <SFML/System/Vector3.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@@ -52,20 +54,24 @@ typedef void (*sfSoundStreamSeekCallback)(sfTime, void*); ///< T
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create a new sound stream
|
/// \brief Create a new sound stream
|
||||||
///
|
///
|
||||||
/// \param onGetData Function called when the stream needs more data (can't be NULL)
|
/// \param onGetData Function called when the stream needs more data (can't be NULL)
|
||||||
/// \param onSeek Function called when the stream seeks (can't be NULL)
|
/// \param onSeek Function called when the stream seeks (can't be NULL)
|
||||||
/// \param channelCount Number of channels to use (1 = mono, 2 = stereo)
|
/// \param channelCount Number of channels to use (1 = mono, 2 = stereo)
|
||||||
/// \param sampleRate Sample rate of the sound (44100 = CD quality)
|
/// \param sampleRate Sample rate of the sound (44100 = CD quality)
|
||||||
/// \param userData Data to pass to the callback functions
|
/// \param channelMapData Pointer to the array of channel map data
|
||||||
|
/// \param channelMapSize Size of channel map data array
|
||||||
|
/// \param userData Data to pass to the callback functions
|
||||||
///
|
///
|
||||||
/// \return A new sfSoundStream object
|
/// \return A new sfSoundStream object
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_AUDIO_API sfSoundStream* sfSoundStream_create(sfSoundStreamGetDataCallback onGetData,
|
CSFML_AUDIO_API sfSoundStream* sfSoundStream_create(sfSoundStreamGetDataCallback onGetData,
|
||||||
sfSoundStreamSeekCallback onSeek,
|
sfSoundStreamSeekCallback onSeek,
|
||||||
unsigned int channelCount,
|
unsigned int channelCount,
|
||||||
unsigned int sampleRate,
|
unsigned int sampleRate,
|
||||||
void* userData);
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize,
|
||||||
|
void* userData);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destroy a sound stream
|
/// \brief Destroy a sound stream
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ typedef enum
|
|||||||
{
|
{
|
||||||
sfEvtClosed, ///< The window requested to be closed (no data)
|
sfEvtClosed, ///< The window requested to be closed (no data)
|
||||||
sfEvtResized, ///< The window was resized (data in event.size)
|
sfEvtResized, ///< The window was resized (data in event.size)
|
||||||
sfEvtLostFocus, ///< The window lost the focus (no data)
|
sfEvtFocusLost, ///< The window lost the focus (no data)
|
||||||
sfEvtGainedFocus, ///< The window gained the focus (no data)
|
sfEvtFocusGained, ///< The window gained the focus (no data)
|
||||||
sfEvtTextEntered, ///< A character was entered (data in event.text)
|
sfEvtTextEntered, ///< A character was entered (data in event.text)
|
||||||
sfEvtKeyPressed, ///< A key was pressed (data in event.key)
|
sfEvtKeyPressed, ///< A key was pressed (data in event.key)
|
||||||
sfEvtKeyReleased, ///< A key was released (data in event.key)
|
sfEvtKeyReleased, ///< A key was released (data in event.key)
|
||||||
|
|||||||
@@ -80,11 +80,19 @@ sfSoundBuffer* sfSoundBuffer_createFromStream(sfInputStream* stream)
|
|||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sfSoundBuffer* sfSoundBuffer_createFromSamples(const int16_t* samples, uint64_t sampleCount, unsigned int channelCount, unsigned int sampleRate)
|
sfSoundBuffer* sfSoundBuffer_createFromSamples(const int16_t* samples,
|
||||||
|
uint64_t sampleCount,
|
||||||
|
unsigned int channelCount,
|
||||||
|
unsigned int sampleRate,
|
||||||
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize)
|
||||||
{
|
{
|
||||||
sfSoundBuffer* buffer = new sfSoundBuffer;
|
sfSoundBuffer* buffer = new sfSoundBuffer;
|
||||||
|
|
||||||
if (!buffer->This.loadFromSamples(samples, sampleCount, channelCount, sampleRate))
|
std::vector<sf::SoundChannel> channelMap(channelMapSize);
|
||||||
|
for (std::size_t i = 0; i < channelMap.size(); ++i)
|
||||||
|
channelMap[i] = static_cast<sf::SoundChannel>(channelMapData[i]);
|
||||||
|
if (!buffer->This.loadFromSamples(samples, sampleCount, channelCount, sampleRate, channelMap))
|
||||||
{
|
{
|
||||||
delete buffer;
|
delete buffer;
|
||||||
buffer = nullptr;
|
buffer = nullptr;
|
||||||
|
|||||||
@@ -75,13 +75,6 @@ bool sfSoundRecorder_isAvailable(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
void sfSoundRecorder_setProcessingInterval(sfSoundRecorder* soundRecorder, sfTime interval)
|
|
||||||
{
|
|
||||||
CSFML_CALL(soundRecorder, setProcessingInterval(interval));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const char** sfSoundRecorder_getAvailableDevices(size_t* count)
|
const char** sfSoundRecorder_getAvailableDevices(size_t* count)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,11 +51,6 @@ public :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void setProcessingInterval(sfTime interval)
|
|
||||||
{
|
|
||||||
sf::SoundRecorder::setProcessingInterval(sf::microseconds(interval.microseconds));
|
|
||||||
}
|
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
bool onStart() override
|
bool onStart() override
|
||||||
|
|||||||
@@ -35,9 +35,11 @@ sfSoundStream* sfSoundStream_create(sfSoundStreamGetDataCallback onGetData,
|
|||||||
sfSoundStreamSeekCallback onSeek,
|
sfSoundStreamSeekCallback onSeek,
|
||||||
unsigned int channelCount,
|
unsigned int channelCount,
|
||||||
unsigned int sampleRate,
|
unsigned int sampleRate,
|
||||||
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize,
|
||||||
void* userData)
|
void* userData)
|
||||||
{
|
{
|
||||||
return new sfSoundStream(onGetData, onSeek, channelCount, sampleRate, userData);
|
return new sfSoundStream(onGetData, onSeek, channelCount, sampleRate, channelMapData, channelMapSize, userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// Headers
|
// Headers
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
#include <SFML/Audio/SoundChannel.h>
|
||||||
#include <SFML/Audio/SoundStream.hpp>
|
#include <SFML/Audio/SoundStream.hpp>
|
||||||
|
|
||||||
|
|
||||||
@@ -43,12 +44,17 @@ public :
|
|||||||
sfSoundStreamSeekCallback onSeek,
|
sfSoundStreamSeekCallback onSeek,
|
||||||
unsigned int channelCount,
|
unsigned int channelCount,
|
||||||
unsigned int sampleRate,
|
unsigned int sampleRate,
|
||||||
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize,
|
||||||
void* userData) :
|
void* userData) :
|
||||||
myGetDataCallback(onGetData),
|
myGetDataCallback(onGetData),
|
||||||
mySeekCallback (onSeek),
|
mySeekCallback (onSeek),
|
||||||
myUserData (userData)
|
myUserData (userData)
|
||||||
{
|
{
|
||||||
initialize(channelCount, sampleRate);
|
std::vector<sf::SoundChannel> channelMap(channelMapSize);
|
||||||
|
for (std::size_t i = 0; i < channelMap.size(); ++i)
|
||||||
|
channelMap[i] = static_cast<sf::SoundChannel>(channelMapData[i]);
|
||||||
|
initialize(channelCount, sampleRate, channelMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
@@ -88,8 +94,10 @@ struct sfSoundStream
|
|||||||
sfSoundStreamSeekCallback onSeek,
|
sfSoundStreamSeekCallback onSeek,
|
||||||
unsigned int channelCount,
|
unsigned int channelCount,
|
||||||
unsigned int sampleRate,
|
unsigned int sampleRate,
|
||||||
|
sfSoundChannel* channelMapData,
|
||||||
|
size_t channelMapSize,
|
||||||
void* userData) :
|
void* userData) :
|
||||||
This(onGetData, onSeek, channelCount, sampleRate, userData)
|
This(onGetData, onSeek, channelCount, sampleRate, channelMapData, channelMapSize, userData)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+135
-77
@@ -37,84 +37,142 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
inline void convertEvent(const sf::Event& sfmlEvent, sfEvent* event)
|
inline void convertEvent(const sf::Event& sfmlEvent, sfEvent* event)
|
||||||
{
|
{
|
||||||
// Convert its type
|
if (sfmlEvent.is<sf::Event::Closed>())
|
||||||
event->type = static_cast<sfEventType>(sfmlEvent.type);
|
|
||||||
|
|
||||||
// Fill its fields
|
|
||||||
switch (event->type)
|
|
||||||
{
|
{
|
||||||
case sfEvtResized :
|
event->type = sfEvtClosed;
|
||||||
event->size.width = sfmlEvent.size.width;
|
}
|
||||||
event->size.height = sfmlEvent.size.height;
|
else if (const auto* resized = sfmlEvent.getIf<sf::Event::Resized>())
|
||||||
break;
|
{
|
||||||
|
event->type = sfEvtResized;
|
||||||
case sfEvtTextEntered :
|
event->size.width = resized->size.x;
|
||||||
event->text.unicode = sfmlEvent.text.unicode;
|
event->size.height = resized->size.y;
|
||||||
break;
|
}
|
||||||
|
else if (sfmlEvent.is<sf::Event::FocusLost>())
|
||||||
case sfEvtKeyReleased :
|
{
|
||||||
case sfEvtKeyPressed :
|
event->type = sfEvtFocusLost;
|
||||||
event->key.code = static_cast<sfKeyCode>(sfmlEvent.key.code);
|
}
|
||||||
event->key.scancode = static_cast<sfScancode>(sfmlEvent.key.scancode);
|
else if (sfmlEvent.is<sf::Event::FocusGained>())
|
||||||
event->key.alt = sfmlEvent.key.alt;
|
{
|
||||||
event->key.control = sfmlEvent.key.control;
|
event->type = sfEvtFocusGained;
|
||||||
event->key.shift = sfmlEvent.key.shift;
|
}
|
||||||
event->key.system = sfmlEvent.key.system;
|
else if (const auto* textEntered = sfmlEvent.getIf<sf::Event::TextEntered>())
|
||||||
break;
|
{
|
||||||
|
event->type = sfEvtTextEntered;
|
||||||
case sfEvtMouseWheelScrolled :
|
event->text.unicode = textEntered->unicode;
|
||||||
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(sfmlEvent.mouseWheelScroll.wheel);
|
}
|
||||||
event->mouseWheelScroll.delta = sfmlEvent.mouseWheelScroll.delta;
|
else if (const auto* keyReleased = sfmlEvent.getIf<sf::Event::KeyReleased>())
|
||||||
event->mouseWheelScroll.x = sfmlEvent.mouseWheelScroll.x;
|
{
|
||||||
event->mouseWheelScroll.y = sfmlEvent.mouseWheelScroll.y;
|
event->type = sfEvtKeyReleased;
|
||||||
break;
|
event->key.code = static_cast<sfKeyCode>(keyReleased->code);
|
||||||
|
event->key.scancode = static_cast<sfScancode>(keyReleased->scancode);
|
||||||
case sfEvtMouseButtonPressed :
|
event->key.alt = keyReleased->alt;
|
||||||
case sfEvtMouseButtonReleased :
|
event->key.control = keyReleased->control;
|
||||||
event->mouseButton.button = static_cast<sfMouseButton>(sfmlEvent.mouseButton.button);
|
event->key.shift = keyReleased->shift;
|
||||||
event->mouseButton.x = sfmlEvent.mouseButton.x;
|
event->key.system = keyReleased->system;
|
||||||
event->mouseButton.y = sfmlEvent.mouseButton.y;
|
}
|
||||||
break;
|
else if (const auto* keyPressed = sfmlEvent.getIf<sf::Event::KeyPressed>())
|
||||||
|
{
|
||||||
case sfEvtMouseMoved :
|
event->type = sfEvtKeyPressed;
|
||||||
event->mouseMove.x = sfmlEvent.mouseMove.x;
|
event->key.code = static_cast<sfKeyCode>(keyPressed->code);
|
||||||
event->mouseMove.y = sfmlEvent.mouseMove.y;
|
event->key.scancode = static_cast<sfScancode>(keyPressed->scancode);
|
||||||
break;
|
event->key.alt = keyPressed->alt;
|
||||||
|
event->key.control = keyPressed->control;
|
||||||
case sfEvtJoystickButtonPressed :
|
event->key.shift = keyPressed->shift;
|
||||||
case sfEvtJoystickButtonReleased :
|
event->key.system = keyPressed->system;
|
||||||
event->joystickButton.joystickId = sfmlEvent.joystickButton.joystickId;
|
}
|
||||||
event->joystickButton.button = sfmlEvent.joystickButton.button;
|
else if (const auto* mouseWheelScrolled = sfmlEvent.getIf<sf::Event::MouseWheelScrolled>())
|
||||||
break;
|
{
|
||||||
|
event->type = sfEvtMouseWheelScrolled;
|
||||||
case sfEvtJoystickMoved :
|
event->mouseWheelScroll.wheel = static_cast<sfMouseWheel>(mouseWheelScrolled->wheel);
|
||||||
event->joystickMove.joystickId = sfmlEvent.joystickMove.joystickId;
|
event->mouseWheelScroll.delta = mouseWheelScrolled->delta;
|
||||||
event->joystickMove.axis = static_cast<sfJoystickAxis>(sfmlEvent.joystickMove.axis);
|
event->mouseWheelScroll.x = mouseWheelScrolled->position.x;
|
||||||
event->joystickMove.position = sfmlEvent.joystickMove.position;
|
event->mouseWheelScroll.y = mouseWheelScrolled->position.y;
|
||||||
break;
|
}
|
||||||
|
else if (const auto* mouseButtonPressed = sfmlEvent.getIf<sf::Event::MouseButtonPressed>())
|
||||||
case sfEvtJoystickConnected :
|
{
|
||||||
case sfEvtJoystickDisconnected :
|
event->type = sfEvtMouseButtonPressed;
|
||||||
event->joystickConnect.joystickId = sfmlEvent.joystickConnect.joystickId;
|
event->mouseButton.button = static_cast<sfMouseButton>(mouseButtonPressed->button);
|
||||||
break;
|
event->mouseButton.x = mouseButtonPressed->position.x;
|
||||||
|
event->mouseButton.y = mouseButtonPressed->position.y;
|
||||||
case sfEvtTouchBegan :
|
}
|
||||||
case sfEvtTouchMoved :
|
else if (const auto* mouseButtonReleased = sfmlEvent.getIf<sf::Event::MouseButtonReleased>())
|
||||||
case sfEvtTouchEnded :
|
{
|
||||||
event->touch.finger = sfmlEvent.touch.finger;
|
event->type = sfEvtMouseButtonReleased;
|
||||||
event->touch.x = sfmlEvent.touch.x;
|
event->mouseButton.button = static_cast<sfMouseButton>(mouseButtonReleased->button);
|
||||||
event->touch.y = sfmlEvent.touch.y;
|
event->mouseButton.x = mouseButtonReleased->position.x;
|
||||||
break;
|
event->mouseButton.y = mouseButtonReleased->position.y;
|
||||||
|
}
|
||||||
case sfEvtSensorChanged :
|
else if (const auto* mouseMoved = sfmlEvent.getIf<sf::Event::MouseMoved>())
|
||||||
event->sensor.sensorType = static_cast<sfSensorType>(sfmlEvent.sensor.type);
|
{
|
||||||
event->sensor.x = sfmlEvent.sensor.x;
|
event->type = sfEvtMouseMoved;
|
||||||
event->sensor.y = sfmlEvent.sensor.y;
|
event->mouseMove.x = mouseMoved->position.x;
|
||||||
event->sensor.z = sfmlEvent.sensor.z;
|
event->mouseMove.y = mouseMoved->position.y;
|
||||||
break;
|
}
|
||||||
|
else if (sfmlEvent.is<sf::Event::MouseEntered>())
|
||||||
default :
|
{
|
||||||
break;
|
event->type = sfEvtMouseEntered;
|
||||||
|
}
|
||||||
|
else if (sfmlEvent.is<sf::Event::MouseLeft>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtMouseLeft;
|
||||||
|
}
|
||||||
|
else if (const auto* joystickButtonPressed = sfmlEvent.getIf<sf::Event::JoystickButtonPressed>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtJoystickButtonPressed;
|
||||||
|
event->joystickButton.joystickId = joystickButtonPressed->joystickId;
|
||||||
|
event->joystickButton.button = joystickButtonPressed->button;
|
||||||
|
}
|
||||||
|
else if (const auto* joystickButtonReleased = sfmlEvent.getIf<sf::Event::JoystickButtonReleased>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtJoystickButtonReleased;
|
||||||
|
event->joystickButton.joystickId = joystickButtonReleased->joystickId;
|
||||||
|
event->joystickButton.button = joystickButtonReleased->button;
|
||||||
|
}
|
||||||
|
else if (const auto* joystickMoved = sfmlEvent.getIf<sf::Event::JoystickMoved>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtJoystickMoved;
|
||||||
|
event->joystickMove.joystickId = joystickMoved->joystickId;
|
||||||
|
event->joystickMove.axis = static_cast<sfJoystickAxis>(joystickMoved->axis);
|
||||||
|
event->joystickMove.position = joystickMoved->position;
|
||||||
|
}
|
||||||
|
else if (const auto* joystickConnected = sfmlEvent.getIf<sf::Event::JoystickConnected>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtJoystickConnected;
|
||||||
|
event->joystickConnect.joystickId = joystickConnected->joystickId;
|
||||||
|
}
|
||||||
|
else if (const auto* joystickDisconnected = sfmlEvent.getIf<sf::Event::JoystickDisconnected>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtJoystickDisconnected;
|
||||||
|
event->joystickConnect.joystickId = joystickDisconnected->joystickId;
|
||||||
|
}
|
||||||
|
else if (const auto* touchBegan = sfmlEvent.getIf<sf::Event::TouchBegan>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtTouchBegan;
|
||||||
|
event->touch.finger = touchBegan->finger;
|
||||||
|
event->touch.x = touchBegan->position.x;
|
||||||
|
event->touch.y = touchBegan->position.y;
|
||||||
|
}
|
||||||
|
else if (const auto* touchMoved = sfmlEvent.getIf<sf::Event::TouchMoved>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtTouchMoved;
|
||||||
|
event->touch.finger = touchMoved->finger;
|
||||||
|
event->touch.x = touchMoved->position.x;
|
||||||
|
event->touch.y = touchMoved->position.y;
|
||||||
|
}
|
||||||
|
else if (const auto* touchEnded = sfmlEvent.getIf<sf::Event::TouchEnded>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtTouchEnded;
|
||||||
|
event->touch.finger = touchEnded->finger;
|
||||||
|
event->touch.x = touchEnded->position.x;
|
||||||
|
event->touch.y = touchEnded->position.y;
|
||||||
|
}
|
||||||
|
else if (const auto* sensorChanged = sfmlEvent.getIf<sf::Event::SensorChanged>())
|
||||||
|
{
|
||||||
|
event->type = sfEvtSensorChanged;
|
||||||
|
event->sensor.sensorType = static_cast<sfSensorType>(sensorChanged->type);
|
||||||
|
event->sensor.x = sensorChanged->value.x;
|
||||||
|
event->sensor.y = sensorChanged->value.y;
|
||||||
|
event->sensor.z = sensorChanged->value.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -150,11 +150,10 @@ bool sfRenderWindow_pollEvent(sfRenderWindow* renderWindow, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = renderWindow->This.pollEvent();
|
||||||
bool ret = renderWindow->This.pollEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// No event, return
|
// No event, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
@@ -171,11 +170,10 @@ bool sfRenderWindow_waitEvent(sfRenderWindow* renderWindow, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = renderWindow->This.waitEvent();
|
||||||
bool ret = renderWindow->This.waitEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// Error, return
|
// Error, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
|
|||||||
@@ -132,11 +132,10 @@ bool sfWindow_pollEvent(sfWindow* window, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = window->This.pollEvent();
|
||||||
bool ret = window->This.pollEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// No event, return
|
// No event, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
@@ -153,11 +152,10 @@ bool sfWindow_waitEvent(sfWindow* window, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = window->This.waitEvent();
|
||||||
bool ret = window->This.waitEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// Error, return
|
// Error, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
|
|||||||
@@ -100,11 +100,10 @@ bool sfWindowBase_pollEvent(sfWindowBase* windowBase, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = windowBase->This.pollEvent();
|
||||||
bool ret = windowBase->This.pollEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// No event, return
|
// No event, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
@@ -121,11 +120,10 @@ bool sfWindowBase_waitEvent(sfWindowBase* windowBase, sfEvent* event)
|
|||||||
CSFML_CHECK_RETURN(event, false);
|
CSFML_CHECK_RETURN(event, false);
|
||||||
|
|
||||||
// Get the event
|
// Get the event
|
||||||
sf::Event sfmlEvent;
|
const sf::Event sfmlEvent = windowBase->This.waitEvent();
|
||||||
bool ret = windowBase->This.waitEvent(sfmlEvent);
|
|
||||||
|
|
||||||
// Error, return
|
// Error, return
|
||||||
if (!ret)
|
if (!sfmlEvent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Convert the sf::Event event to a sfEvent
|
// Convert the sf::Event event to a sfEvent
|
||||||
|
|||||||
Reference in new issue
Block a user