| # ★ Joystick | |
| # ★★★★★★★★ | |
| # | |
| # Author/s : cremno | |
| # RGSS ver : 1 to 3 | |
| module Joystick | |
| class << self | |
| def uint(v) | |
| v & 0xffff_ffff | |
| end | |
| private :uint | |
| def number_of_devices | |
| uint(Win32API.new('winmm', 'joyGetNumDevs', 'V', 'I').call) | |
| end | |
| def position(id = 0) | |
| f = Win32API.new('winmm', 'joyGetPos', 'IP', 'I') | |
| ji = "\0" * 16 | |
| [ | |
| uint(f.call(id, ji)), | |
| ji.unpack('I4') | |
| ] | |
| end | |
| def attached? | |
| number_of_devices != 0 && position[0] == 0 | |
| end | |
| end | |
| end |