diff options
author | Hugues Hiegel <hugues@hiegel.fr> | 2013-11-18 20:57:10 +0100 |
---|---|---|
committer | Hugues Hiegel <hugues@hiegel.fr> | 2013-11-18 20:57:10 +0100 |
commit | 1ad1efb122971563299d626e9210d3943e22e70a (patch) | |
tree | 7ab410edffb70f51af21d8488fbdfea07c450f44 /scripts/gugus | |
parent | 30fe750fb68cf5efcac9c65f650ab7631463cb5c (diff) |
[gugus] controls : LCD up/down in rF/rF2 {WIP}
Diffstat (limited to 'scripts/gugus')
-rw-r--r-- | scripts/gugus/controls.lua | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/gugus/controls.lua b/scripts/gugus/controls.lua new file mode 100644 index 0000000..fc4aa7e --- /dev/null +++ b/scripts/gugus/controls.lua @@ -0,0 +1,91 @@ + +--- +mLCDup = 10 +mLCDdown = 9 +mKeyDelay = 100 + +-- +-- rFactor +-- +mRFactorLCD_keys = { + "H", -- std + "J", -- standings + "K", -- pit + "L", -- vehicle + "Y", -- aids + "I", -- extra + "O" -- race +} +mRFactorLCD_state = 0 + +-- +-- rFactor2 +-- +mRFactor2LCD_keys = { + "6", -- std + "7", -- standings + "8", -- pit + "9", -- vehicle + "]", -- aids + "0", -- extra + "-", -- race + "=" -- penalities +} +mRFactor2LCD_state = 0 + +function custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) + + -- print ( string.format("[%s] %s:%s = %s => %s (%s)", deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) ) + + if funcIndex == -1 then + if ctrlType == 1 and ( ctrlPos == mLCDup or ctrlPos == mLCDdown ) and value == 0 then + local Key = nil + --if ctrlPos == mLCDup then + -- print ( " + LCD up") + --else + -- print ( " + LCD down") + --end + local sim = GetContextInfo("simulation") + if sim == "rFactor2.exe" or sim == "rFactor.exe" then + if sim == "rFactor2.exe" then + + --print ( " >> rF2 :" , mRFactor2LCD_state) + + if ctrlPos == mLCDup then + mRFactor2LCD_state = mRFactor2LCD_state + 1 + elseif ctrlPos == mLCDdown then + mRFactor2LCD_state = mRFactor2LCD_state - 1 + end + + mRFactor2LCD_state = mRFactor2LCD_state % table.getn(mRFactor2LCD_keys) + --print ( " << rF2 :" , mRFactor2LCD_state) + + Key = mRFactor2LCD_keys[mRFactor2LCD_state + 1] + elseif sim == "rFactor.exe" then + + --print ( " >> rF :" , mRFactorLCD_state) + + if ctrlPos == mLCDup then + mRFactorLCD_state = mRFactorLCD_state + 1 + elseif ctrlPos == mLCDdown then + mRFactorLCD_state = mRFactorLCD_state - 1 + end + + mRFactorLCD_state = mRFactorLCD_state % table.getn(mRFactorLCD_keys) + --print ( " << rF :" , mRFactorLCD_state) + + Key = mRFactorLCD_keys[mRFactorLCD_state + 1] + end + end + if Key ~= nil then + --print ( "KeyStroke : ", Key ) + SetKeystroke(Key, mKeyDelay, "") + return 0 + end + end + end + + return 2 +end + +print ( "gugus> + controls" ) |