mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-09-10 09:35:25 -05:00
Add infrastructure for mouse events
This commit is contained in:
@@ -13,6 +13,8 @@
|
||||
#define FT_ASYNC_CALL FT_ReadPipeAsync
|
||||
#endif
|
||||
|
||||
#define REAL_SERIAL_NUMBER_SIZE 16
|
||||
#define SERIAL_NUMBER_SIZE (REAL_SERIAL_NUMBER_SIZE+1)
|
||||
#define MAX_SAMPLES_IN 1096
|
||||
|
||||
// Max value supported by old FTD3XX versions...
|
||||
@@ -39,7 +41,7 @@ struct PACKED CaptureReceived {
|
||||
|
||||
struct CaptureData {
|
||||
FT_HANDLE handle;
|
||||
char chosen_serial_number[17];
|
||||
char chosen_serial_number[SERIAL_NUMBER_SIZE];
|
||||
std::string error_text;
|
||||
bool new_error_text;
|
||||
CaptureReceived capture_buf[NUM_CONCURRENT_DATA_BUFFERS];
|
||||
|
||||
@@ -44,15 +44,18 @@ struct PACKED VideoOutputData {
|
||||
#pragma pack(pop)
|
||||
|
||||
struct SFEvent {
|
||||
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) {}
|
||||
SFEvent(sf::Event::EventType type, sf::Keyboard::Key code, uint32_t unicode, uint32_t joystickId, uint32_t joy_button, sf::Joystick::Axis axis, float position, sf::Mouse::Button mouse_button, int mouse_x, int mouse_y) : type(type), code(code), unicode(unicode), joystickId(joystickId), joy_button(joy_button), axis(axis), position(position), mouse_button(mouse_button), mouse_x(mouse_x), mouse_y(mouse_y) {}
|
||||
|
||||
sf::Event::EventType type;
|
||||
sf::Keyboard::Key code;
|
||||
uint32_t unicode;
|
||||
uint32_t joystickId;
|
||||
uint32_t button;
|
||||
uint32_t joy_button;
|
||||
sf::Joystick::Axis axis;
|
||||
float position;
|
||||
sf::Mouse::Button mouse_button;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
};
|
||||
|
||||
struct out_rect_data {
|
||||
|
||||
@@ -33,12 +33,12 @@ static void list_devices(DevicesList &devices_list) {
|
||||
if (!FT_FAILED(ftStatus) && numDevs > 0)
|
||||
{
|
||||
devices_list.numAllocedDevices = numDevs;
|
||||
devices_list.serialNumbers = new char[devices_list.numAllocedDevices * 17];
|
||||
devices_list.serialNumbers = new char[devices_list.numAllocedDevices * SERIAL_NUMBER_SIZE];
|
||||
FT_HANDLE ftHandle = NULL;
|
||||
DWORD Flags = 0;
|
||||
DWORD Type = 0;
|
||||
DWORD ID = 0;
|
||||
char SerialNumber[16] = { 0 };
|
||||
char SerialNumber[REAL_SERIAL_NUMBER_SIZE] = { 0 };
|
||||
char Description[32] = { 0 };
|
||||
for (DWORD i = 0; i < numDevs; i++)
|
||||
{
|
||||
@@ -48,9 +48,9 @@ static void list_devices(DevicesList &devices_list) {
|
||||
{
|
||||
for(int i = 0; i < sizeof(valid_descriptions) / sizeof(*valid_descriptions); i++) {
|
||||
if(Description == valid_descriptions[i]) {
|
||||
for(int i = 0; i < 16; i++)
|
||||
devices_list.serialNumbers[(17 * devices_list.numValidDevices) + i] = SerialNumber[i];
|
||||
devices_list.serialNumbers[(17 * devices_list.numValidDevices) + 16] = 0;
|
||||
for(int i = 0; i < REAL_SERIAL_NUMBER_SIZE; i++)
|
||||
devices_list.serialNumbers[(SERIAL_NUMBER_SIZE * devices_list.numValidDevices) + i] = SerialNumber[i];
|
||||
devices_list.serialNumbers[(SERIAL_NUMBER_SIZE * devices_list.numValidDevices) + REAL_SERIAL_NUMBER_SIZE] = 0;
|
||||
++devices_list.numValidDevices;
|
||||
break;
|
||||
}
|
||||
@@ -109,8 +109,8 @@ bool connect(bool print_failed, CaptureData* capture_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < 17; i++)
|
||||
capture_data->chosen_serial_number[i] = devices_list.serialNumbers[(17 * chosen_device) + i];
|
||||
for(int i = 0; i < SERIAL_NUMBER_SIZE; i++)
|
||||
capture_data->chosen_serial_number[i] = devices_list.serialNumbers[(SERIAL_NUMBER_SIZE * chosen_device) + i];
|
||||
delete []devices_list.serialNumbers;
|
||||
|
||||
if (FT_Create(capture_data->chosen_serial_number, FT_OPEN_BY_SERIAL_NUMBER, &capture_data->handle)) {
|
||||
|
||||
@@ -517,7 +517,13 @@ void WindowScreen::poll_window() {
|
||||
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);
|
||||
int mouse_x = event.mouseButton.x;
|
||||
int mouse_y = event.mouseButton.y;
|
||||
if(event.type == sf::Event::MouseMoved) {
|
||||
mouse_x = event.mouseMove.x;
|
||||
mouse_y = event.mouseMove.y;
|
||||
}
|
||||
events_queue.emplace(event.type, event.key.code, event.text.unicode, joystickId, event.joystickButton.button, event.joystickMove.axis, event.joystickMove.position, event.mouseButton.button, mouse_x, mouse_y);
|
||||
}
|
||||
this->events_access->unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user