Skip to content

Commit b63c251

Browse files
authored
Merge pull request Rust-SDL2#955 from Cobrand/master
Joy/controller Events all have `which` member of type u32
2 parents 4600bb9 + 1b0da8f commit b63c251

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

src/sdl2/event.rs

+41-41
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,15 @@ pub enum Event {
538538
JoyAxisMotion {
539539
timestamp: u32,
540540
/// The joystick's `id`
541-
which: i32,
541+
which: u32,
542542
axis_idx: u8,
543543
value: i16
544544
},
545545

546546
JoyBallMotion {
547547
timestamp: u32,
548548
/// The joystick's `id`
549-
which: i32,
549+
which: u32,
550550
ball_idx: u8,
551551
xrel: i16,
552552
yrel: i16
@@ -555,70 +555,70 @@ pub enum Event {
555555
JoyHatMotion {
556556
timestamp: u32,
557557
/// The joystick's `id`
558-
which: i32,
558+
which: u32,
559559
hat_idx: u8,
560560
state: HatState
561561
},
562562

563563
JoyButtonDown {
564564
timestamp: u32,
565565
/// The joystick's `id`
566-
which: i32,
566+
which: u32,
567567
button_idx: u8
568568
},
569569
JoyButtonUp {
570570
timestamp: u32,
571571
/// The joystick's `id`
572-
which: i32,
572+
which: u32,
573573
button_idx: u8
574574
},
575575

576576
JoyDeviceAdded {
577577
timestamp: u32,
578578
/// The newly added joystick's `joystick_index`
579-
which: i32
579+
which: u32
580580
},
581581
JoyDeviceRemoved {
582582
timestamp: u32,
583583
/// The joystick's `id`
584-
which: i32
584+
which: u32
585585
},
586586

587587
ControllerAxisMotion {
588588
timestamp: u32,
589589
/// The controller's joystick `id`
590-
which: i32,
590+
which: u32,
591591
axis: Axis,
592592
value: i16
593593
},
594594

595595
ControllerButtonDown {
596596
timestamp: u32,
597597
/// The controller's joystick `id`
598-
which: i32,
598+
which: u32,
599599
button: Button
600600
},
601601
ControllerButtonUp {
602602
timestamp: u32,
603603
/// The controller's joystick `id`
604-
which: i32,
604+
which: u32,
605605
button: Button
606606
},
607607

608608
ControllerDeviceAdded {
609609
timestamp: u32,
610610
/// The newly added controller's `joystick_index`
611-
which: i32
611+
which: u32
612612
},
613613
ControllerDeviceRemoved {
614614
timestamp: u32,
615615
/// The controller's joystick `id`
616-
which: i32
616+
which: u32
617617
},
618618
ControllerDeviceRemapped {
619619
timestamp: u32,
620620
/// The controller's joystick `id`
621-
which: i32
621+
which: u32
622622
},
623623

624624
FingerDown {
@@ -985,7 +985,7 @@ impl Event {
985985
let event = sys::SDL_JoyAxisEvent {
986986
type_: SDL_EventType::SDL_JOYAXISMOTION as u32,
987987
timestamp,
988-
which,
988+
which: which as i32,
989989
axis: axis_idx,
990990
value,
991991
padding1: 0,
@@ -1009,7 +1009,7 @@ impl Event {
10091009
let event = sys::SDL_JoyBallEvent {
10101010
type_: SDL_EventType::SDL_JOYBALLMOTION as u32,
10111011
timestamp,
1012-
which,
1012+
which: which as i32,
10131013
ball: ball_idx,
10141014
xrel,
10151015
yrel,
@@ -1033,7 +1033,7 @@ impl Event {
10331033
let event = sys::SDL_JoyHatEvent {
10341034
type_: SDL_EventType::SDL_JOYHATMOTION as u32,
10351035
timestamp,
1036-
which,
1036+
which: which as i32,
10371037
hat: hat_idx,
10381038
value: hatvalue,
10391039
padding1: 0,
@@ -1053,7 +1053,7 @@ impl Event {
10531053
let event = sys::SDL_JoyButtonEvent {
10541054
type_: SDL_EventType::SDL_JOYBUTTONDOWN as u32,
10551055
timestamp,
1056-
which,
1056+
which: which as i32,
10571057
button: button_idx,
10581058
state: sys::SDL_PRESSED as u8,
10591059
padding1: 0,
@@ -1074,7 +1074,7 @@ impl Event {
10741074
let event = sys::SDL_JoyButtonEvent {
10751075
type_: SDL_EventType::SDL_JOYBUTTONUP as u32,
10761076
timestamp,
1077-
which,
1077+
which: which as i32,
10781078
button: button_idx,
10791079
state: sys::SDL_RELEASED as u8,
10801080
padding1: 0,
@@ -1109,7 +1109,7 @@ impl Event {
11091109
let event = sys::SDL_JoyDeviceEvent {
11101110
type_: SDL_EventType::SDL_JOYDEVICEREMOVED as u32,
11111111
timestamp,
1112-
which,
1112+
which: which as i32,
11131113
};
11141114
unsafe {
11151115
ptr::copy(&event, ret.as_mut_ptr() as *mut sys::SDL_JoyDeviceEvent, 1);
@@ -1127,7 +1127,7 @@ impl Event {
11271127
let event = sys::SDL_ControllerAxisEvent {
11281128
type_: SDL_EventType::SDL_CONTROLLERAXISMOTION as u32,
11291129
timestamp,
1130-
which,
1130+
which: which as i32,
11311131
axis: axisval as u8,
11321132
value,
11331133
padding1: 0,
@@ -1149,7 +1149,7 @@ impl Event {
11491149
let event = sys::SDL_ControllerButtonEvent {
11501150
type_: SDL_EventType::SDL_CONTROLLERBUTTONDOWN as u32,
11511151
timestamp,
1152-
which,
1152+
which: which as i32,
11531153
// This conversion turns an i32 into a u8; signed-to-unsigned conversions
11541154
// are a bit of a code smell, but that appears to be how SDL defines it.
11551155
button: buttonval as u8,
@@ -1172,7 +1172,7 @@ impl Event {
11721172
let event = sys::SDL_ControllerButtonEvent {
11731173
type_: SDL_EventType::SDL_CONTROLLERBUTTONUP as u32,
11741174
timestamp,
1175-
which,
1175+
which: which as i32,
11761176
button: buttonval as u8,
11771177
state: sys::SDL_RELEASED as u8,
11781178
padding1: 0,
@@ -1207,7 +1207,7 @@ impl Event {
12071207
let event = sys::SDL_ControllerDeviceEvent {
12081208
type_: SDL_EventType::SDL_CONTROLLERDEVICEREMOVED as u32,
12091209
timestamp,
1210-
which,
1210+
which: which as i32,
12111211
};
12121212
unsafe {
12131213
ptr::copy(&event, ret.as_mut_ptr() as *mut sys::SDL_ControllerDeviceEvent, 1);
@@ -1223,7 +1223,7 @@ impl Event {
12231223
let event = sys::SDL_ControllerDeviceEvent {
12241224
type_: SDL_EventType::SDL_CONTROLLERDEVICEREMAPPED as u32,
12251225
timestamp,
1226-
which,
1226+
which: which as i32,
12271227
};
12281228
unsafe {
12291229
ptr::copy(&event, ret.as_mut_ptr() as *mut sys::SDL_ControllerDeviceEvent, 1);
@@ -1360,7 +1360,7 @@ impl Event {
13601360
Event::MouseMotion {
13611361
timestamp: event.timestamp,
13621362
window_id: event.windowID,
1363-
which: event.which,
1363+
which: event.which as u32,
13641364
mousestate: mouse::MouseState::from_sdl_state(event.state),
13651365
x: event.x,
13661366
y: event.y,
@@ -1374,7 +1374,7 @@ impl Event {
13741374
Event::MouseButtonDown {
13751375
timestamp: event.timestamp,
13761376
window_id: event.windowID,
1377-
which: event.which,
1377+
which: event.which as u32,
13781378
mouse_btn: mouse::MouseButton::from_ll(event.button),
13791379
clicks: event.clicks,
13801380
x: event.x,
@@ -1387,7 +1387,7 @@ impl Event {
13871387
Event::MouseButtonUp {
13881388
timestamp: event.timestamp,
13891389
window_id: event.windowID,
1390-
which: event.which,
1390+
which: event.which as u32,
13911391
mouse_btn: mouse::MouseButton::from_ll(event.button),
13921392
clicks: event.clicks,
13931393
x: event.x,
@@ -1400,7 +1400,7 @@ impl Event {
14001400
Event::MouseWheel {
14011401
timestamp: event.timestamp,
14021402
window_id: event.windowID,
1403-
which: event.which,
1403+
which: event.which as u32,
14041404
x: event.x,
14051405
y: event.y,
14061406
direction: mouse::MouseWheelDirection::from_ll(event.direction),
@@ -1411,7 +1411,7 @@ impl Event {
14111411
let event = raw.jaxis;
14121412
Event::JoyAxisMotion {
14131413
timestamp: event.timestamp,
1414-
which: event.which,
1414+
which: event.which as u32,
14151415
axis_idx: event.axis,
14161416
value: event.value
14171417
}
@@ -1420,7 +1420,7 @@ impl Event {
14201420
let event = raw.jball;
14211421
Event::JoyBallMotion {
14221422
timestamp: event.timestamp,
1423-
which: event.which,
1423+
which: event.which as u32,
14241424
ball_idx: event.ball,
14251425
xrel: event.xrel,
14261426
yrel: event.yrel
@@ -1430,7 +1430,7 @@ impl Event {
14301430
let event = raw.jhat;
14311431
Event::JoyHatMotion {
14321432
timestamp: event.timestamp,
1433-
which: event.which,
1433+
which: event.which as u32,
14341434
hat_idx: event.hat,
14351435
state: joystick::HatState::from_raw(event.value),
14361436
}
@@ -1439,30 +1439,30 @@ impl Event {
14391439
let event = raw.jbutton;
14401440
Event::JoyButtonDown {
14411441
timestamp: event.timestamp,
1442-
which: event.which,
1442+
which: event.which as u32,
14431443
button_idx: event.button
14441444
}
14451445
}
14461446
EventType::JoyButtonUp => {
14471447
let event = raw.jbutton;
14481448
Event::JoyButtonUp {
14491449
timestamp: event.timestamp,
1450-
which: event.which,
1450+
which: event.which as u32,
14511451
button_idx: event.button
14521452
}
14531453
}
14541454
EventType::JoyDeviceAdded => {
14551455
let event = raw.jdevice;
14561456
Event::JoyDeviceAdded {
14571457
timestamp: event.timestamp,
1458-
which: event.which as i32
1458+
which: event.which as u32,
14591459
}
14601460
}
14611461
EventType::JoyDeviceRemoved => {
14621462
let event = raw.jdevice;
14631463
Event::JoyDeviceRemoved {
14641464
timestamp: event.timestamp,
1465-
which: event.which
1465+
which: event.which as u32,
14661466
}
14671467
}
14681468

@@ -1472,7 +1472,7 @@ impl Event {
14721472

14731473
Event::ControllerAxisMotion {
14741474
timestamp: event.timestamp,
1475-
which: event.which,
1475+
which: event.which as u32,
14761476
axis,
14771477
value: event.value
14781478
}
@@ -1483,7 +1483,7 @@ impl Event {
14831483

14841484
Event::ControllerButtonDown {
14851485
timestamp: event.timestamp,
1486-
which: event.which,
1486+
which: event.which as u32,
14871487
button
14881488
}
14891489
}
@@ -1493,29 +1493,29 @@ impl Event {
14931493

14941494
Event::ControllerButtonUp {
14951495
timestamp: event.timestamp,
1496-
which: event.which,
1496+
which: event.which as u32,
14971497
button
14981498
}
14991499
}
15001500
EventType::ControllerDeviceAdded => {
15011501
let event = raw.cdevice;
15021502
Event::ControllerDeviceAdded {
15031503
timestamp: event.timestamp,
1504-
which: event.which as i32
1504+
which: event.which as u32,
15051505
}
15061506
}
15071507
EventType::ControllerDeviceRemoved => {
15081508
let event = raw.cdevice;
15091509
Event::ControllerDeviceRemoved {
15101510
timestamp: event.timestamp,
1511-
which: event.which
1511+
which: event.which as u32,
15121512
}
15131513
}
15141514
EventType::ControllerDeviceRemapped => {
15151515
let event = raw.cdevice;
15161516
Event::ControllerDeviceRemapped {
15171517
timestamp: event.timestamp,
1518-
which: event.which
1518+
which: event.which as u32,
15191519
}
15201520
}
15211521

0 commit comments

Comments
 (0)