Jump to content

Steel Battalion controller and win 7 64-Bit drivers


417 replies to this topic

#381 HackNFly

    Member

  • PipPipPipPipPip
  • 131 posts

Posted 12 April 2016 - 11:54 AM

View PostevilC, on 12 April 2016 - 10:49 AM, said:

Looking back on it, I can see how the quotes might be interpreted that way, but that was not my intention and I apologize.

"I abandoned trying to emulate a mouse though due to the enormous pain of guestimating maximum twist rates for each mech"
I basically have this one licked. To detect max twist rate, I send a big move (eg +50), then the same amount in the opposite direction but as a series of small moves (ie 50x -1). I then take a screenshot, hit center torso, then take another screenshot. If the two screenshots match, then 50 is below the max twist rate, so the code increases the rate and repeats.

Detecting twist range is also done with pixel detection. I center the torso, then keep twisting until the screen doesnt change after I issue mouse movement, which gives me the twist range in mouse units.

This code is not currently in the zip in my thread, I have some more work to do on it before I release it, hopefully tonight.

You are correct about the bit of code that controls the "buffer". To avoid any confusion, here is the logic that it follows:
I will use fake values to make the math simpler:
TWIST_RATE : The number of mouse units that a mech can twist in one tick (10ms for me). Lets use a value of 20 for this.
TWIST_RANGE: The number of mouse units that a mech can twist. Lets assume that this is 100 units from center to twisted full right.
Let's also assume that a joystick reports -100 to +100 (So center to full twist right is also 100 units)

Current mouse "position" is 0
Joystick is 50% right (+50)
Corresponding mouse move to achieve that view would be +50
TWIST_RATE is 20, so we instead only move +20
End of loop

Next "tick".
Current mouse "position" is +20
Joystick has moved to 30% right
Corresponding mouse move to achieve that view would be +10
+10 is below 20, so allow the full amount that it "wants" to move.

This code is simple in AHK, because I can only poll the joystick manually anyway (Joystick axis input in AHK is not event based), so even if the stick does not change, I get a current value each "tick". If you get joystick position in an event-based manner, then implementing this may be a bit more tricky.

Looking at that code you posted, there seems to be rather a lot of logic going on for POV hats. This is an issue that I have come up against in AHK, and I found that generally the best solution was look up tables (ie prebuilt static arrays) - conversions such as degrees to cardinal directions (At least with a normal POV where the degrees are always in 45deg increments) is actually quite quick and simple with arrays. Lemme know if you need some pointers.


The POV stuff wasn't all me. I extended the code, and although I would have coded it slightly differently it works. Part of my intention for the program is for others to contribute, so I didn't want to erase their work.

As far as your pseudocode, I actually really like the general idea of it. Taking it a step further. You could completely automate the process. I know how to do it in C#, but not in AHK. Apparently AHK does have some image processing capabilities, but I wasn't able to fully understand the extent of them. Programmatically hit the printscreen key and then open the image from within the program using something simple like OpenCV to programmaticallly compare the images. I'm going to log off for a while, but good luck.

#382 Golden Gun

    Member

  • PipPipPip
  • Legendary Founder
  • Legendary Founder
  • 87 posts
  • LocationIdaho

Posted 12 April 2016 - 12:03 PM

@ GreenHell: EvilC hit it right on the nose. Without being able to map the "LOOK" to its own buttons or joystick, it can't happen. If we could just convince Piranha to make that change, I'd be all over that in a New York minute!

@ EvilC: Hey man, thanks for the apology and no hard feelings?

#383 Bloodshoot111

    Member

  • Pip
  • Legendary Founder
  • Legendary Founder
  • 10 posts
  • LocationGermany

Posted 12 April 2016 - 12:50 PM

Wenn i see this i become sad :/
I still hope Razr will one Day release the Artemis...

#384 evilC

    Member

  • PipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 1,298 posts
  • LocationLondon, UK

Posted 13 April 2016 - 03:56 AM

View PostGolden Gun, on 12 April 2016 - 12:03 PM, said:

@ EvilC: Hey man, thanks for the apology and no hard feelings?

Peace.

View PostHackNFly, on 12 April 2016 - 11:54 AM, said:

