Converted applicable enumerations to strongly typed enumerations.
This commit is contained in:
parent
b3b094fc91
commit
24db1dba1a
|
@ -161,10 +161,10 @@ struct SFMLmainWindow
|
|||
|
||||
// Scaling
|
||||
/* /!\ we do this at 60fps so choose low scaling factor! /!\ */
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up))
|
||||
self.mainWindow->sprite.scale(1.01f, 1.01f);
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down))
|
||||
self.mainWindow->sprite.scale(0.99f, 0.99f);
|
||||
|
||||
// Clear the window, display some stuff and display it into our view.
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
std::ostream& operator <<(std::ostream& stream, const sf::Ftp::Response& response)
|
||||
{
|
||||
return stream << response.getStatus() << response.getMessage();
|
||||
return stream << static_cast<unsigned short>(response.getStatus()) << response.getMessage();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -161,21 +161,21 @@ int main()
|
|||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window: exit
|
||||
if (event.type == sf::Event::Closed)
|
||||
if (event.type == sf::Event::Type::Closed)
|
||||
{
|
||||
exit = true;
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Escape key: exit
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
|
||||
{
|
||||
exit = true;
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Return key: toggle mipmapping
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Return))
|
||||
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Return))
|
||||
{
|
||||
if (mipmapEnabled)
|
||||
{
|
||||
|
@ -194,14 +194,14 @@ int main()
|
|||
}
|
||||
|
||||
// Space key: toggle sRGB conversion
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
|
||||
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space))
|
||||
{
|
||||
sRgb = !sRgb;
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Adjust the viewport when the window is resized
|
||||
if (event.type == sf::Event::Resized)
|
||||
if (event.type == sf::Event::Type::Resized)
|
||||
{
|
||||
// Make the window the active window for OpenGL calls
|
||||
window.setActive(true);
|
||||
|
|
|
@ -91,15 +91,15 @@ int main()
|
|||
while (window.pollEvent(event))
|
||||
{
|
||||
// Window closed or escape key pressed: exit
|
||||
if ((event.type == sf::Event::Closed) ||
|
||||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
|
||||
if ((event.type == sf::Event::Type::Closed) ||
|
||||
((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape)))
|
||||
{
|
||||
window.close();
|
||||
break;
|
||||
}
|
||||
|
||||
// Space key pressed: play
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
|
||||
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Space))
|
||||
{
|
||||
if (!isPlaying)
|
||||
{
|
||||
|
@ -128,12 +128,12 @@ int main()
|
|||
float deltaTime = clock.restart().asSeconds();
|
||||
|
||||
// Move the player's paddle
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) &&
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Up) &&
|
||||
(leftPaddle.getPosition().y - paddleSize.y / 2 > 5.f))
|
||||
{
|
||||
leftPaddle.move(0.f, -paddleSpeed * deltaTime);
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) &&
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::Down) &&
|
||||
(leftPaddle.getPosition().y + paddleSize.y / 2 < gameHeight - 5.f))
|
||||
{
|
||||
leftPaddle.move(0.f, paddleSpeed * deltaTime);
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
m_sprite.setTexture(m_texture);
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.loadFromFile("resources/pixelate.frag", sf::Shader::Type::Fragment))
|
||||
return false;
|
||||
m_shader.setUniform("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
|
@ -135,7 +135,7 @@ public:
|
|||
bool onLoad()
|
||||
{
|
||||
// Create the points
|
||||
m_points.setPrimitiveType(sf::Points);
|
||||
m_points.setPrimitiveType(sf::PrimitiveType::Points);
|
||||
for (int i = 0; i < 40000; ++i)
|
||||
{
|
||||
float x = static_cast<float>(std::rand() % 800);
|
||||
|
@ -214,7 +214,7 @@ public:
|
|||
}
|
||||
|
||||
// Load the shader
|
||||
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Fragment))
|
||||
if (!m_shader.loadFromFile("resources/edge.frag", sf::Shader::Type::Fragment))
|
||||
return false;
|
||||
m_shader.setUniform("texture", sf::Shader::CurrentTexture);
|
||||
|
||||
|
@ -268,7 +268,7 @@ public:
|
|||
|
||||
Geometry() :
|
||||
Effect("geometry shader billboards"),
|
||||
m_pointCloud(sf::Points, 10000)
|
||||
m_pointCloud(sf::PrimitiveType::Points, 10000)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -397,20 +397,20 @@ int main()
|
|||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window: exit
|
||||
if (event.type == sf::Event::Closed)
|
||||
if (event.type == sf::Event::Type::Closed)
|
||||
window.close();
|
||||
|
||||
if (event.type == sf::Event::KeyPressed)
|
||||
if (event.type == sf::Event::Type::KeyPressed)
|
||||
{
|
||||
switch (event.key.code)
|
||||
{
|
||||
// Escape key: exit
|
||||
case sf::Keyboard::Escape:
|
||||
case sf::Keyboard::Key::Escape:
|
||||
window.close();
|
||||
break;
|
||||
|
||||
// Left arrow key: previous shader
|
||||
case sf::Keyboard::Left:
|
||||
case sf::Keyboard::Key::Left:
|
||||
if (current == 0)
|
||||
current = effects.size() - 1;
|
||||
else
|
||||
|
@ -419,7 +419,7 @@ int main()
|
|||
break;
|
||||
|
||||
// Right arrow key: next shader
|
||||
case sf::Keyboard::Right:
|
||||
case sf::Keyboard::Key::Right:
|
||||
if (current == effects.size() - 1)
|
||||
current = 0;
|
||||
else
|
||||
|
|
|
@ -17,26 +17,26 @@ void runTcpServer(unsigned short port)
|
|||
sf::TcpListener listener;
|
||||
|
||||
// Listen to the given port for incoming connections
|
||||
if (listener.listen(port) != sf::Socket::Done)
|
||||
if (listener.listen(port) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
|
||||
|
||||
// Wait for a connection
|
||||
sf::TcpSocket socket;
|
||||
if (listener.accept(socket) != sf::Socket::Done)
|
||||
if (listener.accept(socket) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Client connected: " << socket.getRemoteAddress() << std::endl;
|
||||
|
||||
// Send a message to the connected client
|
||||
const char out[] = "Hi, I'm the server";
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
|
||||
|
||||
// Receive a message back from the client
|
||||
char in[128];
|
||||
std::size_t received;
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Answer received from the client: \"" << in << "\"" << std::endl;
|
||||
}
|
||||
|
@ -62,20 +62,20 @@ void runTcpClient(unsigned short port)
|
|||
sf::TcpSocket socket;
|
||||
|
||||
// Connect to the server
|
||||
if (socket.connect(server, port) != sf::Socket::Done)
|
||||
if (socket.connect(server, port) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Connected to server " << server << std::endl;
|
||||
|
||||
// Receive a message from the server
|
||||
char in[128];
|
||||
std::size_t received;
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message received from the server: \"" << in << "\"" << std::endl;
|
||||
|
||||
// Send an answer to the server
|
||||
const char out[] = "Hi, I'm a client";
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out)) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ void runUdpServer(unsigned short port)
|
|||
sf::UdpSocket socket;
|
||||
|
||||
// Listen to messages on the specified port
|
||||
if (socket.bind(port) != sf::Socket::Done)
|
||||
if (socket.bind(port) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for a message... " << std::endl;
|
||||
|
||||
|
@ -25,13 +25,13 @@ void runUdpServer(unsigned short port)
|
|||
std::size_t received;
|
||||
sf::IpAddress sender;
|
||||
unsigned short senderPort;
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message received from client " << sender << ": \"" << in << "\"" << std::endl;
|
||||
|
||||
// Send an answer to the client
|
||||
const char out[] = "Hi, I'm the server";
|
||||
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out), sender, senderPort) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the client: \"" << out << "\"" << std::endl;
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ void runUdpClient(unsigned short port)
|
|||
|
||||
// Send a message to the server
|
||||
const char out[] = "Hi, I'm a client";
|
||||
if (socket.send(out, sizeof(out), server, port) != sf::Socket::Done)
|
||||
if (socket.send(out, sizeof(out), server, port) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message sent to the server: \"" << out << "\"" << std::endl;
|
||||
|
||||
|
@ -66,7 +66,7 @@ void runUdpClient(unsigned short port)
|
|||
std::size_t received;
|
||||
sf::IpAddress sender;
|
||||
unsigned short senderPort;
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Done)
|
||||
if (socket.receive(in, sizeof(in), received, sender, senderPort) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Message received from " << sender << ": \"" << in << "\"" << std::endl;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ void playSound()
|
|||
sound.play();
|
||||
|
||||
// Loop while the sound is playing
|
||||
while (sound.getStatus() == sf::Sound::Playing)
|
||||
while (sound.getStatus() == sf::Sound::Status::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
@ -63,7 +63,7 @@ void playMusic(const std::string& filename)
|
|||
music.play();
|
||||
|
||||
// Loop while the music is playing
|
||||
while (music.getStatus() == sf::Music::Playing)
|
||||
while (music.getStatus() == sf::Music::Status::Playing)
|
||||
{
|
||||
// Leave some CPU time for other processes
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
|
|
@ -72,7 +72,7 @@ int main()
|
|||
sound.play();
|
||||
|
||||
// Wait until finished
|
||||
while (sound.getStatus() == sf::Sound::Playing)
|
||||
while (sound.getStatus() == sf::Sound::Status::Playing)
|
||||
{
|
||||
// Display the playing position
|
||||
std::cout << "\rPlaying... " << sound.getPlayingOffset().asSeconds() << " sec ";
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
virtual bool onStart()
|
||||
{
|
||||
if (m_socket.connect(m_host, m_port) == sf::Socket::Done)
|
||||
if (m_socket.connect(m_host, m_port) == sf::Socket::Status::Done)
|
||||
{
|
||||
std::cout << "Connected to server " << m_host << std::endl;
|
||||
return true;
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
packet.append(samples, sampleCount * sizeof(sf::Int16));
|
||||
|
||||
// Send the audio packet to the server
|
||||
return m_socket.send(packet) == sf::Socket::Done;
|
||||
return m_socket.send(packet) == sf::Socket::Status::Done;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -43,12 +43,12 @@ public:
|
|||
if (!m_hasFinished)
|
||||
{
|
||||
// Listen to the given port for incoming connections
|
||||
if (m_listener.listen(port) != sf::Socket::Done)
|
||||
if (m_listener.listen(port) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Server is listening to port " << port << ", waiting for connections... " << std::endl;
|
||||
|
||||
// Wait for a connection
|
||||
if (m_listener.accept(m_client) != sf::Socket::Done)
|
||||
if (m_listener.accept(m_client) != sf::Socket::Status::Done)
|
||||
return;
|
||||
std::cout << "Client connected: " << m_client.getRemoteAddress() << std::endl;
|
||||
|
||||
|
@ -117,7 +117,7 @@ private:
|
|||
{
|
||||
// Get waiting audio data from the network
|
||||
sf::Packet packet;
|
||||
if (m_client.receive(packet) != sf::Socket::Done)
|
||||
if (m_client.receive(packet) != sf::Socket::Status::Done)
|
||||
break;
|
||||
|
||||
// Extract the message ID
|
||||
|
@ -177,7 +177,7 @@ void doServer(unsigned short port)
|
|||
audioStream.start(port);
|
||||
|
||||
// Loop until the sound playback is finished
|
||||
while (audioStream.getStatus() != sf::SoundStream::Stopped)
|
||||
while (audioStream.getStatus() != sf::SoundStream::Status::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
@ -193,7 +193,7 @@ void doServer(unsigned short port)
|
|||
audioStream.play();
|
||||
|
||||
// Loop until the sound playback is finished
|
||||
while (audioStream.getStatus() != sf::SoundStream::Stopped)
|
||||
while (audioStream.getStatus() != sf::SoundStream::Status::Stopped)
|
||||
{
|
||||
// Leave some CPU time for other threads
|
||||
sf::sleep(sf::milliseconds(100));
|
||||
|
|
|
@ -112,15 +112,15 @@ int main()
|
|||
while (window.pollEvent(event))
|
||||
{
|
||||
// Close window: exit
|
||||
if (event.type == sf::Event::Closed)
|
||||
if (event.type == sf::Event::Type::Closed)
|
||||
window.close();
|
||||
|
||||
// Escape key: exit
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
if ((event.type == sf::Event::Type::KeyPressed) && (event.key.code == sf::Keyboard::Key::Escape))
|
||||
window.close();
|
||||
|
||||
// Resize event: adjust the viewport
|
||||
if (event.type == sf::Event::Resized)
|
||||
if (event.type == sf::Event::Type::Resized)
|
||||
glViewport(0, 0, event.size.width, event.size.height);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
/// \brief Enumeration of the sound source states
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Status
|
||||
enum class Status : unsigned char
|
||||
{
|
||||
Stopped, ///< Sound is not playing
|
||||
Paused, ///< Sound is paused
|
||||
|
|
|
@ -46,7 +46,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||
/// The factors are mapped directly to their OpenGL equivalents,
|
||||
/// specified by glBlendFunc() or glBlendFuncSeparate().
|
||||
////////////////////////////////////////////////////////
|
||||
enum Factor
|
||||
enum class Factor : unsigned char
|
||||
{
|
||||
Zero, ///< (0, 0, 0, 0)
|
||||
One, ///< (1, 1, 1, 1)
|
||||
|
@ -66,7 +66,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||
/// The equations are mapped directly to their OpenGL equivalents,
|
||||
/// specified by glBlendEquation() or glBlendEquationSeparate().
|
||||
////////////////////////////////////////////////////////
|
||||
enum Equation
|
||||
enum class Equation : unsigned char
|
||||
{
|
||||
Add, ///< Pixel = Src * SrcFactor + Dst * DstFactor
|
||||
Subtract, ///< Pixel = Src * SrcFactor - Dst * DstFactor
|
||||
|
@ -92,7 +92,7 @@ struct SFML_GRAPHICS_API BlendMode
|
|||
/// \param blendEquation Specifies how to combine the source and destination colors and alpha.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Add);
|
||||
BlendMode(Factor sourceFactor, Factor destinationFactor, Equation blendEquation = Equation::Add);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Construct the blend mode given the factors and equation.
|
||||
|
|
|
@ -36,20 +36,14 @@ namespace sf
|
|||
/// and view.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum PrimitiveType
|
||||
enum class PrimitiveType : unsigned char
|
||||
{
|
||||
Points, ///< List of individual points
|
||||
Lines, ///< List of individual lines
|
||||
LineStrip, ///< List of connected lines, a point uses the previous point to form a line
|
||||
Triangles, ///< List of individual triangles
|
||||
TriangleStrip, ///< List of connected triangles, a point uses the two previous points to form a triangle
|
||||
TriangleFan, ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
|
||||
Quads, ///< List of individual quads (deprecated, don't work with OpenGL ES)
|
||||
|
||||
// Deprecated names
|
||||
LinesStrip = LineStrip, ///< \deprecated Use LineStrip instead
|
||||
TrianglesStrip = TriangleStrip, ///< \deprecated Use TriangleStrip instead
|
||||
TrianglesFan = TriangleFan ///< \deprecated Use TriangleFan instead
|
||||
TriangleFan ///< List of connected triangles, a point uses the common center and the previous point to form a triangle
|
||||
};
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
/// \brief Types of shaders
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Type
|
||||
enum class Type : unsigned char
|
||||
{
|
||||
Vertex, ///< %Vertex shader
|
||||
Geometry, ///< Geometry shader
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
/// \brief Types of texture coordinates that can be used for rendering
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum CoordinateType
|
||||
enum class CoordinateType : unsigned char
|
||||
{
|
||||
Normalized, ///< Texture coordinates in range [0 .. 1]
|
||||
Pixels ///< Texture coordinates in range [0 .. size]
|
||||
|
@ -568,7 +568,7 @@ public:
|
|||
/// \param coordinateType Type of texture coordinates to use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
static void bind(const Texture* texture, CoordinateType coordinateType = Normalized);
|
||||
static void bind(const Texture* texture, CoordinateType coordinateType = CoordinateType::Normalized);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Get the maximum texture size allowed
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
/// \brief Enumeration of transfer modes
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum TransferMode
|
||||
enum class TransferMode : unsigned char
|
||||
{
|
||||
Binary, ///< Binary mode (file is transfered as a sequence of bytes)
|
||||
Ascii, ///< Text mode using ASCII encoding
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
/// \brief Status codes possibly returned by a FTP response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Status
|
||||
enum class Status : unsigned short
|
||||
{
|
||||
// 1xx: the requested action is being initiated,
|
||||
// expect another reply before proceeding with a new command
|
||||
|
@ -143,7 +143,7 @@ public:
|
|||
/// \param message Response message
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
explicit Response(Status code = InvalidResponse, const std::string& message = "");
|
||||
explicit Response(Status code = Status::InvalidResponse, const std::string& message = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Check if the status code means a success
|
||||
|
@ -465,7 +465,7 @@ public:
|
|||
/// \see upload
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = Binary);
|
||||
Response download(const std::string& remoteFile, const std::string& localPath, TransferMode mode = TransferMode::Binary);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Upload a file to the server
|
||||
|
@ -484,7 +484,7 @@ public:
|
|||
/// \see download
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = Binary);
|
||||
Response upload(const std::string& localFile, const std::string& remotePath, TransferMode mode = TransferMode::Binary);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Send a command to the FTP server
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
/// \brief Enumerate the available HTTP methods for a request
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Method
|
||||
enum class Method : unsigned char
|
||||
{
|
||||
Get, ///< Request in get mode, standard method to retrieve a page
|
||||
Post, ///< Request in post mode, usually to send data to a page
|
||||
|
@ -79,7 +79,7 @@ public:
|
|||
/// \param body Content of the request's body
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
Request(const std::string& uri = "/", Method method = Get, const std::string& body = "");
|
||||
Request(const std::string& uri = "/", Method method = Method::Get, const std::string& body = "");
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Set the value of a field
|
||||
|
@ -198,7 +198,7 @@ public:
|
|||
/// \brief Enumerate all the valid status codes for a response
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Status
|
||||
enum class Status : unsigned short
|
||||
{
|
||||
// 2xx: success
|
||||
Ok = 200, ///< Most common code returned when operation was successful
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
/// \brief Status codes that may be returned by socket functions
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Status
|
||||
enum class Status : unsigned char
|
||||
{
|
||||
Done, ///< The socket has sent / received the data
|
||||
NotReady, ///< The socket is not ready to send / receive data yet
|
||||
|
@ -111,7 +111,7 @@ protected:
|
|||
/// \brief Types of protocols that the socket can use
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Type
|
||||
enum class Type : unsigned char
|
||||
{
|
||||
Tcp, ///< TCP protocol
|
||||
Udp ///< UDP protocol
|
||||
|
|
|
@ -184,7 +184,7 @@ public:
|
|||
/// \brief Enumeration of the different types of events
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum EventType
|
||||
enum class Type : unsigned char
|
||||
{
|
||||
Closed, ///< The window requested to be closed (no data)
|
||||
Resized, ///< The window was resized (data in event.size)
|
||||
|
@ -216,7 +216,7 @@ public:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
EventType type; ///< Type of the event
|
||||
Type type; ///< Type of the event
|
||||
|
||||
union
|
||||
{
|
||||
|
|
|
@ -49,15 +49,14 @@ public:
|
|||
enum
|
||||
{
|
||||
Count = 8, ///< Maximum number of supported joysticks
|
||||
ButtonCount = 32, ///< Maximum number of supported buttons
|
||||
AxisCount = 8 ///< Maximum number of supported axes
|
||||
ButtonCount = 32 ///< Maximum number of supported buttons
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Axes supported by SFML joysticks
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Axis
|
||||
enum class Axis : unsigned char
|
||||
{
|
||||
X, ///< The X axis
|
||||
Y, ///< The Y axis
|
||||
|
@ -66,7 +65,9 @@ public:
|
|||
U, ///< The U axis
|
||||
V, ///< The V axis
|
||||
PovX, ///< The X axis of the point-of-view hat
|
||||
PovY ///< The Y axis of the point-of-view hat
|
||||
PovY, ///< The Y axis of the point-of-view hat
|
||||
|
||||
Count ///< Maximum number of supported axes
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -45,112 +45,113 @@ public:
|
|||
/// \brief Key codes
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Key
|
||||
enum class Key : unsigned char
|
||||
{
|
||||
Unknown = -1, ///< Unhandled key
|
||||
A = 0, ///< The A key
|
||||
B, ///< The B key
|
||||
C, ///< The C key
|
||||
D, ///< The D key
|
||||
E, ///< The E key
|
||||
F, ///< The F key
|
||||
G, ///< The G key
|
||||
H, ///< The H key
|
||||
I, ///< The I key
|
||||
J, ///< The J key
|
||||
K, ///< The K key
|
||||
L, ///< The L key
|
||||
M, ///< The M key
|
||||
N, ///< The N key
|
||||
O, ///< The O key
|
||||
P, ///< The P key
|
||||
Q, ///< The Q key
|
||||
R, ///< The R key
|
||||
S, ///< The S key
|
||||
T, ///< The T key
|
||||
U, ///< The U key
|
||||
V, ///< The V key
|
||||
W, ///< The W key
|
||||
X, ///< The X key
|
||||
Y, ///< The Y key
|
||||
Z, ///< The Z key
|
||||
Num0, ///< The 0 key
|
||||
Num1, ///< The 1 key
|
||||
Num2, ///< The 2 key
|
||||
Num3, ///< The 3 key
|
||||
Num4, ///< The 4 key
|
||||
Num5, ///< The 5 key
|
||||
Num6, ///< The 6 key
|
||||
Num7, ///< The 7 key
|
||||
Num8, ///< The 8 key
|
||||
Num9, ///< The 9 key
|
||||
Escape, ///< The Escape key
|
||||
LControl, ///< The left Control key
|
||||
LShift, ///< The left Shift key
|
||||
LAlt, ///< The left Alt key
|
||||
LSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
RControl, ///< The right Control key
|
||||
RShift, ///< The right Shift key
|
||||
RAlt, ///< The right Alt key
|
||||
RSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
Menu, ///< The Menu key
|
||||
LBracket, ///< The [ key
|
||||
RBracket, ///< The ] key
|
||||
SemiColon, ///< The ; key
|
||||
Comma, ///< The , key
|
||||
Period, ///< The . key
|
||||
Quote, ///< The ' key
|
||||
Slash, ///< The / key
|
||||
BackSlash, ///< The \ key
|
||||
Tilde, ///< The ~ key
|
||||
Equal, ///< The = key
|
||||
Dash, ///< The - key
|
||||
Space, ///< The Space key
|
||||
Return, ///< The Return key
|
||||
BackSpace, ///< The Backspace key
|
||||
Tab, ///< The Tabulation key
|
||||
PageUp, ///< The Page up key
|
||||
PageDown, ///< The Page down key
|
||||
End, ///< The End key
|
||||
Home, ///< The Home key
|
||||
Insert, ///< The Insert key
|
||||
Delete, ///< The Delete key
|
||||
Add, ///< The + key
|
||||
Subtract, ///< The - key
|
||||
Multiply, ///< The * key
|
||||
Divide, ///< The / key
|
||||
Left, ///< Left arrow
|
||||
Right, ///< Right arrow
|
||||
Up, ///< Up arrow
|
||||
Down, ///< Down arrow
|
||||
Numpad0, ///< The numpad 0 key
|
||||
Numpad1, ///< The numpad 1 key
|
||||
Numpad2, ///< The numpad 2 key
|
||||
Numpad3, ///< The numpad 3 key
|
||||
Numpad4, ///< The numpad 4 key
|
||||
Numpad5, ///< The numpad 5 key
|
||||
Numpad6, ///< The numpad 6 key
|
||||
Numpad7, ///< The numpad 7 key
|
||||
Numpad8, ///< The numpad 8 key
|
||||
Numpad9, ///< The numpad 9 key
|
||||
F1, ///< The F1 key
|
||||
F2, ///< The F2 key
|
||||
F3, ///< The F3 key
|
||||
F4, ///< The F4 key
|
||||
F5, ///< The F5 key
|
||||
F6, ///< The F6 key
|
||||
F7, ///< The F7 key
|
||||
F8, ///< The F8 key
|
||||
F9, ///< The F9 key
|
||||
F10, ///< The F10 key
|
||||
F11, ///< The F11 key
|
||||
F12, ///< The F12 key
|
||||
F13, ///< The F13 key
|
||||
F14, ///< The F14 key
|
||||
F15, ///< The F15 key
|
||||
Pause, ///< The Pause key
|
||||
Unknown = static_cast<unsigned char>(-1), ///< Unhandled key
|
||||
|
||||
KeyCount ///< Keep last -- the total number of keyboard keys
|
||||
A = 0, ///< The A key
|
||||
B, ///< The B key
|
||||
C, ///< The C key
|
||||
D, ///< The D key
|
||||
E, ///< The E key
|
||||
F, ///< The F key
|
||||
G, ///< The G key
|
||||
H, ///< The H key
|
||||
I, ///< The I key
|
||||
J, ///< The J key
|
||||
K, ///< The K key
|
||||
L, ///< The L key
|
||||
M, ///< The M key
|
||||
N, ///< The N key
|
||||
O, ///< The O key
|
||||
P, ///< The P key
|
||||
Q, ///< The Q key
|
||||
R, ///< The R key
|
||||
S, ///< The S key
|
||||
T, ///< The T key
|
||||
U, ///< The U key
|
||||
V, ///< The V key
|
||||
W, ///< The W key
|
||||
X, ///< The X key
|
||||
Y, ///< The Y key
|
||||
Z, ///< The Z key
|
||||
Num0, ///< The 0 key
|
||||
Num1, ///< The 1 key
|
||||
Num2, ///< The 2 key
|
||||
Num3, ///< The 3 key
|
||||
Num4, ///< The 4 key
|
||||
Num5, ///< The 5 key
|
||||
Num6, ///< The 6 key
|
||||
Num7, ///< The 7 key
|
||||
Num8, ///< The 8 key
|
||||
Num9, ///< The 9 key
|
||||
Escape, ///< The Escape key
|
||||
LControl, ///< The left Control key
|
||||
LShift, ///< The left Shift key
|
||||
LAlt, ///< The left Alt key
|
||||
LSystem, ///< The left OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
RControl, ///< The right Control key
|
||||
RShift, ///< The right Shift key
|
||||
RAlt, ///< The right Alt key
|
||||
RSystem, ///< The right OS specific key: window (Windows and Linux), apple (MacOS X), ...
|
||||
Menu, ///< The Menu key
|
||||
LBracket, ///< The [ key
|
||||
RBracket, ///< The ] key
|
||||
SemiColon, ///< The ; key
|
||||
Comma, ///< The , key
|
||||
Period, ///< The . key
|
||||
Quote, ///< The ' key
|
||||
Slash, ///< The / key
|
||||
BackSlash, ///< The \ key
|
||||
Tilde, ///< The ~ key
|
||||
Equal, ///< The = key
|
||||
Dash, ///< The - key
|
||||
Space, ///< The Space key
|
||||
Return, ///< The Return key
|
||||
BackSpace, ///< The Backspace key
|
||||
Tab, ///< The Tabulation key
|
||||
PageUp, ///< The Page up key
|
||||
PageDown, ///< The Page down key
|
||||
End, ///< The End key
|
||||
Home, ///< The Home key
|
||||
Insert, ///< The Insert key
|
||||
Delete, ///< The Delete key
|
||||
Add, ///< The + key
|
||||
Subtract, ///< The - key
|
||||
Multiply, ///< The * key
|
||||
Divide, ///< The / key
|
||||
Left, ///< Left arrow
|
||||
Right, ///< Right arrow
|
||||
Up, ///< Up arrow
|
||||
Down, ///< Down arrow
|
||||
Numpad0, ///< The numpad 0 key
|
||||
Numpad1, ///< The numpad 1 key
|
||||
Numpad2, ///< The numpad 2 key
|
||||
Numpad3, ///< The numpad 3 key
|
||||
Numpad4, ///< The numpad 4 key
|
||||
Numpad5, ///< The numpad 5 key
|
||||
Numpad6, ///< The numpad 6 key
|
||||
Numpad7, ///< The numpad 7 key
|
||||
Numpad8, ///< The numpad 8 key
|
||||
Numpad9, ///< The numpad 9 key
|
||||
F1, ///< The F1 key
|
||||
F2, ///< The F2 key
|
||||
F3, ///< The F3 key
|
||||
F4, ///< The F4 key
|
||||
F5, ///< The F5 key
|
||||
F6, ///< The F6 key
|
||||
F7, ///< The F7 key
|
||||
F8, ///< The F8 key
|
||||
F9, ///< The F9 key
|
||||
F10, ///< The F10 key
|
||||
F11, ///< The F11 key
|
||||
F12, ///< The F12 key
|
||||
F13, ///< The F13 key
|
||||
F14, ///< The F14 key
|
||||
F15, ///< The F15 key
|
||||
Pause, ///< The Pause key
|
||||
|
||||
Count ///< Keep last -- the total number of keyboard keys
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
/// \brief Mouse buttons
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Button
|
||||
enum class Button : unsigned char
|
||||
{
|
||||
Left, ///< The left mouse button
|
||||
Right, ///< The right mouse button
|
||||
|
@ -56,14 +56,14 @@ public:
|
|||
XButton1, ///< The first extra mouse button
|
||||
XButton2, ///< The second extra mouse button
|
||||
|
||||
ButtonCount ///< Keep last -- the total number of mouse buttons
|
||||
Count ///< Keep last -- the total number of mouse buttons
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// \brief Mouse wheels
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Wheel
|
||||
enum class Wheel : unsigned char
|
||||
{
|
||||
VerticalWheel, ///< The vertical mouse wheel
|
||||
HorizontalWheel ///< The horizontal mouse wheel
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
/// \brief Sensor type
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
enum Type
|
||||
enum class Type : unsigned char
|
||||
{
|
||||
Accelerometer, ///< Measures the raw acceleration (m/s^2)
|
||||
Gyroscope, ///< Measures the raw rotation rates (degrees/s)
|
||||
|
|
|
@ -198,12 +198,12 @@ SoundSource::Status SoundSource::getStatus() const
|
|||
switch (status)
|
||||
{
|
||||
case AL_INITIAL:
|
||||
case AL_STOPPED: return Stopped;
|
||||
case AL_PAUSED: return Paused;
|
||||
case AL_PLAYING: return Playing;
|
||||
case AL_STOPPED: return Status::Stopped;
|
||||
case AL_PAUSED: return Status::Paused;
|
||||
case AL_PLAYING: return Status::Playing;
|
||||
}
|
||||
|
||||
return Stopped;
|
||||
return Status::Stopped;
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace sf
|
|||
////////////////////////////////////////////////////////////
|
||||
SoundStream::SoundStream() :
|
||||
m_threadMutex (),
|
||||
m_threadStartState(Stopped),
|
||||
m_threadStartState(Status::Stopped),
|
||||
m_isStreaming (false),
|
||||
m_buffers (),
|
||||
m_channelCount (0),
|
||||
|
@ -104,7 +104,7 @@ void SoundStream::play()
|
|||
}
|
||||
|
||||
bool isStreaming = false;
|
||||
Status threadStartState = Stopped;
|
||||
Status threadStartState = Status::Stopped;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
|
@ -114,15 +114,15 @@ void SoundStream::play()
|
|||
}
|
||||
|
||||
|
||||
if (isStreaming && (threadStartState == Paused))
|
||||
if (isStreaming && (threadStartState == Status::Paused))
|
||||
{
|
||||
// If the sound is paused, resume it
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
m_threadStartState = Playing;
|
||||
m_threadStartState = Status::Playing;
|
||||
alCheck(alSourcePlay(m_source));
|
||||
return;
|
||||
}
|
||||
else if (isStreaming && (threadStartState == Playing))
|
||||
else if (isStreaming && (threadStartState == Status::Playing))
|
||||
{
|
||||
// If the sound is playing, stop it and continue as if it was stopped
|
||||
stop();
|
||||
|
@ -130,7 +130,7 @@ void SoundStream::play()
|
|||
|
||||
// Start updating the stream in a separate thread to avoid blocking the application
|
||||
m_isStreaming = true;
|
||||
m_threadStartState = Playing;
|
||||
m_threadStartState = Status::Playing;
|
||||
m_thread = std::thread([this]
|
||||
{
|
||||
streamData();
|
||||
|
@ -148,7 +148,7 @@ void SoundStream::pause()
|
|||
if (!m_isStreaming)
|
||||
return;
|
||||
|
||||
m_threadStartState = Paused;
|
||||
m_threadStartState = Status::Paused;
|
||||
}
|
||||
|
||||
alCheck(alSourcePause(m_source));
|
||||
|
@ -196,7 +196,7 @@ SoundStream::Status SoundStream::getStatus() const
|
|||
Status status = SoundSource::getStatus();
|
||||
|
||||
// To compensate for the lag between play() and alSourceplay()
|
||||
if (status == Stopped)
|
||||
if (status == Status::Stopped)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
|
||||
|
@ -223,7 +223,7 @@ void SoundStream::setPlayingOffset(Time timeOffset)
|
|||
// Restart streaming
|
||||
m_samplesProcessed = static_cast<Uint64>(timeOffset.asSeconds() * m_sampleRate * m_channelCount);
|
||||
|
||||
if (oldStatus == Stopped)
|
||||
if (oldStatus == Status::Stopped)
|
||||
return;
|
||||
|
||||
m_isStreaming = true;
|
||||
|
@ -275,7 +275,7 @@ void SoundStream::streamData()
|
|||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
|
||||
// Check if the thread was launched Stopped
|
||||
if (m_threadStartState == Stopped)
|
||||
if (m_threadStartState == Status::Stopped)
|
||||
{
|
||||
m_isStreaming = false;
|
||||
return;
|
||||
|
@ -297,7 +297,7 @@ void SoundStream::streamData()
|
|||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
|
||||
// Check if the thread was launched Paused
|
||||
if (m_threadStartState == Paused)
|
||||
if (m_threadStartState == Status::Paused)
|
||||
alCheck(alSourcePause(m_source));
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ void SoundStream::streamData()
|
|||
}
|
||||
|
||||
// The stream has been interrupted!
|
||||
if (SoundSource::getStatus() == Stopped)
|
||||
if (SoundSource::getStatus() == Status::Stopped)
|
||||
{
|
||||
if (!requestStop)
|
||||
{
|
||||
|
@ -384,7 +384,7 @@ void SoundStream::streamData()
|
|||
}
|
||||
|
||||
// Leave some time for the other threads if the stream is still playing
|
||||
if (SoundSource::getStatus() != Stopped)
|
||||
if (SoundSource::getStatus() != Status::Stopped)
|
||||
sleep(milliseconds(10));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,22 +33,22 @@ namespace sf
|
|||
////////////////////////////////////////////////////////////
|
||||
// Commonly used blending modes
|
||||
////////////////////////////////////////////////////////////
|
||||
const BlendMode BlendAlpha(BlendMode::SrcAlpha, BlendMode::OneMinusSrcAlpha, BlendMode::Add,
|
||||
BlendMode::One, BlendMode::OneMinusSrcAlpha, BlendMode::Add);
|
||||
const BlendMode BlendAdd(BlendMode::SrcAlpha, BlendMode::One, BlendMode::Add,
|
||||
BlendMode::One, BlendMode::One, BlendMode::Add);
|
||||
const BlendMode BlendMultiply(BlendMode::DstColor, BlendMode::Zero);
|
||||
const BlendMode BlendNone(BlendMode::One, BlendMode::Zero);
|
||||
const BlendMode BlendAlpha(BlendMode::Factor::SrcAlpha, BlendMode::Factor::OneMinusSrcAlpha, BlendMode::Equation::Add,
|
||||
BlendMode::Factor::One, BlendMode::Factor::OneMinusSrcAlpha, BlendMode::Equation::Add);
|
||||
const BlendMode BlendAdd(BlendMode::Factor::SrcAlpha, BlendMode::Factor::One, BlendMode::Equation::Add,
|
||||
BlendMode::Factor::One, BlendMode::Factor::One, BlendMode::Equation::Add);
|
||||
const BlendMode BlendMultiply(BlendMode::Factor::DstColor, BlendMode::Factor::Zero);
|
||||
const BlendMode BlendNone(BlendMode::Factor::One, BlendMode::Factor::Zero);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
BlendMode::BlendMode() :
|
||||
colorSrcFactor(BlendMode::SrcAlpha),
|
||||
colorDstFactor(BlendMode::OneMinusSrcAlpha),
|
||||
colorEquation (BlendMode::Add),
|
||||
alphaSrcFactor(BlendMode::One),
|
||||
alphaDstFactor(BlendMode::OneMinusSrcAlpha),
|
||||
alphaEquation (BlendMode::Add)
|
||||
colorSrcFactor(BlendMode::Factor::SrcAlpha),
|
||||
colorDstFactor(BlendMode::Factor::OneMinusSrcAlpha),
|
||||
colorEquation (BlendMode::Equation::Add),
|
||||
alphaSrcFactor(BlendMode::Factor::One),
|
||||
alphaDstFactor(BlendMode::Factor::OneMinusSrcAlpha),
|
||||
alphaEquation (BlendMode::Equation::Add)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ namespace sf
|
|||
// We cannot use the default constructor here, because it accesses BlendAlpha, which is also global (and dynamically
|
||||
// initialized). Initialization order of global objects in different translation units is not defined.
|
||||
const RenderStates RenderStates::Default(BlendMode(
|
||||
BlendMode::SrcAlpha, BlendMode::OneMinusSrcAlpha, BlendMode::Add,
|
||||
BlendMode::One, BlendMode::OneMinusSrcAlpha, BlendMode::Add));
|
||||
BlendMode::Factor::SrcAlpha, BlendMode::Factor::OneMinusSrcAlpha, BlendMode::Equation::Add,
|
||||
BlendMode::Factor::One, BlendMode::Factor::OneMinusSrcAlpha, BlendMode::Equation::Add));
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -43,16 +43,16 @@ namespace
|
|||
{
|
||||
switch (blendFactor)
|
||||
{
|
||||
case sf::BlendMode::Zero: return GL_ZERO;
|
||||
case sf::BlendMode::One: return GL_ONE;
|
||||
case sf::BlendMode::SrcColor: return GL_SRC_COLOR;
|
||||
case sf::BlendMode::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
|
||||
case sf::BlendMode::DstColor: return GL_DST_COLOR;
|
||||
case sf::BlendMode::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
|
||||
case sf::BlendMode::SrcAlpha: return GL_SRC_ALPHA;
|
||||
case sf::BlendMode::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
||||
case sf::BlendMode::DstAlpha: return GL_DST_ALPHA;
|
||||
case sf::BlendMode::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
||||
case sf::BlendMode::Factor::Zero: return GL_ZERO;
|
||||
case sf::BlendMode::Factor::One: return GL_ONE;
|
||||
case sf::BlendMode::Factor::SrcColor: return GL_SRC_COLOR;
|
||||
case sf::BlendMode::Factor::OneMinusSrcColor: return GL_ONE_MINUS_SRC_COLOR;
|
||||
case sf::BlendMode::Factor::DstColor: return GL_DST_COLOR;
|
||||
case sf::BlendMode::Factor::OneMinusDstColor: return GL_ONE_MINUS_DST_COLOR;
|
||||
case sf::BlendMode::Factor::SrcAlpha: return GL_SRC_ALPHA;
|
||||
case sf::BlendMode::Factor::OneMinusSrcAlpha: return GL_ONE_MINUS_SRC_ALPHA;
|
||||
case sf::BlendMode::Factor::DstAlpha: return GL_DST_ALPHA;
|
||||
case sf::BlendMode::Factor::OneMinusDstAlpha: return GL_ONE_MINUS_DST_ALPHA;
|
||||
}
|
||||
|
||||
sf::err() << "Invalid value for sf::BlendMode::Factor! Fallback to sf::BlendMode::Zero." << std::endl;
|
||||
|
@ -66,9 +66,9 @@ namespace
|
|||
{
|
||||
switch (blendEquation)
|
||||
{
|
||||
case sf::BlendMode::Add: return GLEXT_GL_FUNC_ADD;
|
||||
case sf::BlendMode::Subtract: return GLEXT_GL_FUNC_SUBTRACT;
|
||||
case sf::BlendMode::ReverseSubtract: return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
|
||||
case sf::BlendMode::Equation::Add: return GLEXT_GL_FUNC_ADD;
|
||||
case sf::BlendMode::Equation::Subtract: return GLEXT_GL_FUNC_SUBTRACT;
|
||||
case sf::BlendMode::Equation::ReverseSubtract: return GLEXT_GL_FUNC_REVERSE_SUBTRACT;
|
||||
}
|
||||
|
||||
sf::err() << "Invalid value for sf::BlendMode::Equation! Fallback to sf::BlendMode::Add." << std::endl;
|
||||
|
@ -282,7 +282,7 @@ void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
|
|||
// Find the OpenGL primitive type
|
||||
constexpr GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES,
|
||||
GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS};
|
||||
GLenum mode = modes[type];
|
||||
GLenum mode = modes[static_cast<size_t>(type)];
|
||||
|
||||
// Draw the primitives
|
||||
glCheck(glDrawArrays(mode, 0, vertexCount));
|
||||
|
@ -460,7 +460,7 @@ void RenderTarget::applyBlendMode(const BlendMode& mode)
|
|||
glCheck(GLEXT_glBlendEquation(equationToGlConstant(mode.colorEquation)));
|
||||
}
|
||||
}
|
||||
else if ((mode.colorEquation != BlendMode::Add) || (mode.alphaEquation != BlendMode::Add))
|
||||
else if ((mode.colorEquation != BlendMode::Equation::Add) || (mode.alphaEquation != BlendMode::Equation::Add))
|
||||
{
|
||||
static std::once_flag warned;
|
||||
std::call_once(warned, []
|
||||
|
@ -487,7 +487,7 @@ void RenderTarget::applyTransform(const Transform& transform)
|
|||
////////////////////////////////////////////////////////////
|
||||
void RenderTarget::applyTexture(const Texture* texture)
|
||||
{
|
||||
Texture::bind(texture, Texture::Pixels);
|
||||
Texture::bind(texture, Texture::CoordinateType::Pixels);
|
||||
|
||||
m_cache.lastTextureId = texture ? texture->m_cacheId : 0;
|
||||
}
|
||||
|
|
|
@ -227,9 +227,9 @@ bool Shader::loadFromFile(const std::string& filename, Type type)
|
|||
}
|
||||
|
||||
// Compile the shader program
|
||||
if (type == Vertex)
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader.data(), nullptr, nullptr);
|
||||
else if (type == Geometry)
|
||||
else if (type == Type::Geometry)
|
||||
return compile(nullptr, shader.data(), nullptr);
|
||||
else
|
||||
return compile(nullptr, nullptr, shader.data());
|
||||
|
@ -296,9 +296,9 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st
|
|||
bool Shader::loadFromMemory(const std::string& shader, Type type)
|
||||
{
|
||||
// Compile the shader program
|
||||
if (type == Vertex)
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader.c_str(), nullptr, nullptr);
|
||||
else if (type == Geometry)
|
||||
else if (type == Type::Geometry)
|
||||
return compile(nullptr, shader.c_str(), nullptr);
|
||||
else
|
||||
return compile(nullptr, nullptr, shader.c_str());
|
||||
|
@ -333,9 +333,9 @@ bool Shader::loadFromStream(InputStream& stream, Type type)
|
|||
}
|
||||
|
||||
// Compile the shader program
|
||||
if (type == Vertex)
|
||||
if (type == Type::Vertex)
|
||||
return compile(shader.data(), nullptr, nullptr);
|
||||
else if (type == Geometry)
|
||||
else if (type == Type::Geometry)
|
||||
return compile(nullptr, shader.data(), nullptr);
|
||||
else
|
||||
return compile(nullptr, nullptr, shader.data());
|
||||
|
|
|
@ -163,8 +163,8 @@ m_textureRect (),
|
|||
m_fillColor (255, 255, 255),
|
||||
m_outlineColor (255, 255, 255),
|
||||
m_outlineThickness(0),
|
||||
m_vertices (TriangleFan),
|
||||
m_outlineVertices (TriangleStrip),
|
||||
m_vertices (PrimitiveType::TriangleFan),
|
||||
m_outlineVertices (PrimitiveType::TriangleStrip),
|
||||
m_insideBounds (),
|
||||
m_bounds ()
|
||||
{
|
||||
|
|
|
@ -140,7 +140,7 @@ void Sprite::draw(RenderTarget& target, RenderStates states) const
|
|||
{
|
||||
states.transform *= getTransform();
|
||||
states.texture = m_texture;
|
||||
target.draw(m_vertices, 4, TriangleStrip, states);
|
||||
target.draw(m_vertices, 4, PrimitiveType::TriangleStrip, states);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ m_style (Regular),
|
|||
m_fillColor (255, 255, 255),
|
||||
m_outlineColor (0, 0, 0),
|
||||
m_outlineThickness (0),
|
||||
m_vertices (Triangles),
|
||||
m_outlineVertices (Triangles),
|
||||
m_vertices (PrimitiveType::Triangles),
|
||||
m_outlineVertices (PrimitiveType::Triangles),
|
||||
m_bounds (),
|
||||
m_geometryNeedUpdate(false)
|
||||
{
|
||||
|
@ -99,8 +99,8 @@ m_style (Regular),
|
|||
m_fillColor (255, 255, 255),
|
||||
m_outlineColor (0, 0, 0),
|
||||
m_outlineThickness (0),
|
||||
m_vertices (Triangles),
|
||||
m_outlineVertices (Triangles),
|
||||
m_vertices (PrimitiveType::Triangles),
|
||||
m_outlineVertices (PrimitiveType::Triangles),
|
||||
m_bounds (),
|
||||
m_geometryNeedUpdate(true)
|
||||
{
|
||||
|
|
|
@ -717,7 +717,7 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
|
|||
glCheck(glBindTexture(GL_TEXTURE_2D, texture->m_texture));
|
||||
|
||||
// Check if we need to define a special texture matrix
|
||||
if ((coordinateType == Pixels) || texture->m_pixelsFlipped)
|
||||
if ((coordinateType == CoordinateType::Pixels) || texture->m_pixelsFlipped)
|
||||
{
|
||||
GLfloat matrix[16] = {1.f, 0.f, 0.f, 0.f,
|
||||
0.f, 1.f, 0.f, 0.f,
|
||||
|
@ -726,7 +726,7 @@ void Texture::bind(const Texture* texture, CoordinateType coordinateType)
|
|||
|
||||
// If non-normalized coordinates (= pixels) are requested, we need to
|
||||
// setup scale factors that convert the range [0 .. size] to [0 .. 1]
|
||||
if (coordinateType == Pixels)
|
||||
if (coordinateType == CoordinateType::Pixels)
|
||||
{
|
||||
matrix[0] = 1.f / texture->m_actualSize.x;
|
||||
matrix[5] = 1.f / texture->m_actualSize.y;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace sf
|
|||
////////////////////////////////////////////////////////////
|
||||
VertexArray::VertexArray() :
|
||||
m_vertices (),
|
||||
m_primitiveType(Points)
|
||||
m_primitiveType(PrimitiveType::Points)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ static void onResume(ANativeActivity* activity)
|
|||
|
||||
// Send an event to warn people the activity has been resumed
|
||||
sf::Event event;
|
||||
event.type = sf::Event::MouseEntered;
|
||||
event.type = sf::Event::Type::MouseEntered;
|
||||
|
||||
states->forwardEvent(event);
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ static void onPause(ANativeActivity* activity)
|
|||
|
||||
// Send an event to warn people the activity has been paused
|
||||
sf::Event event;
|
||||
event.type = sf::Event::MouseLeft;
|
||||
event.type = sf::Event::Type::MouseLeft;
|
||||
|
||||
states->forwardEvent(event);
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ static void onDestroy(ANativeActivity* activity)
|
|||
if (!states->mainOver)
|
||||
{
|
||||
sf::Event event;
|
||||
event.type = sf::Event::Closed;
|
||||
event.type = sf::Event::Type::Closed;
|
||||
|
||||
states->forwardEvent(event);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* wind
|
|||
|
||||
// Notify SFML mechanism
|
||||
sf::Event event;
|
||||
event.type = sf::Event::GainedFocus;
|
||||
event.type = sf::Event::Type::GainedFocus;
|
||||
states->forwardEvent(event);
|
||||
|
||||
// Wait for the event to be taken into account by SFML
|
||||
|
@ -357,7 +357,7 @@ static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* wi
|
|||
|
||||
// Notify SFML mechanism
|
||||
sf::Event event;
|
||||
event.type = sf::Event::LostFocus;
|
||||
event.type = sf::Event::Type::LostFocus;
|
||||
states->forwardEvent(event);
|
||||
|
||||
// Wait for the event to be taken into account by SFML
|
||||
|
@ -432,7 +432,7 @@ static void onContentRectChanged(ANativeActivity* activity, const ARect* rect)
|
|||
if (states->window != nullptr) {
|
||||
// Send an event to warn people about the window move/resize
|
||||
sf::Event event;
|
||||
event.type = sf::Event::Resized;
|
||||
event.type = sf::Event::Type::Resized;
|
||||
event.size.width = ANativeWindow_getWidth(states->window);
|
||||
event.size.height = ANativeWindow_getHeight(states->window);
|
||||
|
||||
|
@ -476,7 +476,7 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_
|
|||
states->inputQueue = nullptr;
|
||||
states->config = nullptr;
|
||||
|
||||
for (unsigned int i = 0; i < sf::Mouse::ButtonCount; i++)
|
||||
for (auto i = 0u; i < static_cast<size_t>(sf::Mouse::Button::Count); i++)
|
||||
states->isButtonPressed[i] = false;
|
||||
|
||||
states->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
|
|
|
@ -77,7 +77,7 @@ m_message(message)
|
|||
////////////////////////////////////////////////////////////
|
||||
bool Ftp::Response::isOk() const
|
||||
{
|
||||
return m_status < 400;
|
||||
return static_cast<unsigned short>(m_status) < 400;
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,8 +151,8 @@ Ftp::~Ftp()
|
|||
Ftp::Response Ftp::connect(const IpAddress& server, unsigned short port, Time timeout)
|
||||
{
|
||||
// Connect to the server
|
||||
if (m_commandSocket.connect(server, port, timeout) != Socket::Done)
|
||||
return Response(Response::ConnectionFailed);
|
||||
if (m_commandSocket.connect(server, port, timeout) != Socket::Status::Done)
|
||||
return Response(Response::Status::ConnectionFailed);
|
||||
|
||||
// Get the response to the connection
|
||||
return getResponse();
|
||||
|
@ -209,7 +209,7 @@ Ftp::ListingResponse Ftp::getDirectoryListing(const std::string& directory)
|
|||
// Open a data channel on default port (20) using ASCII transfer mode
|
||||
std::ostringstream directoryData;
|
||||
DataChannel data(*this);
|
||||
Response response = data.open(Ascii);
|
||||
Response response = data.open(TransferMode::Ascii);
|
||||
if (response.isOk())
|
||||
{
|
||||
// Tell the server to send us the listing
|
||||
|
@ -300,7 +300,7 @@ Ftp::Response Ftp::download(const std::string& remoteFile, const std::string& lo
|
|||
// Create the file and truncate it if necessary
|
||||
std::ofstream file((path + filename).c_str(), std::ios_base::binary | std::ios_base::trunc);
|
||||
if (!file)
|
||||
return Response(Response::InvalidFile);
|
||||
return Response(Response::Status::InvalidFile);
|
||||
|
||||
// Receive the file data
|
||||
data.receive(file);
|
||||
|
@ -327,7 +327,7 @@ Ftp::Response Ftp::upload(const std::string& localFile, const std::string& remot
|
|||
// Get the contents of the file to send
|
||||
std::ifstream file(localFile.c_str(), std::ios_base::binary);
|
||||
if (!file)
|
||||
return Response(Response::InvalidFile);
|
||||
return Response(Response::Status::InvalidFile);
|
||||
|
||||
// Extract the filename from the file path
|
||||
std::string filename = localFile;
|
||||
|
@ -372,8 +372,8 @@ Ftp::Response Ftp::sendCommand(const std::string& command, const std::string& pa
|
|||
commandStr = command + "\r\n";
|
||||
|
||||
// Send it to the server
|
||||
if (m_commandSocket.send(commandStr.c_str(), commandStr.length()) != Socket::Done)
|
||||
return Response(Response::ConnectionClosed);
|
||||
if (m_commandSocket.send(commandStr.c_str(), commandStr.length()) != Socket::Status::Done)
|
||||
return Response(Response::Status::ConnectionClosed);
|
||||
|
||||
// Get the response
|
||||
return getResponse();
|
||||
|
@ -398,8 +398,8 @@ Ftp::Response Ftp::getResponse()
|
|||
|
||||
if (m_receiveBuffer.empty())
|
||||
{
|
||||
if (m_commandSocket.receive(buffer, sizeof(buffer), length) != Socket::Done)
|
||||
return Response(Response::ConnectionClosed);
|
||||
if (m_commandSocket.receive(buffer, sizeof(buffer), length) != Socket::Status::Done)
|
||||
return Response(Response::Status::ConnectionClosed);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -513,7 +513,7 @@ Ftp::Response Ftp::getResponse()
|
|||
else
|
||||
{
|
||||
// Error: cannot extract the code, and we are not in a multiline response
|
||||
return Response(Response::InvalidResponse);
|
||||
return Response(Response::Status::InvalidResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -565,15 +565,15 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
|
|||
static_cast<Uint8>(data[3]));
|
||||
|
||||
// Connect the data channel to the server
|
||||
if (m_dataSocket.connect(address, port) == Socket::Done)
|
||||
if (m_dataSocket.connect(address, port) == Socket::Status::Done)
|
||||
{
|
||||
// Translate the transfer mode to the corresponding FTP parameter
|
||||
std::string modeStr;
|
||||
switch (mode)
|
||||
{
|
||||
case Ftp::Binary: modeStr = "I"; break;
|
||||
case Ftp::Ascii: modeStr = "A"; break;
|
||||
case Ftp::Ebcdic: modeStr = "E"; break;
|
||||
case Ftp::TransferMode::Binary: modeStr = "I"; break;
|
||||
case Ftp::TransferMode::Ascii: modeStr = "A"; break;
|
||||
case Ftp::TransferMode::Ebcdic: modeStr = "E"; break;
|
||||
}
|
||||
|
||||
// Set the transfer mode
|
||||
|
@ -582,7 +582,7 @@ Ftp::Response Ftp::DataChannel::open(Ftp::TransferMode mode)
|
|||
else
|
||||
{
|
||||
// Failed to connect to the server
|
||||
response = Ftp::Response(Ftp::Response::ConnectionFailed);
|
||||
response = Ftp::Response(Ftp::Response::Status::ConnectionFailed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ void Ftp::DataChannel::receive(std::ostream& stream)
|
|||
// Receive data
|
||||
char buffer[1024];
|
||||
std::size_t received;
|
||||
while (m_dataSocket.receive(buffer, sizeof(buffer), received) == Socket::Done)
|
||||
while (m_dataSocket.receive(buffer, sizeof(buffer), received) == Socket::Status::Done)
|
||||
{
|
||||
stream.write(buffer, static_cast<std::streamsize>(received));
|
||||
|
||||
|
@ -636,7 +636,7 @@ void Ftp::DataChannel::send(std::istream& stream)
|
|||
if (count > 0)
|
||||
{
|
||||
// we could read more data from the stream: send them
|
||||
if (m_dataSocket.send(buffer, count) != Socket::Done)
|
||||
if (m_dataSocket.send(buffer, count) != Socket::Status::Done)
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -106,11 +106,11 @@ std::string Http::Request::prepare() const
|
|||
std::string method;
|
||||
switch (m_method)
|
||||
{
|
||||
case Get: method = "GET"; break;
|
||||
case Post: method = "POST"; break;
|
||||
case Head: method = "HEAD"; break;
|
||||
case Put: method = "PUT"; break;
|
||||
case Delete: method = "DELETE"; break;
|
||||
case Method::Get: method = "GET"; break;
|
||||
case Method::Post: method = "POST"; break;
|
||||
case Method::Head: method = "HEAD"; break;
|
||||
case Method::Put: method = "PUT"; break;
|
||||
case Method::Delete: method = "DELETE"; break;
|
||||
}
|
||||
|
||||
// Write the first line containing the request type
|
||||
|
@ -142,7 +142,7 @@ bool Http::Request::hasField(const std::string& field) const
|
|||
|
||||
////////////////////////////////////////////////////////////
|
||||
Http::Response::Response() :
|
||||
m_status (ConnectionFailed),
|
||||
m_status (Status::ConnectionFailed),
|
||||
m_majorVersion(0),
|
||||
m_minorVersion(0)
|
||||
{
|
||||
|
@ -213,7 +213,7 @@ void Http::Response::parse(const std::string& data)
|
|||
else
|
||||
{
|
||||
// Invalid HTTP version
|
||||
m_status = InvalidResponse;
|
||||
m_status = Status::InvalidResponse;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void Http::Response::parse(const std::string& data)
|
|||
else
|
||||
{
|
||||
// Invalid status code
|
||||
m_status = InvalidResponse;
|
||||
m_status = Status::InvalidResponse;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ Http::Response Http::sendRequest(const Http::Request& request, Time timeout)
|
|||
out << toSend.m_body.size();
|
||||
toSend.setField("Content-Length", out.str());
|
||||
}
|
||||
if ((toSend.m_method == Request::Post) && !toSend.hasField("Content-Type"))
|
||||
if ((toSend.m_method == Request::Method::Post) && !toSend.hasField("Content-Type"))
|
||||
{
|
||||
toSend.setField("Content-Type", "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ Http::Response Http::sendRequest(const Http::Request& request, Time timeout)
|
|||
Response received;
|
||||
|
||||
// Connect the socket to the host
|
||||
if (m_connection.connect(m_host, m_port, timeout) == Socket::Done)
|
||||
if (m_connection.connect(m_host, m_port, timeout) == Socket::Status::Done)
|
||||
{
|
||||
// Convert the request to string and send it through the connected socket
|
||||
std::string requestStr = toSend.prepare();
|
||||
|
@ -388,13 +388,13 @@ Http::Response Http::sendRequest(const Http::Request& request, Time timeout)
|
|||
if (!requestStr.empty())
|
||||
{
|
||||
// Send it through the socket
|
||||
if (m_connection.send(requestStr.c_str(), requestStr.size()) == Socket::Done)
|
||||
if (m_connection.send(requestStr.c_str(), requestStr.size()) == Socket::Status::Done)
|
||||
{
|
||||
// Wait for the server's response
|
||||
std::string receivedStr;
|
||||
std::size_t size = 0;
|
||||
char buffer[1024];
|
||||
while (m_connection.receive(buffer, sizeof(buffer), size) == Socket::Done)
|
||||
while (m_connection.receive(buffer, sizeof(buffer), size) == Socket::Status::Done)
|
||||
{
|
||||
receivedStr.append(buffer, buffer + size);
|
||||
}
|
||||
|
|
|
@ -150,9 +150,9 @@ IpAddress IpAddress::getPublicAddress(Time timeout)
|
|||
// (not very hard: the web page contains only our IP address).
|
||||
|
||||
Http server("www.sfml-dev.org");
|
||||
Http::Request request("/ip-provider.php", Http::Request::Get);
|
||||
Http::Request request("/ip-provider.php", Http::Request::Method::Get);
|
||||
Http::Response page = server.sendRequest(request, timeout);
|
||||
if (page.getStatus() == Http::Response::Ok)
|
||||
if (page.getStatus() == Http::Response::Status::Ok)
|
||||
return IpAddress(page.getBody());
|
||||
|
||||
// Something failed: return an invalid address
|
||||
|
|
|
@ -81,7 +81,7 @@ void Socket::create()
|
|||
// Don't create the socket if it already exists
|
||||
if (m_socket == priv::SocketImpl::invalidSocket())
|
||||
{
|
||||
SocketHandle handle = socket(PF_INET, m_type == Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
|
||||
SocketHandle handle = socket(PF_INET, m_type == Type::Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
|
||||
|
||||
if (handle == priv::SocketImpl::invalidSocket())
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ void Socket::create(SocketHandle handle)
|
|||
// Set the current blocking state
|
||||
setBlocking(m_isBlocking);
|
||||
|
||||
if (m_type == Tcp)
|
||||
if (m_type == Type::Tcp)
|
||||
{
|
||||
// Disable the Nagle algorithm (i.e. removes buffering of TCP packets)
|
||||
int yes = 1;
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace sf
|
|||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
TcpListener::TcpListener() :
|
||||
Socket(Tcp)
|
||||
Socket(Type::Tcp)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address
|
|||
|
||||
// Check if the address is valid
|
||||
if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
|
||||
return Error;
|
||||
return Status::Error;
|
||||
|
||||
// Bind the socket to the specified port
|
||||
sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
|
||||
|
@ -76,7 +76,7 @@ Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address
|
|||
{
|
||||
// Not likely to happen, but...
|
||||
err() << "Failed to bind listener socket to port " << port << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Listen to the bound port
|
||||
|
@ -84,10 +84,10 @@ Socket::Status TcpListener::listen(unsigned short port, const IpAddress& address
|
|||
{
|
||||
// Oops, socket is deaf
|
||||
err() << "Failed to listen to port " << port << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ Socket::Status TcpListener::accept(TcpSocket& socket)
|
|||
if (getHandle() == priv::SocketImpl::invalidSocket())
|
||||
{
|
||||
err() << "Failed to accept a new connection, the socket is not listening" << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Accept a new connection
|
||||
|
@ -122,7 +122,7 @@ Socket::Status TcpListener::accept(TcpSocket& socket)
|
|||
socket.close();
|
||||
socket.create(remote);
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
} // namespace sf
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace sf
|
|||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
TcpSocket::TcpSocket() :
|
||||
Socket(Tcp)
|
||||
Socket(Type::Tcp)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
|||
return priv::SocketImpl::getErrorStatus();
|
||||
|
||||
// Connection succeeded
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -151,7 +151,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
|||
{
|
||||
// We got instantly connected! (it may no happen a lot...)
|
||||
setBlocking(blocking);
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
// Get the error status
|
||||
|
@ -162,7 +162,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
|||
return status;
|
||||
|
||||
// Otherwise, wait until something happens to our socket (success, timeout or error)
|
||||
if (status == Socket::NotReady)
|
||||
if (status == Status::NotReady)
|
||||
{
|
||||
// Setup the selector
|
||||
fd_set selector;
|
||||
|
@ -182,7 +182,7 @@ Socket::Status TcpSocket::connect(const IpAddress& remoteAddress, unsigned short
|
|||
if (getRemoteAddress() != IpAddress::None)
|
||||
{
|
||||
// Connection accepted
|
||||
status = Done;
|
||||
status = Status::Done;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -235,7 +235,7 @@ Socket::Status TcpSocket::send(const void* data, std::size_t size, std::size_t&
|
|||
if (!data || (size == 0))
|
||||
{
|
||||
err() << "Cannot send data over the network (no data to send)" << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Loop until every byte has been sent
|
||||
|
@ -250,14 +250,14 @@ Socket::Status TcpSocket::send(const void* data, std::size_t size, std::size_t&
|
|||
{
|
||||
Status status = priv::SocketImpl::getErrorStatus();
|
||||
|
||||
if ((status == NotReady) && sent)
|
||||
return Partial;
|
||||
if ((status == Status::NotReady) && sent)
|
||||
return Status::Partial;
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,7 +271,7 @@ Socket::Status TcpSocket::receive(void* data, std::size_t size, std::size_t& rec
|
|||
if (!data)
|
||||
{
|
||||
err() << "Cannot receive data from the network (the destination buffer is invalid)" << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Receive a chunk of bytes
|
||||
|
@ -281,11 +281,11 @@ Socket::Status TcpSocket::receive(void* data, std::size_t size, std::size_t& rec
|
|||
if (sizeReceived > 0)
|
||||
{
|
||||
received = static_cast<std::size_t>(sizeReceived);
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
else if (sizeReceived == 0)
|
||||
{
|
||||
return Socket::Disconnected;
|
||||
return Status::Disconnected;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -326,11 +326,11 @@ Socket::Status TcpSocket::send(Packet& packet)
|
|||
Status status = send(blockToSend.data() + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent);
|
||||
|
||||
// In the case of a partial send, record the location to resume from
|
||||
if (status == Partial)
|
||||
if (status == Status::Partial)
|
||||
{
|
||||
packet.m_sendPos += sent;
|
||||
}
|
||||
else if (status == Done)
|
||||
else if (status == Status::Done)
|
||||
{
|
||||
packet.m_sendPos = 0;
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
|||
Status status = receive(data, sizeof(m_pendingPacket.Size) - m_pendingPacket.SizeReceived, received);
|
||||
m_pendingPacket.SizeReceived += received;
|
||||
|
||||
if (status != Done)
|
||||
if (status != Status::Done)
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
|||
// Receive a chunk of data
|
||||
std::size_t sizeToGet = std::min(static_cast<std::size_t>(packetSize - m_pendingPacket.Data.size()), sizeof(buffer));
|
||||
Status status = receive(buffer, sizeToGet, received);
|
||||
if (status != Done)
|
||||
if (status != Status::Done)
|
||||
return status;
|
||||
|
||||
// Append it into the packet
|
||||
|
@ -397,7 +397,7 @@ Socket::Status TcpSocket::receive(Packet& packet)
|
|||
// Clear the pending packet data
|
||||
m_pendingPacket = PendingPacket();
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace sf
|
|||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
UdpSocket::UdpSocket() :
|
||||
Socket (Udp),
|
||||
Socket (Type::Udp),
|
||||
m_buffer(MaxDatagramSize)
|
||||
{
|
||||
|
||||
|
@ -71,17 +71,17 @@ Socket::Status UdpSocket::bind(unsigned short port, const IpAddress& address)
|
|||
|
||||
// Check if the address is valid
|
||||
if ((address == IpAddress::None) || (address == IpAddress::Broadcast))
|
||||
return Error;
|
||||
return Status::Error;
|
||||
|
||||
// Bind the socket
|
||||
sockaddr_in addr = priv::SocketImpl::createAddress(address.toInteger(), port);
|
||||
if (::bind(getHandle(), reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1)
|
||||
{
|
||||
err() << "Failed to bind socket to port " << port << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,7 +104,7 @@ Socket::Status UdpSocket::send(const void* data, std::size_t size, const IpAddre
|
|||
{
|
||||
err() << "Cannot send data over the network "
|
||||
<< "(the number of bytes to send is greater than sf::UdpSocket::MaxDatagramSize)" << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Build the target address
|
||||
|
@ -117,7 +117,7 @@ Socket::Status UdpSocket::send(const void* data, std::size_t size, const IpAddre
|
|||
if (sent < 0)
|
||||
return priv::SocketImpl::getErrorStatus();
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ Socket::Status UdpSocket::receive(void* data, std::size_t size, std::size_t& rec
|
|||
if (!data)
|
||||
{
|
||||
err() << "Cannot receive data from the network (the destination buffer is invalid)" << std::endl;
|
||||
return Error;
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
// Data that will be filled with the other computer's address
|
||||
|
@ -152,7 +152,7 @@ Socket::Status UdpSocket::receive(void* data, std::size_t size, std::size_t& rec
|
|||
remoteAddress = IpAddress(ntohl(address.sin_addr.s_addr));
|
||||
remotePort = ntohs(address.sin_port);
|
||||
|
||||
return Done;
|
||||
return Status::Done;
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,7 +187,7 @@ Socket::Status UdpSocket::receive(Packet& packet, IpAddress& remoteAddress, unsi
|
|||
|
||||
// If we received valid data, we can copy it to the user packet
|
||||
packet.clear();
|
||||
if ((status == Done) && (received > 0))
|
||||
if ((status == Status::Done) && (received > 0))
|
||||
packet.onReceive(m_buffer.data(), received);
|
||||
|
||||
return status;
|
||||
|
|
|
@ -92,18 +92,18 @@ Socket::Status SocketImpl::getErrorStatus()
|
|||
// so we have to make a special case for them in order
|
||||
// to avoid having double values in the switch case
|
||||
if ((errno == EAGAIN) || (errno == EINPROGRESS))
|
||||
return Socket::NotReady;
|
||||
return Socket::Status::NotReady;
|
||||
|
||||
switch (errno)
|
||||
{
|
||||
case EWOULDBLOCK: return Socket::NotReady;
|
||||
case ECONNABORTED: return Socket::Disconnected;
|
||||
case ECONNRESET: return Socket::Disconnected;
|
||||
case ETIMEDOUT: return Socket::Disconnected;
|
||||
case ENETRESET: return Socket::Disconnected;
|
||||
case ENOTCONN: return Socket::Disconnected;
|
||||
case EPIPE: return Socket::Disconnected;
|
||||
default: return Socket::Error;
|
||||
case EWOULDBLOCK: return Socket::Status::NotReady;
|
||||
case ECONNABORTED: return Socket::Status::Disconnected;
|
||||
case ECONNRESET: return Socket::Status::Disconnected;
|
||||
case ETIMEDOUT: return Socket::Status::Disconnected;
|
||||
case ENETRESET: return Socket::Status::Disconnected;
|
||||
case ENOTCONN: return Socket::Status::Disconnected;
|
||||
case EPIPE: return Socket::Status::Disconnected;
|
||||
default: return Socket::Status::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,15 +73,15 @@ Socket::Status SocketImpl::getErrorStatus()
|
|||
{
|
||||
switch (WSAGetLastError())
|
||||
{
|
||||
case WSAEWOULDBLOCK: return Socket::NotReady;
|
||||
case WSAEALREADY: return Socket::NotReady;
|
||||
case WSAECONNABORTED: return Socket::Disconnected;
|
||||
case WSAECONNRESET: return Socket::Disconnected;
|
||||
case WSAETIMEDOUT: return Socket::Disconnected;
|
||||
case WSAENETRESET: return Socket::Disconnected;
|
||||
case WSAENOTCONN: return Socket::Disconnected;
|
||||
case WSAEISCONN: return Socket::Done; // when connecting a non-blocking socket
|
||||
default: return Socket::Error;
|
||||
case WSAEWOULDBLOCK: return Socket::Status::NotReady;
|
||||
case WSAEALREADY: return Socket::Status::NotReady;
|
||||
case WSAECONNABORTED: return Socket::Status::Disconnected;
|
||||
case WSAECONNRESET: return Socket::Status::Disconnected;
|
||||
case WSAETIMEDOUT: return Socket::Status::Disconnected;
|
||||
case WSAENETRESET: return Socket::Status::Disconnected;
|
||||
case WSAENOTCONN: return Socket::Status::Disconnected;
|
||||
case WSAEISCONN: return Socket::Status::Done; // when connecting a non-blocking socket
|
||||
default: return Socket::Status::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ struct ActivityStates
|
|||
|
||||
std::map<int, Vector2i> touchEvents;
|
||||
Vector2i mousePosition;
|
||||
bool isButtonPressed[Mouse::ButtonCount];
|
||||
bool isButtonPressed[static_cast<size_t>(Mouse::Button::Count)];
|
||||
|
||||
bool mainOver;
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
|||
priv::ActivityStates* states = priv::getActivity(nullptr);
|
||||
std::lock_guard<std::mutex> lock(states->mutex);
|
||||
|
||||
return states->isButtonPressed[button];
|
||||
return states->isButtonPressed[static_cast<size_t>(button)];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ ASensor const* SensorImpl::getDefaultSensor(Sensor::Type sensor)
|
|||
ASENSOR_TYPE_MAGNETIC_FIELD, ASENSOR_TYPE_GRAVITY, ASENSOR_TYPE_LINEAR_ACCELERATION,
|
||||
ASENSOR_TYPE_ORIENTATION};
|
||||
|
||||
int type = types[sensor];
|
||||
int type = types[static_cast<size_t>(sensor)];
|
||||
|
||||
// Retrieve the default sensor matching this type
|
||||
return ASensorManager_getDefaultSensor(sensorManager, type);
|
||||
|
@ -151,48 +151,48 @@ int SensorImpl::processSensorEvents(int fd, int events, void* data)
|
|||
|
||||
while (ASensorEventQueue_getEvents(sensorEventQueue, &event, 1) > 0)
|
||||
{
|
||||
unsigned int type = Sensor::Count;
|
||||
unsigned int type = Sensor::Type::Count;
|
||||
Vector3f data;
|
||||
|
||||
switch (event.type)
|
||||
{
|
||||
case ASENSOR_TYPE_ACCELEROMETER:
|
||||
type = Sensor::Accelerometer;
|
||||
type = Sensor::Type::Accelerometer;
|
||||
data.x = event.acceleration.x;
|
||||
data.y = event.acceleration.y;
|
||||
data.z = event.acceleration.z;
|
||||
break;
|
||||
|
||||
case ASENSOR_TYPE_GYROSCOPE:
|
||||
type = Sensor::Gyroscope;
|
||||
type = Sensor::Type::Gyroscope;
|
||||
data.x = event.vector.x;
|
||||
data.y = event.vector.y;
|
||||
data.z = event.vector.z;
|
||||
break;
|
||||
|
||||
case ASENSOR_TYPE_MAGNETIC_FIELD:
|
||||
type = Sensor::Magnetometer;
|
||||
type = Sensor::Type::Magnetometer;
|
||||
data.x = event.magnetic.x;
|
||||
data.y = event.magnetic.y;
|
||||
data.z = event.magnetic.z;
|
||||
break;
|
||||
|
||||
case ASENSOR_TYPE_GRAVITY:
|
||||
type = Sensor::Gravity;
|
||||
type = Sensor::Type::Gravity;
|
||||
data.x = event.vector.x;
|
||||
data.y = event.vector.y;
|
||||
data.z = event.vector.z;
|
||||
break;
|
||||
|
||||
case ASENSOR_TYPE_LINEAR_ACCELERATION:
|
||||
type = Sensor::UserAcceleration;
|
||||
type = Sensor::Type::UserAcceleration;
|
||||
data.x = event.acceleration.x;
|
||||
data.y = event.acceleration.y;
|
||||
data.z = event.acceleration.z;
|
||||
break;
|
||||
|
||||
case ASENSOR_TYPE_ORIENTATION:
|
||||
type = Sensor::Orientation;
|
||||
type = Sensor::Type::Orientation;
|
||||
data.x = event.vector.x;
|
||||
data.y = event.vector.y;
|
||||
data.z = event.vector.z;
|
||||
|
@ -200,7 +200,7 @@ int SensorImpl::processSensorEvents(int fd, int events, void* data)
|
|||
}
|
||||
|
||||
// An unknown sensor event has been detected, we don't know how to process it
|
||||
if (type == Sensor::Count)
|
||||
if (type == Sensor::Type::Count)
|
||||
continue;
|
||||
|
||||
sensorData[type] = data;
|
||||
|
|
|
@ -211,14 +211,14 @@ void WindowImplAndroid::forwardEvent(const Event& event)
|
|||
{
|
||||
ActivityStates* states = getActivity(nullptr);
|
||||
|
||||
if (event.type == Event::GainedFocus)
|
||||
if (event.type == Event::Type::GainedFocus)
|
||||
{
|
||||
WindowImplAndroid::singleInstance->m_size.x = ANativeWindow_getWidth(states->window);
|
||||
WindowImplAndroid::singleInstance->m_size.y = ANativeWindow_getHeight(states->window);
|
||||
WindowImplAndroid::singleInstance->m_windowBeingCreated = true;
|
||||
WindowImplAndroid::singleInstance->m_hasFocus = true;
|
||||
}
|
||||
else if (event.type == Event::LostFocus)
|
||||
else if (event.type == Event::Type::LostFocus)
|
||||
{
|
||||
WindowImplAndroid::singleInstance->m_windowBeingDestroyed = true;
|
||||
WindowImplAndroid::singleInstance->m_hasFocus = false;
|
||||
|
@ -352,7 +352,7 @@ int WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates* s
|
|||
|
||||
// Create and send our mouse wheel event
|
||||
Event event;
|
||||
event.type = Event::MouseWheelMoved;
|
||||
event.type = Event::Type::MouseWheelMoved;
|
||||
event.mouseWheel.delta = static_cast<double>(delta);
|
||||
event.mouseWheel.x = AMotionEvent_getX(_event, 0);
|
||||
event.mouseWheel.y = AMotionEvent_getY(_event, 0);
|
||||
|
@ -384,16 +384,16 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates* stat
|
|||
switch (action)
|
||||
{
|
||||
case AKEY_EVENT_ACTION_DOWN:
|
||||
event.type = Event::KeyPressed;
|
||||
event.type = Event::Type::KeyPressed;
|
||||
forwardEvent(event);
|
||||
return 1;
|
||||
case AKEY_EVENT_ACTION_UP:
|
||||
event.type = Event::KeyReleased;
|
||||
event.type = Event::Type::KeyReleased;
|
||||
forwardEvent(event);
|
||||
|
||||
if (int unicode = getUnicode(_event))
|
||||
{
|
||||
event.type = Event::TextEntered;
|
||||
event.type = Event::Type::TextEntered;
|
||||
event.text.unicode = unicode;
|
||||
forwardEvent(event);
|
||||
}
|
||||
|
@ -401,9 +401,9 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates* stat
|
|||
case AKEY_EVENT_ACTION_MULTIPLE:
|
||||
// Since complex inputs don't get separate key down/up events
|
||||
// both have to be faked at once
|
||||
event.type = Event::KeyPressed;
|
||||
event.type = Event::Type::KeyPressed;
|
||||
forwardEvent(event);
|
||||
event.type = Event::KeyReleased;
|
||||
event.type = Event::Type::KeyReleased;
|
||||
forwardEvent(event);
|
||||
|
||||
// This requires some special treatment, since this might represent
|
||||
|
@ -416,7 +416,7 @@ int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates* stat
|
|||
}
|
||||
else if (int unicode = getUnicode(_event)) // This is a repeated sequence
|
||||
{
|
||||
event.type = Event::TextEntered;
|
||||
event.type = Event::Type::TextEntered;
|
||||
event.text.unicode = unicode;
|
||||
|
||||
int32_t repeats = AKeyEvent_getRepeatCount(_event);
|
||||
|
@ -439,9 +439,9 @@ int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates* s
|
|||
Event event;
|
||||
|
||||
if (device == AINPUT_SOURCE_MOUSE)
|
||||
event.type = Event::MouseMoved;
|
||||
event.type = Event::Type::MouseMoved;
|
||||
else if (device & AINPUT_SOURCE_TOUCHSCREEN)
|
||||
event.type = Event::TouchMoved;
|
||||
event.type = Event::Type::TouchMoved;
|
||||
|
||||
int pointerCount = AMotionEvent_getPointerCount(_event);
|
||||
|
||||
|
@ -495,17 +495,17 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
|
|||
{
|
||||
if (device == AINPUT_SOURCE_MOUSE)
|
||||
{
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = static_cast<Mouse::Button>(id);
|
||||
event.mouseButton.x = x;
|
||||
event.mouseButton.y = y;
|
||||
|
||||
if (id >= 0 && id < Mouse::ButtonCount)
|
||||
if (id >= 0 && id < Mouse::Button::Count)
|
||||
states->isButtonPressed[id] = true;
|
||||
}
|
||||
else if (device & AINPUT_SOURCE_TOUCHSCREEN)
|
||||
{
|
||||
event.type = Event::TouchBegan;
|
||||
event.type = Event::Type::TouchBegan;
|
||||
event.touch.finger = id;
|
||||
event.touch.x = x;
|
||||
event.touch.y = y;
|
||||
|
@ -517,17 +517,17 @@ int WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, Act
|
|||
{
|
||||
if (device == AINPUT_SOURCE_MOUSE)
|
||||
{
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = static_cast<Mouse::Button>(id);
|
||||
event.mouseButton.x = x;
|
||||
event.mouseButton.y = y;
|
||||
|
||||
if (id >= 0 && id < Mouse::ButtonCount)
|
||||
if (id >= 0 && id < Mouse::Button::Count)
|
||||
states->isButtonPressed[id] = false;
|
||||
}
|
||||
else if (device & AINPUT_SOURCE_TOUCHSCREEN)
|
||||
{
|
||||
event.type = Event::TouchEnded;
|
||||
event.type = Event::Type::TouchEnded;
|
||||
event.touch.finger = id;
|
||||
event.touch.x = x;
|
||||
event.touch.y = y;
|
||||
|
@ -549,20 +549,20 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
|||
case AKEYCODE_UNKNOWN:
|
||||
case AKEYCODE_SOFT_LEFT:
|
||||
case AKEYCODE_SOFT_RIGHT:
|
||||
case AKEYCODE_HOME: return Keyboard::Unknown;
|
||||
case AKEYCODE_BACK: return Keyboard::Escape;
|
||||
case AKEYCODE_HOME: return Keyboard::Key::Unknown;
|
||||
case AKEYCODE_BACK: return Keyboard::Key::Escape;
|
||||
case AKEYCODE_CALL:
|
||||
case AKEYCODE_ENDCALL: return Keyboard::Unknown;
|
||||
case AKEYCODE_0: return Keyboard::Num0;
|
||||
case AKEYCODE_1: return Keyboard::Num1;
|
||||
case AKEYCODE_2: return Keyboard::Num2;
|
||||
case AKEYCODE_3: return Keyboard::Num3;
|
||||
case AKEYCODE_4: return Keyboard::Num4;
|
||||
case AKEYCODE_5: return Keyboard::Num5;
|
||||
case AKEYCODE_6: return Keyboard::Num6;
|
||||
case AKEYCODE_7: return Keyboard::Num7;
|
||||
case AKEYCODE_8: return Keyboard::Num8;
|
||||
case AKEYCODE_9: return Keyboard::Num9;
|
||||
case AKEYCODE_ENDCALL: return Keyboard::Key::Unknown;
|
||||
case AKEYCODE_0: return Keyboard::Key::Num0;
|
||||
case AKEYCODE_1: return Keyboard::Key::Num1;
|
||||
case AKEYCODE_2: return Keyboard::Key::Num2;
|
||||
case AKEYCODE_3: return Keyboard::Key::Num3;
|
||||
case AKEYCODE_4: return Keyboard::Key::Num4;
|
||||
case AKEYCODE_5: return Keyboard::Key::Num5;
|
||||
case AKEYCODE_6: return Keyboard::Key::Num6;
|
||||
case AKEYCODE_7: return Keyboard::Key::Num7;
|
||||
case AKEYCODE_8: return Keyboard::Key::Num8;
|
||||
case AKEYCODE_9: return Keyboard::Key::Num9;
|
||||
case AKEYCODE_STAR:
|
||||
case AKEYCODE_POUND:
|
||||
case AKEYCODE_DPAD_UP:
|
||||
|
@ -574,55 +574,55 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
|||
case AKEYCODE_VOLUME_DOWN:
|
||||
case AKEYCODE_POWER:
|
||||
case AKEYCODE_CAMERA:
|
||||
case AKEYCODE_CLEAR: return Keyboard::Unknown;
|
||||
case AKEYCODE_A: return Keyboard::A;
|
||||
case AKEYCODE_B: return Keyboard::B;
|
||||
case AKEYCODE_C: return Keyboard::C;
|
||||
case AKEYCODE_D: return Keyboard::D;
|
||||
case AKEYCODE_E: return Keyboard::E;
|
||||
case AKEYCODE_F: return Keyboard::F;
|
||||
case AKEYCODE_G: return Keyboard::G;
|
||||
case AKEYCODE_H: return Keyboard::H;
|
||||
case AKEYCODE_I: return Keyboard::I;
|
||||
case AKEYCODE_J: return Keyboard::J;
|
||||
case AKEYCODE_K: return Keyboard::K;
|
||||
case AKEYCODE_L: return Keyboard::L;
|
||||
case AKEYCODE_M: return Keyboard::M;
|
||||
case AKEYCODE_N: return Keyboard::N;
|
||||
case AKEYCODE_O: return Keyboard::O;
|
||||
case AKEYCODE_P: return Keyboard::P;
|
||||
case AKEYCODE_Q: return Keyboard::Q;
|
||||
case AKEYCODE_R: return Keyboard::R;
|
||||
case AKEYCODE_S: return Keyboard::S;
|
||||
case AKEYCODE_T: return Keyboard::T;
|
||||
case AKEYCODE_U: return Keyboard::U;
|
||||
case AKEYCODE_V: return Keyboard::V;
|
||||
case AKEYCODE_W: return Keyboard::W;
|
||||
case AKEYCODE_X: return Keyboard::X;
|
||||
case AKEYCODE_Y: return Keyboard::Y;
|
||||
case AKEYCODE_Z: return Keyboard::Z;
|
||||
case AKEYCODE_COMMA: return Keyboard::Comma;
|
||||
case AKEYCODE_PERIOD: return Keyboard::Period;
|
||||
case AKEYCODE_ALT_LEFT: return Keyboard::LAlt;
|
||||
case AKEYCODE_ALT_RIGHT: return Keyboard::RAlt;
|
||||
case AKEYCODE_SHIFT_LEFT: return Keyboard::LShift;
|
||||
case AKEYCODE_SHIFT_RIGHT: return Keyboard::RShift;
|
||||
case AKEYCODE_TAB: return Keyboard::Tab;
|
||||
case AKEYCODE_SPACE: return Keyboard::Space;
|
||||
case AKEYCODE_CLEAR: return Keyboard::Key::Unknown;
|
||||
case AKEYCODE_A: return Keyboard::Key::A;
|
||||
case AKEYCODE_B: return Keyboard::Key::B;
|
||||
case AKEYCODE_C: return Keyboard::Key::C;
|
||||
case AKEYCODE_D: return Keyboard::Key::D;
|
||||
case AKEYCODE_E: return Keyboard::Key::E;
|
||||
case AKEYCODE_F: return Keyboard::Key::F;
|
||||
case AKEYCODE_G: return Keyboard::Key::G;
|
||||
case AKEYCODE_H: return Keyboard::Key::H;
|
||||
case AKEYCODE_I: return Keyboard::Key::I;
|
||||
case AKEYCODE_J: return Keyboard::Key::J;
|
||||
case AKEYCODE_K: return Keyboard::Key::K;
|
||||
case AKEYCODE_L: return Keyboard::Key::L;
|
||||
case AKEYCODE_M: return Keyboard::Key::M;
|
||||
case AKEYCODE_N: return Keyboard::Key::N;
|
||||
case AKEYCODE_O: return Keyboard::Key::O;
|
||||
case AKEYCODE_P: return Keyboard::Key::P;
|
||||
case AKEYCODE_Q: return Keyboard::Key::Q;
|
||||
case AKEYCODE_R: return Keyboard::Key::R;
|
||||
case AKEYCODE_S: return Keyboard::Key::S;
|
||||
case AKEYCODE_T: return Keyboard::Key::T;
|
||||
case AKEYCODE_U: return Keyboard::Key::U;
|
||||
case AKEYCODE_V: return Keyboard::Key::V;
|
||||
case AKEYCODE_W: return Keyboard::Key::W;
|
||||
case AKEYCODE_X: return Keyboard::Key::X;
|
||||
case AKEYCODE_Y: return Keyboard::Key::Y;
|
||||
case AKEYCODE_Z: return Keyboard::Key::Z;
|
||||
case AKEYCODE_COMMA: return Keyboard::Key::Comma;
|
||||
case AKEYCODE_PERIOD: return Keyboard::Key::Period;
|
||||
case AKEYCODE_ALT_LEFT: return Keyboard::Key::LAlt;
|
||||
case AKEYCODE_ALT_RIGHT: return Keyboard::Key::RAlt;
|
||||
case AKEYCODE_SHIFT_LEFT: return Keyboard::Key::LShift;
|
||||
case AKEYCODE_SHIFT_RIGHT: return Keyboard::Key::RShift;
|
||||
case AKEYCODE_TAB: return Keyboard::Key::Tab;
|
||||
case AKEYCODE_SPACE: return Keyboard::Key::Space;
|
||||
case AKEYCODE_SYM:
|
||||
case AKEYCODE_EXPLORER:
|
||||
case AKEYCODE_ENVELOPE: return Keyboard::Unknown;
|
||||
case AKEYCODE_ENTER: return Keyboard::Return;
|
||||
case AKEYCODE_DEL: return Keyboard::Delete;
|
||||
case AKEYCODE_GRAVE: return Keyboard::Tilde;
|
||||
case AKEYCODE_MINUS: return Keyboard::Subtract;
|
||||
case AKEYCODE_EQUALS: return Keyboard::Equal;
|
||||
case AKEYCODE_LEFT_BRACKET: return Keyboard::LBracket;
|
||||
case AKEYCODE_RIGHT_BRACKET: return Keyboard::RBracket;
|
||||
case AKEYCODE_BACKSLASH: return Keyboard::BackSlash;
|
||||
case AKEYCODE_SEMICOLON: return Keyboard::SemiColon;
|
||||
case AKEYCODE_APOSTROPHE: return Keyboard::Quote;
|
||||
case AKEYCODE_SLASH: return Keyboard::Slash;
|
||||
case AKEYCODE_ENVELOPE: return Keyboard::Key::Unknown;
|
||||
case AKEYCODE_ENTER: return Keyboard::Key::Return;
|
||||
case AKEYCODE_DEL: return Keyboard::Key::Delete;
|
||||
case AKEYCODE_GRAVE: return Keyboard::Key::Tilde;
|
||||
case AKEYCODE_MINUS: return Keyboard::Key::Subtract;
|
||||
case AKEYCODE_EQUALS: return Keyboard::Key::Equal;
|
||||
case AKEYCODE_LEFT_BRACKET: return Keyboard::Key::LBracket;
|
||||
case AKEYCODE_RIGHT_BRACKET: return Keyboard::Key::RBracket;
|
||||
case AKEYCODE_BACKSLASH: return Keyboard::Key::BackSlash;
|
||||
case AKEYCODE_SEMICOLON: return Keyboard::Key::SemiColon;
|
||||
case AKEYCODE_APOSTROPHE: return Keyboard::Key::Quote;
|
||||
case AKEYCODE_SLASH: return Keyboard::Key::Slash;
|
||||
case AKEYCODE_AT:
|
||||
case AKEYCODE_NUM:
|
||||
case AKEYCODE_HEADSETHOOK:
|
||||
|
@ -637,9 +637,9 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
|||
case AKEYCODE_MEDIA_PREVIOUS:
|
||||
case AKEYCODE_MEDIA_REWIND:
|
||||
case AKEYCODE_MEDIA_FAST_FORWARD:
|
||||
case AKEYCODE_MUTE: return Keyboard::Unknown;
|
||||
case AKEYCODE_PAGE_UP: return Keyboard::PageUp;
|
||||
case AKEYCODE_PAGE_DOWN: return Keyboard::PageDown;
|
||||
case AKEYCODE_MUTE: return Keyboard::Key::Unknown;
|
||||
case AKEYCODE_PAGE_UP: return Keyboard::Key::PageUp;
|
||||
case AKEYCODE_PAGE_DOWN: return Keyboard::Key::PageDown;
|
||||
case AKEYCODE_PICTSYMBOLS:
|
||||
case AKEYCODE_SWITCH_CHARSET:
|
||||
case AKEYCODE_BUTTON_A:
|
||||
|
@ -656,7 +656,7 @@ Keyboard::Key WindowImplAndroid::androidKeyToSF(int32_t key)
|
|||
case AKEYCODE_BUTTON_THUMBR:
|
||||
case AKEYCODE_BUTTON_START:
|
||||
case AKEYCODE_BUTTON_SELECT:
|
||||
case AKEYCODE_BUTTON_MODE: return Keyboard::Unknown;
|
||||
case AKEYCODE_BUTTON_MODE: return Keyboard::Key::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -138,20 +138,20 @@ namespace
|
|||
{
|
||||
switch (usage)
|
||||
{
|
||||
case HUG_X: return sf::Joystick::X;
|
||||
case HUG_Y: return sf::Joystick::Y;
|
||||
case HUG_Z: return sf::Joystick::Z;
|
||||
case HUG_RZ: return sf::Joystick::R;
|
||||
case HUG_RX: return sf::Joystick::U;
|
||||
case HUG_RY: return sf::Joystick::V;
|
||||
case HUG_X: return static_cast<int>(sf::Joystick::Axis::X);
|
||||
case HUG_Y: return static_cast<int>(sf::Joystick::Axis::Y);
|
||||
case HUG_Z: return static_cast<int>(sf::Joystick::Axis::Z);
|
||||
case HUG_RZ: return static_cast<int>(sf::Joystick::Axis::R);
|
||||
case HUG_RX: return static_cast<int>(sf::Joystick::Axis::U);
|
||||
case HUG_RY: return static_cast<int>(sf::Joystick::Axis::V);
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
void hatValueToSfml(int value, sf::priv::JoystickState& state)
|
||||
{
|
||||
state.axes[sf::Joystick::PovX] = hatValueMap[value].first;
|
||||
state.axes[sf::Joystick::PovY] = hatValueMap[value].second;
|
||||
state.axes[static_cast<size_t>(sf::Joystick::Axis::PovX)] = hatValueMap[value].first;
|
||||
state.axes[static_cast<size_t>(sf::Joystick::Axis::PovY)] = hatValueMap[value].second;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,8 +266,8 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||
|
||||
if (usage == HUG_HAT_SWITCH)
|
||||
{
|
||||
caps.axes[Joystick::PovX] = true;
|
||||
caps.axes[Joystick::PovY] = true;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::PovX)] = true;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::PovY)] = true;
|
||||
}
|
||||
else if (axis != -1)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ unsigned int Joystick::getButtonCount(unsigned int joystick)
|
|||
////////////////////////////////////////////////////////////
|
||||
bool Joystick::hasAxis(unsigned int joystick, Axis axis)
|
||||
{
|
||||
return priv::JoystickManager::getInstance().getCapabilities(joystick).axes[axis];
|
||||
return priv::JoystickManager::getInstance().getCapabilities(joystick).axes[static_cast<size_t>(axis)];
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ bool Joystick::isButtonPressed(unsigned int joystick, unsigned int button)
|
|||
////////////////////////////////////////////////////////////
|
||||
float Joystick::getAxisPosition(unsigned int joystick, Axis axis)
|
||||
{
|
||||
return priv::JoystickManager::getInstance().getState(joystick).axes[axis];
|
||||
return priv::JoystickManager::getInstance().getState(joystick).axes[static_cast<size_t>(axis)];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ struct JoystickCaps
|
|||
JoystickCaps()
|
||||
{
|
||||
buttonCount = 0;
|
||||
std::fill(axes, axes + Joystick::AxisCount, false);
|
||||
std::fill(std::begin(axes), std::end(axes), false);
|
||||
}
|
||||
|
||||
unsigned int buttonCount; ///< Number of buttons supported by the joystick
|
||||
bool axes[Joystick::AxisCount]; ///< Support for each axis
|
||||
bool axes[static_cast<size_t>(Joystick::Axis::Count)]; ///< Support for each axis
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,12 +64,12 @@ struct JoystickState
|
|||
JoystickState()
|
||||
{
|
||||
connected = false;
|
||||
std::fill(axes, axes + Joystick::AxisCount, 0.f);
|
||||
std::fill(std::begin(axes), std::end(axes), 0.f);
|
||||
std::fill(buttons, buttons + Joystick::ButtonCount, false);
|
||||
}
|
||||
|
||||
bool connected; ///< Is the joystick currently connected?
|
||||
float axes[Joystick::AxisCount]; ///< Position of each axis, in range [-100, 100]
|
||||
float axes[static_cast<size_t>(Joystick::Axis::Count)]; ///< Position of each axis, in range [-100, 100]
|
||||
bool buttons[Joystick::ButtonCount]; ///< Status of each button (true = pressed)
|
||||
};
|
||||
|
||||
|
|
|
@ -212,12 +212,12 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
bool m_isValid; ///< If any error occurs this variable is false
|
||||
CFDataRef m_layoutData; ///< CFData containing the layout
|
||||
UCKeyboardLayout* m_layout; ///< Current Keyboard Layout
|
||||
IOHIDManagerRef m_manager; ///< HID Manager
|
||||
bool m_isValid; ///< If any error occurs this variable is false
|
||||
CFDataRef m_layoutData; ///< CFData containing the layout
|
||||
UCKeyboardLayout* m_layout; ///< Current Keyboard Layout
|
||||
IOHIDManagerRef m_manager; ///< HID Manager
|
||||
|
||||
IOHIDElements m_keys[Keyboard::KeyCount]; ///< All the keys on any connected keyboard
|
||||
IOHIDElements m_keys[static_cast<size_t>(Keyboard::Key::Count)]; ///< All the keys on any connected keyboard
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// m_keys' index corresponds to sf::Keyboard::Key enum.
|
||||
|
|
|
@ -45,7 +45,7 @@ HIDInputManager& HIDInputManager::getInstance()
|
|||
////////////////////////////////////////////////////////////
|
||||
bool HIDInputManager::isKeyPressed(Keyboard::Key key)
|
||||
{
|
||||
return isPressed(m_keys[key]);
|
||||
return isPressed(m_keys[static_cast<size_t>(key)]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,7 +252,7 @@ void HIDInputManager::loadKey(IOHIDElementRef key)
|
|||
// Translation went fine
|
||||
|
||||
// The corresponding SFML key code
|
||||
Keyboard::Key code = Keyboard::Unknown; // KeyCound means 'none'
|
||||
Keyboard::Key code = Keyboard::Key::Unknown;
|
||||
|
||||
// First we look if the key down is from a list of characters
|
||||
// that depend on keyboard localization
|
||||
|
@ -261,18 +261,18 @@ void HIDInputManager::loadKey(IOHIDElementRef key)
|
|||
|
||||
// The key is not a localized one so we try to find a
|
||||
// corresponding code through virtual key code
|
||||
if (code == Keyboard::Unknown)
|
||||
if (code == Keyboard::Key::Unknown)
|
||||
code = nonLocalizedKeys(virtualCode);
|
||||
|
||||
// A code was found, wonderful!
|
||||
if (code != Keyboard::Unknown)
|
||||
if (code != Keyboard::Key::Unknown)
|
||||
{
|
||||
// Ok, everything went fine. Now we have a unique
|
||||
// corresponding sf::Keyboard::Key to one IOHIDElementRef
|
||||
m_keys[code].push_back(key);
|
||||
m_keys[static_cast<size_t>(code)].push_back(key);
|
||||
|
||||
// And don't forget to keep the reference alive for our usage
|
||||
CFRetain(m_keys[code].back());
|
||||
CFRetain(m_keys[static_cast<size_t>(code)].back());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
|
@ -317,12 +317,12 @@ void HIDInputManager::freeUp()
|
|||
if (m_manager != 0)
|
||||
CFRelease(m_manager);
|
||||
|
||||
for (unsigned int i = 0; i < Keyboard::KeyCount; ++i)
|
||||
for (auto& key : m_keys)
|
||||
{
|
||||
for (IOHIDElements::iterator it = m_keys[i].begin(); it != m_keys[i].end(); ++it)
|
||||
CFRelease(*it);
|
||||
for (auto& element : key)
|
||||
CFRelease(element);
|
||||
|
||||
m_keys[i].clear();
|
||||
key.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,85 +608,85 @@ Keyboard::Key HIDInputManager::localizedKeys(UniChar ch)
|
|||
switch (ch)
|
||||
{
|
||||
case 'a':
|
||||
case 'A': return sf::Keyboard::A;
|
||||
case 'A': return sf::Keyboard::Key::A;
|
||||
|
||||
case 'b':
|
||||
case 'B': return sf::Keyboard::B;
|
||||
case 'B': return sf::Keyboard::Key::B;
|
||||
|
||||
case 'c':
|
||||
case 'C': return sf::Keyboard::C;
|
||||
case 'C': return sf::Keyboard::Key::C;
|
||||
|
||||
case 'd':
|
||||
case 'D': return sf::Keyboard::D;
|
||||
case 'D': return sf::Keyboard::Key::D;
|
||||
|
||||
case 'e':
|
||||
case 'E': return sf::Keyboard::E;
|
||||
case 'E': return sf::Keyboard::Key::E;
|
||||
|
||||
case 'f':
|
||||
case 'F': return sf::Keyboard::F;
|
||||
case 'F': return sf::Keyboard::Key::F;
|
||||
|
||||
case 'g':
|
||||
case 'G': return sf::Keyboard::G;
|
||||
case 'G': return sf::Keyboard::Key::G;
|
||||
|
||||
case 'h':
|
||||
case 'H': return sf::Keyboard::H;
|
||||
case 'H': return sf::Keyboard::Key::H;
|
||||
|
||||
case 'i':
|
||||
case 'I': return sf::Keyboard::I;
|
||||
case 'I': return sf::Keyboard::Key::I;
|
||||
|
||||
case 'j':
|
||||
case 'J': return sf::Keyboard::J;
|
||||
case 'J': return sf::Keyboard::Key::J;
|
||||
|
||||
case 'k':
|
||||
case 'K': return sf::Keyboard::K;
|
||||
case 'K': return sf::Keyboard::Key::K;
|
||||
|
||||
case 'l':
|
||||
case 'L': return sf::Keyboard::L;
|
||||
case 'L': return sf::Keyboard::Key::L;
|
||||
|
||||
case 'm':
|
||||
case 'M': return sf::Keyboard::M;
|
||||
case 'M': return sf::Keyboard::Key::M;
|
||||
|
||||
case 'n':
|
||||
case 'N': return sf::Keyboard::N;
|
||||
case 'N': return sf::Keyboard::Key::N;
|
||||
|
||||
case 'o':
|
||||
case 'O': return sf::Keyboard::O;
|
||||
case 'O': return sf::Keyboard::Key::O;
|
||||
|
||||
case 'p':
|
||||
case 'P': return sf::Keyboard::P;
|
||||
case 'P': return sf::Keyboard::Key::P;
|
||||
|
||||
case 'q':
|
||||
case 'Q': return sf::Keyboard::Q;
|
||||
case 'Q': return sf::Keyboard::Key::Q;
|
||||
|
||||
case 'r':
|
||||
case 'R': return sf::Keyboard::R;
|
||||
case 'R': return sf::Keyboard::Key::R;
|
||||
|
||||
case 's':
|
||||
case 'S': return sf::Keyboard::S;
|
||||
case 'S': return sf::Keyboard::Key::S;
|
||||
|
||||
case 't':
|
||||
case 'T': return sf::Keyboard::T;
|
||||
case 'T': return sf::Keyboard::Key::T;
|
||||
|
||||
case 'u':
|
||||
case 'U': return sf::Keyboard::U;
|
||||
case 'U': return sf::Keyboard::Key::U;
|
||||
|
||||
case 'v':
|
||||
case 'V': return sf::Keyboard::V;
|
||||
case 'V': return sf::Keyboard::Key::V;
|
||||
|
||||
case 'w':
|
||||
case 'W': return sf::Keyboard::W;
|
||||
case 'W': return sf::Keyboard::Key::W;
|
||||
|
||||
case 'x':
|
||||
case 'X': return sf::Keyboard::X;
|
||||
case 'X': return sf::Keyboard::Key::X;
|
||||
|
||||
case 'y':
|
||||
case 'Y': return sf::Keyboard::Y;
|
||||
case 'Y': return sf::Keyboard::Key::Y;
|
||||
|
||||
case 'z':
|
||||
case 'Z': return sf::Keyboard::Z;
|
||||
case 'Z': return sf::Keyboard::Key::Z;
|
||||
|
||||
// The key is not 'localized'.
|
||||
default: return sf::Keyboard::Unknown;
|
||||
default: return sf::Keyboard::Key::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -699,167 +699,167 @@ Keyboard::Key HIDInputManager::nonLocalizedKeys(UniChar virtualKeycode)
|
|||
switch (virtualKeycode)
|
||||
{
|
||||
// These cases should not be used but anyway...
|
||||
case 0x00: return sf::Keyboard::A;
|
||||
case 0x0b: return sf::Keyboard::B;
|
||||
case 0x08: return sf::Keyboard::C;
|
||||
case 0x02: return sf::Keyboard::D;
|
||||
case 0x0e: return sf::Keyboard::E;
|
||||
case 0x03: return sf::Keyboard::F;
|
||||
case 0x05: return sf::Keyboard::G;
|
||||
case 0x04: return sf::Keyboard::H;
|
||||
case 0x22: return sf::Keyboard::I;
|
||||
case 0x26: return sf::Keyboard::J;
|
||||
case 0x28: return sf::Keyboard::K;
|
||||
case 0x25: return sf::Keyboard::L;
|
||||
case 0x2e: return sf::Keyboard::M;
|
||||
case 0x2d: return sf::Keyboard::N;
|
||||
case 0x1f: return sf::Keyboard::O;
|
||||
case 0x23: return sf::Keyboard::P;
|
||||
case 0x0c: return sf::Keyboard::Q;
|
||||
case 0x0f: return sf::Keyboard::R;
|
||||
case 0x01: return sf::Keyboard::S;
|
||||
case 0x11: return sf::Keyboard::T;
|
||||
case 0x20: return sf::Keyboard::U;
|
||||
case 0x09: return sf::Keyboard::V;
|
||||
case 0x0d: return sf::Keyboard::W;
|
||||
case 0x07: return sf::Keyboard::X;
|
||||
case 0x10: return sf::Keyboard::Y;
|
||||
case 0x06: return sf::Keyboard::Z;
|
||||
case 0x00: return sf::Keyboard::Key::A;
|
||||
case 0x0b: return sf::Keyboard::Key::B;
|
||||
case 0x08: return sf::Keyboard::Key::C;
|
||||
case 0x02: return sf::Keyboard::Key::D;
|
||||
case 0x0e: return sf::Keyboard::Key::E;
|
||||
case 0x03: return sf::Keyboard::Key::F;
|
||||
case 0x05: return sf::Keyboard::Key::G;
|
||||
case 0x04: return sf::Keyboard::Key::H;
|
||||
case 0x22: return sf::Keyboard::Key::I;
|
||||
case 0x26: return sf::Keyboard::Key::J;
|
||||
case 0x28: return sf::Keyboard::Key::K;
|
||||
case 0x25: return sf::Keyboard::Key::L;
|
||||
case 0x2e: return sf::Keyboard::Key::M;
|
||||
case 0x2d: return sf::Keyboard::Key::N;
|
||||
case 0x1f: return sf::Keyboard::Key::O;
|
||||
case 0x23: return sf::Keyboard::Key::P;
|
||||
case 0x0c: return sf::Keyboard::Key::Q;
|
||||
case 0x0f: return sf::Keyboard::Key::R;
|
||||
case 0x01: return sf::Keyboard::Key::S;
|
||||
case 0x11: return sf::Keyboard::Key::T;
|
||||
case 0x20: return sf::Keyboard::Key::U;
|
||||
case 0x09: return sf::Keyboard::Key::V;
|
||||
case 0x0d: return sf::Keyboard::Key::W;
|
||||
case 0x07: return sf::Keyboard::Key::X;
|
||||
case 0x10: return sf::Keyboard::Key::Y;
|
||||
case 0x06: return sf::Keyboard::Key::Z;
|
||||
|
||||
// These cases should not be used but anyway...
|
||||
case 0x1d: return sf::Keyboard::Num0;
|
||||
case 0x12: return sf::Keyboard::Num1;
|
||||
case 0x13: return sf::Keyboard::Num2;
|
||||
case 0x14: return sf::Keyboard::Num3;
|
||||
case 0x15: return sf::Keyboard::Num4;
|
||||
case 0x17: return sf::Keyboard::Num5;
|
||||
case 0x16: return sf::Keyboard::Num6;
|
||||
case 0x1a: return sf::Keyboard::Num7;
|
||||
case 0x1c: return sf::Keyboard::Num8;
|
||||
case 0x19: return sf::Keyboard::Num9;
|
||||
case 0x1d: return sf::Keyboard::Key::Num0;
|
||||
case 0x12: return sf::Keyboard::Key::Num1;
|
||||
case 0x13: return sf::Keyboard::Key::Num2;
|
||||
case 0x14: return sf::Keyboard::Key::Num3;
|
||||
case 0x15: return sf::Keyboard::Key::Num4;
|
||||
case 0x17: return sf::Keyboard::Key::Num5;
|
||||
case 0x16: return sf::Keyboard::Key::Num6;
|
||||
case 0x1a: return sf::Keyboard::Key::Num7;
|
||||
case 0x1c: return sf::Keyboard::Key::Num8;
|
||||
case 0x19: return sf::Keyboard::Key::Num9;
|
||||
|
||||
case 0x35: return sf::Keyboard::Escape;
|
||||
case 0x35: return sf::Keyboard::Key::Escape;
|
||||
|
||||
// Modifier keys : never happen with keyDown/keyUp methods (?)
|
||||
case 0x3b: return sf::Keyboard::LControl;
|
||||
case 0x38: return sf::Keyboard::LShift;
|
||||
case 0x3a: return sf::Keyboard::LAlt;
|
||||
case 0x37: return sf::Keyboard::LSystem;
|
||||
case 0x3e: return sf::Keyboard::RControl;
|
||||
case 0x3c: return sf::Keyboard::RShift;
|
||||
case 0x3d: return sf::Keyboard::RAlt;
|
||||
case 0x36: return sf::Keyboard::RSystem;
|
||||
case 0x3b: return sf::Keyboard::Key::LControl;
|
||||
case 0x38: return sf::Keyboard::Key::LShift;
|
||||
case 0x3a: return sf::Keyboard::Key::LAlt;
|
||||
case 0x37: return sf::Keyboard::Key::LSystem;
|
||||
case 0x3e: return sf::Keyboard::Key::RControl;
|
||||
case 0x3c: return sf::Keyboard::Key::RShift;
|
||||
case 0x3d: return sf::Keyboard::Key::RAlt;
|
||||
case 0x36: return sf::Keyboard::Key::RSystem;
|
||||
|
||||
case 0x7f: return sf::Keyboard::Menu;
|
||||
case NSMenuFunctionKey: return sf::Keyboard::Menu;
|
||||
case 0x7f: return sf::Keyboard::Key::Menu;
|
||||
case NSMenuFunctionKey: return sf::Keyboard::Key::Menu;
|
||||
|
||||
case 0x21: return sf::Keyboard::LBracket;
|
||||
case 0x1e: return sf::Keyboard::RBracket;
|
||||
case 0x29: return sf::Keyboard::SemiColon;
|
||||
case 0x2b: return sf::Keyboard::Comma;
|
||||
case 0x41: /* keypad */ return sf::Keyboard::Period;
|
||||
case 0x2f: /* keyboard */ return sf::Keyboard::Period;
|
||||
case 0x27: return sf::Keyboard::Quote;
|
||||
case 0x2c: return sf::Keyboard::Slash;
|
||||
case 0x2a: return sf::Keyboard::BackSlash;
|
||||
case 0x21: return sf::Keyboard::Key::LBracket;
|
||||
case 0x1e: return sf::Keyboard::Key::RBracket;
|
||||
case 0x29: return sf::Keyboard::Key::SemiColon;
|
||||
case 0x2b: return sf::Keyboard::Key::Comma;
|
||||
case 0x41: /* keypad */ return sf::Keyboard::Key::Period;
|
||||
case 0x2f: /* keyboard */ return sf::Keyboard::Key::Period;
|
||||
case 0x27: return sf::Keyboard::Key::Quote;
|
||||
case 0x2c: return sf::Keyboard::Key::Slash;
|
||||
case 0x2a: return sf::Keyboard::Key::BackSlash;
|
||||
|
||||
// sf::Keyboard::Tilde might be in conflict with some other key.
|
||||
// sf::Keyboard::Key::Tilde might be in conflict with some other key.
|
||||
// 0x0a is for "Non-US Backslash" according to HID Calibrator,
|
||||
// a sample provided by Apple.
|
||||
case 0x0a: return sf::Keyboard::Tilde;
|
||||
case 0x0a: return sf::Keyboard::Key::Tilde;
|
||||
|
||||
case 0x51: /* keypad */ return sf::Keyboard::Equal;
|
||||
case 0x18: /* keyboard */ return sf::Keyboard::Equal;
|
||||
case 0x32: return sf::Keyboard::Dash;
|
||||
case 0x31: return sf::Keyboard::Space;
|
||||
case 0x4c: /* keypad */ return sf::Keyboard::Return;
|
||||
case 0x24: /* keyboard */ return sf::Keyboard::Return;
|
||||
case 0x33: return sf::Keyboard::BackSpace;
|
||||
case 0x30: return sf::Keyboard::Tab;
|
||||
case 0x51: /* keypad */ return sf::Keyboard::Key::Equal;
|
||||
case 0x18: /* keyboard */ return sf::Keyboard::Key::Equal;
|
||||
case 0x32: return sf::Keyboard::Key::Dash;
|
||||
case 0x31: return sf::Keyboard::Key::Space;
|
||||
case 0x4c: /* keypad */ return sf::Keyboard::Key::Return;
|
||||
case 0x24: /* keyboard */ return sf::Keyboard::Key::Return;
|
||||
case 0x33: return sf::Keyboard::Key::BackSpace;
|
||||
case 0x30: return sf::Keyboard::Key::Tab;
|
||||
|
||||
// Duplicates (see next section).
|
||||
case 0x74: return sf::Keyboard::PageUp;
|
||||
case 0x79: return sf::Keyboard::PageDown;
|
||||
case 0x77: return sf::Keyboard::End;
|
||||
case 0x73: return sf::Keyboard::Home;
|
||||
case 0x74: return sf::Keyboard::Key::PageUp;
|
||||
case 0x79: return sf::Keyboard::Key::PageDown;
|
||||
case 0x77: return sf::Keyboard::Key::End;
|
||||
case 0x73: return sf::Keyboard::Key::Home;
|
||||
|
||||
case NSPageUpFunctionKey: return sf::Keyboard::PageUp;
|
||||
case NSPageDownFunctionKey: return sf::Keyboard::PageDown;
|
||||
case NSEndFunctionKey: return sf::Keyboard::End;
|
||||
case NSHomeFunctionKey: return sf::Keyboard::Home;
|
||||
case NSPageUpFunctionKey: return sf::Keyboard::Key::PageUp;
|
||||
case NSPageDownFunctionKey: return sf::Keyboard::Key::PageDown;
|
||||
case NSEndFunctionKey: return sf::Keyboard::Key::End;
|
||||
case NSHomeFunctionKey: return sf::Keyboard::Key::Home;
|
||||
|
||||
case 0x72: return sf::Keyboard::Insert;
|
||||
case NSInsertFunctionKey: return sf::Keyboard::Insert;
|
||||
case 0x75: return sf::Keyboard::Delete;
|
||||
case NSDeleteFunctionKey: return sf::Keyboard::Delete;
|
||||
case 0x72: return sf::Keyboard::Key::Insert;
|
||||
case NSInsertFunctionKey: return sf::Keyboard::Key::Insert;
|
||||
case 0x75: return sf::Keyboard::Key::Delete;
|
||||
case NSDeleteFunctionKey: return sf::Keyboard::Key::Delete;
|
||||
|
||||
case 0x45: return sf::Keyboard::Add;
|
||||
case 0x4e: return sf::Keyboard::Subtract;
|
||||
case 0x43: return sf::Keyboard::Multiply;
|
||||
case 0x4b: return sf::Keyboard::Divide;
|
||||
case 0x45: return sf::Keyboard::Key::Add;
|
||||
case 0x4e: return sf::Keyboard::Key::Subtract;
|
||||
case 0x43: return sf::Keyboard::Key::Multiply;
|
||||
case 0x4b: return sf::Keyboard::Key::Divide;
|
||||
|
||||
// Duplicates (see next section).
|
||||
case 0x7b: return sf::Keyboard::Left;
|
||||
case 0x7c: return sf::Keyboard::Right;
|
||||
case 0x7e: return sf::Keyboard::Up;
|
||||
case 0x7d: return sf::Keyboard::Down;
|
||||
case 0x7b: return sf::Keyboard::Key::Left;
|
||||
case 0x7c: return sf::Keyboard::Key::Right;
|
||||
case 0x7e: return sf::Keyboard::Key::Up;
|
||||
case 0x7d: return sf::Keyboard::Key::Down;
|
||||
|
||||
case NSLeftArrowFunctionKey: return sf::Keyboard::Left;
|
||||
case NSRightArrowFunctionKey: return sf::Keyboard::Right;
|
||||
case NSUpArrowFunctionKey: return sf::Keyboard::Up;
|
||||
case NSDownArrowFunctionKey: return sf::Keyboard::Down;
|
||||
case NSLeftArrowFunctionKey: return sf::Keyboard::Key::Left;
|
||||
case NSRightArrowFunctionKey: return sf::Keyboard::Key::Right;
|
||||
case NSUpArrowFunctionKey: return sf::Keyboard::Key::Up;
|
||||
case NSDownArrowFunctionKey: return sf::Keyboard::Key::Down;
|
||||
|
||||
case 0x52: return sf::Keyboard::Numpad0;
|
||||
case 0x53: return sf::Keyboard::Numpad1;
|
||||
case 0x54: return sf::Keyboard::Numpad2;
|
||||
case 0x55: return sf::Keyboard::Numpad3;
|
||||
case 0x56: return sf::Keyboard::Numpad4;
|
||||
case 0x57: return sf::Keyboard::Numpad5;
|
||||
case 0x58: return sf::Keyboard::Numpad6;
|
||||
case 0x59: return sf::Keyboard::Numpad7;
|
||||
case 0x5b: return sf::Keyboard::Numpad8;
|
||||
case 0x5c: return sf::Keyboard::Numpad9;
|
||||
case 0x52: return sf::Keyboard::Key::Numpad0;
|
||||
case 0x53: return sf::Keyboard::Key::Numpad1;
|
||||
case 0x54: return sf::Keyboard::Key::Numpad2;
|
||||
case 0x55: return sf::Keyboard::Key::Numpad3;
|
||||
case 0x56: return sf::Keyboard::Key::Numpad4;
|
||||
case 0x57: return sf::Keyboard::Key::Numpad5;
|
||||
case 0x58: return sf::Keyboard::Key::Numpad6;
|
||||
case 0x59: return sf::Keyboard::Key::Numpad7;
|
||||
case 0x5b: return sf::Keyboard::Key::Numpad8;
|
||||
case 0x5c: return sf::Keyboard::Key::Numpad9;
|
||||
|
||||
// Duplicates (see next section).
|
||||
case 0x7a: return sf::Keyboard::F1;
|
||||
case 0x78: return sf::Keyboard::F2;
|
||||
case 0x63: return sf::Keyboard::F3;
|
||||
case 0x76: return sf::Keyboard::F4;
|
||||
case 0x60: return sf::Keyboard::F5;
|
||||
case 0x61: return sf::Keyboard::F6;
|
||||
case 0x62: return sf::Keyboard::F7;
|
||||
case 0x64: return sf::Keyboard::F8;
|
||||
case 0x65: return sf::Keyboard::F9;
|
||||
case 0x6d: return sf::Keyboard::F10;
|
||||
case 0x67: return sf::Keyboard::F11;
|
||||
case 0x6f: return sf::Keyboard::F12;
|
||||
case 0x69: return sf::Keyboard::F13;
|
||||
case 0x6b: return sf::Keyboard::F14;
|
||||
case 0x71: return sf::Keyboard::F15;
|
||||
case 0x7a: return sf::Keyboard::Key::F1;
|
||||
case 0x78: return sf::Keyboard::Key::F2;
|
||||
case 0x63: return sf::Keyboard::Key::F3;
|
||||
case 0x76: return sf::Keyboard::Key::F4;
|
||||
case 0x60: return sf::Keyboard::Key::F5;
|
||||
case 0x61: return sf::Keyboard::Key::F6;
|
||||
case 0x62: return sf::Keyboard::Key::F7;
|
||||
case 0x64: return sf::Keyboard::Key::F8;
|
||||
case 0x65: return sf::Keyboard::Key::F9;
|
||||
case 0x6d: return sf::Keyboard::Key::F10;
|
||||
case 0x67: return sf::Keyboard::Key::F11;
|
||||
case 0x6f: return sf::Keyboard::Key::F12;
|
||||
case 0x69: return sf::Keyboard::Key::F13;
|
||||
case 0x6b: return sf::Keyboard::Key::F14;
|
||||
case 0x71: return sf::Keyboard::Key::F15;
|
||||
|
||||
case NSF1FunctionKey: return sf::Keyboard::F1;
|
||||
case NSF2FunctionKey: return sf::Keyboard::F2;
|
||||
case NSF3FunctionKey: return sf::Keyboard::F3;
|
||||
case NSF4FunctionKey: return sf::Keyboard::F4;
|
||||
case NSF5FunctionKey: return sf::Keyboard::F5;
|
||||
case NSF6FunctionKey: return sf::Keyboard::F6;
|
||||
case NSF7FunctionKey: return sf::Keyboard::F7;
|
||||
case NSF8FunctionKey: return sf::Keyboard::F8;
|
||||
case NSF9FunctionKey: return sf::Keyboard::F9;
|
||||
case NSF10FunctionKey: return sf::Keyboard::F10;
|
||||
case NSF11FunctionKey: return sf::Keyboard::F11;
|
||||
case NSF12FunctionKey: return sf::Keyboard::F12;
|
||||
case NSF13FunctionKey: return sf::Keyboard::F13;
|
||||
case NSF14FunctionKey: return sf::Keyboard::F14;
|
||||
case NSF15FunctionKey: return sf::Keyboard::F15;
|
||||
case NSF1FunctionKey: return sf::Keyboard::Key::F1;
|
||||
case NSF2FunctionKey: return sf::Keyboard::Key::F2;
|
||||
case NSF3FunctionKey: return sf::Keyboard::Key::F3;
|
||||
case NSF4FunctionKey: return sf::Keyboard::Key::F4;
|
||||
case NSF5FunctionKey: return sf::Keyboard::Key::F5;
|
||||
case NSF6FunctionKey: return sf::Keyboard::Key::F6;
|
||||
case NSF7FunctionKey: return sf::Keyboard::Key::F7;
|
||||
case NSF8FunctionKey: return sf::Keyboard::Key::F8;
|
||||
case NSF9FunctionKey: return sf::Keyboard::Key::F9;
|
||||
case NSF10FunctionKey: return sf::Keyboard::Key::F10;
|
||||
case NSF11FunctionKey: return sf::Keyboard::Key::F11;
|
||||
case NSF12FunctionKey: return sf::Keyboard::Key::F12;
|
||||
case NSF13FunctionKey: return sf::Keyboard::Key::F13;
|
||||
case NSF14FunctionKey: return sf::Keyboard::Key::F14;
|
||||
case NSF15FunctionKey: return sf::Keyboard::Key::F15;
|
||||
|
||||
case NSPauseFunctionKey: return sf::Keyboard::Pause;
|
||||
case NSPauseFunctionKey: return sf::Keyboard::Key::Pause;
|
||||
|
||||
// keycode 0x1b is not bound to any key.
|
||||
// This key is ' on CH-FR, ) on FR and - on US layouts.
|
||||
|
||||
// An unknown key.
|
||||
default: return sf::Keyboard::Unknown;
|
||||
default: return sf::Keyboard::Key::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ void InputImpl::setVirtualKeyboardVisible(bool /*visible*/)
|
|||
bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
||||
{
|
||||
NSUInteger state = [NSEvent pressedMouseButtons];
|
||||
NSUInteger flag = 1 << button;
|
||||
NSUInteger flag = 1 << static_cast<size_t>(button);
|
||||
return (state & flag) != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -249,12 +249,12 @@ bool JoystickImpl::open(unsigned int index)
|
|||
case kIOHIDElementTypeInput_Misc:
|
||||
switch (IOHIDElementGetUsage(element))
|
||||
{
|
||||
case kHIDUsage_GD_X: m_axis[Joystick::X] = element; break;
|
||||
case kHIDUsage_GD_Y: m_axis[Joystick::Y] = element; break;
|
||||
case kHIDUsage_GD_Z: m_axis[Joystick::Z] = element; break;
|
||||
case kHIDUsage_GD_Rx: m_axis[Joystick::U] = element; break;
|
||||
case kHIDUsage_GD_Ry: m_axis[Joystick::V] = element; break;
|
||||
case kHIDUsage_GD_Rz: m_axis[Joystick::R] = element; break;
|
||||
case kHIDUsage_GD_X: m_axis[Joystick::Axis::X] = element; break;
|
||||
case kHIDUsage_GD_Y: m_axis[Joystick::Axis::Y] = element; break;
|
||||
case kHIDUsage_GD_Z: m_axis[Joystick::Axis::Z] = element; break;
|
||||
case kHIDUsage_GD_Rx: m_axis[Joystick::Axis::U] = element; break;
|
||||
case kHIDUsage_GD_Ry: m_axis[Joystick::Axis::V] = element; break;
|
||||
case kHIDUsage_GD_Rz: m_axis[Joystick::Axis::R] = element; break;
|
||||
default: break;
|
||||
// kHIDUsage_GD_Vx, kHIDUsage_GD_Vy, kHIDUsage_GD_Vz are ignored.
|
||||
}
|
||||
|
@ -281,8 +281,8 @@ bool JoystickImpl::open(unsigned int index)
|
|||
// Retain all these objects for personal use
|
||||
for (ButtonsVector::iterator it(m_buttons.begin()); it != m_buttons.end(); ++it)
|
||||
CFRetain(*it);
|
||||
for (AxisMap::iterator it(m_axis.begin()); it != m_axis.end(); ++it)
|
||||
CFRetain(it->second);
|
||||
for (auto& axis : m_axis)
|
||||
CFRetain(axis.second);
|
||||
|
||||
// Note: we didn't retain element in the switch because we might have multiple
|
||||
// Axis X (for example) and we want to keep only the last one. So to prevent
|
||||
|
@ -302,8 +302,8 @@ void JoystickImpl::close()
|
|||
CFRelease(*it);
|
||||
m_buttons.clear();
|
||||
|
||||
for (AxisMap::iterator it(m_axis.begin()); it != m_axis.end(); ++it)
|
||||
CFRelease(it->second);
|
||||
for (auto& axis : m_axis)
|
||||
CFRelease(axis.second);
|
||||
m_axis.clear();
|
||||
|
||||
// And we unregister this joystick
|
||||
|
@ -320,8 +320,8 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||
caps.buttonCount = m_buttons.size();
|
||||
|
||||
// Axis:
|
||||
for (AxisMap::const_iterator it(m_axis.begin()); it != m_axis.end(); ++it) {
|
||||
caps.axes[it->first] = true;
|
||||
for (const auto& axis : m_axis) {
|
||||
caps.axes[static_cast<size_t>(axis.first)] = true;
|
||||
}
|
||||
|
||||
return caps;
|
||||
|
@ -339,7 +339,7 @@ Joystick::Identification JoystickImpl::getIdentification() const
|
|||
JoystickState JoystickImpl::update()
|
||||
{
|
||||
static const JoystickState disconnectedState; // return this if joystick was disconnected
|
||||
JoystickState state; // otherwise return that
|
||||
JoystickState state; // otherwise return that
|
||||
state.connected = true;
|
||||
|
||||
// Note: free up is done in close() which is called, if required,
|
||||
|
@ -396,10 +396,10 @@ JoystickState JoystickImpl::update()
|
|||
}
|
||||
|
||||
// Update axes' state
|
||||
for (AxisMap::iterator it = m_axis.begin(); it != m_axis.end(); ++it)
|
||||
for (auto& axis : m_axis)
|
||||
{
|
||||
IOHIDValueRef value = 0;
|
||||
IOHIDDeviceGetValue(IOHIDElementGetDevice(it->second), it->second, &value);
|
||||
IOHIDDeviceGetValue(IOHIDElementGetDevice(axis.second), axis.second, &value);
|
||||
|
||||
// Check for plug out.
|
||||
if (!value)
|
||||
|
@ -418,13 +418,13 @@ JoystickState JoystickImpl::update()
|
|||
// This method might not be very accurate (the "0 position" can be
|
||||
// slightly shift with some device) but we don't care because most
|
||||
// of devices are so sensitive that this is not relevant.
|
||||
double physicalMax = IOHIDElementGetPhysicalMax(it->second);
|
||||
double physicalMin = IOHIDElementGetPhysicalMin(it->second);
|
||||
double physicalMax = IOHIDElementGetPhysicalMax(axis.second);
|
||||
double physicalMin = IOHIDElementGetPhysicalMin(axis.second);
|
||||
double scaledMin = -100;
|
||||
double scaledMax = 100;
|
||||
double physicalValue = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical);
|
||||
float scaledValue = (((physicalValue - physicalMin) * (scaledMax - scaledMin)) / (physicalMax - physicalMin)) + scaledMin;
|
||||
state.axes[it->first] = scaledValue;
|
||||
state.axes[static_cast<size_t>(axis.first)] = scaledValue;
|
||||
}
|
||||
|
||||
return state;
|
||||
|
|
|
@ -157,7 +157,7 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
|
|||
modifiers,
|
||||
NSLeftShiftKeyMask, NSRightShiftKeyMask,
|
||||
state.leftShiftWasDown, state.rightShiftWasDown,
|
||||
sf::Keyboard::LShift, sf::Keyboard::RShift,
|
||||
sf::Keyboard::Key::LShift, sf::Keyboard::Key::RShift,
|
||||
requester
|
||||
);
|
||||
|
||||
|
@ -166,7 +166,7 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
|
|||
modifiers,
|
||||
NSLeftCommandKeyMask, NSRightCommandKeyMask,
|
||||
state.leftCommandWasDown, state.rightCommandWasDown,
|
||||
sf::Keyboard::LSystem, sf::Keyboard::RSystem,
|
||||
sf::Keyboard::Key::LSystem, sf::Keyboard::Key::RSystem,
|
||||
requester
|
||||
);
|
||||
|
||||
|
@ -175,7 +175,7 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
|
|||
modifiers,
|
||||
NSLeftAlternateKeyMask, NSRightAlternateKeyMask,
|
||||
state.leftAlternateWasDown, state.rightAlternateWasDown,
|
||||
sf::Keyboard::LAlt, sf::Keyboard::RAlt,
|
||||
sf::Keyboard::Key::LAlt, sf::Keyboard::Key::RAlt,
|
||||
requester
|
||||
);
|
||||
|
||||
|
@ -184,7 +184,7 @@ void handleModifiersChanged(NSUInteger modifiers, sf::priv::WindowImplCocoa& req
|
|||
modifiers,
|
||||
NSLeftControlKeyMask, NSRightControlKeyMask,
|
||||
state.leftControlWasDown, state.rightControlWasDown,
|
||||
sf::Keyboard::LControl, sf::Keyboard::RControl,
|
||||
sf::Keyboard::Key::LControl, sf::Keyboard::Key::RControl,
|
||||
requester
|
||||
);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
{
|
||||
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
|
||||
|
||||
if (key.code != sf::Keyboard::Unknown) // The key is recognized.
|
||||
if (key.code != sf::Keyboard::Key::Unknown) // The key is recognized.
|
||||
m_requester->keyDown(key);
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@
|
|||
|
||||
sf::Event::KeyEvent key = [SFOpenGLView convertNSKeyEventToSFMLEvent:theEvent];
|
||||
|
||||
if (key.code != sf::Keyboard::Unknown) // The key is recognized.
|
||||
if (key.code != sf::Keyboard::Key::Unknown) // The key is recognized.
|
||||
m_requester->keyUp(key);
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@
|
|||
+(sf::Event::KeyEvent)convertNSKeyEventToSFMLEvent:(NSEvent*)event
|
||||
{
|
||||
// Key code
|
||||
sf::Keyboard::Key key = sf::Keyboard::Unknown;
|
||||
sf::Keyboard::Key key = sf::Keyboard::Key::Unknown;
|
||||
|
||||
// First we look if the key down is from a list of characters
|
||||
// that depend on keyboard localization.
|
||||
|
@ -191,7 +191,7 @@
|
|||
|
||||
// If the key is not a localized one, we try to find a corresponding code
|
||||
// through virtual key code.
|
||||
if (key == sf::Keyboard::Unknown)
|
||||
if (key == sf::Keyboard::Key::Unknown)
|
||||
key = sf::priv::HIDInputManager::nonLocalizedKeys([event keyCode]);
|
||||
|
||||
return keyEventWithModifiers([event modifierFlags], key);
|
||||
|
|
|
@ -116,7 +116,7 @@
|
|||
{
|
||||
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
||||
|
||||
if (button != sf::Mouse::ButtonCount)
|
||||
if (button != sf::Mouse::Button::Count)
|
||||
m_requester->mouseDownAt(button, loc.x, loc.y);
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@
|
|||
{
|
||||
NSPoint loc = [self cursorPositionFromEvent:theEvent];
|
||||
|
||||
if (button != sf::Mouse::ButtonCount)
|
||||
if (button != sf::Mouse::Button::Count)
|
||||
m_requester->mouseUpAt(button, loc.x, loc.y);
|
||||
}
|
||||
}
|
||||
|
@ -389,12 +389,12 @@
|
|||
{
|
||||
switch ([event buttonNumber])
|
||||
{
|
||||
case 0: return sf::Mouse::Left;
|
||||
case 1: return sf::Mouse::Right;
|
||||
case 2: return sf::Mouse::Middle;
|
||||
case 3: return sf::Mouse::XButton1;
|
||||
case 4: return sf::Mouse::XButton2;
|
||||
default: return sf::Mouse::ButtonCount; // Never happens! (hopefully)
|
||||
case 0: return sf::Mouse::Button::Left;
|
||||
case 1: return sf::Mouse::Button::Right;
|
||||
case 2: return sf::Mouse::Button::Middle;
|
||||
case 3: return sf::Mouse::Button::XButton1;
|
||||
case 4: return sf::Mouse::Button::XButton2;
|
||||
default: return sf::Mouse::Button::Count; // Never happens! (hopefully)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ void WindowImplCocoa::setUpProcess(void)
|
|||
void WindowImplCocoa::windowClosed(void)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::Closed;
|
||||
event.type = Event::Type::Closed;
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ void WindowImplCocoa::windowClosed(void)
|
|||
void WindowImplCocoa::windowResized(unsigned int width, unsigned int height)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::Resized;
|
||||
event.type = Event::Type::Resized;
|
||||
event.size.width = width;
|
||||
event.size.height = height;
|
||||
scaleOutWidthHeight(event.size, m_delegate);
|
||||
|
@ -235,7 +235,7 @@ void WindowImplCocoa::windowLostFocus(void)
|
|||
showMouseCursor(); // Make sure the cursor is visible
|
||||
|
||||
Event event;
|
||||
event.type = Event::LostFocus;
|
||||
event.type = Event::Type::LostFocus;
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ void WindowImplCocoa::windowGainedFocus(void)
|
|||
hideMouseCursor(); // Restore user's setting
|
||||
|
||||
Event event;
|
||||
event.type = Event::GainedFocus;
|
||||
event.type = Event::Type::GainedFocus;
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ void WindowImplCocoa::windowGainedFocus(void)
|
|||
void WindowImplCocoa::mouseDownAt(Mouse::Button button, int x, int y)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = button;
|
||||
event.mouseButton.x = x;
|
||||
event.mouseButton.y = y;
|
||||
|
@ -275,7 +275,7 @@ void WindowImplCocoa::mouseDownAt(Mouse::Button button, int x, int y)
|
|||
void WindowImplCocoa::mouseUpAt(Mouse::Button button, int x, int y)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = button;
|
||||
event.mouseButton.x = x;
|
||||
event.mouseButton.y = y;
|
||||
|
@ -289,7 +289,7 @@ void WindowImplCocoa::mouseUpAt(Mouse::Button button, int x, int y)
|
|||
void WindowImplCocoa::mouseMovedAt(int x, int y)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseMoved;
|
||||
event.type = Event::Type::MouseMoved;
|
||||
event.mouseMove.x = x;
|
||||
event.mouseMove.y = y;
|
||||
scaleOutXY(event.mouseMove, m_delegate);
|
||||
|
@ -302,23 +302,23 @@ void WindowImplCocoa::mouseWheelScrolledAt(float deltaX, float deltaY, int x, in
|
|||
{
|
||||
Event event;
|
||||
|
||||
event.type = Event::MouseWheelMoved;
|
||||
event.type = Event::Type::MouseWheelMoved;
|
||||
event.mouseWheel.delta = deltaY;
|
||||
event.mouseWheel.x = x;
|
||||
event.mouseWheel.y = y;
|
||||
scaleOutXY(event.mouseWheel, m_delegate);
|
||||
pushEvent(event);
|
||||
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::VerticalWheel;
|
||||
event.mouseWheelScroll.delta = deltaY;
|
||||
event.mouseWheelScroll.x = x;
|
||||
event.mouseWheelScroll.y = y;
|
||||
scaleOutXY(event.mouseWheelScroll, m_delegate);
|
||||
pushEvent(event);
|
||||
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::HorizontalWheel;
|
||||
event.mouseWheelScroll.delta = deltaX;
|
||||
event.mouseWheelScroll.x = x;
|
||||
event.mouseWheelScroll.y = y;
|
||||
|
@ -333,7 +333,7 @@ void WindowImplCocoa::mouseMovedIn(void)
|
|||
hideMouseCursor(); // Restore user's setting
|
||||
|
||||
Event event;
|
||||
event.type = Event::MouseEntered;
|
||||
event.type = Event::Type::MouseEntered;
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ void WindowImplCocoa::mouseMovedOut(void)
|
|||
showMouseCursor(); // Make sure the cursor is visible
|
||||
|
||||
Event event;
|
||||
event.type = Event::MouseLeft;
|
||||
event.type = Event::Type::MouseLeft;
|
||||
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -359,7 +359,7 @@ void WindowImplCocoa::mouseMovedOut(void)
|
|||
void WindowImplCocoa::keyDown(Event::KeyEvent key)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::KeyPressed;
|
||||
event.type = Event::Type::KeyPressed;
|
||||
event.key = key;
|
||||
|
||||
pushEvent(event);
|
||||
|
@ -370,7 +370,7 @@ void WindowImplCocoa::keyDown(Event::KeyEvent key)
|
|||
void WindowImplCocoa::keyUp(Event::KeyEvent key)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::KeyReleased;
|
||||
event.type = Event::Type::KeyReleased;
|
||||
event.key = key;
|
||||
|
||||
pushEvent(event);
|
||||
|
@ -381,7 +381,7 @@ void WindowImplCocoa::keyUp(Event::KeyEvent key)
|
|||
void WindowImplCocoa::textEntered(unichar charcode)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::TextEntered;
|
||||
event.type = Event::Type::TextEntered;
|
||||
event.text.unicode = charcode;
|
||||
|
||||
pushEvent(event);
|
||||
|
|
|
@ -44,17 +44,17 @@ SensorManager& SensorManager::getInstance()
|
|||
////////////////////////////////////////////////////////////
|
||||
bool SensorManager::isAvailable(Sensor::Type sensor)
|
||||
{
|
||||
return m_sensors[sensor].available;
|
||||
return m_sensors[static_cast<size_t>(sensor)].available;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorManager::setEnabled(Sensor::Type sensor, bool enabled)
|
||||
{
|
||||
if (m_sensors[sensor].available)
|
||||
if (m_sensors[static_cast<size_t>(sensor)].available)
|
||||
{
|
||||
m_sensors[sensor].enabled = enabled;
|
||||
m_sensors[sensor].sensor.setEnabled(enabled);
|
||||
m_sensors[static_cast<size_t>(sensor)].enabled = enabled;
|
||||
m_sensors[static_cast<size_t>(sensor)].sensor.setEnabled(enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -66,25 +66,25 @@ void SensorManager::setEnabled(Sensor::Type sensor, bool enabled)
|
|||
////////////////////////////////////////////////////////////
|
||||
bool SensorManager::isEnabled(Sensor::Type sensor) const
|
||||
{
|
||||
return m_sensors[sensor].enabled;
|
||||
return m_sensors[static_cast<size_t>(sensor)].enabled;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
Vector3f SensorManager::getValue(Sensor::Type sensor) const
|
||||
{
|
||||
return m_sensors[sensor].value;
|
||||
return m_sensors[static_cast<size_t>(sensor)].value;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
void SensorManager::update()
|
||||
{
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
for (auto& sensor : m_sensors)
|
||||
{
|
||||
// Only process available sensors
|
||||
if (m_sensors[i].available)
|
||||
m_sensors[i].value = m_sensors[i].sensor.update();
|
||||
if (sensor.available)
|
||||
sensor.value = sensor.sensor.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ SensorManager::SensorManager()
|
|||
SensorImpl::initialize();
|
||||
|
||||
// Per sensor initialization
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
for (auto i = 0u; i < static_cast<size_t>(Sensor::Type::Count); ++i)
|
||||
{
|
||||
// Check which sensors are available
|
||||
m_sensors[i].available = SensorImpl::isAvailable(static_cast<Sensor::Type>(i));
|
||||
|
@ -114,10 +114,10 @@ SensorManager::SensorManager()
|
|||
SensorManager::~SensorManager()
|
||||
{
|
||||
// Per sensor cleanup
|
||||
for (int i = 0; i < Sensor::Count; ++i)
|
||||
for (auto& sensor : m_sensors)
|
||||
{
|
||||
if (m_sensors[i].available)
|
||||
m_sensors[i].sensor.close();
|
||||
if (sensor.available)
|
||||
sensor.sensor.close();
|
||||
}
|
||||
|
||||
// Global sensor cleanup
|
||||
|
|
|
@ -127,7 +127,7 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
Item m_sensors[Sensor::Count]; ///< Sensors information and state
|
||||
Item m_sensors[static_cast<size_t>(Sensor::Type::Count)]; ///< Sensors information and state
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -44,114 +44,110 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
|||
KeySym keysym = 0;
|
||||
switch (key)
|
||||
{
|
||||
case Keyboard::LShift: keysym = XK_Shift_L; break;
|
||||
case Keyboard::RShift: keysym = XK_Shift_R; break;
|
||||
case Keyboard::LControl: keysym = XK_Control_L; break;
|
||||
case Keyboard::RControl: keysym = XK_Control_R; break;
|
||||
case Keyboard::LAlt: keysym = XK_Alt_L; break;
|
||||
case Keyboard::RAlt: keysym = XK_Alt_R; break;
|
||||
case Keyboard::LSystem: keysym = XK_Super_L; break;
|
||||
case Keyboard::RSystem: keysym = XK_Super_R; break;
|
||||
case Keyboard::Menu: keysym = XK_Menu; break;
|
||||
case Keyboard::Escape: keysym = XK_Escape; break;
|
||||
case Keyboard::SemiColon: keysym = XK_semicolon; break;
|
||||
case Keyboard::Slash: keysym = XK_slash; break;
|
||||
case Keyboard::Equal: keysym = XK_equal; break;
|
||||
case Keyboard::Dash: keysym = XK_minus; break;
|
||||
case Keyboard::LBracket: keysym = XK_bracketleft; break;
|
||||
case Keyboard::RBracket: keysym = XK_bracketright; break;
|
||||
case Keyboard::Comma: keysym = XK_comma; break;
|
||||
case Keyboard::Period: keysym = XK_period; break;
|
||||
case Keyboard::Quote: keysym = XK_apostrophe; break;
|
||||
case Keyboard::BackSlash: keysym = XK_backslash; break;
|
||||
case Keyboard::Tilde: keysym = XK_grave; break;
|
||||
case Keyboard::Space: keysym = XK_space; break;
|
||||
case Keyboard::Return: keysym = XK_Return; break;
|
||||
case Keyboard::BackSpace: keysym = XK_BackSpace; break;
|
||||
case Keyboard::Tab: keysym = XK_Tab; break;
|
||||
case Keyboard::PageUp: keysym = XK_Prior; break;
|
||||
case Keyboard::PageDown: keysym = XK_Next; break;
|
||||
case Keyboard::End: keysym = XK_End; break;
|
||||
case Keyboard::Home: keysym = XK_Home; break;
|
||||
case Keyboard::Insert: keysym = XK_Insert; break;
|
||||
case Keyboard::Delete: keysym = XK_Delete; break;
|
||||
case Keyboard::Add: keysym = XK_KP_Add; break;
|
||||
case Keyboard::Subtract: keysym = XK_KP_Subtract; break;
|
||||
case Keyboard::Multiply: keysym = XK_KP_Multiply; break;
|
||||
case Keyboard::Divide: keysym = XK_KP_Divide; break;
|
||||
case Keyboard::Pause: keysym = XK_Pause; break;
|
||||
case Keyboard::F1: keysym = XK_F1; break;
|
||||
case Keyboard::F2: keysym = XK_F2; break;
|
||||
case Keyboard::F3: keysym = XK_F3; break;
|
||||
case Keyboard::F4: keysym = XK_F4; break;
|
||||
case Keyboard::F5: keysym = XK_F5; break;
|
||||
case Keyboard::F6: keysym = XK_F6; break;
|
||||
case Keyboard::F7: keysym = XK_F7; break;
|
||||
case Keyboard::F8: keysym = XK_F8; break;
|
||||
case Keyboard::F9: keysym = XK_F9; break;
|
||||
case Keyboard::F10: keysym = XK_F10; break;
|
||||
case Keyboard::F11: keysym = XK_F11; break;
|
||||
case Keyboard::F12: keysym = XK_F12; break;
|
||||
case Keyboard::F13: keysym = XK_F13; break;
|
||||
case Keyboard::F14: keysym = XK_F14; break;
|
||||
case Keyboard::F15: keysym = XK_F15; break;
|
||||
case Keyboard::Left: keysym = XK_Left; break;
|
||||
case Keyboard::Right: keysym = XK_Right; break;
|
||||
case Keyboard::Up: keysym = XK_Up; break;
|
||||
case Keyboard::Down: keysym = XK_Down; break;
|
||||
case Keyboard::Numpad0: keysym = XK_KP_Insert; break;
|
||||
case Keyboard::Numpad1: keysym = XK_KP_End; break;
|
||||
case Keyboard::Numpad2: keysym = XK_KP_Down; break;
|
||||
case Keyboard::Numpad3: keysym = XK_KP_Page_Down; break;
|
||||
case Keyboard::Numpad4: keysym = XK_KP_Left; break;
|
||||
case Keyboard::Numpad5: keysym = XK_KP_Begin; break;
|
||||
case Keyboard::Numpad6: keysym = XK_KP_Right; break;
|
||||
case Keyboard::Numpad7: keysym = XK_KP_Home; break;
|
||||
case Keyboard::Numpad8: keysym = XK_KP_Up; break;
|
||||
case Keyboard::Numpad9: keysym = XK_KP_Page_Up; break;
|
||||
case Keyboard::A: keysym = XK_a; break;
|
||||
case Keyboard::B: keysym = XK_b; break;
|
||||
case Keyboard::C: keysym = XK_c; break;
|
||||
case Keyboard::D: keysym = XK_d; break;
|
||||
case Keyboard::E: keysym = XK_e; break;
|
||||
case Keyboard::F: keysym = XK_f; break;
|
||||
case Keyboard::G: keysym = XK_g; break;
|
||||
case Keyboard::H: keysym = XK_h; break;
|
||||
case Keyboard::I: keysym = XK_i; break;
|
||||
case Keyboard::J: keysym = XK_j; break;
|
||||
case Keyboard::K: keysym = XK_k; break;
|
||||
case Keyboard::L: keysym = XK_l; break;
|
||||
case Keyboard::M: keysym = XK_m; break;
|
||||
case Keyboard::N: keysym = XK_n; break;
|
||||
case Keyboard::O: keysym = XK_o; break;
|
||||
case Keyboard::P: keysym = XK_p; break;
|
||||
case Keyboard::Q: keysym = XK_q; break;
|
||||
case Keyboard::R: keysym = XK_r; break;
|
||||
case Keyboard::S: keysym = XK_s; break;
|
||||
case Keyboard::T: keysym = XK_t; break;
|
||||
case Keyboard::U: keysym = XK_u; break;
|
||||
case Keyboard::V: keysym = XK_v; break;
|
||||
case Keyboard::W: keysym = XK_w; break;
|
||||
case Keyboard::X: keysym = XK_x; break;
|
||||
case Keyboard::Y: keysym = XK_y; break;
|
||||
case Keyboard::Z: keysym = XK_z; break;
|
||||
case Keyboard::Num0: keysym = XK_0; break;
|
||||
case Keyboard::Num1: keysym = XK_1; break;
|
||||
case Keyboard::Num2: keysym = XK_2; break;
|
||||
case Keyboard::Num3: keysym = XK_3; break;
|
||||
case Keyboard::Num4: keysym = XK_4; break;
|
||||
case Keyboard::Num5: keysym = XK_5; break;
|
||||
case Keyboard::Num6: keysym = XK_6; break;
|
||||
case Keyboard::Num7: keysym = XK_7; break;
|
||||
case Keyboard::Num8: keysym = XK_8; break;
|
||||
case Keyboard::Num9: keysym = XK_9; break;
|
||||
default: keysym = 0; break;
|
||||
case Keyboard::Key::LShift: keysym = XK_Shift_L; break;
|
||||
case Keyboard::Key::RShift: keysym = XK_Shift_R; break;
|
||||
case Keyboard::Key::LControl: keysym = XK_Control_L; break;
|
||||
case Keyboard::Key::RControl: keysym = XK_Control_R; break;
|
||||
case Keyboard::Key::LAlt: keysym = XK_Alt_L; break;
|
||||
case Keyboard::Key::RAlt: keysym = XK_Alt_R; break;
|
||||
case Keyboard::Key::LSystem: keysym = XK_Super_L; break;
|
||||
case Keyboard::Key::RSystem: keysym = XK_Super_R; break;
|
||||
case Keyboard::Key::Menu: keysym = XK_Menu; break;
|
||||
case Keyboard::Key::Escape: keysym = XK_Escape; break;
|
||||
case Keyboard::Key::SemiColon: keysym = XK_semicolon; break;
|
||||
case Keyboard::Key::Slash: keysym = XK_slash; break;
|
||||
case Keyboard::Key::Equal: keysym = XK_equal; break;
|
||||
case Keyboard::Key::Dash: keysym = XK_minus; break;
|
||||
case Keyboard::Key::LBracket: keysym = XK_bracketleft; break;
|
||||
case Keyboard::Key::RBracket: keysym = XK_bracketright; break;
|
||||
case Keyboard::Key::Comma: keysym = XK_comma; break;
|
||||
case Keyboard::Key::Period: keysym = XK_period; break;
|
||||
case Keyboard::Key::Quote: keysym = XK_apostrophe; break;
|
||||
case Keyboard::Key::BackSlash: keysym = XK_backslash; break;
|
||||
case Keyboard::Key::Tilde: keysym = XK_grave; break;
|
||||
case Keyboard::Key::Space: keysym = XK_space; break;
|
||||
case Keyboard::Key::Return: keysym = XK_Return; break;
|
||||
case Keyboard::Key::BackSpace: keysym = XK_BackSpace; break;
|
||||
case Keyboard::Key::Tab: keysym = XK_Tab; break;
|
||||
case Keyboard::Key::PageUp: keysym = XK_Prior; break;
|
||||
case Keyboard::Key::PageDown: keysym = XK_Next; break;
|
||||
case Keyboard::Key::End: keysym = XK_End; break;
|
||||
case Keyboard::Key::Home: keysym = XK_Home; break;
|
||||
case Keyboard::Key::Insert: keysym = XK_Insert; break;
|
||||
case Keyboard::Key::Delete: keysym = XK_Delete; break;
|
||||
case Keyboard::Key::Add: keysym = XK_KP_Add; break;
|
||||
case Keyboard::Key::Subtract: keysym = XK_KP_Subtract; break;
|
||||
case Keyboard::Key::Multiply: keysym = XK_KP_Multiply; break;
|
||||
case Keyboard::Key::Divide: keysym = XK_KP_Divide; break;
|
||||
case Keyboard::Key::Pause: keysym = XK_Pause; break;
|
||||
case Keyboard::Key::F1: keysym = XK_F1; break;
|
||||
case Keyboard::Key::F2: keysym = XK_F2; break;
|
||||
case Keyboard::Key::F3: keysym = XK_F3; break;
|
||||
case Keyboard::Key::F4: keysym = XK_F4; break;
|
||||
case Keyboard::Key::F5: keysym = XK_F5; break;
|
||||
case Keyboard::Key::F6: keysym = XK_F6; break;
|
||||
case Keyboard::Key::F7: keysym = XK_F7; break;
|
||||
case Keyboard::Key::F8: keysym = XK_F8; break;
|
||||
case Keyboard::Key::F9: keysym = XK_F9; break;
|
||||
case Keyboard::Key::F10: keysym = XK_F10; break;
|
||||
case Keyboard::Key::F11: keysym = XK_F11; break;
|
||||
case Keyboard::Key::F12: keysym = XK_F12; break;
|
||||
case Keyboard::Key::F13: keysym = XK_F13; break;
|
||||
case Keyboard::Key::F14: keysym = XK_F14; break;
|
||||
case Keyboard::Key::F15: keysym = XK_F15; break;
|
||||
case Keyboard::Key::Left: keysym = XK_Left; break;
|
||||
case Keyboard::Key::Right: keysym = XK_Right; break;
|
||||
case Keyboard::Key::Up: keysym = XK_Up; break;
|
||||
case Keyboard::Key::Down: keysym = XK_Down; break;
|
||||
case Keyboard::Key::Numpad0: keysym = XK_KP_Insert; break;
|
||||
case Keyboard::Key::Numpad1: keysym = XK_KP_End; break;
|
||||
case Keyboard::Key::Numpad2: keysym = XK_KP_Down; break;
|
||||
case Keyboard::Key::Numpad3: keysym = XK_KP_Page_Down; break;
|
||||
case Keyboard::Key::Numpad4: keysym = XK_KP_Left; break;
|
||||
case Keyboard::Key::Numpad5: keysym = XK_KP_Begin; break;
|
||||
case Keyboard::Key::Numpad6: keysym = XK_KP_Right; break;
|
||||
case Keyboard::Key::Numpad7: keysym = XK_KP_Home; break;
|
||||
case Keyboard::Key::Numpad8: keysym = XK_KP_Up; break;
|
||||
case Keyboard::Key::Numpad9: keysym = XK_KP_Page_Up; break;
|
||||
case Keyboard::Key::A: keysym = XK_a; break;
|
||||
case Keyboard::Key::B: keysym = XK_b; break;
|
||||
case Keyboard::Key::C: keysym = XK_c; break;
|
||||
case Keyboard::Key::D: keysym = XK_d; break;
|
||||
case Keyboard::Key::E: keysym = XK_e; break;
|
||||
case Keyboard::Key::F: keysym = XK_f; break;
|
||||
case Keyboard::Key::G: keysym = XK_g; break;
|
||||
case Keyboard::Key::H: keysym = XK_h; break;
|
||||
case Keyboard::Key::I: keysym = XK_i; break;
|
||||
case Keyboard::Key::J: keysym = XK_j; break;
|
||||
case Keyboard::Key::K: keysym = XK_k; break;
|
||||
case Keyboard::Key::L: keysym = XK_l; break;
|
||||
case Keyboard::Key::M: keysym = XK_m; break;
|
||||
case Keyboard::Key::N: keysym = XK_n; break;
|
||||
case Keyboard::Key::O: keysym = XK_o; break;
|
||||
case Keyboard::Key::P: keysym = XK_p; break;
|
||||
case Keyboard::Key::Q: keysym = XK_q; break;
|
||||
case Keyboard::Key::R: keysym = XK_r; break;
|
||||
case Keyboard::Key::S: keysym = XK_s; break;
|
||||
case Keyboard::Key::T: keysym = XK_t; break;
|
||||
case Keyboard::Key::U: keysym = XK_u; break;
|
||||
case Keyboard::Key::V: keysym = XK_v; break;
|
||||
case Keyboard::Key::W: keysym = XK_w; break;
|
||||
case Keyboard::Key::X: keysym = XK_x; break;
|
||||
case Keyboard::Key::Y: keysym = XK_y; break;
|
||||
case Keyboard::Key::Z: keysym = XK_z; break;
|
||||
case Keyboard::Key::Num0: keysym = XK_0; break;
|
||||
case Keyboard::Key::Num1: keysym = XK_1; break;
|
||||
case Keyboard::Key::Num2: keysym = XK_2; break;
|
||||
case Keyboard::Key::Num3: keysym = XK_3; break;
|
||||
case Keyboard::Key::Num4: keysym = XK_4; break;
|
||||
case Keyboard::Key::Num5: keysym = XK_5; break;
|
||||
case Keyboard::Key::Num6: keysym = XK_6; break;
|
||||
case Keyboard::Key::Num7: keysym = XK_7; break;
|
||||
case Keyboard::Key::Num8: keysym = XK_8; break;
|
||||
case Keyboard::Key::Num9: keysym = XK_9; break;
|
||||
default: keysym = 0; break;
|
||||
}
|
||||
|
||||
// Sanity checks
|
||||
if (key < 0 || key >= sf::Keyboard::KeyCount)
|
||||
return false;
|
||||
|
||||
// Open a connection with the X server
|
||||
Display* display = OpenDisplay();
|
||||
|
||||
|
@ -205,12 +201,12 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
|||
|
||||
switch (button)
|
||||
{
|
||||
case Mouse::Left: return buttons & Button1Mask;
|
||||
case Mouse::Right: return buttons & Button3Mask;
|
||||
case Mouse::Middle: return buttons & Button2Mask;
|
||||
case Mouse::XButton1: return false; // not supported by X
|
||||
case Mouse::XButton2: return false; // not supported by X
|
||||
default: return false;
|
||||
case Mouse::Button::Left: return buttons & Button1Mask;
|
||||
case Mouse::Button::Right: return buttons & Button3Mask;
|
||||
case Mouse::Button::Middle: return buttons & Button2Mask;
|
||||
case Mouse::Button::XButton1: return false; // not supported by X
|
||||
case Mouse::Button::XButton2: return false; // not supported by X
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -613,16 +613,16 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||
{
|
||||
switch (m_mapping[i])
|
||||
{
|
||||
case ABS_X: caps.axes[Joystick::X] = true; break;
|
||||
case ABS_Y: caps.axes[Joystick::Y] = true; break;
|
||||
case ABS_X: caps.axes[static_cast<size_t>(Joystick::Axis::X)] = true; break;
|
||||
case ABS_Y: caps.axes[static_cast<size_t>(Joystick::Axis::Y)] = true; break;
|
||||
case ABS_Z:
|
||||
case ABS_THROTTLE: caps.axes[Joystick::Z] = true; break;
|
||||
case ABS_THROTTLE: caps.axes[static_cast<size_t>(Joystick::Axis::Z)] = true; break;
|
||||
case ABS_RZ:
|
||||
case ABS_RUDDER: caps.axes[Joystick::R] = true; break;
|
||||
case ABS_RX: caps.axes[Joystick::U] = true; break;
|
||||
case ABS_RY: caps.axes[Joystick::V] = true; break;
|
||||
case ABS_HAT0X: caps.axes[Joystick::PovX] = true; break;
|
||||
case ABS_HAT0Y: caps.axes[Joystick::PovY] = true; break;
|
||||
case ABS_RUDDER: caps.axes[static_cast<size_t>(Joystick::Axis::R)] = true; break;
|
||||
case ABS_RX: caps.axes[static_cast<size_t>(Joystick::Axis::U)] = true; break;
|
||||
case ABS_RY: caps.axes[static_cast<size_t>(Joystick::Axis::V)] = true; break;
|
||||
case ABS_HAT0X: caps.axes[static_cast<size_t>(Joystick::Axis::PovX)] = true; break;
|
||||
case ABS_HAT0Y: caps.axes[static_cast<size_t>(Joystick::Axis::PovY)] = true; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -663,16 +663,16 @@ JoystickState JoystickImpl::JoystickImpl::update()
|
|||
{
|
||||
switch (m_mapping[joyState.number])
|
||||
{
|
||||
case ABS_X: m_state.axes[Joystick::X] = value; break;
|
||||
case ABS_Y: m_state.axes[Joystick::Y] = value; break;
|
||||
case ABS_X: m_state.axes[static_cast<size_t>(Joystick::Axis::X)] = value; break;
|
||||
case ABS_Y: m_state.axes[static_cast<size_t>(Joystick::Axis::Y)] = value; break;
|
||||
case ABS_Z:
|
||||
case ABS_THROTTLE: m_state.axes[Joystick::Z] = value; break;
|
||||
case ABS_THROTTLE: m_state.axes[static_cast<size_t>(Joystick::Axis::Z)] = value; break;
|
||||
case ABS_RZ:
|
||||
case ABS_RUDDER: m_state.axes[Joystick::R] = value; break;
|
||||
case ABS_RX: m_state.axes[Joystick::U] = value; break;
|
||||
case ABS_RY: m_state.axes[Joystick::V] = value; break;
|
||||
case ABS_HAT0X: m_state.axes[Joystick::PovX] = value; break;
|
||||
case ABS_HAT0Y: m_state.axes[Joystick::PovY] = value; break;
|
||||
case ABS_RUDDER: m_state.axes[static_cast<size_t>(Joystick::Axis::R)] = value; break;
|
||||
case ABS_RX: m_state.axes[static_cast<size_t>(Joystick::Axis::U)] = value; break;
|
||||
case ABS_RY: m_state.axes[static_cast<size_t>(Joystick::Axis::V)] = value; break;
|
||||
case ABS_HAT0X: m_state.axes[static_cast<size_t>(Joystick::Axis::PovX)] = value; break;
|
||||
case ABS_HAT0Y: m_state.axes[static_cast<size_t>(Joystick::Axis::PovY)] = value; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,111 +264,111 @@ namespace
|
|||
{
|
||||
switch (symbol)
|
||||
{
|
||||
case XK_Shift_L: return sf::Keyboard::LShift;
|
||||
case XK_Shift_R: return sf::Keyboard::RShift;
|
||||
case XK_Control_L: return sf::Keyboard::LControl;
|
||||
case XK_Control_R: return sf::Keyboard::RControl;
|
||||
case XK_Alt_L: return sf::Keyboard::LAlt;
|
||||
case XK_Alt_R: return sf::Keyboard::RAlt;
|
||||
case XK_Super_L: return sf::Keyboard::LSystem;
|
||||
case XK_Super_R: return sf::Keyboard::RSystem;
|
||||
case XK_Menu: return sf::Keyboard::Menu;
|
||||
case XK_Escape: return sf::Keyboard::Escape;
|
||||
case XK_semicolon: return sf::Keyboard::SemiColon;
|
||||
case XK_slash: return sf::Keyboard::Slash;
|
||||
case XK_equal: return sf::Keyboard::Equal;
|
||||
case XK_minus: return sf::Keyboard::Dash;
|
||||
case XK_bracketleft: return sf::Keyboard::LBracket;
|
||||
case XK_bracketright: return sf::Keyboard::RBracket;
|
||||
case XK_comma: return sf::Keyboard::Comma;
|
||||
case XK_period: return sf::Keyboard::Period;
|
||||
case XK_apostrophe: return sf::Keyboard::Quote;
|
||||
case XK_backslash: return sf::Keyboard::BackSlash;
|
||||
case XK_grave: return sf::Keyboard::Tilde;
|
||||
case XK_space: return sf::Keyboard::Space;
|
||||
case XK_Return: return sf::Keyboard::Return;
|
||||
case XK_KP_Enter: return sf::Keyboard::Return;
|
||||
case XK_BackSpace: return sf::Keyboard::BackSpace;
|
||||
case XK_Tab: return sf::Keyboard::Tab;
|
||||
case XK_Prior: return sf::Keyboard::PageUp;
|
||||
case XK_Next: return sf::Keyboard::PageDown;
|
||||
case XK_End: return sf::Keyboard::End;
|
||||
case XK_Home: return sf::Keyboard::Home;
|
||||
case XK_Insert: return sf::Keyboard::Insert;
|
||||
case XK_Delete: return sf::Keyboard::Delete;
|
||||
case XK_KP_Add: return sf::Keyboard::Add;
|
||||
case XK_KP_Subtract: return sf::Keyboard::Subtract;
|
||||
case XK_KP_Multiply: return sf::Keyboard::Multiply;
|
||||
case XK_KP_Divide: return sf::Keyboard::Divide;
|
||||
case XK_Pause: return sf::Keyboard::Pause;
|
||||
case XK_F1: return sf::Keyboard::F1;
|
||||
case XK_F2: return sf::Keyboard::F2;
|
||||
case XK_F3: return sf::Keyboard::F3;
|
||||
case XK_F4: return sf::Keyboard::F4;
|
||||
case XK_F5: return sf::Keyboard::F5;
|
||||
case XK_F6: return sf::Keyboard::F6;
|
||||
case XK_F7: return sf::Keyboard::F7;
|
||||
case XK_F8: return sf::Keyboard::F8;
|
||||
case XK_F9: return sf::Keyboard::F9;
|
||||
case XK_F10: return sf::Keyboard::F10;
|
||||
case XK_F11: return sf::Keyboard::F11;
|
||||
case XK_F12: return sf::Keyboard::F12;
|
||||
case XK_F13: return sf::Keyboard::F13;
|
||||
case XK_F14: return sf::Keyboard::F14;
|
||||
case XK_F15: return sf::Keyboard::F15;
|
||||
case XK_Left: return sf::Keyboard::Left;
|
||||
case XK_Right: return sf::Keyboard::Right;
|
||||
case XK_Up: return sf::Keyboard::Up;
|
||||
case XK_Down: return sf::Keyboard::Down;
|
||||
case XK_KP_Insert: return sf::Keyboard::Numpad0;
|
||||
case XK_KP_End: return sf::Keyboard::Numpad1;
|
||||
case XK_KP_Down: return sf::Keyboard::Numpad2;
|
||||
case XK_KP_Page_Down: return sf::Keyboard::Numpad3;
|
||||
case XK_KP_Left: return sf::Keyboard::Numpad4;
|
||||
case XK_KP_Begin: return sf::Keyboard::Numpad5;
|
||||
case XK_KP_Right: return sf::Keyboard::Numpad6;
|
||||
case XK_KP_Home: return sf::Keyboard::Numpad7;
|
||||
case XK_KP_Up: return sf::Keyboard::Numpad8;
|
||||
case XK_KP_Page_Up: return sf::Keyboard::Numpad9;
|
||||
case XK_a: return sf::Keyboard::A;
|
||||
case XK_b: return sf::Keyboard::B;
|
||||
case XK_c: return sf::Keyboard::C;
|
||||
case XK_d: return sf::Keyboard::D;
|
||||
case XK_e: return sf::Keyboard::E;
|
||||
case XK_f: return sf::Keyboard::F;
|
||||
case XK_g: return sf::Keyboard::G;
|
||||
case XK_h: return sf::Keyboard::H;
|
||||
case XK_i: return sf::Keyboard::I;
|
||||
case XK_j: return sf::Keyboard::J;
|
||||
case XK_k: return sf::Keyboard::K;
|
||||
case XK_l: return sf::Keyboard::L;
|
||||
case XK_m: return sf::Keyboard::M;
|
||||
case XK_n: return sf::Keyboard::N;
|
||||
case XK_o: return sf::Keyboard::O;
|
||||
case XK_p: return sf::Keyboard::P;
|
||||
case XK_q: return sf::Keyboard::Q;
|
||||
case XK_r: return sf::Keyboard::R;
|
||||
case XK_s: return sf::Keyboard::S;
|
||||
case XK_t: return sf::Keyboard::T;
|
||||
case XK_u: return sf::Keyboard::U;
|
||||
case XK_v: return sf::Keyboard::V;
|
||||
case XK_w: return sf::Keyboard::W;
|
||||
case XK_x: return sf::Keyboard::X;
|
||||
case XK_y: return sf::Keyboard::Y;
|
||||
case XK_z: return sf::Keyboard::Z;
|
||||
case XK_0: return sf::Keyboard::Num0;
|
||||
case XK_1: return sf::Keyboard::Num1;
|
||||
case XK_2: return sf::Keyboard::Num2;
|
||||
case XK_3: return sf::Keyboard::Num3;
|
||||
case XK_4: return sf::Keyboard::Num4;
|
||||
case XK_5: return sf::Keyboard::Num5;
|
||||
case XK_6: return sf::Keyboard::Num6;
|
||||
case XK_7: return sf::Keyboard::Num7;
|
||||
case XK_8: return sf::Keyboard::Num8;
|
||||
case XK_9: return sf::Keyboard::Num9;
|
||||
case XK_Shift_L: return sf::Keyboard::Key::LShift;
|
||||
case XK_Shift_R: return sf::Keyboard::Key::RShift;
|
||||
case XK_Control_L: return sf::Keyboard::Key::LControl;
|
||||
case XK_Control_R: return sf::Keyboard::Key::RControl;
|
||||
case XK_Alt_L: return sf::Keyboard::Key::LAlt;
|
||||
case XK_Alt_R: return sf::Keyboard::Key::RAlt;
|
||||
case XK_Super_L: return sf::Keyboard::Key::LSystem;
|
||||
case XK_Super_R: return sf::Keyboard::Key::RSystem;
|
||||
case XK_Menu: return sf::Keyboard::Key::Menu;
|
||||
case XK_Escape: return sf::Keyboard::Key::Escape;
|
||||
case XK_semicolon: return sf::Keyboard::Key::SemiColon;
|
||||
case XK_slash: return sf::Keyboard::Key::Slash;
|
||||
case XK_equal: return sf::Keyboard::Key::Equal;
|
||||
case XK_minus: return sf::Keyboard::Key::Dash;
|
||||
case XK_bracketleft: return sf::Keyboard::Key::LBracket;
|
||||
case XK_bracketright: return sf::Keyboard::Key::RBracket;
|
||||
case XK_comma: return sf::Keyboard::Key::Comma;
|
||||
case XK_period: return sf::Keyboard::Key::Period;
|
||||
case XK_apostrophe: return sf::Keyboard::Key::Quote;
|
||||
case XK_backslash: return sf::Keyboard::Key::BackSlash;
|
||||
case XK_grave: return sf::Keyboard::Key::Tilde;
|
||||
case XK_space: return sf::Keyboard::Key::Space;
|
||||
case XK_Return: return sf::Keyboard::Key::Return;
|
||||
case XK_KP_Enter: return sf::Keyboard::Key::Return;
|
||||
case XK_BackSpace: return sf::Keyboard::Key::BackSpace;
|
||||
case XK_Tab: return sf::Keyboard::Key::Tab;
|
||||
case XK_Prior: return sf::Keyboard::Key::PageUp;
|
||||
case XK_Next: return sf::Keyboard::Key::PageDown;
|
||||
case XK_End: return sf::Keyboard::Key::End;
|
||||
case XK_Home: return sf::Keyboard::Key::Home;
|
||||
case XK_Insert: return sf::Keyboard::Key::Insert;
|
||||
case XK_Delete: return sf::Keyboard::Key::Delete;
|
||||
case XK_KP_Add: return sf::Keyboard::Key::Add;
|
||||
case XK_KP_Subtract: return sf::Keyboard::Key::Subtract;
|
||||
case XK_KP_Multiply: return sf::Keyboard::Key::Multiply;
|
||||
case XK_KP_Divide: return sf::Keyboard::Key::Divide;
|
||||
case XK_Pause: return sf::Keyboard::Key::Pause;
|
||||
case XK_F1: return sf::Keyboard::Key::F1;
|
||||
case XK_F2: return sf::Keyboard::Key::F2;
|
||||
case XK_F3: return sf::Keyboard::Key::F3;
|
||||
case XK_F4: return sf::Keyboard::Key::F4;
|
||||
case XK_F5: return sf::Keyboard::Key::F5;
|
||||
case XK_F6: return sf::Keyboard::Key::F6;
|
||||
case XK_F7: return sf::Keyboard::Key::F7;
|
||||
case XK_F8: return sf::Keyboard::Key::F8;
|
||||
case XK_F9: return sf::Keyboard::Key::F9;
|
||||
case XK_F10: return sf::Keyboard::Key::F10;
|
||||
case XK_F11: return sf::Keyboard::Key::F11;
|
||||
case XK_F12: return sf::Keyboard::Key::F12;
|
||||
case XK_F13: return sf::Keyboard::Key::F13;
|
||||
case XK_F14: return sf::Keyboard::Key::F14;
|
||||
case XK_F15: return sf::Keyboard::Key::F15;
|
||||
case XK_Left: return sf::Keyboard::Key::Left;
|
||||
case XK_Right: return sf::Keyboard::Key::Right;
|
||||
case XK_Up: return sf::Keyboard::Key::Up;
|
||||
case XK_Down: return sf::Keyboard::Key::Down;
|
||||
case XK_KP_Insert: return sf::Keyboard::Key::Numpad0;
|
||||
case XK_KP_End: return sf::Keyboard::Key::Numpad1;
|
||||
case XK_KP_Down: return sf::Keyboard::Key::Numpad2;
|
||||
case XK_KP_Page_Down: return sf::Keyboard::Key::Numpad3;
|
||||
case XK_KP_Left: return sf::Keyboard::Key::Numpad4;
|
||||
case XK_KP_Begin: return sf::Keyboard::Key::Numpad5;
|
||||
case XK_KP_Right: return sf::Keyboard::Key::Numpad6;
|
||||
case XK_KP_Home: return sf::Keyboard::Key::Numpad7;
|
||||
case XK_KP_Up: return sf::Keyboard::Key::Numpad8;
|
||||
case XK_KP_Page_Up: return sf::Keyboard::Key::Numpad9;
|
||||
case XK_a: return sf::Keyboard::Key::A;
|
||||
case XK_b: return sf::Keyboard::Key::B;
|
||||
case XK_c: return sf::Keyboard::Key::C;
|
||||
case XK_d: return sf::Keyboard::Key::D;
|
||||
case XK_e: return sf::Keyboard::Key::E;
|
||||
case XK_f: return sf::Keyboard::Key::F;
|
||||
case XK_g: return sf::Keyboard::Key::G;
|
||||
case XK_h: return sf::Keyboard::Key::H;
|
||||
case XK_i: return sf::Keyboard::Key::I;
|
||||
case XK_j: return sf::Keyboard::Key::J;
|
||||
case XK_k: return sf::Keyboard::Key::K;
|
||||
case XK_l: return sf::Keyboard::Key::L;
|
||||
case XK_m: return sf::Keyboard::Key::M;
|
||||
case XK_n: return sf::Keyboard::Key::N;
|
||||
case XK_o: return sf::Keyboard::Key::O;
|
||||
case XK_p: return sf::Keyboard::Key::P;
|
||||
case XK_q: return sf::Keyboard::Key::Q;
|
||||
case XK_r: return sf::Keyboard::Key::R;
|
||||
case XK_s: return sf::Keyboard::Key::S;
|
||||
case XK_t: return sf::Keyboard::Key::T;
|
||||
case XK_u: return sf::Keyboard::Key::U;
|
||||
case XK_v: return sf::Keyboard::Key::V;
|
||||
case XK_w: return sf::Keyboard::Key::W;
|
||||
case XK_x: return sf::Keyboard::Key::X;
|
||||
case XK_y: return sf::Keyboard::Key::Y;
|
||||
case XK_z: return sf::Keyboard::Key::Z;
|
||||
case XK_0: return sf::Keyboard::Key::Num0;
|
||||
case XK_1: return sf::Keyboard::Key::Num1;
|
||||
case XK_2: return sf::Keyboard::Key::Num2;
|
||||
case XK_3: return sf::Keyboard::Key::Num3;
|
||||
case XK_4: return sf::Keyboard::Key::Num4;
|
||||
case XK_5: return sf::Keyboard::Key::Num5;
|
||||
case XK_6: return sf::Keyboard::Key::Num6;
|
||||
case XK_7: return sf::Keyboard::Key::Num7;
|
||||
case XK_8: return sf::Keyboard::Key::Num8;
|
||||
case XK_9: return sf::Keyboard::Key::Num9;
|
||||
}
|
||||
|
||||
return sf::Keyboard::Unknown;
|
||||
return sf::Keyboard::Key::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1451,7 +1451,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
}
|
||||
|
||||
Event event;
|
||||
event.type = Event::GainedFocus;
|
||||
event.type = Event::Type::GainedFocus;
|
||||
pushEvent(event);
|
||||
|
||||
// If the window has been previously marked urgent (notification) as a result of a focus request, undo that
|
||||
|
@ -1479,7 +1479,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
XUngrabPointer(m_display, CurrentTime);
|
||||
|
||||
Event event;
|
||||
event.type = Event::LostFocus;
|
||||
event.type = Event::Type::LostFocus;
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
|
@ -1491,7 +1491,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
if ((windowEvent.xconfigure.width != m_previousSize.x) || (windowEvent.xconfigure.height != m_previousSize.y))
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::Resized;
|
||||
event.type = Event::Type::Resized;
|
||||
event.size.width = windowEvent.xconfigure.width;
|
||||
event.size.height = windowEvent.xconfigure.height;
|
||||
pushEvent(event);
|
||||
|
@ -1517,7 +1517,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
{
|
||||
// Handle the WM_DELETE_WINDOW message
|
||||
Event event;
|
||||
event.type = Event::Closed;
|
||||
event.type = Event::Type::Closed;
|
||||
pushEvent(event);
|
||||
}
|
||||
else if (netWmPing && (windowEvent.xclient.format == 32) && (windowEvent.xclient.data.l[0]) == static_cast<long>(netWmPing))
|
||||
|
@ -1534,7 +1534,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
// Key down event
|
||||
case KeyPress:
|
||||
{
|
||||
Keyboard::Key key = Keyboard::Unknown;
|
||||
Keyboard::Key key = Keyboard::Key::Unknown;
|
||||
|
||||
// Try each KeySym index (modifier group) until we get a match
|
||||
for (int i = 0; i < 4; ++i)
|
||||
|
@ -1542,14 +1542,14 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
// Get the SFML keyboard code from the keysym of the key that has been pressed
|
||||
key = keysymToSF(XLookupKeysym(&windowEvent.xkey, i));
|
||||
|
||||
if (key != Keyboard::Unknown)
|
||||
if (key != Keyboard::Key::Unknown)
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill the event parameters
|
||||
// TODO: if modifiers are wrong, use XGetModifierMapping to retrieve the actual modifiers mapping
|
||||
Event event;
|
||||
event.type = Event::KeyPressed;
|
||||
event.type = Event::Type::KeyPressed;
|
||||
event.key.code = key;
|
||||
event.key.alt = windowEvent.xkey.state & Mod1Mask;
|
||||
event.key.control = windowEvent.xkey.state & ControlMask;
|
||||
|
@ -1582,7 +1582,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
if (unicode != 0)
|
||||
{
|
||||
Event textEvent;
|
||||
textEvent.type = Event::TextEntered;
|
||||
textEvent.type = Event::Type::TextEntered;
|
||||
textEvent.text.unicode = unicode;
|
||||
pushEvent(textEvent);
|
||||
}
|
||||
|
@ -1596,7 +1596,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
if (XLookupString(&windowEvent.xkey, keyBuffer, sizeof(keyBuffer), nullptr, &status))
|
||||
{
|
||||
Event textEvent;
|
||||
textEvent.type = Event::TextEntered;
|
||||
textEvent.type = Event::Type::TextEntered;
|
||||
textEvent.text.unicode = static_cast<Uint32>(keyBuffer[0]);
|
||||
pushEvent(textEvent);
|
||||
}
|
||||
|
@ -1611,7 +1611,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
// Key up event
|
||||
case KeyRelease:
|
||||
{
|
||||
Keyboard::Key key = Keyboard::Unknown;
|
||||
Keyboard::Key key = Keyboard::Key::Unknown;
|
||||
|
||||
// Try each KeySym index (modifier group) until we get a match
|
||||
for (int i = 0; i < 4; ++i)
|
||||
|
@ -1619,13 +1619,13 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
// Get the SFML keyboard code from the keysym of the key that has been released
|
||||
key = keysymToSF(XLookupKeysym(&windowEvent.xkey, i));
|
||||
|
||||
if (key != Keyboard::Unknown)
|
||||
if (key != Keyboard::Key::Unknown)
|
||||
break;
|
||||
}
|
||||
|
||||
// Fill the event parameters
|
||||
Event event;
|
||||
event.type = Event::KeyReleased;
|
||||
event.type = Event::Type::KeyReleased;
|
||||
event.key.code = key;
|
||||
event.key.alt = windowEvent.xkey.state & Mod1Mask;
|
||||
event.key.control = windowEvent.xkey.state & ControlMask;
|
||||
|
@ -1649,16 +1649,16 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
(button == 9))
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.x = windowEvent.xbutton.x;
|
||||
event.mouseButton.y = windowEvent.xbutton.y;
|
||||
switch(button)
|
||||
{
|
||||
case Button1: event.mouseButton.button = Mouse::Left; break;
|
||||
case Button2: event.mouseButton.button = Mouse::Middle; break;
|
||||
case Button3: event.mouseButton.button = Mouse::Right; break;
|
||||
case 8: event.mouseButton.button = Mouse::XButton1; break;
|
||||
case 9: event.mouseButton.button = Mouse::XButton2; break;
|
||||
case Button1: event.mouseButton.button = Mouse::Button::Left; break;
|
||||
case Button2: event.mouseButton.button = Mouse::Button::Middle; break;
|
||||
case Button3: event.mouseButton.button = Mouse::Button::Right; break;
|
||||
case 8: event.mouseButton.button = Mouse::Button::XButton1; break;
|
||||
case 9: event.mouseButton.button = Mouse::Button::XButton2; break;
|
||||
}
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -1679,16 +1679,16 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
(button == 9))
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.x = windowEvent.xbutton.x;
|
||||
event.mouseButton.y = windowEvent.xbutton.y;
|
||||
switch(button)
|
||||
{
|
||||
case Button1: event.mouseButton.button = Mouse::Left; break;
|
||||
case Button2: event.mouseButton.button = Mouse::Middle; break;
|
||||
case Button3: event.mouseButton.button = Mouse::Right; break;
|
||||
case 8: event.mouseButton.button = Mouse::XButton1; break;
|
||||
case 9: event.mouseButton.button = Mouse::XButton2; break;
|
||||
case Button1: event.mouseButton.button = Mouse::Button::Left; break;
|
||||
case Button2: event.mouseButton.button = Mouse::Button::Middle; break;
|
||||
case Button3: event.mouseButton.button = Mouse::Button::Right; break;
|
||||
case 8: event.mouseButton.button = Mouse::Button::XButton1; break;
|
||||
case 9: event.mouseButton.button = Mouse::Button::XButton2; break;
|
||||
}
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -1696,14 +1696,14 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
{
|
||||
Event event;
|
||||
|
||||
event.type = Event::MouseWheelMoved;
|
||||
event.type = Event::Type::MouseWheelMoved;
|
||||
event.mouseWheel.delta = (button == Button4) ? 1 : -1;
|
||||
event.mouseWheel.x = windowEvent.xbutton.x;
|
||||
event.mouseWheel.y = windowEvent.xbutton.y;
|
||||
pushEvent(event);
|
||||
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::VerticalWheel;
|
||||
event.mouseWheelScroll.delta = (button == Button4) ? 1 : -1;
|
||||
event.mouseWheelScroll.x = windowEvent.xbutton.x;
|
||||
event.mouseWheelScroll.y = windowEvent.xbutton.y;
|
||||
|
@ -1712,8 +1712,8 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
else if ((button == 6) || (button == 7))
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::HorizontalWheel;
|
||||
event.mouseWheelScroll.delta = (button == 6) ? 1 : -1;
|
||||
event.mouseWheelScroll.x = windowEvent.xbutton.x;
|
||||
event.mouseWheelScroll.y = windowEvent.xbutton.y;
|
||||
|
@ -1726,7 +1726,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
case MotionNotify:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseMoved;
|
||||
event.type = Event::Type::MouseMoved;
|
||||
event.mouseMove.x = windowEvent.xmotion.x;
|
||||
event.mouseMove.y = windowEvent.xmotion.y;
|
||||
pushEvent(event);
|
||||
|
@ -1739,7 +1739,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
if (windowEvent.xcrossing.mode == NotifyNormal)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseEntered;
|
||||
event.type = Event::Type::MouseEntered;
|
||||
pushEvent(event);
|
||||
}
|
||||
break;
|
||||
|
@ -1751,7 +1751,7 @@ bool WindowImplX11::processEvent(XEvent& windowEvent)
|
|||
if (windowEvent.xcrossing.mode == NotifyNormal)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseLeft;
|
||||
event.type = Event::Type::MouseLeft;
|
||||
pushEvent(event);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -49,107 +49,107 @@ bool InputImpl::isKeyPressed(Keyboard::Key key)
|
|||
switch (key)
|
||||
{
|
||||
default: vkey = 0; break;
|
||||
case Keyboard::A: vkey = 'A'; break;
|
||||
case Keyboard::B: vkey = 'B'; break;
|
||||
case Keyboard::C: vkey = 'C'; break;
|
||||
case Keyboard::D: vkey = 'D'; break;
|
||||
case Keyboard::E: vkey = 'E'; break;
|
||||
case Keyboard::F: vkey = 'F'; break;
|
||||
case Keyboard::G: vkey = 'G'; break;
|
||||
case Keyboard::H: vkey = 'H'; break;
|
||||
case Keyboard::I: vkey = 'I'; break;
|
||||
case Keyboard::J: vkey = 'J'; break;
|
||||
case Keyboard::K: vkey = 'K'; break;
|
||||
case Keyboard::L: vkey = 'L'; break;
|
||||
case Keyboard::M: vkey = 'M'; break;
|
||||
case Keyboard::N: vkey = 'N'; break;
|
||||
case Keyboard::O: vkey = 'O'; break;
|
||||
case Keyboard::P: vkey = 'P'; break;
|
||||
case Keyboard::Q: vkey = 'Q'; break;
|
||||
case Keyboard::R: vkey = 'R'; break;
|
||||
case Keyboard::S: vkey = 'S'; break;
|
||||
case Keyboard::T: vkey = 'T'; break;
|
||||
case Keyboard::U: vkey = 'U'; break;
|
||||
case Keyboard::V: vkey = 'V'; break;
|
||||
case Keyboard::W: vkey = 'W'; break;
|
||||
case Keyboard::X: vkey = 'X'; break;
|
||||
case Keyboard::Y: vkey = 'Y'; break;
|
||||
case Keyboard::Z: vkey = 'Z'; break;
|
||||
case Keyboard::Num0: vkey = '0'; break;
|
||||
case Keyboard::Num1: vkey = '1'; break;
|
||||
case Keyboard::Num2: vkey = '2'; break;
|
||||
case Keyboard::Num3: vkey = '3'; break;
|
||||
case Keyboard::Num4: vkey = '4'; break;
|
||||
case Keyboard::Num5: vkey = '5'; break;
|
||||
case Keyboard::Num6: vkey = '6'; break;
|
||||
case Keyboard::Num7: vkey = '7'; break;
|
||||
case Keyboard::Num8: vkey = '8'; break;
|
||||
case Keyboard::Num9: vkey = '9'; break;
|
||||
case Keyboard::Escape: vkey = VK_ESCAPE; break;
|
||||
case Keyboard::LControl: vkey = VK_LCONTROL; break;
|
||||
case Keyboard::LShift: vkey = VK_LSHIFT; break;
|
||||
case Keyboard::LAlt: vkey = VK_LMENU; break;
|
||||
case Keyboard::LSystem: vkey = VK_LWIN; break;
|
||||
case Keyboard::RControl: vkey = VK_RCONTROL; break;
|
||||
case Keyboard::RShift: vkey = VK_RSHIFT; break;
|
||||
case Keyboard::RAlt: vkey = VK_RMENU; break;
|
||||
case Keyboard::RSystem: vkey = VK_RWIN; break;
|
||||
case Keyboard::Menu: vkey = VK_APPS; break;
|
||||
case Keyboard::LBracket: vkey = VK_OEM_4; break;
|
||||
case Keyboard::RBracket: vkey = VK_OEM_6; break;
|
||||
case Keyboard::SemiColon: vkey = VK_OEM_1; break;
|
||||
case Keyboard::Comma: vkey = VK_OEM_COMMA; break;
|
||||
case Keyboard::Period: vkey = VK_OEM_PERIOD; break;
|
||||
case Keyboard::Quote: vkey = VK_OEM_7; break;
|
||||
case Keyboard::Slash: vkey = VK_OEM_2; break;
|
||||
case Keyboard::BackSlash: vkey = VK_OEM_5; break;
|
||||
case Keyboard::Tilde: vkey = VK_OEM_3; break;
|
||||
case Keyboard::Equal: vkey = VK_OEM_PLUS; break;
|
||||
case Keyboard::Dash: vkey = VK_OEM_MINUS; break;
|
||||
case Keyboard::Space: vkey = VK_SPACE; break;
|
||||
case Keyboard::Return: vkey = VK_RETURN; break;
|
||||
case Keyboard::BackSpace: vkey = VK_BACK; break;
|
||||
case Keyboard::Tab: vkey = VK_TAB; break;
|
||||
case Keyboard::PageUp: vkey = VK_PRIOR; break;
|
||||
case Keyboard::PageDown: vkey = VK_NEXT; break;
|
||||
case Keyboard::End: vkey = VK_END; break;
|
||||
case Keyboard::Home: vkey = VK_HOME; break;
|
||||
case Keyboard::Insert: vkey = VK_INSERT; break;
|
||||
case Keyboard::Delete: vkey = VK_DELETE; break;
|
||||
case Keyboard::Add: vkey = VK_ADD; break;
|
||||
case Keyboard::Subtract: vkey = VK_SUBTRACT; break;
|
||||
case Keyboard::Multiply: vkey = VK_MULTIPLY; break;
|
||||
case Keyboard::Divide: vkey = VK_DIVIDE; break;
|
||||
case Keyboard::Left: vkey = VK_LEFT; break;
|
||||
case Keyboard::Right: vkey = VK_RIGHT; break;
|
||||
case Keyboard::Up: vkey = VK_UP; break;
|
||||
case Keyboard::Down: vkey = VK_DOWN; break;
|
||||
case Keyboard::Numpad0: vkey = VK_NUMPAD0; break;
|
||||
case Keyboard::Numpad1: vkey = VK_NUMPAD1; break;
|
||||
case Keyboard::Numpad2: vkey = VK_NUMPAD2; break;
|
||||
case Keyboard::Numpad3: vkey = VK_NUMPAD3; break;
|
||||
case Keyboard::Numpad4: vkey = VK_NUMPAD4; break;
|
||||
case Keyboard::Numpad5: vkey = VK_NUMPAD5; break;
|
||||
case Keyboard::Numpad6: vkey = VK_NUMPAD6; break;
|
||||
case Keyboard::Numpad7: vkey = VK_NUMPAD7; break;
|
||||
case Keyboard::Numpad8: vkey = VK_NUMPAD8; break;
|
||||
case Keyboard::Numpad9: vkey = VK_NUMPAD9; break;
|
||||
case Keyboard::F1: vkey = VK_F1; break;
|
||||
case Keyboard::F2: vkey = VK_F2; break;
|
||||
case Keyboard::F3: vkey = VK_F3; break;
|
||||
case Keyboard::F4: vkey = VK_F4; break;
|
||||
case Keyboard::F5: vkey = VK_F5; break;
|
||||
case Keyboard::F6: vkey = VK_F6; break;
|
||||
case Keyboard::F7: vkey = VK_F7; break;
|
||||
case Keyboard::F8: vkey = VK_F8; break;
|
||||
case Keyboard::F9: vkey = VK_F9; break;
|
||||
case Keyboard::F10: vkey = VK_F10; break;
|
||||
case Keyboard::F11: vkey = VK_F11; break;
|
||||
case Keyboard::F12: vkey = VK_F12; break;
|
||||
case Keyboard::F13: vkey = VK_F13; break;
|
||||
case Keyboard::F14: vkey = VK_F14; break;
|
||||
case Keyboard::F15: vkey = VK_F15; break;
|
||||
case Keyboard::Pause: vkey = VK_PAUSE; break;
|
||||
case Keyboard::Key::A: vkey = 'A'; break;
|
||||
case Keyboard::Key::B: vkey = 'B'; break;
|
||||
case Keyboard::Key::C: vkey = 'C'; break;
|
||||
case Keyboard::Key::D: vkey = 'D'; break;
|
||||
case Keyboard::Key::E: vkey = 'E'; break;
|
||||
case Keyboard::Key::F: vkey = 'F'; break;
|
||||
case Keyboard::Key::G: vkey = 'G'; break;
|
||||
case Keyboard::Key::H: vkey = 'H'; break;
|
||||
case Keyboard::Key::I: vkey = 'I'; break;
|
||||
case Keyboard::Key::J: vkey = 'J'; break;
|
||||
case Keyboard::Key::K: vkey = 'K'; break;
|
||||
case Keyboard::Key::L: vkey = 'L'; break;
|
||||
case Keyboard::Key::M: vkey = 'M'; break;
|
||||
case Keyboard::Key::N: vkey = 'N'; break;
|
||||
case Keyboard::Key::O: vkey = 'O'; break;
|
||||
case Keyboard::Key::P: vkey = 'P'; break;
|
||||
case Keyboard::Key::Q: vkey = 'Q'; break;
|
||||
case Keyboard::Key::R: vkey = 'R'; break;
|
||||
case Keyboard::Key::S: vkey = 'S'; break;
|
||||
case Keyboard::Key::T: vkey = 'T'; break;
|
||||
case Keyboard::Key::U: vkey = 'U'; break;
|
||||
case Keyboard::Key::V: vkey = 'V'; break;
|
||||
case Keyboard::Key::W: vkey = 'W'; break;
|
||||
case Keyboard::Key::X: vkey = 'X'; break;
|
||||
case Keyboard::Key::Y: vkey = 'Y'; break;
|
||||
case Keyboard::Key::Z: vkey = 'Z'; break;
|
||||
case Keyboard::Key::Num0: vkey = '0'; break;
|
||||
case Keyboard::Key::Num1: vkey = '1'; break;
|
||||
case Keyboard::Key::Num2: vkey = '2'; break;
|
||||
case Keyboard::Key::Num3: vkey = '3'; break;
|
||||
case Keyboard::Key::Num4: vkey = '4'; break;
|
||||
case Keyboard::Key::Num5: vkey = '5'; break;
|
||||
case Keyboard::Key::Num6: vkey = '6'; break;
|
||||
case Keyboard::Key::Num7: vkey = '7'; break;
|
||||
case Keyboard::Key::Num8: vkey = '8'; break;
|
||||
case Keyboard::Key::Num9: vkey = '9'; break;
|
||||
case Keyboard::Key::Escape: vkey = VK_ESCAPE; break;
|
||||
case Keyboard::Key::LControl: vkey = VK_LCONTROL; break;
|
||||
case Keyboard::Key::LShift: vkey = VK_LSHIFT; break;
|
||||
case Keyboard::Key::LAlt: vkey = VK_LMENU; break;
|
||||
case Keyboard::Key::LSystem: vkey = VK_LWIN; break;
|
||||
case Keyboard::Key::RControl: vkey = VK_RCONTROL; break;
|
||||
case Keyboard::Key::RShift: vkey = VK_RSHIFT; break;
|
||||
case Keyboard::Key::RAlt: vkey = VK_RMENU; break;
|
||||
case Keyboard::Key::RSystem: vkey = VK_RWIN; break;
|
||||
case Keyboard::Key::Menu: vkey = VK_APPS; break;
|
||||
case Keyboard::Key::LBracket: vkey = VK_OEM_4; break;
|
||||
case Keyboard::Key::RBracket: vkey = VK_OEM_6; break;
|
||||
case Keyboard::Key::SemiColon: vkey = VK_OEM_1; break;
|
||||
case Keyboard::Key::Comma: vkey = VK_OEM_COMMA; break;
|
||||
case Keyboard::Key::Period: vkey = VK_OEM_PERIOD; break;
|
||||
case Keyboard::Key::Quote: vkey = VK_OEM_7; break;
|
||||
case Keyboard::Key::Slash: vkey = VK_OEM_2; break;
|
||||
case Keyboard::Key::BackSlash: vkey = VK_OEM_5; break;
|
||||
case Keyboard::Key::Tilde: vkey = VK_OEM_3; break;
|
||||
case Keyboard::Key::Equal: vkey = VK_OEM_PLUS; break;
|
||||
case Keyboard::Key::Dash: vkey = VK_OEM_MINUS; break;
|
||||
case Keyboard::Key::Space: vkey = VK_SPACE; break;
|
||||
case Keyboard::Key::Return: vkey = VK_RETURN; break;
|
||||
case Keyboard::Key::BackSpace: vkey = VK_BACK; break;
|
||||
case Keyboard::Key::Tab: vkey = VK_TAB; break;
|
||||
case Keyboard::Key::PageUp: vkey = VK_PRIOR; break;
|
||||
case Keyboard::Key::PageDown: vkey = VK_NEXT; break;
|
||||
case Keyboard::Key::End: vkey = VK_END; break;
|
||||
case Keyboard::Key::Home: vkey = VK_HOME; break;
|
||||
case Keyboard::Key::Insert: vkey = VK_INSERT; break;
|
||||
case Keyboard::Key::Delete: vkey = VK_DELETE; break;
|
||||
case Keyboard::Key::Add: vkey = VK_ADD; break;
|
||||
case Keyboard::Key::Subtract: vkey = VK_SUBTRACT; break;
|
||||
case Keyboard::Key::Multiply: vkey = VK_MULTIPLY; break;
|
||||
case Keyboard::Key::Divide: vkey = VK_DIVIDE; break;
|
||||
case Keyboard::Key::Left: vkey = VK_LEFT; break;
|
||||
case Keyboard::Key::Right: vkey = VK_RIGHT; break;
|
||||
case Keyboard::Key::Up: vkey = VK_UP; break;
|
||||
case Keyboard::Key::Down: vkey = VK_DOWN; break;
|
||||
case Keyboard::Key::Numpad0: vkey = VK_NUMPAD0; break;
|
||||
case Keyboard::Key::Numpad1: vkey = VK_NUMPAD1; break;
|
||||
case Keyboard::Key::Numpad2: vkey = VK_NUMPAD2; break;
|
||||
case Keyboard::Key::Numpad3: vkey = VK_NUMPAD3; break;
|
||||
case Keyboard::Key::Numpad4: vkey = VK_NUMPAD4; break;
|
||||
case Keyboard::Key::Numpad5: vkey = VK_NUMPAD5; break;
|
||||
case Keyboard::Key::Numpad6: vkey = VK_NUMPAD6; break;
|
||||
case Keyboard::Key::Numpad7: vkey = VK_NUMPAD7; break;
|
||||
case Keyboard::Key::Numpad8: vkey = VK_NUMPAD8; break;
|
||||
case Keyboard::Key::Numpad9: vkey = VK_NUMPAD9; break;
|
||||
case Keyboard::Key::F1: vkey = VK_F1; break;
|
||||
case Keyboard::Key::F2: vkey = VK_F2; break;
|
||||
case Keyboard::Key::F3: vkey = VK_F3; break;
|
||||
case Keyboard::Key::F4: vkey = VK_F4; break;
|
||||
case Keyboard::Key::F5: vkey = VK_F5; break;
|
||||
case Keyboard::Key::F6: vkey = VK_F6; break;
|
||||
case Keyboard::Key::F7: vkey = VK_F7; break;
|
||||
case Keyboard::Key::F8: vkey = VK_F8; break;
|
||||
case Keyboard::Key::F9: vkey = VK_F9; break;
|
||||
case Keyboard::Key::F10: vkey = VK_F10; break;
|
||||
case Keyboard::Key::F11: vkey = VK_F11; break;
|
||||
case Keyboard::Key::F12: vkey = VK_F12; break;
|
||||
case Keyboard::Key::F13: vkey = VK_F13; break;
|
||||
case Keyboard::Key::F14: vkey = VK_F14; break;
|
||||
case Keyboard::Key::F15: vkey = VK_F15; break;
|
||||
case Keyboard::Key::Pause: vkey = VK_PAUSE; break;
|
||||
}
|
||||
|
||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
||||
|
@ -169,12 +169,12 @@ bool InputImpl::isMouseButtonPressed(Mouse::Button button)
|
|||
int vkey = 0;
|
||||
switch (button)
|
||||
{
|
||||
case Mouse::Left: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; break;
|
||||
case Mouse::Right: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON; break;
|
||||
case Mouse::Middle: vkey = VK_MBUTTON; break;
|
||||
case Mouse::XButton1: vkey = VK_XBUTTON1; break;
|
||||
case Mouse::XButton2: vkey = VK_XBUTTON2; break;
|
||||
default: vkey = 0; break;
|
||||
case Mouse::Button::Left: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; break;
|
||||
case Mouse::Button::Right: vkey = GetSystemMetrics(SM_SWAPBUTTON) ? VK_LBUTTON : VK_RBUTTON; break;
|
||||
case Mouse::Button::Middle: vkey = VK_MBUTTON; break;
|
||||
case Mouse::Button::XButton1: vkey = VK_XBUTTON1; break;
|
||||
case Mouse::Button::XButton2: vkey = VK_XBUTTON2; break;
|
||||
default: vkey = 0; break;
|
||||
}
|
||||
|
||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
||||
|
|
|
@ -236,14 +236,14 @@ JoystickCaps JoystickImpl::getCapabilities() const
|
|||
if (caps.buttonCount > Joystick::ButtonCount)
|
||||
caps.buttonCount = Joystick::ButtonCount;
|
||||
|
||||
caps.axes[Joystick::X] = true;
|
||||
caps.axes[Joystick::Y] = true;
|
||||
caps.axes[Joystick::Z] = (m_caps.wCaps & JOYCAPS_HASZ) != 0;
|
||||
caps.axes[Joystick::R] = (m_caps.wCaps & JOYCAPS_HASR) != 0;
|
||||
caps.axes[Joystick::U] = (m_caps.wCaps & JOYCAPS_HASU) != 0;
|
||||
caps.axes[Joystick::V] = (m_caps.wCaps & JOYCAPS_HASV) != 0;
|
||||
caps.axes[Joystick::PovX] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
|
||||
caps.axes[Joystick::PovY] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::X)] = true;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::Y)] = true;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::Z)] = (m_caps.wCaps & JOYCAPS_HASZ) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::R)] = (m_caps.wCaps & JOYCAPS_HASR) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::U)] = (m_caps.wCaps & JOYCAPS_HASU) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::V)] = (m_caps.wCaps & JOYCAPS_HASV) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::PovX)] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
|
||||
caps.axes[static_cast<size_t>(Joystick::Axis::PovY)] = (m_caps.wCaps & JOYCAPS_HASPOV) != 0;
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
@ -272,24 +272,24 @@ JoystickState JoystickImpl::update()
|
|||
state.connected = true;
|
||||
|
||||
// Axes
|
||||
state.axes[Joystick::X] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
|
||||
state.axes[Joystick::Y] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
|
||||
state.axes[Joystick::Z] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
|
||||
state.axes[Joystick::R] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
|
||||
state.axes[Joystick::U] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
|
||||
state.axes[Joystick::V] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::X)] = (pos.dwXpos - (m_caps.wXmax + m_caps.wXmin) / 2.f) * 200.f / (m_caps.wXmax - m_caps.wXmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::Y)] = (pos.dwYpos - (m_caps.wYmax + m_caps.wYmin) / 2.f) * 200.f / (m_caps.wYmax - m_caps.wYmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::Z)] = (pos.dwZpos - (m_caps.wZmax + m_caps.wZmin) / 2.f) * 200.f / (m_caps.wZmax - m_caps.wZmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::R)] = (pos.dwRpos - (m_caps.wRmax + m_caps.wRmin) / 2.f) * 200.f / (m_caps.wRmax - m_caps.wRmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::U)] = (pos.dwUpos - (m_caps.wUmax + m_caps.wUmin) / 2.f) * 200.f / (m_caps.wUmax - m_caps.wUmin);
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::V)] = (pos.dwVpos - (m_caps.wVmax + m_caps.wVmin) / 2.f) * 200.f / (m_caps.wVmax - m_caps.wVmin);
|
||||
|
||||
// Special case for POV, it is given as an angle
|
||||
if (pos.dwPOV != 0xFFFF)
|
||||
{
|
||||
float angle = pos.dwPOV / 18000.f * 3.141592654f;
|
||||
state.axes[Joystick::PovX] = std::sin(angle) * 100;
|
||||
state.axes[Joystick::PovY] = std::cos(angle) * 100;
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::PovX)] = std::sin(angle) * 100;
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::PovY)] = std::cos(angle) * 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
state.axes[Joystick::PovX] = 0;
|
||||
state.axes[Joystick::PovY] = 0;
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::PovX)] = 0;
|
||||
state.axes[static_cast<size_t>(Joystick::Axis::PovY)] = 0;
|
||||
}
|
||||
|
||||
// Buttons
|
||||
|
|
|
@ -576,7 +576,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_CLOSE:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::Closed;
|
||||
event.type = Event::Type::Closed;
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
|
@ -592,7 +592,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Push a resize event
|
||||
Event event;
|
||||
event.type = Event::Resized;
|
||||
event.type = Event::Type::Resized;
|
||||
event.size.width = m_lastSize.x;
|
||||
event.size.height = m_lastSize.y;
|
||||
pushEvent(event);
|
||||
|
@ -624,7 +624,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Push a resize event
|
||||
Event event;
|
||||
event.type = Event::Resized;
|
||||
event.type = Event::Type::Resized;
|
||||
event.size.width = m_lastSize.x;
|
||||
event.size.height = m_lastSize.y;
|
||||
pushEvent(event);
|
||||
|
@ -653,7 +653,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
grabCursor(m_cursorGrabbed);
|
||||
|
||||
Event event;
|
||||
event.type = Event::GainedFocus;
|
||||
event.type = Event::Type::GainedFocus;
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
grabCursor(false);
|
||||
|
||||
Event event;
|
||||
event.type = Event::LostFocus;
|
||||
event.type = Event::Type::LostFocus;
|
||||
pushEvent(event);
|
||||
break;
|
||||
}
|
||||
|
@ -697,7 +697,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Send a TextEntered event
|
||||
Event event;
|
||||
event.type = Event::TextEntered;
|
||||
event.type = Event::Type::TextEntered;
|
||||
event.text.unicode = character;
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -712,7 +712,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
if (m_keyRepeatEnabled || ((HIWORD(lParam) & KF_REPEAT) == 0))
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::KeyPressed;
|
||||
event.type = Event::Type::KeyPressed;
|
||||
event.key.alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0;
|
||||
event.key.control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
|
||||
event.key.shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
|
||||
|
@ -728,7 +728,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_SYSKEYUP:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::KeyReleased;
|
||||
event.type = Event::Type::KeyReleased;
|
||||
event.key.alt = HIWORD(GetAsyncKeyState(VK_MENU)) != 0;
|
||||
event.key.control = HIWORD(GetAsyncKeyState(VK_CONTROL)) != 0;
|
||||
event.key.shift = HIWORD(GetAsyncKeyState(VK_SHIFT)) != 0;
|
||||
|
@ -751,14 +751,14 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
Event event;
|
||||
|
||||
event.type = Event::MouseWheelMoved;
|
||||
event.type = Event::Type::MouseWheelMoved;
|
||||
event.mouseWheel.delta = delta / 120;
|
||||
event.mouseWheel.x = position.x;
|
||||
event.mouseWheel.y = position.y;
|
||||
pushEvent(event);
|
||||
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::VerticalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::VerticalWheel;
|
||||
event.mouseWheelScroll.delta = static_cast<float>(delta) / 120.f;
|
||||
event.mouseWheelScroll.x = position.x;
|
||||
event.mouseWheelScroll.y = position.y;
|
||||
|
@ -778,8 +778,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
Int16 delta = static_cast<Int16>(HIWORD(wParam));
|
||||
|
||||
Event event;
|
||||
event.type = Event::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::HorizontalWheel;
|
||||
event.type = Event::Type::MouseWheelScrolled;
|
||||
event.mouseWheelScroll.wheel = Mouse::Wheel::HorizontalWheel;
|
||||
event.mouseWheelScroll.delta = -static_cast<float>(delta) / 120.f;
|
||||
event.mouseWheelScroll.x = position.x;
|
||||
event.mouseWheelScroll.y = position.y;
|
||||
|
@ -791,8 +791,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_LBUTTONDOWN:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Left;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Button::Left;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -803,8 +803,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_LBUTTONUP:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Left;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Button::Left;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -815,8 +815,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_RBUTTONDOWN:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Right;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Button::Right;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -827,8 +827,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_RBUTTONUP:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Right;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Button::Right;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -839,8 +839,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_MBUTTONDOWN:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Middle;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = Mouse::Button::Middle;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -851,8 +851,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_MBUTTONUP:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Middle;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = Mouse::Button::Middle;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -863,8 +863,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_XBUTTONDOWN:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonPressed;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
|
||||
event.type = Event::Type::MouseButtonPressed;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::XButton1 : Mouse::Button::XButton2;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -875,8 +875,8 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_XBUTTONUP:
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::MouseButtonReleased;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::XButton1 : Mouse::XButton2;
|
||||
event.type = Event::Type::MouseButtonReleased;
|
||||
event.mouseButton.button = HIWORD(wParam) == XBUTTON1 ? Mouse::Button::XButton1 : Mouse::Button::XButton2;
|
||||
event.mouseButton.x = static_cast<Int16>(LOWORD(lParam));
|
||||
event.mouseButton.y = static_cast<Int16>(HIWORD(lParam));
|
||||
pushEvent(event);
|
||||
|
@ -893,7 +893,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Generate a MouseLeft event
|
||||
Event event;
|
||||
event.type = Event::MouseLeft;
|
||||
event.type = Event::Type::MouseLeft;
|
||||
pushEvent(event);
|
||||
}
|
||||
break;
|
||||
|
@ -936,7 +936,7 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Generate a MouseLeft event
|
||||
Event event;
|
||||
event.type = Event::MouseLeft;
|
||||
event.type = Event::Type::MouseLeft;
|
||||
pushEvent(event);
|
||||
}
|
||||
}
|
||||
|
@ -952,14 +952,14 @@ void WindowImplWin32::processEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
|
||||
// Generate a MouseEntered event
|
||||
Event event;
|
||||
event.type = Event::MouseEntered;
|
||||
event.type = Event::Type::MouseEntered;
|
||||
pushEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a MouseMove event
|
||||
Event event;
|
||||
event.type = Event::MouseMoved;
|
||||
event.type = Event::Type::MouseMoved;
|
||||
event.mouseMove.x = x;
|
||||
event.mouseMove.y = y;
|
||||
pushEvent(event);
|
||||
|
@ -986,114 +986,114 @@ Keyboard::Key WindowImplWin32::virtualKeyCodeToSF(WPARAM key, LPARAM flags)
|
|||
{
|
||||
static const auto lShift = MapVirtualKeyW(VK_LSHIFT, MAPVK_VK_TO_VSC);
|
||||
UINT scancode = static_cast<UINT>((flags & (0xFF << 16)) >> 16);
|
||||
return scancode == lShift ? Keyboard::LShift : Keyboard::RShift;
|
||||
return scancode == lShift ? Keyboard::Key::LShift : Keyboard::Key::RShift;
|
||||
}
|
||||
|
||||
// Check the "extended" flag to distinguish between left and right alt
|
||||
case VK_MENU : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RAlt : Keyboard::LAlt;
|
||||
case VK_MENU : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::Key::RAlt : Keyboard::Key::LAlt;
|
||||
|
||||
// Check the "extended" flag to distinguish between left and right control
|
||||
case VK_CONTROL : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::RControl : Keyboard::LControl;
|
||||
case VK_CONTROL : return (HIWORD(flags) & KF_EXTENDED) ? Keyboard::Key::RControl : Keyboard::Key::LControl;
|
||||
|
||||
// Other keys are reported properly
|
||||
case VK_LWIN: return Keyboard::LSystem;
|
||||
case VK_RWIN: return Keyboard::RSystem;
|
||||
case VK_APPS: return Keyboard::Menu;
|
||||
case VK_OEM_1: return Keyboard::SemiColon;
|
||||
case VK_OEM_2: return Keyboard::Slash;
|
||||
case VK_OEM_PLUS: return Keyboard::Equal;
|
||||
case VK_OEM_MINUS: return Keyboard::Dash;
|
||||
case VK_OEM_4: return Keyboard::LBracket;
|
||||
case VK_OEM_6: return Keyboard::RBracket;
|
||||
case VK_OEM_COMMA: return Keyboard::Comma;
|
||||
case VK_OEM_PERIOD: return Keyboard::Period;
|
||||
case VK_OEM_7: return Keyboard::Quote;
|
||||
case VK_OEM_5: return Keyboard::BackSlash;
|
||||
case VK_OEM_3: return Keyboard::Tilde;
|
||||
case VK_ESCAPE: return Keyboard::Escape;
|
||||
case VK_SPACE: return Keyboard::Space;
|
||||
case VK_RETURN: return Keyboard::Return;
|
||||
case VK_BACK: return Keyboard::BackSpace;
|
||||
case VK_TAB: return Keyboard::Tab;
|
||||
case VK_PRIOR: return Keyboard::PageUp;
|
||||
case VK_NEXT: return Keyboard::PageDown;
|
||||
case VK_END: return Keyboard::End;
|
||||
case VK_HOME: return Keyboard::Home;
|
||||
case VK_INSERT: return Keyboard::Insert;
|
||||
case VK_DELETE: return Keyboard::Delete;
|
||||
case VK_ADD: return Keyboard::Add;
|
||||
case VK_SUBTRACT: return Keyboard::Subtract;
|
||||
case VK_MULTIPLY: return Keyboard::Multiply;
|
||||
case VK_DIVIDE: return Keyboard::Divide;
|
||||
case VK_PAUSE: return Keyboard::Pause;
|
||||
case VK_F1: return Keyboard::F1;
|
||||
case VK_F2: return Keyboard::F2;
|
||||
case VK_F3: return Keyboard::F3;
|
||||
case VK_F4: return Keyboard::F4;
|
||||
case VK_F5: return Keyboard::F5;
|
||||
case VK_F6: return Keyboard::F6;
|
||||
case VK_F7: return Keyboard::F7;
|
||||
case VK_F8: return Keyboard::F8;
|
||||
case VK_F9: return Keyboard::F9;
|
||||
case VK_F10: return Keyboard::F10;
|
||||
case VK_F11: return Keyboard::F11;
|
||||
case VK_F12: return Keyboard::F12;
|
||||
case VK_F13: return Keyboard::F13;
|
||||
case VK_F14: return Keyboard::F14;
|
||||
case VK_F15: return Keyboard::F15;
|
||||
case VK_LEFT: return Keyboard::Left;
|
||||
case VK_RIGHT: return Keyboard::Right;
|
||||
case VK_UP: return Keyboard::Up;
|
||||
case VK_DOWN: return Keyboard::Down;
|
||||
case VK_NUMPAD0: return Keyboard::Numpad0;
|
||||
case VK_NUMPAD1: return Keyboard::Numpad1;
|
||||
case VK_NUMPAD2: return Keyboard::Numpad2;
|
||||
case VK_NUMPAD3: return Keyboard::Numpad3;
|
||||
case VK_NUMPAD4: return Keyboard::Numpad4;
|
||||
case VK_NUMPAD5: return Keyboard::Numpad5;
|
||||
case VK_NUMPAD6: return Keyboard::Numpad6;
|
||||
case VK_NUMPAD7: return Keyboard::Numpad7;
|
||||
case VK_NUMPAD8: return Keyboard::Numpad8;
|
||||
case VK_NUMPAD9: return Keyboard::Numpad9;
|
||||
case 'A': return Keyboard::A;
|
||||
case 'Z': return Keyboard::Z;
|
||||
case 'E': return Keyboard::E;
|
||||
case 'R': return Keyboard::R;
|
||||
case 'T': return Keyboard::T;
|
||||
case 'Y': return Keyboard::Y;
|
||||
case 'U': return Keyboard::U;
|
||||
case 'I': return Keyboard::I;
|
||||
case 'O': return Keyboard::O;
|
||||
case 'P': return Keyboard::P;
|
||||
case 'Q': return Keyboard::Q;
|
||||
case 'S': return Keyboard::S;
|
||||
case 'D': return Keyboard::D;
|
||||
case 'F': return Keyboard::F;
|
||||
case 'G': return Keyboard::G;
|
||||
case 'H': return Keyboard::H;
|
||||
case 'J': return Keyboard::J;
|
||||
case 'K': return Keyboard::K;
|
||||
case 'L': return Keyboard::L;
|
||||
case 'M': return Keyboard::M;
|
||||
case 'W': return Keyboard::W;
|
||||
case 'X': return Keyboard::X;
|
||||
case 'C': return Keyboard::C;
|
||||
case 'V': return Keyboard::V;
|
||||
case 'B': return Keyboard::B;
|
||||
case 'N': return Keyboard::N;
|
||||
case '0': return Keyboard::Num0;
|
||||
case '1': return Keyboard::Num1;
|
||||
case '2': return Keyboard::Num2;
|
||||
case '3': return Keyboard::Num3;
|
||||
case '4': return Keyboard::Num4;
|
||||
case '5': return Keyboard::Num5;
|
||||
case '6': return Keyboard::Num6;
|
||||
case '7': return Keyboard::Num7;
|
||||
case '8': return Keyboard::Num8;
|
||||
case '9': return Keyboard::Num9;
|
||||
case VK_LWIN: return Keyboard::Key::LSystem;
|
||||
case VK_RWIN: return Keyboard::Key::RSystem;
|
||||
case VK_APPS: return Keyboard::Key::Menu;
|
||||
case VK_OEM_1: return Keyboard::Key::SemiColon;
|
||||
case VK_OEM_2: return Keyboard::Key::Slash;
|
||||
case VK_OEM_PLUS: return Keyboard::Key::Equal;
|
||||
case VK_OEM_MINUS: return Keyboard::Key::Dash;
|
||||
case VK_OEM_4: return Keyboard::Key::LBracket;
|
||||
case VK_OEM_6: return Keyboard::Key::RBracket;
|
||||
case VK_OEM_COMMA: return Keyboard::Key::Comma;
|
||||
case VK_OEM_PERIOD: return Keyboard::Key::Period;
|
||||
case VK_OEM_7: return Keyboard::Key::Quote;
|
||||
case VK_OEM_5: return Keyboard::Key::BackSlash;
|
||||
case VK_OEM_3: return Keyboard::Key::Tilde;
|
||||
case VK_ESCAPE: return Keyboard::Key::Escape;
|
||||
case VK_SPACE: return Keyboard::Key::Space;
|
||||
case VK_RETURN: return Keyboard::Key::Return;
|
||||
case VK_BACK: return Keyboard::Key::BackSpace;
|
||||
case VK_TAB: return Keyboard::Key::Tab;
|
||||
case VK_PRIOR: return Keyboard::Key::PageUp;
|
||||
case VK_NEXT: return Keyboard::Key::PageDown;
|
||||
case VK_END: return Keyboard::Key::End;
|
||||
case VK_HOME: return Keyboard::Key::Home;
|
||||
case VK_INSERT: return Keyboard::Key::Insert;
|
||||
case VK_DELETE: return Keyboard::Key::Delete;
|
||||
case VK_ADD: return Keyboard::Key::Add;
|
||||
case VK_SUBTRACT: return Keyboard::Key::Subtract;
|
||||
case VK_MULTIPLY: return Keyboard::Key::Multiply;
|
||||
case VK_DIVIDE: return Keyboard::Key::Divide;
|
||||
case VK_PAUSE: return Keyboard::Key::Pause;
|
||||
case VK_F1: return Keyboard::Key::F1;
|
||||
case VK_F2: return Keyboard::Key::F2;
|
||||
case VK_F3: return Keyboard::Key::F3;
|
||||
case VK_F4: return Keyboard::Key::F4;
|
||||
case VK_F5: return Keyboard::Key::F5;
|
||||
case VK_F6: return Keyboard::Key::F6;
|
||||
case VK_F7: return Keyboard::Key::F7;
|
||||
case VK_F8: return Keyboard::Key::F8;
|
||||
case VK_F9: return Keyboard::Key::F9;
|
||||
case VK_F10: return Keyboard::Key::F10;
|
||||
case VK_F11: return Keyboard::Key::F11;
|
||||
case VK_F12: return Keyboard::Key::F12;
|
||||
case VK_F13: return Keyboard::Key::F13;
|
||||
case VK_F14: return Keyboard::Key::F14;
|
||||
case VK_F15: return Keyboard::Key::F15;
|
||||
case VK_LEFT: return Keyboard::Key::Left;
|
||||
case VK_RIGHT: return Keyboard::Key::Right;
|
||||
case VK_UP: return Keyboard::Key::Up;
|
||||
case VK_DOWN: return Keyboard::Key::Down;
|
||||
case VK_NUMPAD0: return Keyboard::Key::Numpad0;
|
||||
case VK_NUMPAD1: return Keyboard::Key::Numpad1;
|
||||
case VK_NUMPAD2: return Keyboard::Key::Numpad2;
|
||||
case VK_NUMPAD3: return Keyboard::Key::Numpad3;
|
||||
case VK_NUMPAD4: return Keyboard::Key::Numpad4;
|
||||
case VK_NUMPAD5: return Keyboard::Key::Numpad5;
|
||||
case VK_NUMPAD6: return Keyboard::Key::Numpad6;
|
||||
case VK_NUMPAD7: return Keyboard::Key::Numpad7;
|
||||
case VK_NUMPAD8: return Keyboard::Key::Numpad8;
|
||||
case VK_NUMPAD9: return Keyboard::Key::Numpad9;
|
||||
case 'A': return Keyboard::Key::A;
|
||||
case 'Z': return Keyboard::Key::Z;
|
||||
case 'E': return Keyboard::Key::E;
|
||||
case 'R': return Keyboard::Key::R;
|
||||
case 'T': return Keyboard::Key::T;
|
||||
case 'Y': return Keyboard::Key::Y;
|
||||
case 'U': return Keyboard::Key::U;
|
||||
case 'I': return Keyboard::Key::I;
|
||||
case 'O': return Keyboard::Key::O;
|
||||
case 'P': return Keyboard::Key::P;
|
||||
case 'Q': return Keyboard::Key::Q;
|
||||
case 'S': return Keyboard::Key::S;
|
||||
case 'D': return Keyboard::Key::D;
|
||||
case 'F': return Keyboard::Key::F;
|
||||
case 'G': return Keyboard::Key::G;
|
||||
case 'H': return Keyboard::Key::H;
|
||||
case 'J': return Keyboard::Key::J;
|
||||
case 'K': return Keyboard::Key::K;
|
||||
case 'L': return Keyboard::Key::L;
|
||||
case 'M': return Keyboard::Key::M;
|
||||
case 'W': return Keyboard::Key::W;
|
||||
case 'X': return Keyboard::Key::X;
|
||||
case 'C': return Keyboard::Key::C;
|
||||
case 'V': return Keyboard::Key::V;
|
||||
case 'B': return Keyboard::Key::B;
|
||||
case 'N': return Keyboard::Key::N;
|
||||
case '0': return Keyboard::Key::Num0;
|
||||
case '1': return Keyboard::Key::Num1;
|
||||
case '2': return Keyboard::Key::Num2;
|
||||
case '3': return Keyboard::Key::Num3;
|
||||
case '4': return Keyboard::Key::Num4;
|
||||
case '5': return Keyboard::Key::Num5;
|
||||
case '6': return Keyboard::Key::Num6;
|
||||
case '7': return Keyboard::Key::Num7;
|
||||
case '8': return Keyboard::Key::Num8;
|
||||
case '9': return Keyboard::Key::Num9;
|
||||
}
|
||||
|
||||
return Keyboard::Unknown;
|
||||
return Keyboard::Key::Unknown;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ void Window::onResize()
|
|||
bool Window::filterEvent(const Event& event)
|
||||
{
|
||||
// Notify resize events to the derived class
|
||||
if (event.type == Event::Resized)
|
||||
if (event.type == Event::Type::Resized)
|
||||
{
|
||||
// Cache the new size
|
||||
m_size.x = event.size.width;
|
||||
|
|
|
@ -89,8 +89,8 @@ m_joystickThreshold(0.1f)
|
|||
m_joystickStates[i] = JoystickManager::getInstance().getState(i);
|
||||
|
||||
// Get the initial sensor states
|
||||
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
||||
m_sensorValue[i] = Vector3f(0, 0, 0);
|
||||
for (auto& sensorValue : m_sensorValue)
|
||||
sensorValue = Vector3f(0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,7 +173,7 @@ void WindowImpl::processJoystickEvents()
|
|||
if (previousState.connected ^ connected)
|
||||
{
|
||||
Event event;
|
||||
event.type = connected ? Event::JoystickConnected : Event::JoystickDisconnected;
|
||||
event.type = connected ? Event::Type::JoystickConnected : Event::Type::JoystickDisconnected;
|
||||
event.joystickButton.joystickId = i;
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -181,19 +181,18 @@ void WindowImpl::processJoystickEvents()
|
|||
if (connected)
|
||||
{
|
||||
// Axes
|
||||
for (unsigned int j = 0; j < Joystick::AxisCount; ++j)
|
||||
for (auto j = 0u; j < static_cast<size_t>(Joystick::Axis::Count); ++j)
|
||||
{
|
||||
if (caps.axes[j])
|
||||
{
|
||||
Joystick::Axis axis = static_cast<Joystick::Axis>(j);
|
||||
float prevPos = previousState.axes[axis];
|
||||
float currPos = m_joystickStates[i].axes[axis];
|
||||
float prevPos = previousState.axes[j];
|
||||
float currPos = m_joystickStates[i].axes[j];
|
||||
if (fabs(currPos - prevPos) >= m_joystickThreshold)
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::JoystickMoved;
|
||||
event.type = Event::Type::JoystickMoved;
|
||||
event.joystickMove.joystickId = i;
|
||||
event.joystickMove.axis = axis;
|
||||
event.joystickMove.axis = static_cast<Joystick::Axis>(j);
|
||||
event.joystickMove.position = currPos;
|
||||
pushEvent(event);
|
||||
}
|
||||
|
@ -209,7 +208,7 @@ void WindowImpl::processJoystickEvents()
|
|||
if (prevPressed ^ currPressed)
|
||||
{
|
||||
Event event;
|
||||
event.type = currPressed ? Event::JoystickButtonPressed : Event::JoystickButtonReleased;
|
||||
event.type = currPressed ? Event::Type::JoystickButtonPressed : Event::Type::JoystickButtonReleased;
|
||||
event.joystickButton.joystickId = i;
|
||||
event.joystickButton.button = j;
|
||||
pushEvent(event);
|
||||
|
@ -226,7 +225,7 @@ void WindowImpl::processSensorEvents()
|
|||
// First update the sensor states
|
||||
SensorManager::getInstance().update();
|
||||
|
||||
for (unsigned int i = 0; i < Sensor::Count; ++i)
|
||||
for (auto i = 0u; i < static_cast<size_t>(Sensor::Type::Count); ++i)
|
||||
{
|
||||
Sensor::Type sensor = static_cast<Sensor::Type>(i);
|
||||
|
||||
|
@ -241,7 +240,7 @@ void WindowImpl::processSensorEvents()
|
|||
if (m_sensorValue[i] != previousValue) // @todo use a threshold?
|
||||
{
|
||||
Event event;
|
||||
event.type = Event::SensorChanged;
|
||||
event.type = Event::Type::SensorChanged;
|
||||
event.sensor.type = sensor;
|
||||
event.sensor.x = m_sensorValue[i].x;
|
||||
event.sensor.y = m_sensorValue[i].y;
|
||||
|
|
|
@ -262,10 +262,10 @@ private:
|
|||
////////////////////////////////////////////////////////////
|
||||
// Member data
|
||||
////////////////////////////////////////////////////////////
|
||||
std::queue<Event> m_events; ///< Queue of available events
|
||||
JoystickState m_joystickStates[Joystick::Count]; ///< Previous state of the joysticks
|
||||
Vector3f m_sensorValue[Sensor::Count]; ///< Previous value of the sensors
|
||||
float m_joystickThreshold; ///< Joystick threshold (minimum motion for "move" event to be generated)
|
||||
std::queue<Event> m_events; ///< Queue of available events
|
||||
JoystickState m_joystickStates[Joystick::Count]; ///< Previous state of the joysticks
|
||||
Vector3f m_sensorValue[static_cast<size_t>(Sensor::Type::Count)]; ///< Previous value of the sensors
|
||||
float m_joystickThreshold; ///< Joystick threshold (minimum motion for "move" event to be generated)
|
||||
};
|
||||
|
||||
} // namespace priv
|
||||
|
|
|
@ -63,18 +63,18 @@ bool SensorImpl::isAvailable(Sensor::Type sensor)
|
|||
{
|
||||
switch (sensor)
|
||||
{
|
||||
case Sensor::Accelerometer:
|
||||
case Sensor::Type::Accelerometer:
|
||||
return [SFAppDelegate getInstance].motionManager.accelerometerAvailable;
|
||||
|
||||
case Sensor::Gyroscope:
|
||||
case Sensor::Type::Gyroscope:
|
||||
return [SFAppDelegate getInstance].motionManager.gyroAvailable;
|
||||
|
||||
case Sensor::Magnetometer:
|
||||
case Sensor::Type::Magnetometer:
|
||||
return [SFAppDelegate getInstance].motionManager.magnetometerAvailable;
|
||||
|
||||
case Sensor::Gravity:
|
||||
case Sensor::UserAcceleration:
|
||||
case Sensor::Orientation:
|
||||
case Sensor::Type::Gravity:
|
||||
case Sensor::Type::UserAcceleration:
|
||||
case Sensor::Type::Orientation:
|
||||
return [SFAppDelegate getInstance].motionManager.deviceMotionAvailable;
|
||||
|
||||
default:
|
||||
|
@ -96,21 +96,21 @@ bool SensorImpl::open(Sensor::Type sensor)
|
|||
static const NSTimeInterval updateInterval = 1. / 60.;
|
||||
switch (sensor)
|
||||
{
|
||||
case Sensor::Accelerometer:
|
||||
case Sensor::Type::Accelerometer:
|
||||
[SFAppDelegate getInstance].motionManager.accelerometerUpdateInterval = updateInterval;
|
||||
break;
|
||||
|
||||
case Sensor::Gyroscope:
|
||||
case Sensor::Type::Gyroscope:
|
||||
[SFAppDelegate getInstance].motionManager.gyroUpdateInterval = updateInterval;
|
||||
break;
|
||||
|
||||
case Sensor::Magnetometer:
|
||||
case Sensor::Type::Magnetometer:
|
||||
[SFAppDelegate getInstance].motionManager.magnetometerUpdateInterval = updateInterval;
|
||||
break;
|
||||
|
||||
case Sensor::Gravity:
|
||||
case Sensor::UserAcceleration:
|
||||
case Sensor::Orientation:
|
||||
case Sensor::Type::Gravity:
|
||||
case Sensor::Type::UserAcceleration:
|
||||
case Sensor::Type::Orientation:
|
||||
[SFAppDelegate getInstance].motionManager.deviceMotionUpdateInterval = updateInterval;
|
||||
break;
|
||||
|
||||
|
@ -137,35 +137,35 @@ Vector3f SensorImpl::update()
|
|||
|
||||
switch (m_sensor)
|
||||
{
|
||||
case Sensor::Accelerometer:
|
||||
case Sensor::Type::Accelerometer:
|
||||
// Acceleration is given in G, convert to m/s^2
|
||||
value.x = manager.accelerometerData.acceleration.x * 9.81f;
|
||||
value.y = manager.accelerometerData.acceleration.y * 9.81f;
|
||||
value.z = manager.accelerometerData.acceleration.z * 9.81f;
|
||||
break;
|
||||
|
||||
case Sensor::Gyroscope:
|
||||
case Sensor::Type::Gyroscope:
|
||||
// Rotation rates are given in rad/s, convert to deg/s
|
||||
value.x = toDegrees(manager.gyroData.rotationRate.x);
|
||||
value.y = toDegrees(manager.gyroData.rotationRate.y);
|
||||
value.z = toDegrees(manager.gyroData.rotationRate.z);
|
||||
break;
|
||||
|
||||
case Sensor::Magnetometer:
|
||||
case Sensor::Type::Magnetometer:
|
||||
// Magnetic field is given in microteslas
|
||||
value.x = manager.magnetometerData.magneticField.x;
|
||||
value.y = manager.magnetometerData.magneticField.y;
|
||||
value.z = manager.magnetometerData.magneticField.z;
|
||||
break;
|
||||
|
||||
case Sensor::UserAcceleration:
|
||||
case Sensor::Type::UserAcceleration:
|
||||
// User acceleration is given in G, convert to m/s^2
|
||||
value.x = manager.deviceMotion.userAcceleration.x * 9.81f;
|
||||
value.y = manager.deviceMotion.userAcceleration.y * 9.81f;
|
||||
value.z = manager.deviceMotion.userAcceleration.z * 9.81f;
|
||||
break;
|
||||
|
||||
case Sensor::Orientation:
|
||||
case Sensor::Type::Orientation:
|
||||
// Absolute rotation (Euler) angles are given in radians, convert to degrees
|
||||
value.x = toDegrees(manager.deviceMotion.attitude.yaw);
|
||||
value.y = toDegrees(manager.deviceMotion.attitude.pitch);
|
||||
|
@ -189,30 +189,30 @@ void SensorImpl::setEnabled(bool enabled)
|
|||
|
||||
switch (m_sensor)
|
||||
{
|
||||
case Sensor::Accelerometer:
|
||||
case Sensor::Type::Accelerometer:
|
||||
if (enabled)
|
||||
[[SFAppDelegate getInstance].motionManager startAccelerometerUpdates];
|
||||
else
|
||||
[[SFAppDelegate getInstance].motionManager stopAccelerometerUpdates];
|
||||
break;
|
||||
|
||||
case Sensor::Gyroscope:
|
||||
case Sensor::Type::Gyroscope:
|
||||
if (enabled)
|
||||
[[SFAppDelegate getInstance].motionManager startGyroUpdates];
|
||||
else
|
||||
[[SFAppDelegate getInstance].motionManager stopGyroUpdates];
|
||||
break;
|
||||
|
||||
case Sensor::Magnetometer:
|
||||
case Sensor::Type::Magnetometer:
|
||||
if (enabled)
|
||||
[[SFAppDelegate getInstance].motionManager startMagnetometerUpdates];
|
||||
else
|
||||
[[SFAppDelegate getInstance].motionManager stopMagnetometerUpdates];
|
||||
break;
|
||||
|
||||
case Sensor::Gravity:
|
||||
case Sensor::UserAcceleration:
|
||||
case Sensor::Orientation:
|
||||
case Sensor::Type::Gravity:
|
||||
case Sensor::Type::UserAcceleration:
|
||||
case Sensor::Type::Orientation:
|
||||
// these 3 sensors all share the same implementation, so we must disable
|
||||
// it only if the three sensors are disabled
|
||||
if (enabled)
|
||||
|
|
|
@ -214,9 +214,9 @@ bool WindowImplUIKit::hasFocus() const
|
|||
////////////////////////////////////////////////////////////
|
||||
void WindowImplUIKit::forwardEvent(Event event)
|
||||
{
|
||||
if (event.type == Event::GainedFocus)
|
||||
if (event.type == Event::Type::GainedFocus)
|
||||
m_hasFocus = true;
|
||||
else if (event.type == Event::LostFocus)
|
||||
else if (event.type == Event::Type::LostFocus)
|
||||
m_hasFocus = false;
|
||||
|
||||
pushEvent(event);
|
||||
|
|
Loading…
Reference in a new issue