Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul device events API and add gamepad support on Windows #804

Merged
merged 39 commits into from
Jun 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
700e65e
Initial implementation
francesca64 Nov 4, 2018
b552370
Corrected RAWINPUT buffer sizing
francesca64 Nov 4, 2018
8c7f720
Mostly complete XInput implementation
francesca64 Nov 4, 2018
666a391
XInput triggers
francesca64 Nov 4, 2018
da57daa
Add preliminary CHANGELOG entry.
francesca64 Nov 4, 2018
89b6cb7
match unix common API to evl 2.0
elinorbgr Nov 15, 2018
ae6ca46
wayland: eventloop2.0
elinorbgr Nov 15, 2018
e67c500
Merge onto EL2.0 branch
Osspial Feb 15, 2019
7164a69
make EventLoopProxy require T: 'static
elinorbgr Feb 15, 2019
4202b60
Merge branch 'evl2' of https://github.com/vberger/winit into el2-win-joy
Osspial Feb 15, 2019
de20a68
Revamp device event API, as well as several misc. fixes on Windows:
Osspial Feb 24, 2019
8d2826c
Add MouseEvent documentation and Device ID debug passthrough
Osspial Feb 24, 2019
abea210
Improve type safety on get_raw_input_data
Osspial Mar 1, 2019
eb6d43e
Remove button_id field from MouseEvent::Button in favor of utton
Osspial Mar 1, 2019
2f4e18a
Remove regex dependency on Windows
Osspial Mar 1, 2019
e76f47e
Remove axis filtering in XInput
Osspial Mar 1, 2019
7775524
Make gamepads not use lazy_static
Osspial Mar 2, 2019
a3468c3
Publicly expose gamepad rumble
Osspial Mar 3, 2019
437ead3
Unstack DeviceEvent and fix examples/tests
Osspial Mar 3, 2019
36b95e2
Add HANDLE retrieval method to DeviceExtWindows
Osspial Mar 3, 2019
b48bd27
Add distinction between non-joystick axes and joystick axes.
Osspial Mar 4, 2019
0b0066b
Add ability to get gamepad port
Osspial Mar 4, 2019
81eb196
Fix xinput controller hot swapping
Osspial Mar 4, 2019
a44aafa
Add functions for enumerating attached devices
Osspial Mar 4, 2019
8fe2e2c
Clamp input to [0.0, 1.0] on gamepad rumble
Osspial Mar 4, 2019
5334537
Expose gamepad rumble errors
Osspial Mar 4, 2019
af110f9
Add method to check if device is still connected
Osspial Mar 5, 2019
ffbb7b9
Add docs
Osspial Mar 5, 2019
ca6cc12
Rename AxisHint and ButtonHint to GamepadAxis and GamepadButton
Osspial Mar 5, 2019
17a9eae
Merge branch 'eventloop-2.0' into el2-win-joy
Osspial Mar 5, 2019
8fee08a
Add CHANGELOG entry
Osspial Mar 5, 2019
f29b53d
Update CHANGELOG.md
Osspial Mar 6, 2019
d65b9d8
Add HidId and MovedAbsolute
Osspial Mar 7, 2019
1e589d9
Merge branch 'eventloop-2.0' into el2-win-joy
Osspial May 29, 2019
ef5bdd5
Merge branch 'master' into el2-win-joy
Osspial Jun 19, 2019
b3f03c3
Fix xinput deprecation warnings
Osspial Jun 19, 2019
0bc48d6
Add ability to retrieve gamepad battery level
Osspial Jun 20, 2019
592d891
Fix weird imports in gamepad example
Osspial Jun 20, 2019
7bb1118
Update CHANGELOG.md
Osspial Jun 20, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add HANDLE retrieval method to DeviceExtWindows
  • Loading branch information
Osspial committed Mar 3, 2019
commit 36b95e2a2ef92ebd280c8f62cedc738c3b46df2a
18 changes: 18 additions & 0 deletions src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,43 @@ pub trait DeviceExtWindows {
///
/// Will return `None` if the device is no longer available.
fn get_persistent_identifier(&self) -> Option<String>;

/// Returns the handle of the device - `HANDLE`.
fn handle(&self) -> *mut c_void;
}

impl DeviceExtWindows for MouseId {
#[inline]
fn get_persistent_identifier(&self) -> Option<String> {
self.0.get_persistent_identifier()
}

#[inline]
fn handle(&self) -> *mut c_void {
self.0.handle() as _
}
}

impl DeviceExtWindows for KeyboardId {
#[inline]
fn get_persistent_identifier(&self) -> Option<String> {
self.0.get_persistent_identifier()
}

#[inline]
fn handle(&self) -> *mut c_void {
self.0.handle() as _
}
}

impl DeviceExtWindows for GamepadHandle {
#[inline]
fn get_persistent_identifier(&self) -> Option<String> {
self.0.get_persistent_identifier()
}

#[inline]
fn handle(&self) -> *mut c_void {
self.0.handle() as _
}
}
10 changes: 10 additions & 0 deletions src/platform_impl/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ macro_rules! device_id {
pub fn get_persistent_identifier(&self) -> Option<String> {
raw_input::get_raw_input_device_name(self.0)
}

#[inline(always)]
pub fn handle(&self) -> HANDLE {
self.0
}
}

impl From<$name> for crate::event::device::$name {
Expand Down Expand Up @@ -104,6 +109,11 @@ impl GamepadHandle {
raw_input::get_raw_input_device_name(self.handle)
}

#[inline(always)]
pub fn handle(&self) -> HANDLE {
self.handle
}

pub fn rumble(&self, left_speed: f64, right_speed: f64) {
self.rumbler.rumble(left_speed, right_speed);
}
Expand Down