As far as your pseudocode, I actually really like the general idea of it. Taking it a step further. You could completely automate the process. I know how to do it in C#, but not in AHK. Apparently AHK does have some image processing capabilities, but I wasn't able to fully understand the extent of them. Programmatically hit the printscreen key and then open the image from within the program using something simple like OpenCV to programmaticallly compare the images. I'm going to log off for a while, but good luck.

The built-in AHK image comparison commands are slow and not that suitable for what we are trying to do. I use a 3rd-party library (written by Tic) which implements the GDI API (gdip_all.ahk). I then have my own AHK library which further simplifies using GDI (CGdipSnapshot.ahk).

So with CGDipSnapshot, you can take a snapshot of a screen area using:

snap1 := new CGdipSnapshot(300,300,200,200) ; x, y, width, height
snap1.TakeSnapshot()

Lets then say after some time, you take another snapshot of the same area:

snap2 := new CGdipSnapshot(300,300,200,200) ; x, y, width, height
snap2.TakeSnapshot()

You can then compare the two snapshots (with a tolerance) using:

; tol := 5 ; 5% difference allowed
same := snap1.Compare(snap2, tol)

same is a boolean: 1=same, 0=different

Or you can compare individual pixels using:

same := snap1[0,10].Compare(snap2[0,10])

You can find the forum thread for CGdipSnapshot here: https://autohotkey.c...opic.php?t=5682

Edited by evilC, 13 April 2016 - 04:04 AM.


#385 SCHLIMMER BESTIMMER XXX

    Member

  • PipPipPipPipPipPipPip
  • Shredder
  • 879 posts
  • LocationNiemalsland

Posted 13 April 2016 - 06:28 AM

View PostevilC, on 13 April 2016 - 03:56 AM, said:

Peace.


The built-in AHK image comparison commands are slow and not that suitable for what we are trying to do. I use a 3rd-party library (written by Tic) which implements the GDI API (gdip_all.ahk). I then have my own AHK library which further simplifies using GDI (CGdipSnapshot.ahk).

So with CGDipSnapshot, you can take a snapshot of a screen area using:

snap1 := new CGdipSnapshot(300,300,200,200) ; x, y, width, height
snap1.TakeSnapshot()

Lets then say after some time, you take another snapshot of the same area:

snap2 := new CGdipSnapshot(300,300,200,200) ; x, y, width, height
snap2.TakeSnapshot()

You can then compare the two snapshots (with a tolerance) using:

; tol := 5 ; 5% difference allowed
same := snap1.Compare(snap2, tol)

same is a boolean: 1=same, 0=different

Or you can compare individual pixels using:

same := snap1[0,10].Compare(snap2[0,10])

You can find the forum thread for CGdipSnapshot here: https://autohotkey.c...opic.php?t=5682

Posted Image

#386 HackNFly

    Member

  • PipPipPipPipPip
  • 131 posts

Posted 13 April 2016 - 11:12 AM

EvilC, if you can, please make a video of your program working. Specifically the torso twist calculations part. I spent some time coding up some psuedocode before I realized you had described exactly the same thing yesterday.

#387 Graem

    Rookie

  • Survivor
  • 2 posts

Posted 13 April 2016 - 02:36 PM

Hey, so I am pretty new when it comes to this, mostly cause I don't know what variables I can change in the simple.cs, I was wandering if someone can tell me some basics on editing the .cs files and maybe some examples someone can point me to. I really would like to use this on Warrior online and other amazing games.

#388 Golden Gun

    Member

  • PipPipPip
  • Legendary Founder
  • Legendary Founder
  • 87 posts
  • LocationIdaho

Posted 13 April 2016 - 07:09 PM

View PostGraem, on 13 April 2016 - 02:36 PM, said:

Hey, so I am pretty new when it comes to this, mostly cause I don't know what variables I can change in the simple.cs, I was wandering if someone can tell me some basics on editing the .cs files and maybe some examples someone can point me to. I really would like to use this on Warrior online and other amazing games.


Hey Graem, welcome to the thread! if you want to get started on the right foot, I'd recommend looking at the Wiki section on the Sourceforge page: https://sourceforge....l-batallion-64/

That'll give you a good start on what and how you can edit the .CS file. GOOD LUCK!

#389 evilC

    Member

  • PipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 1,298 posts
  • LocationLondon, UK

Posted 14 April 2016 - 03:19 AM

View PostHackNFly, on 13 April 2016 - 11:12 AM, said:

EvilC, if you can, please make a video of your program working. Specifically the torso twist calculations part. I spent some time coding up some psuedocode before I realized you had described exactly the same thing yesterday.

