• gmcl_joystick - DirectInput module with simplified interface
    316 replies, posted
  • Avatar of Night-Eagle
  • [url=http://eagle.undo.it:8083/download?id=23&act=url][img]http://eagle.undo.it:8083/download?id=23&act=img[/img] Download[/url] To find older versions, or to link to the project download, use this link: [url=http://eagle.undo.it:8083/project?id=1&act=info][img]http://eagle.undo.it:8083/project?id=1&act=img[/img] Project Link[/url] [img]http://img392.imageshack.us/img392/4052/joysticktopfaster.jpg[/img] [media]http://www.youtube.com/watch?v=kDMazLVRuWM[/media]Pod linking to share contraptions with friends [media]http://www.youtube.com/watch?v=5OY-gJhKTa8[/media]Playing around [media]http://www.youtube.com/watch?v=C5t_b2pmkxY[/media] Easy-to-use with Wire [img]http://img94.imageshack.us/img94/1423/joystickwire.jpg[/img] [img]http://img392.imageshack.us/img392/4548/joystickgui.jpg[/img] [url=http://eagle.undo.it:8083/download?id=23&act=url][img]http://eagle.undo.it:8083/download?id=23&act=img[/img] Download[/url] [img]http://eagle.undo.it:8083/download?id=5&act=img[/img] [url=http://eagle.undo.it:8083/download?id=5&act=url]Source code[/url] [B]Description[/B]: A DirectInput interface and wire chip. Comes with configuration menu to ease developer integration. (Does not support mouse input yet. Sends data to server.) [B]Features[/B]:[list] [*][b] *NEW* [/b] Supports keyboard input [*][b] *NEW* [/b] Scan for newly attached devices mid-game [*][b] *NEW* [/b] .125 second faster Joystick Wire updates - now works as fast as Sandbox thrusters [*][b] *NEW* [/b] Two boolean inputs can be mapped to a single analog input [*]Automatically saves bindings [*]Wire integration chip that links to pods for bind sharing [*]Multi-input chip for Wire that supports 8 separate joystick bindings [*]Full networking at 10 Hz data rate with serializing [*]Both standalone clientside and networked bindings [*]Axis calibration [*]All DirectInput joystick outputs available:[list] [*]8 Axes [*]32 Buttons [*]2 POV Hats[/list] [*]Easy-to-integrate analog and digital bindings interface for the developer (No messing with axes, buttons, and hats!) [*]Click-and-drag interface [*]Categorized and tabbed configuration menu [*]Reverse compatibility with the old joystick module [/list] [B]Future features[/B]:[list] [*]Two button/hat position incremental analog bindings [/list] [B]Warnings[/B]:[list] [*]Calibration is not saved [/list] [B]Binding support[/B]:[list] [*]Full axis to analog binding [*]Half axis to analog binding [*]Button to analog binding [*]HAT position to analog binding [*]Button to digital binding [*]HAT position to digital binding [*]Full axis to digital binding with thresholds [*]Half axis to digital binding with thresholds [*][b] *NEW* [/b] Any combination of two buttons, hats, or keys to make an analog input [/list] [B]Usage[/B]: Open the menus using the console command "joyconfig". To bind a control to a binding, click the desired control from the [i]Device Menu[/i] then the desired binding from the [i]Joystick Configuration[/i] menu. To invert an axis, check the box next to the readout in the [i]Joystick Configuration[/i] menu. To adjust the minimum threshold for an axis to digital binding, click and drag on the readout in the [i]Joystick Configuration[/i] menu. To unbind a control, click the binding in the [i]Joystick Configuration[/i] menu. To link a Wire joystick input to a pod, use reload on the joystick input, then reload on the pod. [B]Example[/B]: Change the first "true" in lua/autorun/client/joyexample.lua and lua/autorun/server/joyexample.lua to "false", then start Garry's Mod. [URL=http://imageshack.us][IMG]http://imageshack.us/img/iss1.png[/IMG][/URL]
  • You just made my goal of the week to butcher a poor xbox controller and male usb connector with wirecutters. I hope you're happy :( [b]Edit:[/b] Hope I can find one of the first style gamepads. Those big ol' bulcky tanks.
  • Avatar of CapsAdmin
  • Very nice. I'm gonna see if I can find a MIDI to Joystick program so I can use my 64 knob synthesizer.
  • Avatar of kimba23
  • Hey, what does it mean that is reverse compatible with old joystick module? Does it mean one can use axis thrusters and wire axis input? Anyhow, great work, gold star for you! ;) Well I cannot get it to work. I am using a wiimote and I see it in the "device menu" as a ppjoy virtual joystick but I cannot set the "joystick configurator" So, do I leave the old mudule installed? The axis thruster? the axis wire? Help please. Thanks
  • Avatar of Night-Eagle
  • Theoretically, the old axis thrusters should still work. In order to use the configurator, you must be using something that integrates with it. This could be a gamemode, addon, etc. There is, again, an example included that lets you see how binding is done. Perhaps I should make an axis input for wire?
  • Avatar of kimba23
  • Yes, an axis input for wire would be great; i will try to do the bindings from your example thanks
  • Avatar of Treelor
  • Oh dear. There's semen. EVERYWHERE. Look what you've done Night-Eagle. [spoiler]Not caring how old the thread is, certainly worth any length bump.[/spoiler] Damn epic job, bud.
  • Avatar of Night-Eagle
  • New version released. Now with full serialized networking. All the inputs of an Xbox 360 controller can be sent in 10 bytes per poll. Currently, the client sends data to the server at a rate of up to 10 Hz. No updates are sent when there is no change in data. Latency is more noticeable than resolution, however. [img]http://garrysmod.org/img/dl/55522_3.jpg[/img] A chip for wire is included. All that is needed is a UID; the configuration panel lets the user take care of the rest easily. You can test the module on this server: [url]steam://connect/69.162.110.93:27018[/url] I should have probably mentioned that UIDs may only consist of the following characters and may only be 20 characters long (17 for the Wire chip): [code] ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz,.<>?:[]{}\|1234567890-=!@#$%^&*()_+ [/code] No spaces are accepted. [b]Edit:[/b] Version 15 released. Fixed bugs with digital inputs and made some cosmetic changes. Unregistering of bindings is now supported and exploited. Maximum and minimum values are now adjustable. [img]http://img505.imageshack.us/img505/3995/joyctb9.jpg[/img]
  • Avatar of Night-Eagle
  • Well shit, its already on the top of the list. Couldn't really implement a save system without the backbone behind it. [QUOTE=2598matt]Hey just wandering, will it work with a PS3 controller?[/QUOTE] Any controller for the PC that has a DirectInput driver - pretty much every PC controller ever made. There is a DInput hack for the PS3 controller.
  • Avatar of Night-Eagle
  • Version 16 Binary 1.1 released. This version adds a save feature. All saves are made by the GUID of the controller and the UID of the bind. Inactive but bounded binds carry through games and save as well. Here is an example data file: [code] GUID Guide {123456789-12345-1234-123:1:12:12:12:12:1:1} = Microsoft Xbox 360 Wireless Controller Binding List (Lower entries override higher entries) [START] jm_a GUID={123456789-12345-1234-123:1:12:12:12:12:1:1} TYPE=analog type=str:axis index=num:0 axismod=num:0 jm_s GUID={123456789-12345-1234-123:1:12:12:12:12:1:1} TYPE=analog type=str:axis index=num:1 axismod=num:2 invert=boo:false [END] [/code] This means that the order of your devices does not mess up the binds. It does mean, however, that a UID can only be saved to a single device. The GUID guide is included for manual user editing, and is not used by the parser. Unregistered binds are cached as well - if you undo a Joystick chip and replace it, your bind will carry over. If you never replace it, the bind will saved from the cache. [b]Edit:[/b] Version 18 Binary 1.1 released. Various bugs have been fixed.
  • Avatar of Airdoo
  • I'm still getting this error with the newest version, v.18 bin V1.1. [code] weapons\gmod_tool\stools/wire_joystick.lua:255: attempt to call field 'getRegisterByUID' (a nil value) [/code]
  • Avatar of Night-Eagle
  • I am unable to reproduce that error. Try to get the error in singleplayer/on a listenserver and do [code] lua_run_cl PrintTable(jcon) [/code] Are you sure you're not getting an error before that one?
  • Avatar of Night-Eagle
  • You have a conflicting addon installed. If you have a version of my joystick module released by LIghtDemon, you need to uninstall it. You can delete that wall of text if you'd like, now.
  • Avatar of Airdoo
  • Wait I think I may have found it, Space Build Model pack has the gmcl_joystick.dll in it. Could I have found it? [b]EDIT:[/b] I erased all traces of a joystick for my gmod folder and it didn't work in Single Player, error on line 255, but then I joined your server and it works, confusing is it not? Also was looking through the code of the offending file and I realized where is this,[code]reg.IsJoystickReg[/code] declared?
  • Avatar of Night-Eagle
  • It is defined in joyconfig.lua. If you want to batch search the contents of your scripts, do this: Download [url=http://www.autohotkey.com/]AutoHotkey[/url] Run this AHK file from the garrysmod/garrysmod directory: [code] Gui, Add, Edit, Default vtofind x6 y0 w370 h20 ,Search Gui, Add, ListView, x6 y30 w460 h340 , ListView Gui, Add, Button, Default gSearch x376 y0 w90 h20 , Search Gui, Show, x131 y91 h378 w473, New GUI Window Return GuiClose: ExitApp Search: GuiControlGet, tofind LV_Delete() Loop, *.lua, 0, 1 { found = false Loop, Read, %A_LoopFileFullPath% { if found = false { if InStr(A_LoopReadLine,tofind,0) { LV_Add("",A_LoopFileFullPath) found = true } } } } return [/code] I would search for "joystick." and "jcon.". If it isn't in addons/joystick, see if it looks like a near duplicate file - if it is, delete it. This is definitely a conflict with an errant script.
  • Avatar of OlivierHamel
  • I'll have to update the SVN for wiremod... One sec. [b]Edit:[/b] Bug report: All registration entries seem to HAVE to be network, which seems pointless. That and the fact that it's getting all pissy because it's trying to network everything and my old numpad controller script didn't specify UIDs for everything (hooks dying, which is causing a chained failure in the system).
  • Avatar of Night-Eagle
  • Yeah, I don't have a net request for bindings yet. As for UIDs, UIDs are used for saving and networking; there is a purpose for them if the bind is clientside in saving and loading binds. Also, scripts don't get pissy. Developers do. There shouldn't be a problem with networking unless you have around 250 analog binds or 1500 digital binds or a proportional combination of both. I don't see a point in a hard-coded registry without a UID - that simply means that the user must rebind it every time they play. I will make the server send a list of needed binds, though.
  • Avatar of OlivierHamel
  • The reason I'm avoiding your UID networking feature is that I don't want to have to add the serverside code to the SBMP & relatives, I'm already managing my own networking (which isn't totally optimal but it's not bad, and it's independent). As for graceful handling, a random this-session-only UID should be allocated if a bind without one is added. Just graceful error handling. I said wiremod. :blah: Got to do that too perhaps but I was meaning SBMP. (Goes off to add a loopz to his SENTs.) [b]Edit:[/b] What if we DON'T want it to save the configs? [b]Edit:[/b] Personally I've used the 'v.uid = v.category .. "_" .. v.description' as a default UID if none is provided, seems to work ok... [b]Edit:[/b] 'joyconfig.lua: 1143: 'joynet.update()'' Causes error on startup of CL Lua. This in turn causes: 'Timer Error: autorun\client\joynet.lua:24: bad argument #1 to 'pairs' (table expected, got nil)'
  • Avatar of Night-Eagle
  • You don't need to add serverside code at any point - the joystick module can be used 100% clientside, although it is currently assumed that "ja" is a valid console command. Careful, because the maximum UID length is 20 characters. As for that error on 1143, did you manually load any script? Are you using any unorthodox or strange methods in interfacing with the module? The only way that should happen is if the script failed and the user tried to re-load a script.
  • Avatar of OlivierHamel
  • The 20 char thing might be it, but I haven't done anything hackzy, I've been a good citizen: I've reported all the rebels in my section for an extra ration. I've followed your hooker instructions. I've filled in all the boxes in the form (the fields in the tables). [b]Edit:[/b] [code] Joystick module loaded! 1.0 Night-Eagle Night-Eagle's joystick module loaded. Script version 1.1. Binary version 1.1. Night-Eagle's joystick configurator loaded. Version 1. Night-Eagle's joystick module loaded. Script version 1. Binary version 1.1. autorun\client\joyconfig.lua:1143: attempt to index global 'joynet' (a nil value) Night-Eagle's joystick configurator loaded. Version 1.2. <LATER ON> Timer Error: autorun\client\joynet.lua:24: bad argument #1 to 'pairs' (table expected, got nil) Redownloading all lightmaps R_RedownloadAllLightmaps took 3.166 msec! Finished! 57 achievements loaded! hooking into LS RD1 system... hooking into LS RD1 system... <DONE INIT.> [/code] :confused:
  • Avatar of Night-Eagle
  • The sequence of characters "1.2" occurs a total number of 0 times in my officially released scripts. You have conflicting scripts/addons installed.
  • Hey, i just downloaded Joystick mod and i cant seem to get it working. I installed it like you said, but I get this error: Timer Error: autorun\client\joyconfig.lua:2376: PEBCAK error. RTFM or slap developer around with a large trout. uid is not a string Have a nice day. Is this fixable? or am I being an idiot? Thanks in advance.
  • Avatar of Urablahblah
  • So correct me if I'm wrong, but you have to have one chip per one control? (axis, button) That seems very inefficient to me but I may just be stupid and can't figure out how to get more than one.