Jump to content

"Joystick" Control in GUI


 Share

Recommended Posts

I would like to create a control in my GUI that acts like a joystick. My code so far:

;Sony VISCA Camera Controller
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\My Dropbox\AutoIT Scripts\Sony VISCA Controller\Form1.kxf
$Form1 = GUICreate("Form1", 477, 398)
$Group1 = GUICtrlCreateGroup("  Camera Configuration  ", 8, 8, 460, 105)
$Label1 = GUICtrlCreateLabel("Camera IP", 24, 32, 53, 17)
$cmbIPAddr = GUICtrlCreateCombo("", 24, 49, 161, 25)
$inpPort = GUICtrlCreateInput("", 200, 49, 81, 21)
$cmbModel = GUICtrlCreateCombo("", 296, 49, 153, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "BRC-300|BRC-330")
$Label2 = GUICtrlCreateLabel("Camera Port", 200, 32, 62, 17)
$Label3 = GUICtrlCreateLabel("Camera Model", 296, 32, 72, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Connect", 295, 80, 75, 25, $WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button2 = GUICtrlCreateButton("Disconnect", 375, 80, 75, 25, $WS_GROUP)
GUICtrlSetState(-1, $GUI_DISABLE)
$sldPanTilt = GUICtrlCreateSlider(8, 360, 150, 29)
GUICtrlSetLimit(-1, 15, 0)
$sldZoom = GUICtrlCreateSlider(160, 360, 150, 29)
GUICtrlSetLimit(-1, 7, 0)
$Label4 = GUICtrlCreateLabel("Pan/Tilt Speed", 16, 344, 76, 17)
$Label5 = GUICtrlCreateLabel("Zoom Speed", 168, 344, 65, 17)
$sldPanCtrl = GUICtrlCreatePic("", 158, 144, 161, 161, BitOR($SS_NOTIFY,$SS_SUNKEN,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
$sldZoomCtrl = GUICtrlCreateSlider(328, 144, 33, 161, BitOR($TBS_VERT,$TBS_TOP,$TBS_LEFT,$TBS_BOTH,$TBS_NOTICKS,$TBS_ENABLESELRANGE))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $sldPanCtrl
MsgBox(0,'Hey','Hey Pan Control changed.')

Case $sldZoomCtrl
MsgBox(0,'Hey','Hey Zoom Control changed.')
EndSwitch
WEnd

So, the $sldPanControl I just made a Pic element because I could make an empty clickable element. I'm sure it will have to change or something. Basically I'd like to create a handle in the center of that box and when it's clicked, _MouseTrap to the boundaries of the box and report back to a function the relative position from the center. Sounds hard. ;) I'm not sure what kind of GUI control I'd even start with. I guess it would act like the AutoIT Window Info finder tool only confined to the control that it is in. Is that the correct direction for me to start?

Link to comment
Share on other sites

  • 8 months later...
  • 9 years later...

For anyone who is interested in this topic, I created a first version of a ptz / visca over ip application which can be controlled via a PlayStation or Xbox controller:

https://github.com/bart96/PTZ-Visca-Playstation-Controller

 

To get a PlayStation controller up and running I used the ScpToolkit drivers:

https://github.com/nefarius/ScpToolkit/releases/tag/v1.6.238.16010

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...