Which program, the actual mouse emulator or the calibration script?

#390 HackNFly

    Member

  • PipPipPipPipPip
  • 131 posts

Posted 14 April 2016 - 11:18 AM

The calibration script. It would be nice to see a sample of it working. If that's too much trouble please just let me know the results of your work.

#391 evilC

    Member

  • PipPipPipPipPipPipPipPip
  • Legendary Founder
  • Legendary Founder
  • 1,298 posts
  • LocationLondon, UK

Posted 14 April 2016 - 12:40 PM

http://evilc.com/fil...AbsoluteJoy.zip

calibrate2.ahk in there - double-click it.
PGDN for twist range detection, PGUP for twist rate detection. END aborts. (Though these keys are easily configurable by editing the script).
I use Frozen City to test, as there is lots of detail in the landscape.
Will that do?

#392 Graem

    Rookie

  • Survivor
  • 2 posts

Posted 15 April 2016 - 06:34 AM

View PostGolden Gun, on 13 April 2016 - 07:09 PM, said:


Hey Graem, welcome to the thread! if you want to get started on the right foot, I'd recommend looking at the Wiki section on the Sourceforge page: https://sourceforge....l-batallion-64/

That'll give you a good start on what and how you can edit the .CS file. GOOD LUCK!


https://sourceforge....n-64/wiki/Home/

Hey I gave it a try and its giving me a 403 error code?

#393 HackNFly

    Member

  • PipPipPipPipPip
  • 131 posts

Posted 15 April 2016 - 08:27 AM

View PostGraem, on 15 April 2016 - 06:34 AM, said:


https://sourceforge....n-64/wiki/Home/

Hey I gave it a try and its giving me a 403 error code?

Not sure what happened to the main page of the wiki, but here is the configuration page.
https://sourceforge..../Configuration/

View PostevilC, on 14 April 2016 - 12:40 PM, said:

http://evilc.com/fil...AbsoluteJoy.zip

calibrate2.ahk in there - double-click it.
PGDN for twist range detection, PGUP for twist rate detection. END aborts. (Though these keys are easily configurable by editing the script).
I use Frozen City to test, as there is lots of detail in the landscape.
Will that do?

I looked through your code. It looks good. Looking forward to seeing the results of your work. Maybe Golden Gun can help gather data from all the Mechs.

#394 Golden Gun

    Member

  • PipPipPip
  • Legendary Founder
  • Legendary Founder
  • 87 posts
  • LocationIdaho

Posted 16 April 2016 - 08:57 AM

View PostHackNFly, on 15 April 2016 - 08:27 AM, said:

I looked through your code. It looks good. Looking forward to seeing the results of your work. Maybe Golden Gun can help gather data from all the Mechs.

Like you had to ask. ;)

#395 Digital_Angel

    Member

  • PipPipPipPipPipPip
  • Bridesmaid
  • Bridesmaid
  • 441 posts

Posted 06 May 2016 - 10:00 AM

Talking to someone who had questions about using dual joys in MWO the other day got me thinking about if i could do make my old SBC work with MWO. Then I found this thread and another in the forums. I will definitely be taking a closer look at all of this in the future.

Thank you for all the work everyone has already put into this.

#396 LordC

    Rookie

  • 6 posts

Posted 12 June 2016 - 05:34 PM

Hello,
firstly I would like to say big thanks to HackNFly for his work on SBC64 and all of you guys here, you did amazing work!
And secondly, I would like to ask on few things (especially about GearLever). Since Im not programmer, and I know nothing about C# its a litle bit more complicated for me to create my own CS file, but Im slowly getting to the point where I'll have fully working basic CS file for Steel Battalion Controller... right now only thing I missing for full basic functionality is working GearLever. Hence my first question:

Q1)
Do I have to write some extra configuration for GearLever to work? According to:

View PostHackNFly, on 01 February 2013 - 09:35 PM, said:

View PostMrManiacal, on 29 January 2013 - 08:53 AM, said:

I'm trying to find out how to use the throttle lever in game instead of the pedals (mine are dead). How would I map "W", "S", and "X" to the various positions of the throttle? Even the ID's of the throttle positions would be enough to get me started...

