summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-08-01 22:10:38 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-08-01 22:10:38 -0300
commit678948068bbde7f12a9c5f28a467b6cf4d127851 (patch)
tree75572f3a5cc6089a6ca3046e9307d0a7c0b72c51 /platform/windows
parent9ff6d55822647c87eef392147ea15641d0922d47 (diff)
Small Issues & Maintenance
-=-=-=-=-=-=-=-=-=-=-=-=-= -Begin work on Navigation Meshes (simple pathfinding for now, will improve soon) -More doc on theme overriding -Upgraded OpenSSL to version without bugs -Misc bugfixes
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp49
-rw-r--r--platform/windows/os_windows.h4
2 files changed, 42 insertions, 11 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 64219d6c17..778609950e 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -574,6 +574,8 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
void OS_Windows::probe_joysticks() {
+ static uint32_t last_attached = 0;
+
int device_count = joyGetNumDevs();
JOYINFOEX jinfo;
@@ -582,21 +584,40 @@ void OS_Windows::probe_joysticks() {
for (int i=0; i<JOYSTICKS_MAX; i++) {
- joysticks[i].attached = (device_count > 0) && (joyGetPosEx(JOYSTICKID1 + i, &jinfo) == JOYERR_NOERROR);
-
- if (!joysticks[i].attached) {
+ Joystick joy;
+ joy.id = i;
+ joy.attached = (device_count > 0) && (joyGetPosEx(JOYSTICKID1 + i, &jinfo) == JOYERR_NOERROR);
+ if (joy.attached == (last_attached & (1 << i) != 0)) {
continue;
};
- joysticks[i].last_buttons = jinfo.dwButtons;
+ // there's been a change since last call
+
+ if (joy.attached)
+ last_attached = last_attached | (1 << i);
+ else
+ last_attached &= ~(1 << i);
+
+ if (joy.attached) {
- joysticks[i].last_axis[0] = jinfo.dwXpos;
- joysticks[i].last_axis[1] = jinfo.dwYpos;
- joysticks[i].last_axis[2] = jinfo.dwZpos;
- joysticks[i].last_axis[3] = jinfo.dwRpos;
- joysticks[i].last_axis[4] = jinfo.dwUpos;
- joysticks[i].last_axis[5] = jinfo.dwVpos;
+ joy.last_buttons = jinfo.dwButtons;
+
+ joy.last_axis[0] = jinfo.dwXpos;
+ joy.last_axis[1] = jinfo.dwYpos;
+ joy.last_axis[2] = jinfo.dwZpos;
+ joy.last_axis[3] = jinfo.dwRpos;
+ joy.last_axis[4] = jinfo.dwUpos;
+ joy.last_axis[5] = jinfo.dwVpos;
+
+ JOYCAPS jcaps;
+ MMRESULT res = joyGetDevCaps(JOYSTICKID1 + i, &jcaps, sizeof(jcaps));
+ if (res == JOYERR_NOERROR) {
+ joy.name = jcaps.szPname;
+ };
+ };
+
+ joystick_change_queue.push_back(joy);
};
};
@@ -998,7 +1019,13 @@ void OS_Windows::initialize(const VideoMode& p_desired,int p_video_driver,int p_
spatial_sound_2d_server = memnew( SpatialSound2DServerSW );
spatial_sound_2d_server->init();
- probe_joysticks();
+ probe_joysticks(); // todo: move this to a thread
+ while (joystick_change_queue.size() > 0) {
+ Joystick joy = joystick_change_queue.front()->get();
+ joystick_change_queue.pop_front();
+ joysticks[joy.id] = joy;
+ input->joy_connection_changed(joy.id, joy.attached, joy.name);
+ };
TRACKMOUSEEVENT tme;
tme.cbSize=sizeof(TRACKMOUSEEVENT);
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 365808d175..c9eb475e1a 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -106,13 +106,16 @@ class OS_Windows : public OS {
struct Joystick {
+ int id;
bool attached;
DWORD last_axis[JOY_AXIS_COUNT];
DWORD last_buttons;
DWORD last_pov;
+ String name;
Joystick() {
+ id = -1;
attached = false;
for (int i=0; i<JOY_AXIS_COUNT; i++) {
@@ -123,6 +126,7 @@ class OS_Windows : public OS {
};
};
+ List<Joystick> joystick_change_queue;
int joystick_count;
Joystick joysticks[JOYSTICKS_MAX];