diff --git a/Input/Joysticks/ThrustMaster/Warthog/README b/Input/Joysticks/ThrustMaster/Warthog/README index a0aa1d4e5..aced0ebcf 100644 --- a/Input/Joysticks/ThrustMaster/Warthog/README +++ b/Input/Joysticks/ThrustMaster/Warthog/README @@ -69,7 +69,7 @@ via raw HID support. If you don't have a user group "js" (for joystick hardware access) either create one or, in the fourth line, use a group instead where all joystick users are member, e.g. GROUP:="users". Then plug your Warthog devices out - and in again and check if this created two device files under /dev/hid/: + and in again and check if this created two device links: $ ls -l /dev/input/hidraw/* lrwxrwxrwx 1 root root 10 Oct 2 14:23 Thrustmaster_Throttle_-_HOTAS_Warthog -> ../hidraw1 @@ -80,7 +80,7 @@ via raw HID support. $ ls -l /dev/hidraw* crw-rw---- 1 root js 251, 0 Oct 2 09:11 /dev/hidraw0 crw-rw---- 1 root js 251, 1 Oct 2 14:23 /dev/hidraw1 - + ^^ ^^ (3) Allow FlightGear to write to the two devices. The best way to do this is diff --git a/Input/Joysticks/ThrustMaster/Warthog/Warthog-Throttle.xml b/Input/Joysticks/ThrustMaster/Warthog/Warthog-Throttle.xml index 03fa15e62..4df6572b8 100644 --- a/Input/Joysticks/ThrustMaster/Warthog/Warthog-Throttle.xml +++ b/Input/Joysticks/ThrustMaster/Warthog/Warthog-Throttle.xml @@ -50,7 +50,8 @@ warthog.throttle.set_leds(0, 1, 2, 3, 4, 5); settimer(gearcheck, 0.5); }; - init and gearcheck(); + if (init) + gearcheck(); var mod = 0; var m = props.globals.initNode("/devices/status/joysticks/warthog/modifier", mod, "INT"); diff --git a/Input/Joysticks/ThrustMaster/Warthog/warthog.nas b/Input/Joysticks/ThrustMaster/Warthog/warthog.nas index 847a8defa..56cf3d96a 100644 --- a/Input/Joysticks/ThrustMaster/Warthog/warthog.nas +++ b/Input/Joysticks/ThrustMaster/Warthog/warthog.nas @@ -1,4 +1,4 @@ -# HIDRAW Interface (currently Linux-only; see README) +# Hardware Interface (currently Linux/HIDRAW-only; see README) var device = { new: func(path, bufsize) { @@ -21,9 +21,19 @@ var device = { io.write(file, buf); io.close(file); }, - set_leds: func(on, which...) { # on/off, list of leds (0: background, 1-5) +}; + + +var joystick = { + parents: [device.new("/dev/input/hidraw/Thustmaster_Joystick_-_HOTAS_Warthog", 12)], +}; + + +var throttle = { + parents: [device.new("/dev/input/hidraw/Thrustmaster_Throttle_-_HOTAS_Warthog", 36)], + set_leds: func(state, which...) { # on/off, list of leds (0: background, 1-5) foreach (var w; which) - me.leds = bits.switch(me.leds, me._ledmap[w], on); + me.leds = bits.switch(me.leds, me._ledmap[w], state); me.send(6, me.leds, me.bright); }, toggle_leds: func(which...) { @@ -31,7 +41,7 @@ var device = { me.leds = bits.toggle(me.leds, me._ledmap[w]); me.send(6, me.leds, me.bright); }, - set_brightness: func(v) { + set_brightness: func(v) { # clamped to [0,5], where 0 is off and 5 is bright me.send(6, me.leds, me.bright = v < 0 ? 0 : v > 5 ? 5 : v); }, brighter: func { @@ -46,9 +56,6 @@ var device = { }; -var joystick = device.new("/dev/input/hidraw/Thustmaster_Joystick_-_HOTAS_Warthog", 12); -var throttle = device.new("/dev/input/hidraw/Thrustmaster_Throttle_-_HOTAS_Warthog", 36); - -throttle.set_brightness(1); +throttle.set_brightness(1); # LEDs dark (but on) throttle.set_leds(1, 0); # backlight on -throttle.set_leds(0, 1, 2, 3, 4, 5); # other LEDs off +setlistener("/sim/signals/exit", func throttle.set_leds(0, 1, 2, 3, 4, 5), 1); # other LEDs off (now and at exit)