if you take a look at the Simple.cs file, you'll find the section like this:
public void mainLoop()
{
joystick.setAxis(1,controller.AimingX,HID_USAGES.HID_USAGE_X);
joystick.setAxis(1,controller.AimingY,HID_USAGES.HID_USAGE_Y);
joystick.setAxis(1,(controller.RightPedal - controller.MiddlePedal),HID_USAGES.HID_USAGE_Z);//throttle
joystick.setAxis(1,controller.RotationLever,HID_USAGES.HID_USAGE_RZ);
joystick.setAxis(1,controller.SightChangeX,HID_USAGES.HID_USAGE_SL0);
joystick.setAxis(1,controller.SightChangeY,HID_USAGES.HID_USAGE_RX);
joystick.setAxis(1,controller.LeftPedal,HID_USAGES.HID_USAGE_RY);
joystick.setAxis(1,controller.GearLever,HID_USAGES.HID_USAGE_SL1);

This is where I set the values for each axis, the first value 1 stands for the joystick. I wrote the software
to support multiple. The second is the joystick axes, and the third is the axes you are writing to on the
virtual joystick. To accomplish what you are looking for, do this:
public void mainLoop()
{
joystick.setAxis(1,controller.AimingX,HID_USAGES.HID_USAGE_X);
joystick.setAxis(1,controller.AimingY,HID_USAGES.HID_USAGE_Y);
joystick.setAxis(1,controller.GearLever,HID_USAGES.HID_USAGE_Z);//throttle
joystick.setAxis(1,controller.RotationLever,HID_USAGES.HID_USAGE_RZ);
joystick.setAxis(1,controller.SightChangeX,HID_USAGES.HID_USAGE_SL0);
joystick.setAxis(1,controller.SightChangeY,HID_USAGES.HID_USAGE_RX);
joystick.setAxis(1,controller.LeftPedal,HID_USAGES.HID_USAGE_RY);
//joystick.setAxis(1,controller.GearLever,HID_USAGES.HID_USAGE_SL1);
Then open the file in my program and click start, then check out the results within game control panel. All I'm doing is commenting out the previous section dealing with the GearLever and having the GearLever modify the virtual throttle

According to this it seems to me that I dont need to write nothing extra and GearLever should work ok on SL1 axis. If thats true than Im afraid that GearLever does not work in SBC_v3.0.1.
GearLever is by default Simple.cs assigned to SL1 axis: joystick.setAxis(1,controller.Scaled.GearLever,HID_USAGES.HID_USAGE_SL1); but vJoy does not recognise any input for SL1 axis or any other axis I assign to GearLever!?


Q2)
I wasnt able to find any CS file with some GearLever part in it that I could use. Only exception is something in MW4.cs and in KSPSBC.cs, but unfortunately I'm completely lost for what and how is GearLever used in these CS files. Can you share with me how you cofigure GearLever in your CS files?


Q3)
I also tried to write some pseudo nonsense (that doesnt work of course) as idea what I aiming for with GearLever:
	 if (controller.GearLever == -3) // R gear
	  {
	  controller.SL1 = -100%;
	  }
	 else if (controller.GearLever == -2) // N gear
	  {
	  controller.SL1 = 0%;
	  }
	 else if (controller.GearLever == -1) // 1 gear
	  {
	  controller.SL1 = 20%;
	  }
	 else if (controller.GearLever == 0) // 2 gear
	  {
	  controller.SL1 = 40%;
	  }
	 else if (controller.GearLever == 1) // 3 gear
	  {
	  controller.SL1 = 60%;
	  }
	 else if (controller.GearLever == 2) // 4 gear
	  {
	  controller.SL1 = 80%;
	  }
	 else if (controller.GearLever == 3) // 5 gear
	  {
	  controller.SL1 = 100%;
	  }
	 else
	  {
	  controller.SL1 = 0%; //or maybe nothing will be better
	  }
But Im open to any working scripts for GearLever as I would like to get more inspiration/learning examples about what can I do.


Q4)
Windows maximal limit for joystick buttons is 32? So only way to get buttons 33-39 to work, is to define for them a keyboard character in CS file?


Q5)
Can I change button numbers for controller keys?
I guess not since these will be probably hardcoded in the SBC64 driver right?

Than I would like to propose a suggestion to next version of SBC64 release:
Exchange button 34 (LeftJoySightChange Key) with button 8 (MultiMonOpenClose Key) or with button 4 (Eject Key) or at least with button 32 (Comm4 Key)!

