mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-04-25 15:45:42 -05:00
Add basic infrastructure for JoyStick support
This commit is contained in:
parent
3a63c04f7f
commit
54ef5f52fd
|
|
@ -44,11 +44,15 @@ struct PACKED VideoOutputData {
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
struct SFEvent {
|
struct SFEvent {
|
||||||
SFEvent(sf::Event::EventType type, sf::Keyboard::Key code, uint32_t unicode) : type(type), code(code), unicode(unicode) {}
|
SFEvent(sf::Event::EventType type, sf::Keyboard::Key code, uint32_t unicode, uint32_t joystickId, uint32_t button, sf::Joystick::Axis axis, float position) : type(type), code(code), unicode(unicode), joystickId(joystickId), button(button), axis(axis), position(position) {}
|
||||||
|
|
||||||
sf::Event::EventType type;
|
sf::Event::EventType type;
|
||||||
sf::Keyboard::Key code;
|
sf::Keyboard::Key code;
|
||||||
uint32_t unicode;
|
uint32_t unicode;
|
||||||
|
uint32_t joystickId;
|
||||||
|
uint32_t button;
|
||||||
|
sf::Joystick::Axis axis;
|
||||||
|
float position;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct out_rect_data {
|
struct out_rect_data {
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,10 @@ void WindowScreen::poll() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case sf::Event::JoystickButtonPressed:
|
||||||
|
break;
|
||||||
|
case sf::Event::JoystickMoved:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
@ -508,7 +512,12 @@ void WindowScreen::poll_window() {
|
||||||
sf::Event event;
|
sf::Event event;
|
||||||
this->events_access->lock();
|
this->events_access->lock();
|
||||||
while(this->m_win.pollEvent(event)) {
|
while(this->m_win.pollEvent(event)) {
|
||||||
events_queue.emplace(event.type, event.key.code, event.text.unicode);
|
int joystickId = event.joystickConnect.joystickId;
|
||||||
|
if(event.type == sf::Event::JoystickButtonPressed)
|
||||||
|
joystickId = event.joystickButton.joystickId;
|
||||||
|
else if(event.type == sf::Event::JoystickMoved)
|
||||||
|
joystickId = event.joystickMove.joystickId;
|
||||||
|
events_queue.emplace(event.type, event.key.code, event.text.unicode, joystickId, event.joystickButton.button, event.joystickMove.axis, event.joystickMove.position);
|
||||||
}
|
}
|
||||||
this->events_access->unlock();
|
this->events_access->unlock();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user