- Remove vjoy functionality

- Rename files for consistency
- Fix accidental creation of both *.ini and *io.ini files
- Change hardcoded "version" so that the ini file is called `MidiToMacro.ini`
This commit is contained in:
Laurence Dougal Myers 2020-08-29 12:00:46 +10:00
parent c2f678893d
commit aacb44c7a8
13 changed files with 782 additions and 2339 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
*.bak *.bak
*.ini

View File

@ -1,25 +1,25 @@
DisplayOutput(event, value) { DisplayOutput(event, value) {
Gui,14:default Gui,14:default
Gui,14:ListView, Out1 ; see the second listview midi out monitor Gui,14:ListView, Out1 ; see the second listview midi out monitor
LV_Add("",event,value) LV_Add("",event,value)
LV_ModifyCol(1,"center") LV_ModifyCol(1,"center")
LV_ModifyCol(2,"center") LV_ModifyCol(2,"center")
If (LV_GetCount() > 10) If (LV_GetCount() > 10)
{ {
LV_Delete(1) LV_Delete(1)
} }
} }
ConvertToAxis(value, maximum_axis_value) { ConvertToAxis(value, maximum_axis_value) {
return Floor(value * maximum_axis_value) return Floor(value * maximum_axis_value)
} }
ConvertCCValueToScale(value, minimum_value, maximum_value) { ConvertCCValueToScale(value, minimum_value, maximum_value) {
if (value > maximum_value) { if (value > maximum_value) {
value := maximum_value value := maximum_value
} else if (value < minimum_value) { } else if (value < minimum_value) {
value := minimum_value value := minimum_value
} }
return (value - minimum_value) / (maximum_value - minimum_value) return (value - minimum_value) / (maximum_value - minimum_value)
} }

View File