Why? Well... LeftJoySightChange Key is very important key and right now is asigned by SBCdriver to buttons that are not recognised by windows as joystick buttons (above button 32)! Personaly I think that LeftJoySightChange button should be one of first 8 buttons which are working with default installation of SBC64. LeftJoySightChange key is surely more important than MultiMonOpenClose key, or as alternative I would consider between first 8 buttons also Eject key (since Im trying to use Eject button at least as possible to save the molly-guard Posted Image ).


Q6)
At many places there is mentioned the "SolExodus.cs" file... but I cant find it... do you have link for it?


Q7)
Can I download older versions of SBC64? Where are they? I was able to find only latest SBC_v3.0.1.


Q8)
Is it possible to achive more axis than 8 with one Steel Battalion Controller? Maybe via vJoy Device #2 ?
My idea:
Defining one switcher as a shift key. For example ToggleFilterControl:
When is ToggleFilterControl switched OFF, than will be active configuration for vJoy Device #1
When is ToggleFilterControl switched ON, than will be active configuration for vJoy Device #2
That way I could assign two functions for SightChangeX and SightChangeY (I could use SightChange for strafing with spacecraft in battle or by flipping a switch to looking around cockpit) For now is my skill very far from writing something like this in C# to CS file... but I would like to know if its possible/doable via CS file with SBC64?


Q9)
(Cosmetic question) Is there a way to define for a button to be always slightly lightened with light intensity 1 and while pressed to be lightened with light intensity 10? Can you write an example?

Edited by LordC, 12 June 2016 - 05:56 PM.


#397 LordC

    Rookie

  • 6 posts

Posted 13 June 2016 - 03:42 AM

One more question...

Q10)
is there a way for LeftPedal to define it only for 0 and positive values on axis?

