Update: UCR plugin:shift button and extra joystick buttons

Post gaming related scripts
smootchat
Posts: 9
Joined: 17 Jan 2018, 00:57

Update: UCR plugin:shift button and extra joystick buttons

17 Jan 2018, 22:40

Updated: Scroll down to see updated versions.

I call this plugin, ButtonsToButtons

This will allow assigning one button or key as a "shift" and reassigning up to 16 shifted and non-shifted buttons to the vJoy virtual joystick (which has over 64 buttons).

You can load more than one plugin at once and assign a different shift button, but there is some overlap and it needs to be experimented to get the right outcome. Hat buttons seem happy to duplicate, others not.

You can get combinations happening if you load the same plugin twice and assign either the same keys or others. These side effects may or may not be desirable.

It's possible in some cases to assign two output against one input if you have more than one plugin loaded.

The "Ignore if other proc shifted" checkbox is to help overcome the situation where you have 2 plugins loaded, and the first plugin sees your shift key, but the second only sees your output key. You might have 2 virtual buttons activate at one time which may not be desirable. It's kinda hard to explain. Only way to understand is to just experiment.

I used the original ButtonToButton plugin as a template. Thanks go to the original author.

Code: [Select all] [Expand] [Download] (ButtonsToButtons.ahk)GeSHi © Codebox Plus



Image

The plugin is named .. ButtonsToButtons.ahk

The above goes in the UCR/plugins/user/folder

Main programs are here ...

https://autohotkey.com/boards/viewtopic ... cr+plugins

http://vjoystick.sourceforge.net/site/i ... l/download

You set up all the virtual buttons and then assign in your game. You can merge several joysticks into one, have a mixture of your physical, virtual and shifted virtual buttons depending on what you assign in UCR and your game.
Last edited by smootchat on 21 Jan 2018, 21:37, edited 3 times in total.
Helgef
Posts: 2674
Joined: 17 Jul 2016, 01:02
Contact:

Re: UCR plugin:shift button and extra joystick buttons

18 Jan 2018, 05:57

Hello, thanks for sharing :wave:.

Minor comments, you can use a static variable instead of the global, eg,

Code: [Select all] [Download] GeSHi © Codebox Plus

class ButtonsToButtons extends _UCR.Classes.Plugin {
static GlobalShiftingFlag := 0 ; Lets us know if another instance is currently in shift mode.
; ...
MyHkChangedState() {
; something
ButtonsToButtons.GlobalShiftingFlag := ...
; something
}
}

Avoing globals is an unspoken convention for UCR plugins, I believe, but as I said, it it minor. For future projects, keep in mind that loop can reduce your typing efforts substantially, eg,

Code: [Select all] [Download] GeSHi © Codebox Plus

this.IOControls.IB1.Set(0)
; ...
this.IOControls.IB17.Set(0)

can be replaced with

Code: [Select all] [Download] GeSHi © Codebox Plus

loop 17
this.IOControls["IB" A_Index].Set(0)

I will link to this in my UCR plugin thread (and now I've link to mine ;) ), to make it easier for people to find custom plugins.

Cheers.
smootchat
Posts: 9
Joined: 17 Jan 2018, 00:57

Re: UCR plugin:shift button and extra joystick buttons

18 Jan 2018, 08:42

Yeah thanks for the advice. I knew it wasn't elegant, but I wanted to share it anyway.

I'll have a go at cleaning it up.
smootchat
Posts: 9
Joined: 17 Jan 2018, 00:57

Re: UCR plugin:shift button and extra joystick buttons

18 Jan 2018, 22:53

Here is a cleaner version with a few touchups to the logic as well. Updated to V1.02

Code: [Select all] [Expand] [Download] (ButtonsToButtons.ahk)GeSHi © Codebox Plus



Old Version Screenshot (New version looks the same except for the checkbox text)
Image
Attachments
ButtonsToButtons v1.02.zip
(1.43 KiB) Downloaded 4 times
Capture.jpg
(192.3 KiB) Not downloaded yet
smootchat
Posts: 9
Joined: 17 Jan 2018, 00:57

Re: UCR plugin:shift button and extra joystick buttons

21 Jan 2018, 21:27

Update 2.2

My goal is to be able to assign multiple shift buttons to a given output button.

eg

Up_Hatswitch looks up (as normal)
Shift + Up_Hatswitch Raises Flaps
Shift2 + Up_Hatswitch Raises Gear
Shift3 + Up_Hatswitch Starts Engine

Thereby quadrupling the number of available functions per button.

(Note: You can double your joystick buttons with one plugin loaded. Multiple plugins and multiple shifts only seem to work with the hat switch at this point in time)

eg: Button 1 as shift button, HatSwitch "UP" as "input" button.

The hatswitch can be an input in several loaded ButtonsToButtons plugins, but a normal button will only trigger in one of the plugins.

Here is a more multi process aware version to help prevent multiple plugin situations where one plugin output conflicts with another plugins output.

The multi process aware versions require a unique plugin file for each shift key. There are 4 variables/function names within each that are unique, allowing them to "play nicely" together.

There is also a less "smart" version.
This is single file which you can load as many times as you like, however it is less smart or "aware" of other instances of itself and you may get output duplication or odd things happening. But it is mostly well behaved, especially if you use the UCR profile switcher to switch between input output sets. In which case you might only use theButtonsToButtons plugin to redirect several buttons via a single plugin.

Here is the multi process version for your perusal.

The Inter Process communication is simply done by calling functions within each plugin's class. A global array holds the object references required.

Much of the shifting function is made redundant by the UCR Profile switcher plugin, but someone might find parts of this to be useful.

I apologize to the purists as I have broken a few rules regarding global variables and class method and library etiquette in order to get this to work.

The full set of required files and instructions is included in the attached zip.

Saitek Yoke Users: Remember to delete or rename the SaiD0BAC.pr0 file in the system32 directory to get access to the mode switch.

Code: [Select all] [Expand] [Download] (ButtonsToButtons1.ahk)GeSHi © Codebox Plus



My setup for the Saitek Yoke + extra Throttle quadrant. I now have 40 functions avialable by doubling the buttons and using the mode switch to toggle between shifted and unshifted mode.
Image
Attachments
ButtonsToButtons v2.3.zip
(10.72 KiB) Downloaded 4 times
Capture.jpg
(158.47 KiB) Not downloaded yet

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 7 guests