@ -1,133 +1,133 @@
/* /*
PARSE - LAST MIDI MESSAGE RECEIVED - PARSE - LAST MIDI MESSAGE RECEIVED -
Midi monitor. Midi monitor.
*/ */
;************************************************* ;*************************************************
;* MIDI INPUT PARSE FUNCTION ;* MIDI INPUT PARSE FUNCTION
;* ;*
;************************************************* ;*************************************************
; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! no edit below here .... ; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! no edit below here ....
MidiMsgDetect(hInput, midiMsg, wMsg) ; Midi input section in "under the hood" calls this function each time a midi message is received. Then the midi message is broken up into parts for manipulation. See http://www.midi.org/techspecs/midimessages.php (decimal values). MidiMsgDetect(hInput, midiMsg, wMsg) ; Midi input section in "under the hood" calls this function each time a midi message is received. Then the midi message is broken up into parts for manipulation. See http://www.midi.org/techspecs/midimessages.php (decimal values).
{ {
global statusbyte, chan, note, cc, byte1, byte2, stb global statusbyte, chan, note, cc, byte1, byte2, stb
statusbyte := midiMsg & 0xFF ; EXTRACT THE STATUS BYTE (WHAT KIND OF MIDI MESSAGE IS IT?) statusbyte := midiMsg & 0xFF ; EXTRACT THE STATUS BYTE (WHAT KIND OF MIDI MESSAGE IS IT?)
chan := (statusbyte & 0x0f) + 1 ; WHAT MIDI CHANNEL IS THE MESSAGE ON? chan := (statusbyte & 0x0f) + 1 ; WHAT MIDI CHANNEL IS THE MESSAGE ON?
byte1 := (midiMsg >> 8) & 0xFF ; THIS IS DATA1 VALUE = NOTE NUMBER OR CC NUMBER byte1 := (midiMsg >> 8) & 0xFF ; THIS IS DATA1 VALUE = NOTE NUMBER OR CC NUMBER
byte2 := (midiMsg >> 16) & 0xFF ; DATA2 VALUE IS NOTE VELEOCITY OR CC VALUE byte2 := (midiMsg >> 16) & 0xFF ; DATA2 VALUE IS NOTE VELEOCITY OR CC VALUE
pitchb := (byte2 << 7) | byte1 ;(midiMsg >> 8) & 0x7F7F masking to extract the pbs pitchb := (byte2 << 7) | byte1 ;(midiMsg >> 8) & 0x7F7F masking to extract the pbs
if statusbyte between 176 and 191 ; test for cc if statusbyte between 176 and 191 ; test for cc
stb := "CC" ; if so then set stp to cc stb := "CC" ; if so then set stp to cc
if statusbyte between 144 and 159 if statusbyte between 144 and 159
stb := "NoteOn" stb := "NoteOn"
if statusbyte between 128 and 143 if statusbyte between 128 and 143
stb := "NoteOff" stb := "NoteOff"
if statusbyte between 224 and 239 if statusbyte between 224 and 239
stb := "PitchB" stb := "PitchB"
gosub, ShowMidiInMessage ; show updated midi input message on midi monitor gui. gosub, ShowMidiInMessage ; show updated midi input message on midi monitor gui.
gosub, MidiRules ; run the label in file MidiRules.ahk Edit that file. gosub, MidiRules ; run the label in file MidiRules.ahk Edit that file.
} }
; end of MidiMsgDetect funciton ; end of MidiMsgDetect funciton
Return Return
;************************************************* ;*************************************************
;* SHOW MIDI INPUT ON GUI MONITOR ;* SHOW MIDI INPUT ON GUI MONITOR
;************************************************* ;*************************************************
ShowMidiInMessage: ; update the midimonitor gui ShowMidiInMessage: ; update the midimonitor gui
Gui,14:default Gui,14:default
Gui,14:ListView, In1 ; see the first listview midi in monitor Gui,14:ListView, In1 ; see the first listview midi in monitor
LV_Add("",stb,statusbyte,chan,byte1,byte2) LV_Add("",stb,statusbyte,chan,byte1,byte2)
LV_ModifyCol(1,"center") LV_ModifyCol(1,"center")
LV_ModifyCol(2,"center") LV_ModifyCol(2,"center")
LV_ModifyCol(3,"center") LV_ModifyCol(3,"center")
LV_ModifyCol(4,"center") LV_ModifyCol(4,"center")
LV_ModifyCol(5,"center") LV_ModifyCol(5,"center")
If (LV_GetCount() > 10) If (LV_GetCount() > 10)
{ {
LV_Delete(1) LV_Delete(1)
} }
return return
;************************************************* ;*************************************************
;* SHOW MIDI OUTPUT ON GUI MONITOR ;* SHOW MIDI OUTPUT ON GUI MONITOR
;************************************************* ;*************************************************
ShowMidiOutMessage: ; update the midimonitor gui ShowMidiOutMessage: ; update the midimonitor gui
Gui,14:default Gui,14:default
Gui,14:ListView, Out1 ; see the second listview midi out monitor Gui,14:ListView, Out1 ; see the second listview midi out monitor
LV_Add("",stb,statusbyte,chan,byte1,byte2) LV_Add("",stb,statusbyte,chan,byte1,byte2)
LV_ModifyCol(1,"center") LV_ModifyCol(1,"center")
LV_ModifyCol(2,"center") LV_ModifyCol(2,"center")
LV_ModifyCol(3,"center") LV_ModifyCol(3,"center")
LV_ModifyCol(4,"center") LV_ModifyCol(4,"center")
LV_ModifyCol(5,"center") LV_ModifyCol(5,"center")
If (LV_GetCount() > 10) If (LV_GetCount() > 10)
{ {
LV_Delete(1) LV_Delete(1)
} }
return return
;************************************************* ;*************************************************
;* MIDI MONITOR GUI CODE ;* MIDI MONITOR GUI CODE
;************************************************* ;*************************************************
midiMon: ; midi monitor gui with listviews midiMon: ; midi monitor gui with listviews
gui,14:destroy gui,14:destroy
gui,14:default gui,14:default
gui,14:add,text, x80 y5, Midi Input ; %TheChoice% gui,14:add,text, x80 y5, Midi Input ; %TheChoice%
Gui,14:Add, DropDownList, x40 y20 w140 Choose%TheChoice% vMidiInPort gDoneInChange altsubmit, %MiList% ; ( Gui,14:Add, DropDownList, x40 y20 w140 Choose%TheChoice% vMidiInPort gDoneInChange altsubmit, %MiList% ; (
gui,14:add,text, x305 y5, Midi Ouput ; %TheChoice2% gui,14:add,text, x305 y5, Midi Ouput ; %TheChoice2%
Gui,14:Add, DropDownList, x270 y20 w140 Choose%TheChoice2% vMidiOutPort gDoneOutChange altsubmit , %MoList% Gui,14:Add, DropDownList, x270 y20 w140 Choose%TheChoice2% vMidiOutPort gDoneOutChange altsubmit , %MoList%
Gui,14:Add, ListView, x5 r11 w220 Backgroundblack caqua Count10 vIn1, EventType|StatB|Ch|Byte1|Byte2| Gui,14:Add, ListView, x5 r11 w220 Backgroundblack caqua Count10 vIn1, EventType|StatB|Ch|Byte1|Byte2|
gui,14:Add, ListView, x+5 r11 w220 Backgroundblack cyellow Count10 vOut1, Event|Value| gui,14:Add, ListView, x+5 r11 w220 Backgroundblack cyellow Count10 vOut1, Event|Value|
LV_ModifyCol(1, 105) LV_ModifyCol(1, 105)
LV_ModifyCol(2, 110) LV_ModifyCol(2, 110)
gui,14:Show, autosize xcenter y5, MidiMonitor gui,14:Show, autosize xcenter y5, MidiMonitor
Return Return
;************************************************* ;*************************************************
;* MIDI OUTPUT LABELS TO CALL ;* MIDI OUTPUT LABELS TO CALL
;************************************************* ;*************************************************
SendNote: ;(h_midiout,Note) ; send out note messages ; this should probably be a funciton SendNote: ;(h_midiout,Note) ; send out note messages ; this should probably be a funciton
note = %byte1% ; this var is added to allow transpostion of a note note = %byte1% ; this var is added to allow transpostion of a note
midiOutShortMsg(h_midiout, statusbyte, note, byte2) ; call the midi funcitons with these params. midiOutShortMsg(h_midiout, statusbyte, note, byte2) ; call the midi funcitons with these params.
gosub, ShowMidiOutMessage gosub, ShowMidiOutMessage
Return Return
SendCC: SendCC:
midiOutShortMsg(h_midiout, statusbyte, cc, byte2) midiOutShortMsg(h_midiout, statusbyte, cc, byte2)
Return Return
SendPC: SendPC:
gosub, ShowMidiOutMessage gosub, ShowMidiOutMessage
midiOutShortMsg(h_midiout, statusbyte, pc, byte2) midiOutShortMsg(h_midiout, statusbyte, pc, byte2)
Return Return
; MIDI Rules dispatcher ; MIDI Rules dispatcher
MidiRules: MidiRules:
if (statusbyte >= 128 and statusbyte <= 159) { ; Note off/on if (statusbyte >= 128 and statusbyte <= 159) { ; Note off/on
isNoteOn := (statusbyte >= 144 and byte2 > 0) isNoteOn := (statusbyte >= 144 and byte2 > 0)
ProcessNote(0, chan, byte1, byte2, isNoteOn) ProcessNote(0, chan, byte1, byte2, isNoteOn)
} else if (statusbyte >= 176 and statusbyte <= 191) { ; CC } else if (statusbyte >= 176 and statusbyte <= 191) { ; CC
ProcessCC(0, chan, byte1, byte2) ProcessCC(0, chan, byte1, byte2)
} else if (statusbyte >= 192 and statusbyte <= 208) { ; PC } else if (statusbyte >= 192 and statusbyte <= 208) { ; PC
ProcessPC(0, chan, byte1, byte2) ProcessPC(0, chan, byte1, byte2)
} else if (statusbyte >= 224 and statusbyte <= 239) { ; Pitch bend } else if (statusbyte >= 224 and statusbyte <= 239) { ; Pitch bend
ProcessPitchBend(0, chan, pitchb) ProcessPitchBend(0, chan, pitchb)
} }
; Maybe TODO: Key aftertouch, channel aftertouch, ; Maybe TODO: Key aftertouch, channel aftertouch,
Return Return

View File

@ -1,50 +1,50 @@
/* /*
MIDI to joy. MIDI to joy.
Based on GENERIC MIDI APP V.0.6 by genmce and contributors. Based on GENERIC MIDI APP V.0.6 by genmce and contributors.
Edit the "VARIBLES TO SET @ STARTUP" section. Edit the "VARIBLES TO SET @ STARTUP" section.
MidiRules.ahk contains the logic that maps from MIDI controllers to VJoy. MidiRules.ahk contains the logic that maps from MIDI controllers to VJoy.
Sections with !!!!!!!!!!!!!!!!!!!! - don't edit between these, unless you know what you are doing (uykwyad) ! Sections with !!!!!!!!!!!!!!!!!!!! - don't edit between these, unless you know what you are doing (uykwyad) !
Sections with ++++++++++++++++++++ Edit between these marks. You won't break it, I don't think??? Sections with ++++++++++++++++++++ Edit between these marks. You won't break it, I don't think???
*/ */
#Include mtjFunctions.ahk #Include CommonFunctions.ahk
#Persistent #Persistent
#SingleInstance #SingleInstance
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
if A_OSVersion in WIN_NT4,WIN_95,WIN_98,WIN_ME ; if not xp or 2000 quit if A_OSVersion in WIN_NT4,WIN_95,WIN_98,WIN_ME ; if not xp or 2000 quit
{ {
MsgBox This script requires Windows 2000/XP or later. MsgBox This script requires Windows 2000/XP or later.
ExitApp ExitApp
} }
version = midi_to_joy_3 version = MidiToMacro
readini() ; load values from the ini file, via the readini function - see Midi_under_the_hood.ahk file readini() ; load values from the ini file, via the readini function - see Midi_under_the_hood.ahk file
gosub, MidiPortRefresh ; used to refresh the input and output port lists - see Midi_under_the_hood.ahk file gosub, MidiPortRefresh ; used to refresh the input and output port lists - see Midi_under_the_hood.ahk file
port_test(numports,numports2) ; test the ports - check for valid ports? - see Midi_under_the_hood.ahk file port_test(numports,numports2) ; test the ports - check for valid ports? - see Midi_under_the_hood.ahk file
gosub, midiin_go ; opens the midi input port listening routine see Midi_under_the_hood.ahk file gosub, midiin_go ; opens the midi input port listening routine see Midi_under_the_hood.ahk file
gosub, midiout ; opens the midi out port see Midi_under_the_hood.ahk file gosub, midiout ; opens the midi out port see Midi_under_the_hood.ahk file
gosub, midiMon ; see below - a monitor gui - see Midi_In_and_GuiMonitor.ahk gosub, midiMon ; see below - a monitor gui - see Midi_In_and_GuiMonitor.ahk
;************************************************* ;*************************************************
;* VARIBLES TO SET @ STARTUP ;* VARIBLES TO SET @ STARTUP
;************************************************* ;*************************************************
#Include UserVariables.ahk #Include userVariables.ahk
return return
#Include Midi_In_and_GuiMonitor.ahk ; this file contains: the function to parse midi message into parts we can work with and a midi monitor. #Include MidiInAndGuiMonitor.ahk ; this file contains: the function to parse midi message into parts we can work with and a midi monitor.
#Include MidiRules.ahk ; this file contains: Rules for manipulating midi input then sending modified midi output. #Include MidiRules.ahk ; this file contains: Rules for manipulating midi input then sending modified midi output.
#Include Midi_under_the_hood.ahk ; this file contains: (DO NOT EDIT THIS FILE) all the dialogs to set up midi ports and midi message handling. #Include MidiUnderTheHood.ahk ; this file contains: (DO NOT EDIT THIS FILE) all the dialogs to set up midi ports and midi message handling.

File diff suppressed because it is too large Load Diff

View File

@ -1,460 +0,0 @@
; VJoy_Test.ahk
#include %A_ScriptDir%\VJoy_lib.ahk
VJoy_Init()
nButtons := VJoy_GetVJDButtonNumber(iInterface)
cbtn := 1
StatStr := (status = VJD_STAT_OWN) ? "OWN" : "FREE" ; only FREE state required.
AxisMax_X := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_X)
AxisMax_Y := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_Y)
AxisMax_Z := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_Z)
AxisMax_RX := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_RX)
AxisMax_RY := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_RY)
AxisMax_RZ := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_RZ)
AxisMax_SL0 := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_SL0)
AxisMax_SL1 := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_SL1)
AxisMax_WHL := VJoy_GetVJDAxisMax(iInterface, HID_USAGE_WHL)
; build gui
Gui, Add, Text, w80 , Status: %StatStr%
Gui, add, Button, x100 y5 Default gBtnReset, Re&set
Gui, add, Button, x150 y5 gBtnReload, &Reload
Gui, add, Button, x200 y5 gBtnjoycpl, Open &cpl
Gui, Add, Text, x10, %nButtons% Buttons supported
Gui, Add, Button, x140 y30 gBtnTestAllON, Test all On
Gui, Add, Button, x210 y30 gBtnTestAllOFF, Off
Loop, %nButtons%
{
bX := ((Mod((A_Index-1), 8)) * 30 ) + 10
bY := FLOOR((A_Index-1) / 8) * 24 + 70
Gui, add, Button, h5 x%bx% y%by% gBtn%A_Index%, %A_Index%
}
nexty := 180
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_X)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis X: 0 / %AxisMax_X%
Gui, Add, Slider, x140 y%nexty% vAxisX gSliderXChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_Y)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis Y: 0 / %AxisMax_Y%
Gui, Add, Slider, x140 y%nexty% vAxisY gSliderYChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_Z)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis Z: 0 / %AxisMax_Z%
Gui, Add, Slider, x140 y%nexty% vAxisZ gSliderZChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_RX)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis RX: 0 / %AxisMax_RX%
Gui, Add, Slider, x140 y%nexty% vAxisRX gSliderRXChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_RY)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis RY: 0 / %AxisMax_RY%
Gui, Add, Slider, x140 y%nexty% vAxisRY gSliderRYChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_RZ)) {
Gui, Add, Text, x10 w130 y%nexty%, Axis RZ: 0 / %AxisMax_RZ%
Gui, Add, Slider, x140 y%nexty% vAxisRZ gSliderRZChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_SL0)) {
Gui, Add, Text, x10 w130 y%nexty%, Slider0: 0 / %AxisMax_SL0%
Gui, Add, Slider, x140 y%nexty% vAxisSL0 gSliderSL0Changed
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_SL1)) {
Gui, Add, Text, x10 w130 y%nexty%, Slider1: 0 / %AxisMax_SL1%
Gui, Add, Slider, x140 y%nexty% vAxisSL1 gSliderSL1Changed
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (VJoy_GetVJDAxisExist(iInterface, HID_USAGE_WHL)) {
Gui, Add, Text, x10 w130 y%nexty%, Wheel: 0 / %AxisMax_WHL%
Gui, Add, Slider, x140 y%nexty% vAxisWHL gSliderWHLChanged
nexty += 40
} else {
Gui, Add, Text, x0 y0
}
if (ContPovNumber) {
Gui, Add, Text, x10 y%nexty%,Number of Continuous POVs: %ContPovNumber%
nexty += 20
Gui, Add, Text, x10 y%nexty%, Continuous Pov test
Gui, Add, Slider, x140 y%nexty% vPovValSlider gSliderContPov
nexty+=40
Gui, Add, Edit, x10 w80 y%nexty% vPovValDirect gEditContPov, -1
Loop, %ContPovNumber%
{
_contpov_listing := % _contpov_listing . A_Index
if (A_Index < ContPovNumber) {
_contpov_listing := % _contpov_listing . "|"
}
}
Gui, Add, ListBox, x140 w40 y%nexty% vContPovChoice gContPovChoose, %_contpov_listing%
nexty += 30
}
if (DiscPovNumber) {
Gui, Add, Text, x10 y%nexty%,Number of Descrete POVs: %DiscPovNumber%
nexty += 20
tmpy := nexty
Gui, Add, Button, x160 y%tmpy% gBtnPovN, N
tmpy := nexty + 30
Gui, Add, Button, x155 y%tmpy% gBtnPovNeu, Neu
tmpy := nexty + 60
Gui, Add, Button, x160 y%tmpy% gBtnPovS, S
tmpy := nexty + 30
Gui, Add, Button, x120 y%tmpy% gBtnPovW, W
Gui, Add, Button, x200 y%tmpy% gBtnPovE, E
Loop, %DiscPovNumber%
{
_contpov_listing := % _contpov_listing . A_Index
if (A_Index < DiscPovNumber) {
_contpov_listing := % _contpov_listing . "|"
}
}
Gui, Add, ListBox, x10 w40 y%nexty% vDiscPovChoice gDiscPovChoose, %_contpov_listing%
nexty += 100
}
GetKeyState, _JoyStat, JoyInfo
Gui, Add, Text, x10 y%nexty%, JoyInfo: %_JoyStat%
Gui, Show
return
SliderXChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_X * AxisX / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_X)
ControlSetText, Static3, Axis X %tmp_axis_val% / %AxisMax_X%
return
SliderYChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_Y * AxisY / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_Y)
ControlSetText, Static4, Axis Y %tmp_axis_val% / %AxisMax_Y%
return
SliderZChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_Z * AxisZ / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_Z)
ControlSetText, Static5, Axis Z %tmp_axis_val% / %AxisMax_Z%
return
SliderRXChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_RX * AxisRX / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_RX)
ControlSetText, Static6, Axis RX %tmp_axis_val% / %AxisMax_RX%
return
SliderRYChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_RY * AxisRY / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_RY)
ControlSetText, Static7, Axis RY %tmp_axis_val% / %AxisMax_RY%
return
SliderRZChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_RZ * AxisRZ / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_RZ)
ControlSetText, Static8, Axis RZ %tmp_axis_val% / %AxisMax_RZ%
return
SliderSL0Changed:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_SL0 * AxisSL0 / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_SL0)
ControlSetText, Static9, Slider0 %tmp_axis_val% / %AxisMax_SL0%
return
SliderSL1Changed:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_SL1 * AxisSL1 / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_SL1)
ControlSetText, Static10, Slider1 %tmp_axis_val% / %AxisMax_SL1%
return
SliderWHLChanged:
Gui, Submit, NoHide
tmp_axis_val := Floor(AxisMax_WHL * AxisWHL / 100)
VJoy_SetAxis(tmp_axis_val, iInterface, HID_USAGE_WHL)
ControlSetText, Static11, Wheel %tmp_axis_val% / %AxisMax_WHL%
return
BtnReload:
F12::
VJoy_Close(iInterface)
Reload
return
;GuiClose:
; ExitApp
;return
OnExit:
VJoy_Close(iInterface)
return
; GUIBtn test all buttons
BtnTestAllON:
Loop, %nButtons%
{
VJoy_SetBtn(1, iInterface, A_Index)
}
return
BtnTestAllOFF:
Loop, %nButtons%
{
VJoy_SetBtn(0, iInterface, A_Index)
}
return
BtnTest(id, btn) {
VJoy_SetBtn(1, id, btn)
Sleep, 100
VJoy_SetBtn(0, id, btn) ; Release button 1
}
; GUIBtn1 for test button1
Btn1:
BtnTest(iInterface, 1)
return
Btn2:
BtnTest(iInterface, 2)
return
Btn3:
BtnTest(iInterface, 3)
return
Btn4:
BtnTest(iInterface, 4)
return
Btn5:
BtnTest(iInterface, 5)
return
Btn6:
BtnTest(iInterface, 6)
return
Btn7:
BtnTest(iInterface, 7)
return
Btn8:
BtnTest(iInterface, 8)
return
Btn9:
BtnTest(iInterface, 9)
return
Btn10:
BtnTest(iInterface, 10)
return
Btn11:
BtnTest(iInterface, 11)
return
Btn12:
BtnTest(iInterface, 12)
return
Btn13:
BtnTest(iInterface, 13)
return
Btn14:
BtnTest(iInterface, 14)
return
Btn15:
BtnTest(iInterface, 15)
return
Btn16:
BtnTest(iInterface, 16)
return
Btn17:
BtnTest(iInterface, 17)
return
Btn18:
BtnTest(iInterface, 18)
return
Btn19:
BtnTest(iInterface, 19)
return
Btn20:
BtnTest(iInterface, 20)
return
Btn21:
BtnTest(iInterface, 21)
return
Btn22:
BtnTest(iInterface, 22)
return
Btn23:
BtnTest(iInterface, 23)
return
Btn24:
BtnTest(iInterface, 24)
return
Btn25:
BtnTest(iInterface, 25)
return
Btn26:
BtnTest(iInterface, 26)
return
Btn27:
BtnTest(iInterface, 27)
return
Btn28:
BtnTest(iInterface, 28)
return
Btn29:
BtnTest(iInterface, 29)
return
Btn30:
BtnTest(iInterface, 30)
return
Btn31:
BtnTest(iInterface, 31)
return
Btn32:
BtnTest(iInterface, 32)
return
; Open Game Control Panel
Btnjoycpl:
RunWait %ComSpec% /C start joy.cpl,, Hide
return
BtnReset:
AxisX := AxisY := AxisZ := AxisRX := AxisRY := AxisRZ := Slider0 := Slider1 := 0
Gui, Submit, NoHide
VJoy_Close(iInterface)
VJoy_Init()
return
EditContPov:
Gui, Submit, NoHide
GuiControlGet, ContPovChoice
if (ContPovChoice < 1 or ContPovChoice > ContPovNumber) {
MsgBox, Please select a pov
return
}
if (PovValDirect < -1) {
PovValDirect := -1
Gui, Submit, NoHide
return
}
if (PovValDirect > 35999) {
PovValDirect := 35999
Gui, Submit, NoHide
return
}
VJoy_SetContPov(PovValDirect, iInterface, ContPovChoice)
return
SliderContPov:
Gui, Submit, NoHide
GuiControlGet, ContPovChoice
if (ContPovChoice < 1 or ContPovChoice > ContPovNumber) {
MsgBox, Please select a pov
return
}
PovValDirect := Floor(35999 * PovValSlider / 100)
ControlSetText, Edit1, %PovValDirect%
VJoy_SetContPov(PovValDirect, iInterface, ContPovChoice)
return
ContPovChoose:
Gui, Submit, NoHide
GuiControlGet, ContPovChoice
return
BtnPovNeu:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
if (DiscPovChoice < 1 or DiscPovChoice > DiscPovNumber) {
MsgBox, Please select a pov
return
}
VJoy_SetDiscPov(-1, iInterface, DiscPovChoice)
return
BtnPovN:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
if (DiscPovChoice < 1 or DiscPovChoice > DiscPovNumber) {
MsgBox, Please select a pov
return
}
VJoy_SetDiscPov(0, iInterface, DiscPovChoice)
return
BtnPovE:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
if (DiscPovChoice < 1 or DiscPovChoice > DiscPovNumber) {
MsgBox, Please select a pov
return
}
VJoy_SetDiscPov(1, iInterface, DiscPovChoice)
return
BtnPovS:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
if (DiscPovChoice < 1 or DiscPovChoice > DiscPovNumber) {
MsgBox, Please select a pov
return
}
VJoy_SetDiscPov(2, iInterface, DiscPovChoice)
return
BtnPovW:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
if (DiscPovChoice < 1 or DiscPovChoice > DiscPovNumber) {
MsgBox, Please select a pov
return
}
VJoy_SetDiscPov(3, iInterface, DiscPovChoice)
return
DiscPovChoose:
Gui, Submit, NoHide
GuiControlGet, DiscPovChoice
return