In Simple.cs is LeftPedal defined as joystick.setAxis(1,controller.Scaled.LeftPedal,HID_USAGES.HID_USAGE_RY);
This definition make the LeftPedal start (when not pressed) on highest negative value on RY axis.
I would like to use it only for positive values... so that if LeftPedal is not pressed than RY axis should be 0. (kinda same functionality like with RightPedal, but without MiddlePedal (thanks to that would be via LeftPedal accesible only positive values on RY axis)

Edited by LordC, 13 June 2016 - 03:42 AM.


#398 Buttsechuani

    Rookie

  • 6 posts

Posted 27 July 2016 - 04:03 PM

using the kerbal controller configuration that exists for this device as a template/study guide I was able to come up with an interesting way to use the gear lever as a slider and the dial as a a sort of fine tuner for it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SBC
{
	public class DynamicClass
	{
		String debugString = "";
		SteelBattalionController controller;
		vJoy joystick;
		int vJoyButtons = 39;
		bool acquired;
		const int refreshRate = 50;
		public void Initialize()
		{
			int baseLineIntensity = 1;
			int emergencyLightIntensity = 15;
			controller = new SteelBattalionController();
			controller.Init(50);
			for (int i = 4; i < 4 + 30; i++)
			{
				if (i != (int)ButtonEnum.Eject)
					controller.AddButtonLightMapping((ButtonEnum)(i - 1), (ControllerLEDEnum)(i), true, baseLineIntensity);
			}
			controller.AddButtonKeyLightMapping(ButtonEnum.CockpitHatch, true, 3, SBC.Key.A, true);
			controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF1, true, 3, Microsoft.DirectX.DirectInput.Key.BackSpace, true);
			controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, SBC.Key.C, true);
			joystick = new vJoy();
			acquired = joystick.acquireVJD(1);
			joystick.resetAll();
		}
		public int getRefreshRate()
		{
			return refreshRate;
		}
		//Warp Speed Tunner
		int tunerValueSaved = 0;
		//sets neutral position for sl1
		int defaultValue = 16384;
		//the total value of tuner position 15 * forwardStepValue
		int fullRotationValue = 3270;
		//reverse stepValue
		int stepValue = 1092;
		//forwardStepValue
		int ForwardStepValue = 218;
		//tunerValue * stepValue set inside warp speed tuner dial loop
		int tunerMultiplier = 0;
		//defaultValue - tunerMultiplier;
		int reverseMath = 0;
		//set by gearing essentially makes tuner dial operate only within certain range based on maths
		int forwardMath = 0;
		public void mainLoop()
		{
            joystick.setAxis(1, controller.Scaled.AimingX, HID_USAGES.HID_USAGE_X);
			joystick.setAxis(1, controller.Scaled.AimingY, HID_USAGES.HID_USAGE_Y);
			joystick.setAxis(1, controller.Scaled.RightMiddlePedal, HID_USAGES.HID_USAGE_Z);//throttle
			joystick.setAxis(1, controller.Scaled.RotationLever, HID_USAGES.HID_USAGE_RZ);
			joystick.setAxis(1, controller.Scaled.SightChangeX, HID_USAGES.HID_USAGE_SL0);
			joystick.setAxis(1, controller.Scaled.SightChangeY, HID_USAGES.HID_USAGE_RX);
			joystick.setAxis(1, controller.Scaled.LeftPedal, HID_USAGES.HID_USAGE_RY);
			for (int i = 1; i <= vJoyButtons; i++)
			{
				joystick.setButton((bool)controller.GetButtonState(i - 1), (uint)1, (char)(i - 1));
			}
			// Warp speed, tuner dial
			int tunerValue = controller.TunerDial;
			int gearValue = controller.GearLever;
			if (gearValue == -2)
			{
				joystick.setAxis(1, reverseMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * stepValue;
				reverseMath = defaultValue - tunerMultiplier;
			}
 
			else if (gearValue == -1)
			{
				joystick.setAxis(1, defaultValue, HID_USAGES.HID_USAGE_SL1);
			}
			else if (gearValue == 1)
			{
				joystick.setAxis(1, forwardMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * ForwardStepValue;
				forwardMath = defaultValue + tunerMultiplier;
			}
			else if (gearValue == 2)
			{
				joystick.setAxis(1, forwardMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * ForwardStepValue;
				forwardMath = defaultValue + fullRotationValue + tunerMultiplier;
			}
			else if (gearValue == 3)
			{
				joystick.setAxis(1, forwardMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * ForwardStepValue;
				forwardMath = defaultValue + fullRotationValue * 2 + tunerMultiplier;
			}
			else if (gearValue == 4)
			{
				joystick.setAxis(1, forwardMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * ForwardStepValue;
				forwardMath = defaultValue + fullRotationValue * 3 + tunerMultiplier;
			}
			else if (gearValue == 5)
			{
				joystick.setAxis(1, forwardMath, HID_USAGES.HID_USAGE_SL1);
				tunerValueSaved = tunerValue;
				tunerMultiplier = tunerValue * ForwardStepValue;
				forwardMath = defaultValue + fullRotationValue * 4 + tunerMultiplier;
			}
			joystick.sendUpdate(1);
		  
		}
		//new necessary function used for debugging purposes
		public String getDebugString()
		{
			return debugString;
		}
		//this gets called at the end of the program and must be present, as it cleans up resources
		public void shutDown()
		{
			controller.UnInit();
			joystick.Release(1);
		}
	}
}
 


hope this is helpful to someone.

Edited by Buttsechuani, 27 July 2016 - 04:26 PM.


#399 LordC

    Rookie

  • 6 posts

Posted 03 August 2016 - 12:56 AM

...mm looks interesting
thank you for sharing Buttsechuani Posted Image

Now to answer few of my questions I asked here before:

Q1)

View PostLordC, on 12 June 2016 - 05:34 PM, said:

Do I have to write some extra configuration for GearLever to work?
...
Answer:
Yes, you do have to write some configuration code for GearLever to work.

Q2)

View PostLordC, on 12 June 2016 - 05:34 PM, said:

...
Can you share with me how you cofigure GearLever in your CS files?
Answer:
For example this is simple working configuration code from mainloop for GearLever to work as +/-
	  if (gearLever != GearLeverSaved)
	   {	
	   if (controller.GearLever < GearLeverSaved)
		{
		controller.sendKeyPress(SBC.Key.NumPadMinus);
		}
		else if (controller.GearLever > GearLeverSaved)
		 {
		 controller.sendKeyPress(SBC.Key.NumPadPlus);
		 }
	   GearLeverSaved = gearLever;
	   }

Q3)

View PostLordC, on 12 June 2016 - 05:34 PM, said:

I also tried to write some pseudo nonsense (that doesnt work of course) as idea what I aiming for with GearLever
...
Answer:
GearLever code for same functionality like in Q3 looks like this:

First part define what values should each gear return for axis SL1:
public class DynamicClass
{	   String debugString = "";
		SteelBattalionController controller;
 
		int GearLeverAxisValueR = 0;
		int GearLeverAxisValueN = 16383;
		int GearLeverAxisValue1 = 19660;
		int GearLeverAxisValue2 = 22936;
		int GearLeverAxisValue3 = 26213;
		int GearLeverAxisValue4 = 29489;
		int GearLeverAxisValue5 = 32766;
Second part should be located in main loop:
	 int GearLeverStateChange = 0;
	 int GearLeverState = controller.GearLever;
	 if (GearLeverState != GearLeverStateChange)
	  {	
	  if (controller.GearLever == -2)
	   {
	   joystick.setAxis(1, GearLeverAxisValueR, HID_USAGES.HID_USAGE_SL1);
	   }
	   else if (controller.GearLever == -1)
		{
		joystick.setAxis(1, GearLeverAxisValueN, HID_USAGES.HID_USAGE_SL1);
		}
		else if (controller.GearLever == 1)
		 {
		 joystick.setAxis(1, GearLeverAxisValue1, HID_USAGES.HID_USAGE_SL1);
		 }
		 else if (controller.GearLever == 2)
		  {
		  joystick.setAxis(1, GearLeverAxisValue2, HID_USAGES.HID_USAGE_SL1);
		  }
		  else if (controller.GearLever == 3)
		   {
		   joystick.setAxis(1, GearLeverAxisValue3, HID_USAGES.HID_USAGE_SL1);
		   }
		   else if (controller.GearLever == 4)
			{
			joystick.setAxis(1, GearLeverAxisValue4, HID_USAGES.HID_USAGE_SL1);
			}
			else if (controller.GearLever == 5)
			 {
			 joystick.setAxis(1, GearLeverAxisValue5, HID_USAGES.HID_USAGE_SL1);
			 }
	  }

Q9)

View PostLordC, on 12 June 2016 - 05:34 PM, said:

(Cosmetic question) Is there a way to define for a button to be always slightly lightened with light intensity 1 and while pressed to be lightened with light intensity 10? Can you write an example?
Answer:
Yes, there is, but I'll not write an example here yet because it still doesnt work fully the way I want, but "comming soon" Posted Image


Q4, Q5, Q6, Q7, Q8 & Q10
are still valid unanswered questions, if you know the answer please post it here, thanks

#400 Golden Gun

    Member

  • PipPipPip
  • Legendary Founder
  • Legendary Founder
  • 87 posts
  • LocationIdaho

Posted 03 August 2016 - 04:04 PM

View PostLordC, on 12 June 2016 - 05:34 PM, said:


Q1)
Do I have to write some extra configuration for GearLever to work? According to:

