Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
barkermn01 committed Jan 21, 2020
2 parents a9e4470 + 892d7fd commit b8f10fe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
4 changes: 0 additions & 4 deletions Ultrasound 7H/Ultrasound7H/Ultrasound7H.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@
<Project>{e614a97e-9dc7-4272-b7ff-ab9504379fda}</Project>
<Name>UltrasoundLib</Name>
</ProjectReference>
<ProjectReference Include="..\..\Ultrasound\Ultrasound.csproj">
<Project>{8687ae4b-adfb-49c0-896f-b86bc6d39def}</Project>
<Name>Ultrasound</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="bell.ico">
Expand Down
11 changes: 4 additions & 7 deletions Ultrasound 7H/Ultrasound7H/fVoices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Ultrasound;

namespace Voices
{
Expand Down Expand Up @@ -312,7 +311,7 @@ private void NewDialogue(
this.lbText.TopIndex = this.lbText.Items.Count - itemsPerPage;
if (this._current != null)
voiceEntry2 = this._current.Entries.Find((Predicate<VoiceEntry>)(e => e.Matches(DID, SID, charsInParty) && dlgSel.ToString().Equals(e.Choice)));
if (voiceEntry2 != null && this._data.Exists(voiceEntry2.File))
if (voiceEntry2 != null && this._data.Exists(this._config.strightApplyAudioPath(voiceEntry2.File)))
this.TriggerChoice(this.CreateSound(voiceEntry2.DID, voiceEntry2.File));
}
}
Expand All @@ -336,13 +335,13 @@ private int GetSoundLength(string fileName)
private void IncomingSEvent(fVoices.SoundEvent se)
{
Sound s = this._ultrasound.Select((int)se.Sound, (int)se.FieldID, (int)se.PPV);
if (s == null || !this._data.Exists(s.File))
if (s == null || !this._data.Exists(this._config.strightApplyAudioPath(s.File)))
return;

this.Invoke(new Action(() => this.LogSEvent(" --> playing " + s.File + " with length of " + GetSoundLength(s.File).ToString() + " Frames")));
this.Invoke(new Action(() => this.LogSEvent(" --> playing " + s.File + " with length of " + GetSoundLength(s.File).ToString() + " Frames")));
this._output.Play(new ALOutput.SoundPlay()
{
File = s.File,
File = this._config.strightApplyAudioPath(s.File),
Pan = Math.Max(Math.Min(1f, (float)se.Pan / 128f), 0.0f),
Volume = 1f,
OnComplete = new Action(() => {
Expand Down Expand Up @@ -526,14 +525,12 @@ private void bTest_Click(object sender, EventArgs e)

private void bTools_Click(object sender, EventArgs e)
{
new fTools().Show();
}

private void fVoices_FormClosed(object sender, FormClosedEventArgs e)
{
this._output.Terminate();
Registry.SetValue("HKEY_CURRENT_USER\\Software\\Ficedula\\Ultrasound", "Logging", (object)this.cbLogging.SelectedIndex);
Application.Exit();
}

protected override void Dispose(bool disposing)
Expand Down
Binary file not shown.
47 changes: 30 additions & 17 deletions UltrasoundInputHooker/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,41 @@ private void getProccess()
if (test.IsMatch(procExeName))
{
ff7 = proc;
procPath[procPath.Length - 1] = "";
BasePath = String.Join("\\", procPath);
break;
}
}
catch (Exception) { }
}

inputSim = new WindowsInput.InputSimulator();
keySim = new WindowsInput.KeyboardSimulator(inputSim);

windowHandle = ff7.MainWindowHandle;
try
{
inputSim = new WindowsInput.InputSimulator();
keySim = new WindowsInput.KeyboardSimulator(inputSim);
windowHandle = ff7.MainWindowHandle;
}
catch (Exception) { }
}

private Dictionary<KeyBoardBindings, UInt16> Keys { get; set; }
private DateTime keysLastUpdated = DateTime.MinValue;

private void getKeys()
{
DateTime lastWrite = File.GetLastWriteTime(BasePath + "ff7input.cfg");

if (lastWrite > keysLastUpdated)
try
{
Keys = readUserInputs();
keysLastUpdated = lastWrite;
DateTime lastWrite = File.GetLastWriteTime(BasePath + "ff7input.cfg");

if (lastWrite > keysLastUpdated)
{
Keys = readUserInputs();
keysLastUpdated = lastWrite;
}
}
catch (Exception) {

}

}

public override void Start(RuntimeMod mod)
Expand All @@ -161,13 +171,16 @@ public override void Start(RuntimeMod mod)
{
Console.WriteLine("Voice from file " + f + " has finished");

getKeys();
IntPtr thisThread = GetCurrentThreadId();
AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), true);
keySim.KeyDown((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]);
Thread.Sleep(200);
keySim.KeyUp((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]);
AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), false);
if (!ff7.HasExited)
{
getKeys();
IntPtr thisThread = GetCurrentThreadId();
AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), true);
keySim.KeyDown((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]);
Thread.Sleep(200);
keySim.KeyUp((WindowsInput.Native.VirtualKeyCode)Keys[KeyBoardBindings.OK]);
AttachThreadInput(thisThread, new IntPtr(ff7.Threads[0].Id), false);
}
}));
initId = hooks_instance.hookInit(new InitAction(() =>
{
Expand Down

0 comments on commit b8f10fe

Please # to comment.