Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
vortex1942 authored Apr 26, 2023
1 parent 3634ad9 commit 75b3cab
Show file tree
Hide file tree
Showing 4 changed files with 1,155 additions and 0 deletions.
98 changes: 98 additions & 0 deletions AFMAnalogAxis.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
; Check the readme provided
; Also damned good job for actually checking the script before you ran it +10 Points


;;; Debugging
;;;#Warn
;;;If !(A_IsAdmin) {
;;; Msgbox Script needs to be run with admin rights, press ok to run as admin instead.
;;; Run *RunAs "%A_ScriptFullPath%"
;;;}

#NoEnv
SendMode InputThenPlay
#SingleInstance, force
#IfTimeout 100

; Loads vjoy_lib.ahk from the location of AFMAnalogAxis.ahk
SetWorkingDir %A_ScriptDir%
#include vjoy_lib.ahk

; A warning will appear if this is set too low
; May need to be raised if your mouse is able to scroll quickly
#MaxHotkeysPerInterval, 250

; Set the vjoy device id (Controller ID)
; Leave default unless
vjoy_id := 1

; Init the vJoy stick
vjoy_init(vjoy_id)

; Check SL0 axis exists on stick
if (!VJoy_GetAxisExist_SL0(vjoy_id)){
msgbox Please enable the SL0 axis of vjoy ID %vjoy_id% using the vJoy config utility.
}

; Reload script : F1
F1::
Reload
SoundBeep
Return

; Emergency script kill : Shift+F1
+F1::ExitApp


;###################
;Slow traverse speed
;###################
; Shift + Wheel = 5%
+WheelUp::
; Pick a number between 0 and 32767 and store it in val
val += 1638.25 ;This will set the traverse speed
IfLess val,0, SetEnv val,0
IfGreater val,32767, SetEnv val,32767
; Set axis value
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
return

+WheelDown::
; Pick a number between 0 and 32767 and store it in val
val -= 1638.25 ;This will set the traverse speed
IfLess val,0, SetEnv val,0
IfGreater val,32767, SetEnv val,32767
; Set axis value
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
return

;###################
;Fast traverse speed
;###################
;Ctrl + Wheel = 10% x 1% Multiplier

^WheelUp::
val += 3276.7 ;This will set the traverse speed
; Set axis value
IfLess val,0, SetEnv val,0
IfGreater val,32767, SetEnv val,32767

VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
return

^WheelDown::
val -= 3276.7 ;This will set the traverse speed
; Set axis value
IfLess val,0, SetEnv val,0
IfGreater val,32767, SetEnv val,32767

VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
return


x::
val = 32767
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
sleep, 500
val = 0
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
56 changes: 56 additions & 0 deletions AxisKeybinding.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
; Check the readme provided
; Good job for actually checking the script before you ran it +10 Points

;;; Debugging
;;;#Warn
;;;If !(A_IsAdmin) {
;;; Msgbox Script needs to be run with admin rights, press ok to run as admin instead.
;;; Run *RunAs "%A_ScriptFullPath%"
;;;}

#NoEnv
SendMode InputThenPlay
#SingleInstance, force
#IfTimeout 100
SetWorkingDir %A_ScriptDir%
#include vjoy_lib.ahk
#MaxHotkeysPerInterval, 250
vjoy_id := 1
vjoy_init(vjoy_id)

;KeyboardHooks to record keypresses inside of Arma
#InstallKeybdHook
#UseHook On

; Check SL0 axis exists on stick
if (!VJoy_GetAxisExist_SL0(vjoy_id)){
msgbox Please enable the SL0 axis of vjoy ID %vjoy_id% using the vJoy config utility.
}

; Reload script : F1
F1::
Reload
SoundBeep
Return

; Emergency script kill : Shift+F1
+F1::ExitApp

x::
SoundBeep
; Raise from 50% to 100%
val = 16383
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
sleep, 500
val = 32767
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
sleep, 500

; Lower from 50% to 0%
val = 16383
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
sleep, 500
val = 0
VJoy_SetAxis(val, vjoy_id, HID_USAGE_SL0)
SoundBeep
Return
Loading

0 comments on commit 75b3cab

Please sign in to comment.