According to this it seems to me that I dont need to write nothing extra and GearLever should work ok on SL1 axis. If thats true than Im afraid that GearLever does not work in SBC_v3.0.1.
GearLever is by default Simple.cs assigned to SL1 axis: joystick.setAxis(1,controller.Scaled.GearLever,HID_USAGES.HID_USAGE_SL1); but vJoy does not recognise any input for SL1 axis or any other axis I assign to GearLever!?


I've seen your own answers and I must say, GOOD JOB! But there is a layer of understanding of how the whole driver works that I think you are missing.

The constraints for the SBC driver come more from VJoy, then Windows. The last VJoy version attached to SBC had increased its abilities thus giving SBC access to more options. More about this later.

I have answered as many of your questions as I could. Hope it all helps!

Quote

Q2)
I wasnt able to find any CS file with some GearLever part in it that I could use. Only exception is something in MW4.cs and in KSPSBC.cs, but unfortunately I'm completely lost for what and how is GearLever used in these CS files. Can you share with me how you configure GearLever in your CS files?


I'll talk more about this later, but these .CS files are old and programmed for very different version of SBC.

Quote

Q3)
I also tried to write some pseudo nonsense (that doesnt work of course) as idea what I aiming for with GearLever:
	 if (controller.GearLever == -3) // R gear
	  {
	  controller.SL1 = -100%;
	  }
	 else if (controller.GearLever == -2) // N gear
	  {
	  controller.SL1 = 0%;
	  }
	 else if (controller.GearLever == -1) // 1 gear
	  {
	  controller.SL1 = 20%;
	  }
	 else if (controller.GearLever == 0) // 2 gear
	  {
	  controller.SL1 = 40%;
	  }
	 else if (controller.GearLever == 1) // 3 gear
	  {
	  controller.SL1 = 60%;
	  }
	 else if (controller.GearLever == 2) // 4 gear
	  {
	  controller.SL1 = 80%;
	  }
	 else if (controller.GearLever == 3) // 5 gear
	  {
	  controller.SL1 = 100%;
	  }
	 else
	  {
	  controller.SL1 = 0%; //or maybe nothing will be better
	  }
