The new Direct Input plugin is out. You can break-down a cheap $3 gamepad, and use all the buttons/axes as USB or Joystick port wired inputs for HomeSeer.
Requirements:
- Direct X 3.0C (see dxdiag.exe)
- HomeSeer 2.0 (as it's a .Net plugin)
- At least one Direct Input compatible GamePad / Joystick.
Features:
- AutoCreate a new HomeSeer device per Joystick Axis / Button. You get "realtime" updates of HomeSeer device values according to device moves.
- Range update Mode for each Axis. This saves on CPU a lot as the HomeSeer device value is updated only on range jumps.
- DeviceStrings : you can configure any device string per range of values or button state.
- You can Enable / Disable any Joystick or Axis or button
- The plugin is notification based. There is no thread polling the joystick devices every 10ms...
- Sequences. You can define millisec timed sequences that will trigger a HomeSeer Event with the same name as the sequence. Double-Clicks, timed hold and release of a particular sequence of buttons, cabling a gamepad buttons to a simple pinpad for access control....
Quick how to:
- Stop HomeSeer 2
- Copy the content of the attached .ZIP to your HomeSeer 2 directory. There is a directory structure inside the ZIP file that must be kept like that. Make sure your zip/unzip utility doesn't unzip in "flat" mode (flat mode removes the directory structure, and that's bad).
- Restart HomeSeer 2
- Plug a Joystick / gamepad, and make sure it is loaded by the system (control panel - Games, or dxdiag.exe - Inputs). If you want to use one of the Joystick Axis inputs seriously, you should calibrate the input first through the control panel applet.
- Go to config, ENABLE the plugin and watch your HomeSeer log.
- Now have a look at your devices, and watch device value changes.
- You can set any trigger on Device Value changes.
More on Device Parameters and Ranges:
Have a look at the Config/hspi_di.ini file
;LIST OF YOUR DEVICES
[DirectInputDevices]
DirectInputDevice0=08809590-bf28-11d6-8001-444553540000
;EACH DEVICE HAS HIS OWN SECTION
[DirectInputDevice0]
Enabled=True
;EACH DEVICE ELEMENT HAS HIS OWN SECTION
;ELEMENT-CODES ARE: X,Y,Z,RX,RY,RZ,B0,B1...Bn
[DirectInputDevice0/Y]
Enabled=True
Mode=Auto
RangeMini=-10
RangeMaxi=10
DeadZone=1000
Saturation=9000
HomeSeerDeviceRef=817
Range0=-10,-5,-1,Negative Inclinaison
Range1=-5,5,0,Zero Inclinaison
Range2=5,10,1,Positive Inclinaison
-------------------------------------------------------
Enabled=False means you can remove the HomeSeer device, and it won't be recreated.
Mode=Auto,Range,Sequence,Direct
Direct = Forward input changes to HomeSeer directly (bypassing Range0...RangeX definition), and according to RangeMini and RangeMaxi.
Range = Forward input changes to HomeSeer according to defined Ranges.
Auto = Direct if Range0 is not defined, or Range if Range0 is defined
Sequence = Do not forward input changes to HomeSeer (saves on CPU a lot). However, sequences with this input are still active.
RangeMini = Minimum value reported by the Axis when it's on lowest position.
RangeMaxi = Maximum value reported by the Axis when it's on highest position.
Default range is (-10,10), but you can set (-1000,1000) or (0,100)...
DeadZone = This parameter is always based on 10.000. DeadZone=1000 means the center 10% of the Axix are seen as a 0 input.
Saturation = Always based on 10.000. Saturation = 9000 means all moves above 90% of the Axis are seen as a 100% value.
Range0=-10,-5,-1,Left Direction
Range1=-5,5,0,Center position
Range2=5,10,1,Right Direction
You should use this feature to save on CPU, and report only Range jumps to HomeSeer. The first range number MUST be 0. The range is defined as:
RangeX = MinimumValue,MaximumValue,HomeSeerDeviceValue,HomeSeerDevice String
The 2 following .ini keys replace ranges for simple buttons, and lets you assign device strings for each value 1 or 0.
Pressed=Mybutton is pressed
Released=My button is not pressed
Note: Currently, device strings are loaded into HomeSeer when the Device is Created. If you want device string change taken into account, you must delete the HomeSeer device yourself, and reload the plugin. This will recreate the device with new device strings attached.
More on Sequences:
If a specific timed sequence of inputs is recognized, the HomeSeer event with the same name as the sequence will be run. For this example, I have defined three manual HomeSeer events Circle, DoubleClick, and BothButtons.
A sequence step is made of four comma separated elements:
StepX=DirectInputDevice0/Y,<-5,0,0
1) DirectInput0/Y is the input ID. This is the Joystick input id, followed by a slash, and the Object id (X,Y,Z,RX,RY,RZ,B0,B1...Bn)
2) < -5 is an operator and a value. Valid operators are <,>,= or nothing which means =
3) Number of millisecs the above comparison must remain valid before the step matches. 0 means the Step is valid as soon as the comparison is valid. The last step of a sequence should finish with a 0 "hold" value if you want instant reaction (as the plugin is notification based).
4) Timeout in millisec to wait for step match (3). The value 0 means no timeout (usefull for Step0). If Timeout=200, the comparison and held time must match before 200ms have elapsed. If the TimeOut is smaller than the "hold" value, it means the comparison must already have been valid for some time before entering the step. This is usefull to match when several inputs must be pressed simultaneously.
[Sequences]
Sequence0=Circle
Sequence1=DoubleClick
Sequence2=BothButtons
; AXES X and Y make a clockwise circle starting north. This example may not be adapted to your joystick
; Axis configuration. Watch the values yourself before writting a sequence.
[Sequence Circle]
Step0=DirectInputDevice0/Y,<-5,0,0
Step1=DirectInputDevice0/X,>5,0,1000
Step2=DirectInputDevice0/Y,>5,0,1000
Step3=DirectInputDevice0/X,<-5,0,1000
Step4=DirectInputDevice0/Y,<-5,0,1000
; BUTTON0 makes a quick double-click (200ms up and downs)
[Sequence DoubleClick]
Step0=DirectInputDevice0/B0, 1, 1,0
Step1=DirectInputDevice0/B0, 0, 0,200
Step2=DirectInputDevice0/B0, 1, 0,200
Step3=DirectInputDevice0/B0, 0, 0,200
; BUTTONS 0 and 1 MUST BE PRESSED SIMULTANEOUSLY (within 200ms)
; AND HOLD FOR AT LEAST 500ms and no more than 3s.
[Sequence BothButtons]
Step0=DirectInputDevice0/B0,1,500,0
Step1=DirectInputDevice0/B1,1,500,200
Step2=DirectInputDevice0/B0,0,0,3000
Step3=DirectInputDevice0/B1,0,0,200
Note:
First sequence id must be Sequence0, and the parser stops reading if there is a gap. Same for sequence Steps...
Have fun, and tell me if you like it, need more features, or find bugs. It's a first beta version but it works well. If you have a problem try deleting the HomeSeer devices, and let the plugin recreates them on reload.
Stipus
Requirements:
- Direct X 3.0C (see dxdiag.exe)
- HomeSeer 2.0 (as it's a .Net plugin)
- At least one Direct Input compatible GamePad / Joystick.
Features:
- AutoCreate a new HomeSeer device per Joystick Axis / Button. You get "realtime" updates of HomeSeer device values according to device moves.
- Range update Mode for each Axis. This saves on CPU a lot as the HomeSeer device value is updated only on range jumps.
- DeviceStrings : you can configure any device string per range of values or button state.
- You can Enable / Disable any Joystick or Axis or button
- The plugin is notification based. There is no thread polling the joystick devices every 10ms...
- Sequences. You can define millisec timed sequences that will trigger a HomeSeer Event with the same name as the sequence. Double-Clicks, timed hold and release of a particular sequence of buttons, cabling a gamepad buttons to a simple pinpad for access control....
Quick how to:
- Stop HomeSeer 2
- Copy the content of the attached .ZIP to your HomeSeer 2 directory. There is a directory structure inside the ZIP file that must be kept like that. Make sure your zip/unzip utility doesn't unzip in "flat" mode (flat mode removes the directory structure, and that's bad).
- Restart HomeSeer 2
- Plug a Joystick / gamepad, and make sure it is loaded by the system (control panel - Games, or dxdiag.exe - Inputs). If you want to use one of the Joystick Axis inputs seriously, you should calibrate the input first through the control panel applet.
- Go to config, ENABLE the plugin and watch your HomeSeer log.
- Now have a look at your devices, and watch device value changes.
- You can set any trigger on Device Value changes.
More on Device Parameters and Ranges:
Have a look at the Config/hspi_di.ini file
;LIST OF YOUR DEVICES
[DirectInputDevices]
DirectInputDevice0=08809590-bf28-11d6-8001-444553540000
;EACH DEVICE HAS HIS OWN SECTION
[DirectInputDevice0]
Enabled=True
;EACH DEVICE ELEMENT HAS HIS OWN SECTION
;ELEMENT-CODES ARE: X,Y,Z,RX,RY,RZ,B0,B1...Bn
[DirectInputDevice0/Y]
Enabled=True
Mode=Auto
RangeMini=-10
RangeMaxi=10
DeadZone=1000
Saturation=9000
HomeSeerDeviceRef=817
Range0=-10,-5,-1,Negative Inclinaison
Range1=-5,5,0,Zero Inclinaison
Range2=5,10,1,Positive Inclinaison
-------------------------------------------------------
Enabled=False means you can remove the HomeSeer device, and it won't be recreated.
Mode=Auto,Range,Sequence,Direct
Direct = Forward input changes to HomeSeer directly (bypassing Range0...RangeX definition), and according to RangeMini and RangeMaxi.
Range = Forward input changes to HomeSeer according to defined Ranges.
Auto = Direct if Range0 is not defined, or Range if Range0 is defined
Sequence = Do not forward input changes to HomeSeer (saves on CPU a lot). However, sequences with this input are still active.
RangeMini = Minimum value reported by the Axis when it's on lowest position.
RangeMaxi = Maximum value reported by the Axis when it's on highest position.
Default range is (-10,10), but you can set (-1000,1000) or (0,100)...
DeadZone = This parameter is always based on 10.000. DeadZone=1000 means the center 10% of the Axix are seen as a 0 input.
Saturation = Always based on 10.000. Saturation = 9000 means all moves above 90% of the Axis are seen as a 100% value.
Range0=-10,-5,-1,Left Direction
Range1=-5,5,0,Center position
Range2=5,10,1,Right Direction
You should use this feature to save on CPU, and report only Range jumps to HomeSeer. The first range number MUST be 0. The range is defined as:
RangeX = MinimumValue,MaximumValue,HomeSeerDeviceValue,HomeSeerDevice String
The 2 following .ini keys replace ranges for simple buttons, and lets you assign device strings for each value 1 or 0.
Pressed=Mybutton is pressed
Released=My button is not pressed
Note: Currently, device strings are loaded into HomeSeer when the Device is Created. If you want device string change taken into account, you must delete the HomeSeer device yourself, and reload the plugin. This will recreate the device with new device strings attached.
More on Sequences:
If a specific timed sequence of inputs is recognized, the HomeSeer event with the same name as the sequence will be run. For this example, I have defined three manual HomeSeer events Circle, DoubleClick, and BothButtons.
A sequence step is made of four comma separated elements:
StepX=DirectInputDevice0/Y,<-5,0,0
1) DirectInput0/Y is the input ID. This is the Joystick input id, followed by a slash, and the Object id (X,Y,Z,RX,RY,RZ,B0,B1...Bn)
2) < -5 is an operator and a value. Valid operators are <,>,= or nothing which means =
3) Number of millisecs the above comparison must remain valid before the step matches. 0 means the Step is valid as soon as the comparison is valid. The last step of a sequence should finish with a 0 "hold" value if you want instant reaction (as the plugin is notification based).
4) Timeout in millisec to wait for step match (3). The value 0 means no timeout (usefull for Step0). If Timeout=200, the comparison and held time must match before 200ms have elapsed. If the TimeOut is smaller than the "hold" value, it means the comparison must already have been valid for some time before entering the step. This is usefull to match when several inputs must be pressed simultaneously.
[Sequences]
Sequence0=Circle
Sequence1=DoubleClick
Sequence2=BothButtons
; AXES X and Y make a clockwise circle starting north. This example may not be adapted to your joystick
; Axis configuration. Watch the values yourself before writting a sequence.
[Sequence Circle]
Step0=DirectInputDevice0/Y,<-5,0,0
Step1=DirectInputDevice0/X,>5,0,1000
Step2=DirectInputDevice0/Y,>5,0,1000
Step3=DirectInputDevice0/X,<-5,0,1000
Step4=DirectInputDevice0/Y,<-5,0,1000
; BUTTON0 makes a quick double-click (200ms up and downs)
[Sequence DoubleClick]
Step0=DirectInputDevice0/B0, 1, 1,0
Step1=DirectInputDevice0/B0, 0, 0,200
Step2=DirectInputDevice0/B0, 1, 0,200
Step3=DirectInputDevice0/B0, 0, 0,200
; BUTTONS 0 and 1 MUST BE PRESSED SIMULTANEOUSLY (within 200ms)
; AND HOLD FOR AT LEAST 500ms and no more than 3s.
[Sequence BothButtons]
Step0=DirectInputDevice0/B0,1,500,0
Step1=DirectInputDevice0/B1,1,500,200
Step2=DirectInputDevice0/B0,0,0,3000
Step3=DirectInputDevice0/B1,0,0,200
Note:
First sequence id must be Sequence0, and the parser stops reading if there is a gap. Same for sequence Steps...
Have fun, and tell me if you like it, need more features, or find bugs. It's a first beta version but it works well. If you have a problem try deleting the HomeSeer devices, and let the plugin recreates them on reload.
Stipus
Comment