Class: Carbuncle::Gamepad
- Extended by:
- Enumerable
- Defined in:
- gems/carbuncle-input/mrblib/gamepad.rb
Constant Summary collapse
- DPAD_UP =
1- DPAD_RIGHT =
2- DPAD_DOWN =
3- DPAD_LEFT =
4- LEFT_UP =
1- LEFT_RIGHT =
2- LEFT_DOWN =
3- LEFT_FACE_LEFT =
4- LEFT_FACE_UP =
1- LEFT_FACE_RIGHT =
2- LEFT_FACE_DOWN =
3- UP =
1- RIGHT =
2- DOWN =
3- LEFT =
4- RIGHT_UP =
5- RIGHT_RIGHT =
6- RIGHT_DOWN =
7- RIGHT_LEFT =
8- RIGHT_FACE_UP =
5- RIGHT_FACE_RIGHT =
6- RIGHT_FACE_DOWN =
7- RIGHT_FACE_LEFT =
8- L1 =
9- L2 =
10- LEFT1 =
9- LEFT2 =
10- LB =
9- LT =
10- LEFT_BUTTON =
9- LEFT_TRIGGER =
10- ZL =
10- R1 =
11- R2 =
12- RIGHT1 =
11- RIGHT2 =
12- RB =
11- RT =
12- RIGHT_BUTTON =
11- RIGHT_TRIGGER =
12- ZR =
12- MIDDLE_LEFT =
13- SELECT =
13- MIDDLE =
14- HOME =
14- MIDDLE_RIGHT =
15- START =
15- LEFT_THUMB =
16- L3 =
16- RIGHT_THUMB =
17- R3 =
17
Constants included from Enumerable
Class Method Summary collapse
Instance Method Summary collapse
-
#layout ⇒ Symbol
Returns the detected controller layout.
-
#nintendo? ⇒ Boolean
Checks if the controller has the Nintendo™ layout.
-
#play_station? ⇒ Boolean
Checks if the controller has the PlayStation™ layout.
-
#playstation? ⇒ Boolean
Checks if the controller has the PlayStation™ layout.
-
#ps? ⇒ Boolean
Checks if the controller has the PlayStation™ layout.
-
#xbox? ⇒ Boolean
Checks if the controller has the XBox™ layout.
Methods included from Enumerable
__update_hash, all?, any?, chain, collect, count, cycle, detect, drop, drop_while, each_cons, each_slice, each_with_index, each_with_object, entries, filter_map, find_all, find_index, first, flat_map, grep, group_by, hash, include?, inject, lazy, max, max_by, min, min_by, minmax, minmax_by, none?, one?, partition, reject, reverse_each, sort, sort_by, sum, take, take_while, tally, to_h, uniq, zip
Class Method Details
.each(&block) ⇒ Object
6 7 8 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 6 def each(&block) size.times.map { |i| self[i] }.each(&block) end |
Instance Method Details
#layout ⇒ Symbol
Returns the detected controller layout.
38 39 40 41 42 43 44 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 38 def layout return :xbox if xbox? return :nintendo if nintendo? return :play_station if ps? :unknown end |
#nintendo? ⇒ Boolean
Checks if the controller has the Nintendo™ layout
32 33 34 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 32 def nintendo? name =~ /Nintendo/i end |
#play_station? ⇒ Boolean
Checks if the controller has the PlayStation™ layout
22 23 24 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 22 def play_station? ps? end |
#playstation? ⇒ Boolean
Checks if the controller has the PlayStation™ layout
27 28 29 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 27 def playstation? ps? end |
#ps? ⇒ Boolean
Checks if the controller has the PlayStation™ layout
17 18 19 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 17 def ps? name.present? && (name =~ /PlayStation/i || name =~ /Sony/i) end |
#xbox? ⇒ Boolean
Checks if the controller has the XBox™ layout
12 13 14 |
# File 'gems/carbuncle-input/mrblib/gamepad.rb', line 12 def xbox? name.present? && (name =~ /Microsoft/i || name =~ /XBox/i) end |