View File

@ -1,175 +0,0 @@
;VJoy_lib.ahk
iInterface = 2 ; Default target vJoy device
; ported from VjdStat in vjoyinterface.h
VJD_STAT_OWN := 0 ; The vJoy Device is owned by this application.
VJD_STAT_FREE := 1 ; The vJoy Device is NOT owned by any application (including this one).
VJD_STAT_BUSY := 2 ; The vJoy Device is owned by another application. It cannot be acquired by this application.
VJD_STAT_MISS := 3 ; The vJoy Device is missing. It either does not exist or the driver is down.
VJD_STAT_UNKN := 4 ; Unknown
;HID Descriptor definitions(ported from public.h
HID_USAGE_X := 0x30
HID_USAGE_Y := 0x31
HID_USAGE_Z := 0x32
HID_USAGE_RX := 0x33
HID_USAGE_RY := 0x34
HID_USAGE_RZ := 0x35
HID_USAGE_SL0 := 0x36
HID_USAGE_SL1 := 0x37
HID_USAGE_WHL := 0x38
HID_USAGE_POV := 0x39
VJoy_init() {
Global iInterface, VJD_STAT_OWN, VJD_STAT_FREE, VJD_STAT_BUSY, VJD_STAT_MISS, VJD_STAT_UNKN, ContPovNumber, DiscPovNumber, hDLL
SetWorkingDir, %A_ScriptDir%
curdir:=A_WorkingDir
if (!hDLL) {
dllpath = %A_ScriptDir%\vJoyInterface.dll
hDLL := DLLCall("LoadLibrary", "Str", dllpath)
if (!hDLL) {
MsgBox, LoadLibrary %dllpath% fail
}
}
result := DllCall("vJoyInterface.dll\vJoyEnabled", "Int")
if (ErrorLevel = 4) {
MsgBox, Error! VJoy library "vJoyInterface.dll" is not found!`nErrorLevel:%ErrorLevel%
ExitApp
}
if (!result) {
MsgBox, Error! VJoy interface is not installed!`nErrorLevel:%ErrorLevel%
ExitApp
}
status := DllCall("vJoyInterface\GetVJDStatus", "Int", iInterface)
if (status = VJD_STAT_OWN) {
ToolTip, vJoy Device %iInterface% is already owned by this feeder
} else if (status = VJD_STAT_FREE) {
ToolTip, vJoy Device %iInterface% is free
} else if (status = VJD_STAT_BUSY) {
MsgBox vJoy Device %iInterface% is already owned by another feeder`nCannot continue`n
ExitApp
} else if (status = VJD_STAT_MISS) {
MsgBox vJoy Device %iInterface% is not installed or disabled`nCannot continue`n
ExitApp
} else {
MsgBox vJoy Device %iInterface% general error`nCannot continue`n
ExitApp
}
Sleep, 50
ToolTip
; Get the number of buttons and POV Hat switchessupported by this vJoy device
ContPovNumber := DllCall("vJoyInterface\GetVJDContPovNumber", "UInt", iInterface, "Int")
DiscPovNumber := DllCall("vJoyInterface\GetVJDDiscPovNumber", "UInt", iInterface, "Int")
; Acquire the target device
if (status = VJD_STAT_FREE) {
ac_jvd := VJoy_AcquireVJD(iInterface)
}
if ((status = VJD_STAT_OWN) || ((status = VJD_STAT_FREE) && (!ac_jvd))) {
MsgBox % "Failed to acquire vJoy device number % iInterface "
ExitApp
} else {
ToolTip, Acquired: vJoy device number %iInterface%
}
Sleep, 50
ToolTip
VJoy_ResetVJD(iInterface)
; VJoy_RelinquishVJD(iInterface)
return
}
VJoy_AcquireVJD(id) {
return DllCall("vJoyInterface\AcquireVJD", "UInt", id)
}
VJoy_GetVJDStatus(id) {
status := DllCall("vJoyInterface\GetVJDStatus", "UInt", id)
return status
}
VJoy_GetVJDButtonNumber(id) {
res := DllCall("vJoyInterface\GetVJDButtonNumber", "Int", id)
return res
}
VJoy_SetBtn(sw, id, btn_id) {
res := DllCall("vJoyInterface\SetBtn", "Int", sw, "UInt", id, "UChar", btn_id)
if (!res) {
MsgBox, SetBtn(%sw%, %id%, %btn_id%) err: %ErrorLevel%`nnLastError: %A_LastError%
}
return res
}
VJoy_ResetAll() {
res := DllCall("vJoyInterface\ResetAll")
return res
}
VJoy_ResetVJD(id) {
res := DllCall("vJoyInterface\ResetVJD", "UInt", id)
return res
}
VJoy_GetVJDAxisMax(id, usage) {
res := DllCall("vJoyInterface\GetVJDAxisMax", "Int", id, "Int", usage, "IntP", Max_Axis)
return Max_Axis
}
VJoy_GetVJDAxisExist(id, usage) {
Axis_t := DllCall("vJoyInterface\GetVJDAxisExist", "UInt", id, "UInt", usage)
if (!Axis_t) {
; MsgBox, GetVJDAxisExist Error!`nErrorLevel:%ErrorLevel%
}
if (ErrorLevel) {
ToolTip, GetVJDAxisExist Warning!`nErrorLevel:%ErrorLevel%
ToolTip
}
return Axis_t
}
VJoy_SetAxis(axis_val, id, usage) {
res := DllCall("vJoyInterface\SetAxis", "Int", axis_val, "UInt", id, "UInt", usage)
if (!res) {
MsgBox, SetAxis Error!`nErrorLevel:%ErrorLevel%
}
return res
}
VJoy_RelinquishVJD(id) {
DllCall("vJoyInterface\RelinquishVJD", "UInt", id)
}
VJoy_Close(id) {
VJoy_ResetAll()
VJoy_RelinquishVJD(id)
if (hDLL) {
DLLCall("FreeLibraly", "Ptr", hDLL)
hDLL:=
}
}
VJoy_SetDiscPov(Value, id, nPov) {
_res := DllCall("vJoyInterface\SetDiscPov", "Int", Value, "UInt", id, "UChar", nPov)
if (!_res) {
MsgBox, SetDiscPov err: %ErrorLevel%
}
return _ef_res
}
VJoy_SetContPov(Value, id, nPov) {
_res := DllCall("vJoyInterface\SetContPov", "Int", Value, "UInt", id, "UChar", nPov)
if (!_res) {
MsgBox, SetContPov err: %ErrorLevel%
}
return _ef_res
}

View File

@ -1,839 +0,0 @@
; VJoy_lib.ahk Ver1.1
; Original code by Axlar - http://www.autohotkey.com/board/topic/87690-
; modded by evilC - VJoy_SetAxis fix (Bad ternary operator)
VJD_MAXDEV := 16
; ported from VjdStat in vjoyinterface.h
VJD_STAT_OWN := 0 ; The vJoy Device is owned by this application.
VJD_STAT_FREE := 1 ; The vJoy Device is NOT owned by any application (including this one).
VJD_STAT_BUSY := 2 ; The vJoy Device is owned by another application. It cannot be acquired by this application.
VJD_STAT_MISS := 3 ; The vJoy Device is missing. It either does not exist or the driver is down.
VJD_STAT_UNKN := 4 ; Unknown
; HID Descriptor definitions(ported from public.h
HID_USAGE_X := 0x30
HID_USAGE_Y := 0x31
HID_USAGE_Z := 0x32
HID_USAGE_RX:= 0x33
HID_USAGE_RY:= 0x34
HID_USAGE_RZ:= 0x35
HID_USAGE_SL0:= 0x36
HID_USAGE_SL1:= 0x37
VJDev := Object()
; Load lib from already load or current/system directory
VJoy_LoadLibrary() {
Global hVJDLL
if (hVJDLL) {
return hVJDLL
}
; Load dll from any path or get handle of already loaded
hVJDLL := DLLCall("LoadLibrary", "Str", "vJoyInterface")
if (hVJDLL) {
return hVJDLL
}
; If dll deployed into current and it was wrong, warn
dllpath = %A_ScriptDir%\vJoyInterface.dll
if (FileExist(dllpath)) {
if (A_Is64bitOS) {
is64bit = 64-bitOS
}
AHKEd := (A_PtrSize = 4) ? "32-bit" : "64-bit"
RequiredDLL := (A_PtrSize = 4) ? "x86" : "x64"
dll_info := GetFileVersion(dllpath)
if (dll_info and !InStr(dll_info, RequiredDLL)) {
isWrong = =wrong!
}
MsgBox,
(
LoadLibrary %dllpath% failed!
Exiting.
Make sure %RequiredDLL% vJoyInterface.dll is in %A_ScriptDir%
(%dll_info%%isWrong%)
AutoHotkey: %AHKEd%
OSVersion:%A_OSVersion% %is64bit%
)
}
return 0
}
GetFileVersion(pszFilePath) {
dwSize := DLLCall("Version\GetFileVersionInfoSize", "Str", pszFilePath)
if (!dwSize) {
return
}
VarSetCapacity(pvData, dwSize)
if (!DLLCall("Version\GetFileVersionInfo", "Str", pszFilePath
, "Int", 0, "Int", dwSize, "Ptr", &pvData)) {
return
}
; Get British product version string
if (!DLLCall("Version\VerQueryValue", "UInt", &pvData, "Str"
, "\\StringFileInfo\\040904b0\\ProductVersion", "UIntP"
, lpTranslate, "UInt", 0)) {
return
}
return StrGet(lpTranslate)
}
Class VJoyDev {
__New(dev_id) {
Global NoticeDone, hVJDLL, VJD_STAT_OWN, VJD_STAT_FREE, VJD_STAT_BUSY, VJD_STAT_MISS, VJD_STAT_UNKN,HID_USAGE_X,HID_USAGE_Y,HID_USAGE_Z,HID_USAGE_RX,HID_USAGE_RY,HID_USAGE_RZ,HID_USAGE_SL0,HID_USAGE_SL1
if (!hVJDLL) {
hVJDLL := VJoy_LoadLibrary()
}
if (!hVJDLL) {
if (!NoticeDone) {
NoticeDone := True
MsgBox, [VJoy Constructer] LoadLibrary vJoyInterface.dll failed!
}
return
}
this.DeviceEnabled := DllCall("vJoyInterface.dll\vJoyEnabled")
if (ErrorLevel = 4) {
MsgBox, Error! VJoy library "vJoyInterface.dll" is not found!`nErrorLevel:%ErrorLevel%
return
}
if (!this.DeviceEnabled) {
;MsgBox, Error! VJoy interface is not installed!`nErrorLevel:%ErrorLevel%
return
}
DeviceStatus := DllCall("vJoyInterface\GetVJDStatus", "UInt", dev_id)
if (DeviceStatus = VJD_STAT_OWN) {
stat_str = VJD_STAT_OWN
;ToolTip, vJoy Device %dev_id% is already owned by this feeder
} else if (DeviceStatus = VJD_STAT_FREE) {
;ToolTip, vJoy Device %dev_id% is free
stat_str = VJD_STAT_FREE
} else if (DeviceStatus = VJD_STAT_BUSY) {
MsgBox vJoy Device %dev_id% is already owned by another feeder`nCannot continue`n
stat_str = VJD_STAT_BUSY
return
} else if (DeviceStatus = VJD_STAT_MISS) {
;MsgBox vJoy Device %dev_id% is not installed or disabled`nCannot continue`n
stat_str = VJD_STAT_MISS
return
} else {
stat_str = VJD_STAT_UNKN
MsgBox vJoy Device %dev_id% general error`nCannot continue`n
return
}
;ToolTip
; Get the number of buttons and POV Hat switchessupported by this vJoy device
this.ContPovNumber := DllCall("vJoyInterface\GetVJDContPovNumber", "UInt", dev_id)
this.ContPov := Object()
Loop, % this.ContPovNumber ; insert dummy
this.ContPov.Insert(A_Index, 0)
this.DiscPovNumber := DllCall("vJoyInterface\GetVJDDiscPovNumber", "UInt", dev_id)
this.DiscPov := Object()
Loop, % this.DiscPovNumber ; insert dummy
this.DiscPov.Insert(A_Index, 0)
this.NumberOfButtons := DllCall("vJoyInterface\GetVJDButtonNumber", "Int", dev_id)
this.Btn := Object()
Loop, % this.NumberOfButtons ; insert dummy
this.Btn.Insert(A_Index, 0)
this.AxisExist_X := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_X )
this.AxisExist_Y := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_Y )
this.AxisExist_Z := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_Z )
this.AxisExist_RX := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_RX )
this.AxisExist_RY := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_RY )
this.AxisExist_RZ := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_RZ )
this.AxisExist_SL0 := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_SL0)
this.AxisExist_SL1 := DllCall("vJoyInterface\GetVJDAxisExist", "Int", dev_id, "Int", HID_USAGE_SL1)
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_X, "IntP", nResult)) {
this.AxisMax_X := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_Y, "IntP", nResult)) {
this.AxisMax_Y := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_Z, "IntP", nResult)) {
this.AxisMax_Z := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_RX, "IntP", nResult)) {
this.AxisMax_RX := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_RY, "IntP", nResult)) {
this.AxisMax_RY := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_RZ, "IntP", nResult)) {
this.AxisMax_RZ := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_SL0, "IntP", nResult)) {
this.Slider0_Max := nResult
}
if (DllCall("vJoyInterface\GetVJDAxisMax", "Int", dev_id, "Int", HID_USAGE_SL1, "IntP", nResult)) {
this.Slider1_Max := nResult
}
; Acquire the target device
if (DeviceStatus = VJD_STAT_FREE) {
ac_jvd := DllCall("vJoyInterface\AcquireVJD", "UInt", dev_id)
if (!ac_jvd) {
MsgBox, Dev:%dev_id% aquire fail ErrorLevel: %ErrorLevel%
}
}
if (DeviceStatus = VJD_STAT_OWN) {
MsgBox % "Failed to acquire vJoy device number: " dev_id "`n(Other process owned device)"
return
} else if (DeviceStatus = VJD_STAT_FREE and !ac_jvd ) {
MsgBox % "Failed to acquire vJoy device number: " dev_id "`nAcquired: " ac_jvd
return
} else {
;ToolTip, % "Acquired: vJoy device number: " dev_id
}
;ToolTip
this.DeviceID := dev_id
this.DeviceStatus := DeviceStatus
this.Reset()
this.DeviceReady := True
return this
}
__Delete() {
this.Relinquish()
}
SetAxis(axis_val, usage) {
res := DllCall("vJoyInterface\SetAxis", "Int", axis_val, "UInt", this.DeviceID, "UInt", usage)
if (!res) {
MsgBox, SetAxis(%axis_val%`,%usage%) Error!`nErrorLevel:%ErrorLevel%
}
return res
}
SetAxis_X(axis_val) {
Global HID_USAGE_X
new_val := parse_rel_val(axis_val, this.Axis_X, this.AxisMax_X)
res := this.SetAxis(new_val, HID_USAGE_X)
if (res) {
this.Axis_X := new_val
}
return res
}
SetAxis_Y(axis_val) {
Global HID_USAGE_Y
new_val := parse_rel_val(axis_val, this.Axis_Y, this.AxisMax_Y)
res := this.SetAxis(new_val, HID_USAGE_Y)
if (res) {
this.Axis_Y := new_val
}
return res
}
SetAxis_Z(axis_val) {
Global HID_USAGE_Z
new_val := parse_rel_val(axis_val, this.Axis_Z, this.AxisMax_Z)
res := this.SetAxis(new_val, HID_USAGE_Z)
if (res) {
this.Axis_Z := new_val
}
return res
}
SetAxis_RX(axis_val) {
Global HID_USAGE_RX
new_val := parse_rel_val(axis_val, this.Axis_RX, this.AxisMax_RX)
res := this.SetAxis(new_val, HID_USAGE_RX)
if (res) {
this.Axis_RX := new_val
}
return res
}
SetAxis_RY(axis_val) {
Global HID_USAGE_RY
new_val := parse_rel_val(axis_val, this.Axis_RY, this.AxisMax_RY)
res := this.SetAxis(new_val, HID_USAGE_RY)
if (res) {
this.Axis_RY := new_val
}
return res
}
SetAxis_RZ(axis_val) {
Global HID_USAGE_RZ
new_val := parse_rel_val(axis_val, this.Axis_RZ, this.AxisMax_RZ)
res := this.SetAxis(new_val, HID_USAGE_RZ)
if (res) {
this.Axis_RZ := new_val
}
return res
}
SetAxis_SL0(axis_val) {
Global HID_USAGE_SL0
new_val := parse_rel_val(axis_val, this.Axis_SL0, this.AxisMax_SL0)
res := this.SetAxis(new_val, HID_USAGE_SL0)
if (res) {
this.Slider0 := new_val
}
return res
}
SetAxis_SL1(axis_val) {
Global HID_USAGE_SL1
new_val := parse_rel_val(axis_val, this.Axis_SL1, this.AxisMax_SL1)
res := this.SetAxis(new_val, HID_USAGE_SL1)
if (res) {
this.Slider1 := new_val
}
return res
}
GetBtn(bid) {
if (bid < 1 or bid > this.NumberOfButtons) {
return 0
}
return this.Btn[bid]
}
SetBtn(sw, btn_id) {
if (btn_id < 1 or btn_id > this.NumberOfButtons) {
MsgBox, SetBtn: range check error!
return 0
}
res := DllCall("vJoyInterface\SetBtn", "Int", sw, "UInt", this.DeviceID, "UChar", btn_id)
if (res) {
this.Btn[btn_id] := sw
}
return res
}
SetDiscPov(Value, nPov) {
_res := DllCall("vJoyInterface\SetDiscPov", "Int", Value, "UInt", this.DeviceID, "UChar", nPov)
if (!_res) {
MsgBox, SetDiscPov err: %ErrorLevel%
} else {
this.DiscPov[nPov] := Value
}
return _res
}
SetContPov(Value, nPov) {
_res := DllCall("vJoyInterface\SetContPov", "Int", Value, "UInt", this.DeviceID, "UChar", nPov)
if (!_res) {
MsgBox, SetContPov err: %ErrorLevel%
} else {
this.ContPov[nPov] := Value
}
return _res
}
Reset() {
; Reset local state values
this.Axis_X := 0
this.Axis_Y := 0
this.Axis_Z := 0
this.Axis_RX := 0
this.Axis_RY := 0
this.Axis_RZ := 0
this.Slider0 := 0
this.Slider1 := 0
for i in this.ContPov
this.ContPov[i] := 0
for i in this.DiscPov
this.DiscPov[i] := 0
for i in this.Btn
this.Btn[i] := 0
return DllCall("vJoyInterface\ResetVJD", "UInt", this.DeviceID)
}
Relinquish() {
return DllCall("vJoyInterface\RelinquishVJD", "UInt", this.DeviceID)
}
}
VJoy_init(id := 1) {
Global VJDev, VJD_MAXDEV
if (id < 1 || id > VJD_MAXDEV) {
MsgBox, [%A_ThisFunc%] Device %id% is invalid. Please specify 1-%VJD_MAXDEV%.
return
}
VJDev[id] := new VJoyDev(id)
return VJDev[id]
}
VJoy_DeviceErr(id) {
Global VJD_MAXDEV, VJDev
if (id < 1 or id > VJD_MAXDEV) {
MsgBox, [%A_ThisFunc%] Device %id% is invalid. Please specify 1-%VJD_MAXDEV%.
return True
}
if (!VJDev[id].DeviceReady) {
MsgBox, [%A_ThisFunc%] Device %id% is not ready.
return True
}
return False
}
VJoy_Ready(id) {
Global VJD_MAXDEV, VJDev
if (id < 1 || id > VJD_MAXDEV) {
return False
}
return VJDev[id].DeviceReady
}
VJoy_ResetVJD(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Reset()
}
VJoy_ResetAll() {
return DllCall("vJoyInterface\ResetAll")
}
; Release device
VJoy_RelinquishVJD(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Relinquish()
}
; Acquire device - added by evilC
VJoy_AcquireVJD(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return DllCall("vJoyInterface\AcquireVJD", "UInt", id)
}
; destructor
VJoy_Close() {
Global VJDev
VJoy_ResetAll()
for idx, dev in VJDev
dev.delete
if (hVJDLL) {
DLLCall("FreeLibraly", "Ptr", hVJDLL)
hVJDLL:=
}
}
VJoy_GetContPovNumber(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].ContPovNumber
}
VJoy_GetDiscPovNumber(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].DiscPovNumber
}
VJoy_GetVJDButtonNumber(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].NumberOfButtons
}
VJoy_GetAxisExist_X(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_X
}
VJoy_GetAxisExist_Y(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_Y
}
VJoy_GetAxisExist_Z(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_Z
}
VJoy_GetAxisExist_RX(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_RX
}
VJoy_GetAxisExist_RY(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_RY
}
VJoy_GetAxisExist_RZ(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_RZ
}
VJoy_GetAxisExist_SL0(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_SL0
}
VJoy_GetAxisExist_SL1(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisExist_SL1
}
VJoy_GetAxisMax_X(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_X
}
VJoy_GetAxisMax_Y(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_Y
}
VJoy_GetAxisMax_Z(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_Z
}
VJoy_GetAxisMax_RX(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_RX
}
VJoy_GetAxisMax_RY(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_RY
}
VJoy_GetAxisMax_RZ(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].AxisMax_RZ
}
VJoy_GetAxisMax_SL0(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Slider0_Max
}
VJoy_GetAxisMax_SL1(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Slider1_Max
}
; for compatibility
VJoy_GetVJDAxisMax(id, usage) {
Global VJDev, HID_USAGE_X,HID_USAGE_Y,HID_USAGE_Z,HID_USAGE_RX,HID_USAGE_RY,HID_USAGE_RZ,HID_USAGE_SL0,HID_USAGE_SL1
if (VJoy_DeviceErr(id))
return False
return (usage = HID_USAGE_X) ? VJDev[id].AxisMax_X :
(usage = HID_USAGE_Y) ? VJDev[id].AxisMax_Y :
(usage = HID_USAGE_Z) ? VJDev[id].AxisMax_Z :
(usage = HID_USAGE_RX) ? VJDev[id].AxisMax_RX :
(usage = HID_USAGE_RY) ? VJDev[id].AxisMax_RY :
(usage = HID_USAGE_RZ) ? VJDev[id].AxisMax_RZ :
(usage = HID_USAGE_SL0) ? VJDev[id].AxisMax_Y :
VJDev[id].AxisMax_SL1
}
VJoy_GetVJDAxisExist(id, usage) {
Global VJDev, HID_USAGE_X,HID_USAGE_Y,HID_USAGE_Z,HID_USAGE_RX,HID_USAGE_RY,HID_USAGE_RZ,HID_USAGE_SL0,HID_USAGE_SL1
if (VJoy_DeviceErr(id))
return False
return (usage = HID_USAGE_X) ? VJDev[id].AxisExist_X :
(usage = HID_USAGE_Y) ? VJDev[id].AxisExist_Y :
(usage = HID_USAGE_Z) ? VJDev[id].AxisExist_Z :
(usage = HID_USAGE_RX) ? VJDev[id].AxisExist_RX :
(usage = HID_USAGE_RY) ? VJDev[id].AxisExist_RY :
(usage = HID_USAGE_RZ) ? VJDev[id].AxisExist_RZ :
(usage = HID_USAGE_SL0) ? VJDev[id].AxisExist_Y :
VJDev[id].AxisExist_SL1
}
VJoy_GetBtn(id, btn_id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].GetBtn(btn_id)
}
VJoy_SetBtn(sw, id, btn_id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
res := VJDev[id].SetBtn(sw, btn_id)
if (!res) {
MsgBox, SetBtn(%sw%, %id%, %btn_id%) err: %ErrorLevel%`nnLastError: %A_LastError%
}
return res
}
VJoy_GetAxis_X(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_X
}
VJoy_GetAxis_Y(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_Y
}
VJoy_GetAxis_Z(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_Z
}
VJoy_GetAxis_RX(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_RX
}
VJoy_GetAxis_RY(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_RY
}
VJoy_GetAxis_RZ(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Axis_RZ
}
VJoy_GetAxis_SL0(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Slider0
}
VJoy_GetAxis_SL1(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].Slider1
}
VJoy_SetAxis_X(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_X(axis_val)
}
VJoy_SetAxis_Y(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_Y(axis_val)
}
VJoy_SetAxis_Z(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_Z(axis_val)
}
VJoy_SetAxis_RX(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_RX(axis_val)
}
VJoy_SetAxis_RY(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_RY(axis_val)
}
VJoy_SetAxis_RZ(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_RZ(axis_val)
}
VJoy_SetAxis_SL0(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_SL0(axis_val)
}
VJoy_SetAxis_SL1(axis_val, id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetAxis_SL1(axis_val)
}
; for compatibility
VJoy_SetAxis(axis_val, id, usage) {
Global VJDev, HID_USAGE_X,HID_USAGE_Y,HID_USAGE_Z,HID_USAGE_RX,HID_USAGE_RY,HID_USAGE_RZ,HID_USAGE_SL0,HID_USAGE_SL1
if (VJoy_DeviceErr(id))
return False
if (usage == HID_USAGE_X){
return VJDev[id].SetAxis_X(axis_val)
} else if (usage == HID_USAGE_Y){
return VJDev[id].SetAxis_Y(axis_val)
} else if (usage == HID_USAGE_Z){
return VJDev[id].SetAxis_Z(axis_val)
} else if (usage == HID_USAGE_RX){
return VJDev[id].SetAxis_RX(axis_val)
} else if (usage == HID_USAGE_RY){
return VJDev[id].SetAxis_RY(axis_val)
} else if (usage == HID_USAGE_RZ){
return VJDev[id].SetAxis_RZ(axis_val)
} else if (usage == HID_USAGE_SL0){
return VJDev[id].SetAxis_SL0(axis_val)
} else if (usage == HID_USAGE_SL1){
return VJDev[id].SetAxis_SL1(axis_val)
} else {
MsgBox, Unknown Axis: %usage%
}
}
VJoy_GetDiscPov(id, nPov) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].DiscPov[nPov]
}
VJoy_SetDiscPov(Value, id, nPov) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetDiscPov(Value, nPov)
}
VJoy_GetContPov(id, nPov) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].ContPov[nPov]
}
VJoy_SetContPov(Value, id, nPov) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
return VJDev[id].SetContPov(Value, nPov)
}
; for debug: dump value of structure
VJoy_Dump(id) {
Global VJDev
if (VJoy_DeviceErr(id))
return False
num := VJoy_GetVJDButtonNumber(id)
for idx, btn in VJDev[id].Btn
{
if (idx<10)
buf1 .= "_"
buf1 .= idx . "|"
buf2 .= "_" . btn . "|"
}
str_btn = Button(%num%):`n %buf1%`n %buf2%`n
if (VJoy_GetAxisMax_X(id)) {
str_btn .= "Axis_X: " . VJoy_GetAxis_X(id) . "`n"
}
if (VJoy_GetAxisMax_Y(id)) {
str_btn .= "Axis_Y: " . VJoy_GetAxis_Y(id) . "`n"
}
if (VJoy_GetAxisMax_Z(id)) {
str_btn .= "Axis_Z: " . VJoy_GetAxis_Z(id) . "`n"
}
if (VJoy_GetAxisMax_RX(id)) {
str_btn .= "Axis_RX: " . VJoy_GetAxis_RX(id) . "`n"
}
if (VJoy_GetAxisMax_RY(id)) {
str_btn .= "Axis_RY: " . VJoy_GetAxis_RY(id) . "`n"
}
if (VJoy_GetAxisMax_RZ(id)) {
str_btn .= "Axis_RZ: " . VJoy_GetAxis_RZ(id) . "`n"
}
if (VJoy_GetAxisMax_SL0(id)) {
str_btn .= "Axis_SL0: " . VJoy_GetAxis_SL0(id) . "`n"
}
if (VJoy_GetAxisMax_SL1(id)) {
str_btn .= "Axis_SL1: " . VJoy_GetAxis_SL1(id) . "`n"
}
num := VJoy_GetContPovNumber(id)
if (num) {
for idx, btn in VJDev[id].ContPov
{
Loop, % (StrLen(btn) - 1)
buf3 .= "_"
buf3 .= idx . "|"
buf4 .= btn . "|"
}
str_cont = ContPov(%num%):`n %buf3%`n %buf4%`n
} else {
str_cont = No Continuous Button.`n
}
str_btn .= str_cont
num := VJoy_GetDiscPovNumber(id)
if (num) {
for idx, btn in VJDev[id].DiscPov
{
Loop, % (StrLen(btn) - 1)
buf5 .= "_"
buf5 .= idx . "|"
buf6 .= btn . "|"
}
str_Disc = DiscPov(%num%):`n %buf5%`n %buf6%`n
} else {
str_Disc = No Discrete Button.`n
}
str_btn .= str_Disc
ToolTip, %str_btn%
}
parse_rel_val(invar, curval, max) {
if (InStr(invar, "+")) {
StringReplace, _buffer, invar, +
res := curval + _buffer
if (res > max)
return max
return res
} else if (InStr(invar, "-")) {
StringReplace, _buffer, invar, -
res := curval - _buffer
if (res < 0)
return 0
return res
}
return invar
}

View File

@ -1,84 +0,0 @@
; none of this is written by genmce - just lifted from ahk forum
; I think Chris wrote it - good for joystick info.
; July 6, 2005: Added auto-detection of joystick number.
; May 8, 2005 : Fixed: JoyAxes is no longer queried as a means of
; detecting whether the joystick is connected. Some joysticks are
; gamepads and don't have even a single axis.
; If you want to unconditionally use a specific joystick number, change
; the following value from 0 to the number of the joystick (1-16).
; A value of 0 causes the joystick number to be auto-detected:
JoystickNumber = 2
; END OF CONFIG SECTION. Do not make changes below this point unless
; you wish to alter the basic functionality of the script.
; Auto-detect the joystick number if called for:
if JoystickNumber <= 0
{
Loop 16 ; Query each joystick number to find out which ones exist.
{
GetKeyState, JoyName, %A_Index%JoyName
if JoyName <>
{
JoystickNumber = %A_Index%
break
}
}
if JoystickNumber <= 0
{
MsgBox The system does not appear to have any joysticks.
ExitApp
}
}
#SingleInstance
SetFormat, float, 03 ; Omit decimal point from axis position percentages.
GetKeyState, joy_buttons, %JoystickNumber%JoyButtons
GetKeyState, joy_name, %JoystickNumber%JoyName
GetKeyState, joy_info, %JoystickNumber%JoyInfo
Loop
{
buttons_down =
Loop, %joy_buttons%
{
GetKeyState, joy%a_index%, %JoystickNumber%joy%a_index%
if joy%a_index% = D
buttons_down = %buttons_down%%a_space%%a_index%
}
GetKeyState, joyx, %JoystickNumber%JoyX
axis_info = X%joyx%
GetKeyState, joyy, %JoystickNumber%JoyY
axis_info = %axis_info%%a_space%%a_space%Y%joyy%
IfInString, joy_info, Z
{
GetKeyState, joyz, %JoystickNumber%JoyZ
axis_info = %axis_info%%a_space%%a_space%Z%joyz%
}
IfInString, joy_info, R
{
GetKeyState, joyr, %JoystickNumber%JoyR
axis_info = %axis_info%%a_space%%a_space%R%joyr%
}
IfInString, joy_info, U
{
GetKeyState, joyu, %JoystickNumber%JoyU
axis_info = %axis_info%%a_space%%a_space%U%joyu%
}
IfInString, joy_info, V
{
GetKeyState, joyv, %JoystickNumber%JoyV
axis_info = %axis_info%%a_space%%a_space%V%joyv%
}
IfInString, joy_info, P
{
GetKeyState, joyp, %JoystickNumber%JoyPOV
axis_info = %axis_info%%a_space%%a_space%POV%joyp%
}
ToolTip, %joy_name% (#%JoystickNumber%):`n%axis_info%`nButtons Down: %buttons_down%`n`n(right-click the tray icon to exit)
Sleep, 100
}
return
esc::ExitApp

View File

Binary file not shown.

Binary file not shown.

Binary file not shown.