Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
AurelTristen

Registered:
Posts: 15
Reply with quote  #1 

I've recently picked up a Steel Battalion controller via a local trade.  Thanks to Google and those who have been down this path before me, I've been able to get it up and running.  I'm at the stage where I'm trying to write a good .cs file for Artemis but wanted to see if anyone has already done this.  If so, can you share your .cs file? (I did search the forum first, but only found passing mentions of the controller)

I'm able to assign buttons to send off key commands, but I'm struggling with controlling lights and getting the gear shift and tuner dial to do something useful.

Because I found everything I know so far due to Google, I'll leave a short outline here for anyone who might find this post by Google in the future.

About the game and controller.
Windows drivers and more info on how to make it work


My current .cs file.  I don't have the pedals, so I've re-assigned that axis to the gear shift.


//If you want a quick overview of how the configuration system works, take a look at SolExodus.cs
//This example was meant to recreate the functionality I displayed for the system in the original release
//however that also means that it is actually pretty complicated.
using System;
namespace SBC{
public class DynamicClass
{        String debugString = "";
        SteelBattalionController controller;
        vJoy joystick;
    int vJoyButtons = 39;//change to 39 to fully support SBC, need to use vJoy config to change
    //number of buttons to 39.
    bool acquired;
        const int refreshRate = 50;//number of milliseconds between call to mainLoop

        //this gets called once by main program
        public void Initialize()
        {
            int baseLineIntensity = 15;//just an average value for LED intensity
            int emergencyLightIntensity = 15;//for stuff like eject,cockpit Hatch,Ignition, and Start
            controller = new SteelBattalionController();
            controller.Init(20);//50 is refresh rate in milliseconds
            //set all buttons by default to light up only when you press them down
            for (int i = 4; i < 4 + 30; i++)
            {
                if (i != (int)ButtonEnum.Eject)//excluding eject since we are going to flash that one
                    controller.AddButtonLightMapping((ButtonEnum)(i - 1), (ControllerLEDEnum)(i), true, baseLineIntensity);
            }
      
      //Trying to assign the gear lever to a button but it won't work
      //{
      //  if (controller.GearLever > 0)
      //    controller.AddButtonKeyMapping(SBC.Key.K, true);
      //
      
            
            controller.AddButtonKeyLightMapping(ButtonEnum.CockpitHatch, true, 3, SBC.Key.A, true);//last true means if you hold down the button,    
            //no longer using Microsoft.DirectX.DirectInput but included this in here to show that I made
      //code backwards compatible
      controller.AddButtonKeyLightMapping(ButtonEnum.FunctionF1, true, 3, Microsoft.DirectX.DirectInput.Key.BackSpace, true);
            controller.AddButtonKeyMapping(ButtonEnum.RightJoyMainWeapon, SBC.Key.C, true);
      
      //My custom crap
      controller.AddButtonKeyMapping(ButtonEnum.LeftJoySightChange, SBC.Key.C, true);
      controller.AddButtonKeyMapping(ButtonEnum.ToggleFuelFlowRate, SBC.Key.D, true);
      controller.AddButtonKeyMapping(ButtonEnum.ToggleVTLocation, SBC.Key.E, true);
      controller.AddButtonKeyMapping(ButtonEnum.ToggleBufferMaterial, SBC.Key.F, true);
      controller.AddButtonKeyMapping(ButtonEnum.ToggleOxygenSupply, SBC.Key.G, true);
      controller.AddButtonKeyMapping(ButtonEnum.GearLeverStateChange, SBC.Key.H, true);
      controller.AddButtonKeyMapping(ButtonEnum.ToggleFilterControl, SBC.Key.I, true);
      controller.AddButtonKeyMapping(ButtonEnum.GearLeverStateChange, SBC.Key.J, true);
      controller.AddButtonKeyMapping(ButtonEnum.Comm5, SBC.Key.Z, true);
            joystick = new vJoy();
            acquired = joystick.acquireVJD(1);
            joystick.resetAll();//have to reset before we use it
        }
        //this is necessary, as main program calls this to know how often to call mainLoop
        public int getRefreshRate()
        {
            return refreshRate;
        }
        //this gets called once every refreshRate milliseconds by main program
        public void mainLoop()
        {
            joystick.setAxis(1,controller.Scaled.GearLever,HID_USAGES.HID_USAGE_SL0);
            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_RY);
            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));
            }
            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);
        }
    }
}
  


MarkBell

Avatar / Picture

Administrator
Registered:
Posts: 2,018
Reply with quote  #2 
Ooh, love my SB controller.  I've used it for Helm and a Fighter console - Helm worked out ok with the gear shift as impulse throttle, but it's really pretty stiff for that.  Maybe as a Warp/Reverse control would have been better (plus you'll never need to figure out why you can't go to warp [tongue] ).  I used the Left Block as yaw, and I think I used the pedals as pitch.  Maybe the tuner dial for that?  I used the aiming lever as a mouse input, because sometimes you just need to click on something...  For Fighter I used Left Block as yaw, Aiming Lever as pitch and roll, and [SOME BUTTONS] for boost/brake (I don't remember which, it's been a while).

I didn't write any code myself, I used an https://github.com/TylorF/SteelBattalionWindows64 , then vJoy to set up buttons and axes, and left the config file to pulse the buttons when I hit them.  



__________________
Note - this is in no way intended to be an official position of Thom or Artemis, as I am not an official representative of the creator or game.
AurelTristen

Registered:
Posts: 15
Reply with quote  #3 
So you just use the 'simple.cs' file that came with SteelBattalion64?  I'm still struggling to get everything to map, especially the shifter and tuner dial, but my controller was bought used and without the pedals.  (Well, not bought, but traded for a few N64 games).

I'm thinking about designing and cutting some custom overlays to put around the buttons and update the labels to match Artemis.  This'll help cut down the learning curve, as I have a rotating crew.
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.