But Im open to any working scripts for GearLever as I would like to get more inspiration/learning examples about what can I do.


The gear shift, as it stands in the original code, has it mapped to SL1. But there seems to be a very simple way to use its output. Once you activate SBC, go to the windows joystick config. and start to calibrate.

Continue through the calibration until you get to SL1. At this point (or earlier if you want) click on the box for raw data. For all the other axes, there were numbers that ranged into the thousands, but for SL1 they are sequential single digits. IIRC, -2, -1, 1, 2, 3, 4, 5.

Since the output is so specific, there is no reason you couldn't make each position a different button press. I thought of doing a cruse control type setup for Mechwarrior where:

-2/R = full reverse (constant press)
-1/N = Full stop (single press)
1/1 = 20% (single press)
2/2 = 40% (single press)
3/3 = 60% (single press)
4/4 = 80% (single press)
5/5 = 100% (single press)

By doing the single presses, using the throttle peddles (forward and reverse) will automatically override the gear shift input. This also means it won't take back control of your mech until reengaged.

Quote

Q4)
Windows maximal limit for joystick buttons is 32? So only way to get buttons 33-39 to work, is to define for them a keyboard character in CS file?


The latest version of VJoy can use up to 128 joystick buttons so there is no need to pick and choose. Just make sure when you setup VJoy you increase the button count as well as the other needed configs. You can doublecheck this change in the Windows Joystick Config. program.

Quote

Q5)
Can I change button numbers for controller keys?
I guess not since these will be probably hardcoded in the SBC64 driver right?


None of the inputs from the controller are hard bound. This includes all axes. For example, you can bind the "Main Weapon" button to a joystick button, a single keyboard key, or a multitude of keys. you can also make it so the press-and-hold of the joystick button translates to a constant press or a singe press (even if you hold down the button longer).

I've never liked the mapping for the axes myself so i changed them around to something that made more sense to me. I also map buttons to keystrokes, thus eliminating the need for more mapped buttons. Heh, one late LATE night, I mistakenly mapped the same button two a joystick button AND a keyboard key so when I would zoom in it also auto centered my mech! Posted Image

Quote

Q6)
At many places there is mentioned the "SolExodus.cs" file... but I cant find it... do you have link for it?


I might have it, but honestly SBC has matured so much that most of the .CS files from earlier versions do not translate well. I can still look to see if I have it though if you are still interested.

Quote

Q7)
Can I download older versions of SBC64? Where are they? I was able to find only latest SBC_v3.0.1.


About a year or two ago, the host site was switched to Sourceforge and many of the outdated files were not put up. Again, the older versions did not play well with the newer OSs or were written in a completely different language. Also, most of them weren't signed so you had to run in test mode just to get it to work...

Quote

Q8)
Is it possible to achive more axis than 8 with one Steel Battalion Controller? Maybe via vJoy Device #2 ?
My idea:
Defining one switcher as a shift key. For example ToggleFilterControl:
When is ToggleFilterControl switched OFF, than will be active configuration for vJoy Device #1
When is ToggleFilterControl switched ON, than will be active configuration for vJoy Device #2
That way I could assign two functions for SightChangeX and SightChangeY (I could use SightChange for strafing with spacecraft in battle or by flipping a switch to looking around cockpit) For now is my skill very far from writing something like this in C# to CS file... but I would like to know if its possible/doable via CS file with SBC64?


There is no reason you couldn't, but using other smart short cuts would be quicker and keep things from sprawling all over the place. That is one of the reasons why the middle and right peddles are mapped to one input.

Quote

Q9)
(Cosmetic question) Is there a way to define for a button to be always slightly lightened with light intensity 1 and while pressed to be lightened with light intensity 10? Can you write an example?


Yes. If you look at the sample code provided on Sourceforge, scroll down until you get to the button mapping. There is a piece of code you can stick in any button configuration line to control the passive glow and the pressed glow.

Hope this helps you on your way to making some cool configs. By the Way, what operating system are you using SBC on?





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users