Media control script

This commit is contained in:
Laurence Dougal Myers 2014-06-25 22:38:28 +10:00
parent 33da05e5e9
commit 5e06493275
2 changed files with 28 additions and 32 deletions

View File

@ -9,27 +9,37 @@
*/
ProcessNote(device, channel, note, velocity, isNoteOn) {
global iInterface
if (note >= 1 and note <= 32) {
VJoy_SetBtn(isNoteOn, iInterface, note)
button_state_text := isNoteOn ? "On" : "Off"
DisplayOutput("Button " + button_state_text, note)
}
}
ProcessCC(device, channel, cc, value) {
global iInterface, HID_USAGE_X, HID_USAGE_Y, AxisMax_X, AxisMax_Y
if (cc == 7) {
scaled_value := ConvertCCValueToScale(value, 8, 120)
new_axis_value := ConvertToAxis(scaled_value, AxisMax_X)
VJoy_SetAxis(new_axis_value, iInterface, HID_USAGE_X)
DisplayOutput("Axis X", scaled_value)
} else if (cc == 27) {
scaled_value := ConvertCCValueToScale(value, 8, 112)
new_axis_value := ConvertToAxis(scaled_value, AxisMax_Y)
VJoy_SetAxis(new_axis_value, iInterface, HID_USAGE_Y)
DisplayOutput("Axis Y", scaled_value)
if (cc = 21 or cc = 29) {
scaled_value := ConvertCCValueToScale(value, 0, 127)
vol := scaled_value * 100
SoundSet, vol
DisplayOutput("Volume", vol)
} else if (cc = 51) {
Send {Volume_Mute}
DisplayOutput("Volume", "Mute")
} else if (cc = 52 and value != 0) {
Send {Volume_Down}
DisplayOutput("Volume", "Down")
} else if (cc = 53 and value != 0) {
Send {Volume_Up}
DisplayOutput("Volume", "Up")
} else if (cc = 54 and value != 0) {
Send {Media_Play_Pause}
DisplayOutput("Media", "Play/Pause")
} else if (cc = 55 and value != 0) {
Send {Media_Stop}
DisplayOutput("Media", "Stop")
} else if (cc = 56 and value != 0) {
Send {Media_Prev}
DisplayOutput("Media", "Previous")
} else if (cc = 57 and value != 0) {
Send {Media_Next}
DisplayOutput("Media", "Next")
}
}

View File

@ -14,7 +14,7 @@ Sections with ++++++++++++++++++++ Edit between these marks. You won't break it,
*/
#Include VJoy_lib.ahk
#Include mtjFunctions.ahk
#Persistent
@ -28,9 +28,7 @@ if A_OSVersion in WIN_NT4,WIN_95,WIN_98,WIN_ME ; if not xp or 2000 quit
ExitApp
}
version = midi_to_joy_2
VJoy_Init()
gosub VJoyInitMaxValues
version = midi_to_joy_3
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
port_test(numports,numports2) ; test the ports - check for valid ports? - see Midi_under_the_hood.ahk file
@ -46,18 +44,6 @@ gosub, midiMon ; see below - a monitor gui - see Midi_In_and_Gu
return
VJoyInitMaxValues:
global AxisMax_X, AxisMax_Y, AxisMax_Z, AxisMax_RX, AxisMax_RY, AxisMax_RZ, AxisMax_SL0, AxisMax_SL1, AxisMax_WHL
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)
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 MidiRules.ahk ; this file contains: Rules for manipulating midi input then sending modified midi output.