summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/context_gl_win.cpp2
-rw-r--r--platform/windows/detect.py4
-rw-r--r--platform/windows/joypad.cpp30
-rw-r--r--platform/windows/joypad.h4
-rw-r--r--platform/windows/os_windows.cpp10
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/windows/packet_peer_udp_winsock.cpp25
-rw-r--r--platform/windows/packet_peer_udp_winsock.h4
8 files changed, 37 insertions, 43 deletions
diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp
index d737502bf5..449ac264a6 100644
--- a/platform/windows/context_gl_win.cpp
+++ b/platform/windows/context_gl_win.cpp
@@ -169,7 +169,7 @@ Error ContextGL_Win::initialize() {
if (wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported
{
- MessageBox(NULL, "Cannot get Proc Adress for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION);
+ MessageBox(NULL, "Cannot get Proc Address for CreateContextAttribs", "ERROR", MB_OK | MB_ICONEXCLAMATION);
wglDeleteContext(hRC);
return ERR_CANT_CREATE;
}
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 382783d6bc..6080c6f1dc 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -283,7 +283,7 @@ def configure(env):
+ " will be executed and inform you.")
sys.exit()
- # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the propper command prompt
+ # Forcing bits argument because MSVC does not have a flag to set this through SCons... it's different compilers (cl.exe's) called from the proper command prompt
# that decide the architecture that is build for. Scons can only detect the os.getenviron (because vsvarsall.bat sets a lot of stuff for cl.exe to work with)
env["bits"] = "32"
env["x86_libtheora_opt_vc"] = True
@@ -361,7 +361,7 @@ def configure(env):
elif (env["target"] == "debug"):
- env.Append(CCFLAGS=['-g', '-Wall', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
+ env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
env["CC"] = mingw_prefix + "gcc"
env['AS'] = mingw_prefix + "as"
diff --git a/platform/windows/joypad.cpp b/platform/windows/joypad.cpp
index 2472940ef3..86f7033d40 100644
--- a/platform/windows/joypad.cpp
+++ b/platform/windows/joypad.cpp
@@ -319,7 +319,7 @@ void JoypadWindows::probe_joypads() {
}
}
-unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
+void JoypadWindows::process_joypads() {
HRESULT hr;
@@ -337,16 +337,16 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int i = 0; i <= 16; i++) {
- p_last_id = input->joy_button(p_last_id, joy.id, i, joy.state.Gamepad.wButtons & button_mask);
+ input->joy_button(joy.id, i, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2;
}
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
- p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
+ input->joy_axis(joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true));
+ input->joy_axis(joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true));
+ input->joy_axis(joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
+ input->joy_axis(joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
+ input->joy_axis(joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
joy.last_packet = joy.state.dwPacketNumber;
}
uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id);
@@ -384,7 +384,7 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
continue;
}
- p_last_id = post_hat(p_last_id, joy->id, js.rgdwPOV[0]);
+ post_hat(joy->id, js.rgdwPOV[0]);
for (int j = 0; j < 128; j++) {
@@ -392,14 +392,14 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
if (!joy->last_buttons[j]) {
- p_last_id = input->joy_button(p_last_id, joy->id, j, true);
+ input->joy_button(joy->id, j, true);
joy->last_buttons[j] = true;
}
} else {
if (joy->last_buttons[j]) {
- p_last_id = input->joy_button(p_last_id, joy->id, j, false);
+ input->joy_button(joy->id, j, false);
joy->last_buttons[j] = false;
}
}
@@ -414,16 +414,16 @@ unsigned int JoypadWindows::process_joypads(unsigned int p_last_id) {
for (int k = 0; k < count; k++) {
if (joy->joy_axis[j] == axes[k]) {
- p_last_id = input->joy_axis(p_last_id, joy->id, j, axis_correct(values[k]));
+ input->joy_axis(joy->id, j, axis_correct(values[k]));
break;
};
};
};
}
- return p_last_id;
+ return;
}
-unsigned int JoypadWindows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) {
+void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
int dpad_val = 0;
@@ -462,7 +462,7 @@ unsigned int JoypadWindows::post_hat(unsigned int p_last_id, int p_device, DWORD
dpad_val = (InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_UP);
}
- return input->joy_hat(p_last_id, p_device, dpad_val);
+ input->joy_hat(p_device, dpad_val);
};
InputDefault::JoyAxis JoypadWindows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
diff --git a/platform/windows/joypad.h b/platform/windows/joypad.h
index 7e4f6ff328..9e6aa41a34 100644
--- a/platform/windows/joypad.h
+++ b/platform/windows/joypad.h
@@ -53,7 +53,7 @@ public:
~JoypadWindows();
void probe_joypads();
- unsigned int process_joypads(unsigned int p_last_id);
+ void process_joypads();
private:
enum {
@@ -130,7 +130,7 @@ private:
void load_xinput();
void unload_xinput();
- unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad);
+ void post_hat(int p_device, DWORD p_dpad);
bool have_device(const GUID &p_guid);
bool is_xinput_device(const GUID *p_guid);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 2046ae9f44..f1a9ba5598 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -216,7 +216,6 @@ void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) {
InputEvent event;
event.type = InputEvent::SCREEN_TOUCH;
- event.ID = ++last_id;
event.screen_touch.index = idx;
event.screen_touch.pressed = p_pressed;
@@ -233,7 +232,6 @@ void OS_Windows::_drag_event(int p_x, int p_y, int idx) {
InputEvent event;
event.type = InputEvent::SCREEN_DRAG;
- event.ID = ++last_id;
event.screen_drag.index = idx;
event.screen_drag.x = p_x;
@@ -370,7 +368,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InputEvent event;
event.type = InputEvent::MOUSE_MOTION;
- event.ID = ++last_id;
InputEventMouseMotion &mm = event.mouse_motion;
mm.mod.control = (wParam & MK_CONTROL) != 0;
@@ -451,7 +448,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
InputEvent event;
event.type = InputEvent::MOUSE_BUTTON;
- event.ID = ++last_id;
InputEventMouseButton &mb = event.mouse_button;
switch (uMsg) {
@@ -582,7 +578,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
if (mb.pressed && mb.button_index > 3) {
//send release for mouse wheel
mb.pressed = false;
- event.ID = ++last_id;
input->parse_input_event(event);
}
}
@@ -780,7 +775,6 @@ void OS_Windows::process_key_events() {
if ((i == 0 && ke.uMsg == WM_CHAR) || (i > 0 && key_event_buffer[i - 1].uMsg == WM_CHAR)) {
InputEvent event;
event.type = InputEvent::KEY;
- event.ID = ++last_id;
InputEventKey &k = event.key;
k.mod = ke.mod_state;
@@ -805,7 +799,6 @@ void OS_Windows::process_key_events() {
InputEvent event;
event.type = InputEvent::KEY;
- event.ID = ++last_id;
InputEventKey &k = event.key;
k.mod = ke.mod_state;
@@ -1819,7 +1812,7 @@ void OS_Windows::process_events() {
MSG msg;
- last_id = joypad->process_joypads(last_id);
+ joypad->process_joypads();
while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
@@ -2303,7 +2296,6 @@ OS_Windows::OS_Windows(HINSTANCE _hInstance) {
hInstance = _hInstance;
pressrc = 0;
old_invalid = true;
- last_id = 0;
mouse_mode = MOUSE_MODE_VISIBLE;
#ifdef STDOUT_FILE
stdo = fopen("stdout.txt", "wb");
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index e7376d6800..25c3102ee6 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -83,7 +83,6 @@ class OS_Windows : public OS {
bool outside;
int old_x, old_y;
Point2i center;
- unsigned int last_id;
#if defined(OPENGL_ENABLED)
ContextGL_Win *gl_context;
#endif
diff --git a/platform/windows/packet_peer_udp_winsock.cpp b/platform/windows/packet_peer_udp_winsock.cpp
index 2df8addece..d98b64df7c 100644
--- a/platform/windows/packet_peer_udp_winsock.cpp
+++ b/platform/windows/packet_peer_udp_winsock.cpp
@@ -82,7 +82,7 @@ Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer, int p_buffer_siz
struct sockaddr_storage addr;
size_t addr_size = _set_sockaddr(&addr, peer_addr, peer_port, sock_type);
- _set_blocking(true);
+ _set_sock_blocking(blocking);
errno = 0;
int err;
@@ -90,7 +90,9 @@ Error PacketPeerUDPWinsock::put_packet(const uint8_t *p_buffer, int p_buffer_siz
if (WSAGetLastError() != WSAEWOULDBLOCK) {
return FAILED;
- };
+ } else if (!blocking) {
+ return ERR_UNAVAILABLE;
+ }
}
return OK;
@@ -101,15 +103,13 @@ int PacketPeerUDPWinsock::get_max_packet_size() const {
return 512; // uhm maybe not
}
-void PacketPeerUDPWinsock::_set_blocking(bool p_blocking) {
- //am no windows expert
- //hope this is the right thing
+void PacketPeerUDPWinsock::_set_sock_blocking(bool p_blocking) {
- if (blocking == p_blocking)
+ if (sock_blocking == p_blocking)
return;
- blocking = p_blocking;
- unsigned long par = blocking ? 0 : 1;
+ sock_blocking = p_blocking;
+ unsigned long par = sock_blocking ? 0 : 1;
if (ioctlsocket(sockfd, FIONBIO, &par)) {
perror("setting non-block mode");
//close();
@@ -139,8 +139,6 @@ Error PacketPeerUDPWinsock::listen(int p_port, IP_Address p_bind_address, int p_
return ERR_UNAVAILABLE;
}
- blocking = true;
-
printf("UDP Connection listening on port %i\n", p_port);
rb.resize(nearest_shift(p_recv_buffer_size));
return OK;
@@ -166,7 +164,7 @@ Error PacketPeerUDPWinsock::_poll(bool p_wait) {
return FAILED;
}
- _set_blocking(p_wait);
+ _set_sock_blocking(p_wait);
struct sockaddr_storage from = { 0 };
int len = sizeof(struct sockaddr_storage);
@@ -252,6 +250,9 @@ int PacketPeerUDPWinsock::_get_socket() {
sockfd = _socket_create(sock_type, SOCK_DGRAM, IPPROTO_UDP);
+ if (sockfd != -1)
+ _set_sock_blocking(false);
+
return sockfd;
}
@@ -273,6 +274,8 @@ PacketPeerUDP *PacketPeerUDPWinsock::_create() {
PacketPeerUDPWinsock::PacketPeerUDPWinsock() {
+ blocking = true;
+ sock_blocking = true;
sockfd = -1;
packet_port = 0;
queue_count = 0;
diff --git a/platform/windows/packet_peer_udp_winsock.h b/platform/windows/packet_peer_udp_winsock.h
index 62107364af..6b37aefead 100644
--- a/platform/windows/packet_peer_udp_winsock.h
+++ b/platform/windows/packet_peer_udp_winsock.h
@@ -45,6 +45,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
mutable int packet_port;
mutable int queue_count;
int sockfd;
+ bool sock_blocking;
IP::Type sock_type;
IP_Address peer_addr;
@@ -54,8 +55,7 @@ class PacketPeerUDPWinsock : public PacketPeerUDP {
static PacketPeerUDP *_create();
- bool blocking;
- void _set_blocking(bool p_blocking);
+ void _set_sock_blocking(bool p_blocking);
Error _poll(bool p_wait);