ah, i see
if anyone's interested in getting started with a PacDrive or U-HID using pacdrive.dll, here's a quick and dirty script to flash LEDs 1 and 2 randomly
Thanks again
- gwarble
Hi gwarble and engunneer.
You've got no idea how much this post helped me!!! Thankyou so much for sharing your code and knowledge.
Yesterday I didn't know the first thing about ANY scripting language as all of my previous programming is done in Assembly MCU and binary coding. All this higher level stuff with squiggly lines didn't mean anything to me hahaha
Last night I sat down and watched all RaptorX's tutorials, and played with your code gwarble and managed to make it work on my new PacDrive which I'm using to emulate a Sega VR Panel on an old Sega Touring Car DX arcade machine I bought.
My intention is to eventually get the LED's to light the appropiate buttons depending on events in racing games... ie Shift Light, Caution Flags, Fuel warning, Nitrous (for those NFS waahooo games) etc etc...
First thing I needed to do was... well.... learn a programming language - and AutoHotKey seemed like exactly what I need right now. Find some example code and talk to the PacDrive.... Thankyou for the above code... great starting point!
So now I have installed a Simple Gamepad into my cabinet, wired up the buttons and asked AHK to light up each button as it is pressed.
Here is my code and feel free to distrobute and change as you all feel. Please post back here with your updates however so I can learn from your experience aswell as banging my head trying to learn scripting from scratch.
#SingleInstance Force
#Persistent
#NoEnv
SetWorkingDir, %A_ScriptDir%
; Uses of the PacDrive.dll
; First, Load the Library with DllCall("LoadLibrary", "str", "PacDrive.dll")
; Then Initialize the PacDrive with DllCall("PacDrive.dll\PacInitialize")
; To set the LEDs as a whole use DllCall("PacDrive.dll\PacSetLEDStates",Int,0,UShort,0) - Note (integer, pacdrive ID, short integer, decimal value for LEDs)
; To set induvidual LEDs, use DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,0,Int,1) - Note (integer, pacdrive ID, integer, pin0, integer, 1 means ON)
;
; This program, loads the PacDrive.dll (which should be in the same folder as the AHK file you ran) and initializes it.
; Then it will refresh the LED output status for Pin 0 -3 (ie the first 4 LED ports on the PacDrive) after reading what the status of the joystick buttons are
;
; For this program, I used a basic gamepad and wired the buttons to some Arcade LED buttons on my Sega Touring Car Arcade to simulate the Sega VR Buttons.
; My Buttons from left to right are, RED, YELLOW, GREEN and BLUE. It just so happened as I wired them that RED = Joy6, Yellow = Joy8, Green = Joy5 and Blue = Joy7
; Every 100ms the ChangeLED routine is called from the settimer command and it reads a Joy button, checks to see if it's (D) Down and if so, sets the LED port pin
; to (1) ON. If it is not Down, then it sets the LED port to (0) OFF.
;
; So, in the routine for checking the Joy Buttons, I can also trigger a Keystroke send too. So if you want to reconfigure a Joypad button to a Keystroke... thats's
; where you would put it.
;
; Original code by Gwarble - THANKYOU!!!
;
; Modified for basic Gamepad/Joypad/Joystick indication by Ramjet - Later to be upgraded to Arcade/RaceSim cockpit
If DllCall("LoadLibrary", "str", "PacDrive.dll")
If DllCall("PacDrive.dll\PacInitialize")
DllCall("PacDrive.dll\PacSetLEDStates",Int,0,UShort,0) "`n`nError: " ErrorLevel
Else
ExitApp
SetTimer, ChangeLED, 100
Return
ChangeLED:
GetKeyState, state, 1joy6 ;Red Button
if state = D
{
DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,0,Int,1)
}
else
{DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,0,Int,0)
}
GetKeyState, state, 1joy8 ;Yellow Button
if state = D
{
DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,1,Int,1)
}
else
{DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,1,Int,0)
}
GetKeyState, state, 1joy5 ;Green Button
if state = D
{
DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,2,Int,1)
}
else
{
DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,2,Int,0)
}
GetKeyState, state, 1joy7 ;Blue Button
if state = D
{
DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,3,Int,1)
}
else
{DllCall("PacDrive.dll\PacSetLEDState",Int,0,Int,3,Int,0)
}
return
The usage for calling the DLL's were the hardest part and trying to figure out the syntax and how to scan the joystick buttons would work and not interferre with the initialising of the dll Gwarble posted.
But hey, for a few hours of watching tutorials and messing with code... it works. All the buttons light when I press the corrosponding gamepad button, and now I have to get my head around Cheat Engine for scanning and reading game memory for pulling out values such as Shift lights, NOS available, etc etc...
Thanks again
Ramjet