-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Mapping POV Hat in vJoySF #43
Comments
You are correct - there is no such feature at this time. I considered hats at the time of writing but there are many different ways one can map axes/buttons to hats. For example, we can have buttons for each direction. Or we can have two X/Y axes in hat space where the angle to the XY point is measured and the direction of the hat determined accordingly. Probably the easiest way (from my perspective as a developer) to implement this feature would be to add the support in the Scripting module. There one would be free to use whatever raw data one likes in order to determine the hat position. Another thing I haven't investigated is what support for hats the different virtual joystick drivers have. I'm pretty sure vJoy has support but not sure about xbox and linux. In any case right in this moment I physically don't have the time for this. Maybe beginning of next year I'll look into it. If there's some movement with this I'll let you know. Best~ |
As best I understand, the most minimal hat implementation is the 8-way on 4 buttons, passing angle-heading or -1 to the vJoy device. it's implemented such that most games parse-as four buttons. and the D-pad on xbox is a Hat, programatically and, very understandable re: 'don't have time'. just putting some thoughts up for consideration wandering thoughts: just went and checked, vJoy has support for up to four 8way-or-Continuous Hats, which is equal to Windows DirectInput HID handling per joystick device |
Thanks for the info. Yeah, this only confirms that probably the best way would be to implement HAT API interface in the script module and from there anyone to use however he likes. Otherwise it's just too many variants and a GUI control will become extremely complicated. |
Are you interested to experiment with Lua scripting? I can implement hat API relatively quickly but it will be up to you to test it. |
I think so. throwing code at an arduino is easy enough, so that part's a nonissue. I've never really dug into Lua so this would be a good chance to cut my teeth on it |
Here's a custom build: Well, I wouldn't say you need to dig inside Lua at all. You just need to call single function: function update()
VJoy.SetDiscPov(1, Channel(1))
-- or
VJoy.SetContPov(1, Channel(1))
end There are two kinds of hats in vJoy driver - Discrete and Continuous. Discrete are four directions only. You set them with For
If you need to convert two axis system to continuous hat, maybe something like: -- assuming channels vary between 0 and 1023
-- map [0; 1023] -> [-1; 1]
x = (Channel(1)/1023 - 0.5) * 2
y = (Channel(2)/1023 - 0.5) * 2
d = math.sqrt(x*x + y*y) -- distance to (0,0)
if d < .1 then
-- below certain threshold - move to neutral
VJoy.SetContPov(1, -1)
else
sn = y/d
cs = x/d
-- vjoy angle increases in CW direction and 0 is UP, while mathematical degrees increase in CCW direction and 0 is RIGHT
deg = deg = (90 - 180*math.atan(sn, cs)/math.pi ) % 360
VJoy.SetContPov(3, deg)
end If you need any help just write. |
I've got it working (oof, all-nighter) and the SDK Docs are actually wrong: -- place initialization code here
local outputdelaydura = 500
local outputdelaytick = 0
function update()
heading = {
-1,
0,
45,
90,
135,
180,
225,
270,
315
}
bitmask = {
0x0,
0x1,
0x3,
0x2,
0x6,
0x4,
0xC,
0x8,
0x9
}
-- [place code to be executed on every update here --]
local bitRead = bit32.band(0xF,bit32.rshift(Channel(8),0)) --bit32.band(0xF000,Channel(1))
for headingIndex = 1,9
do
--print(headingIndex,headings[headingIndex],string.format('%x',bitmask[headingIndex]),bitmask[headingIndex])
if( bitRead == bitmask[headingIndex]) then
VJoy.SetContPov(1,heading[headingIndex])
if outputdelaytick == outputdelaydura then -- reduce console spam
print(heading[headingIndex])
end
break
end
end
if outputdelaytick == outputdelaydura -- reduce console spam
then
print(bitRead, string.format('%x',bitRead))
outputdelaytick = 0
end
outputdelaytick = outputdelaytick + 1
end (my feeder hardware is actually not Arduino U-series (16/32u) but a Cypress PSoC with discrete USB-serial adapter. I was not able to get VJSF to listen to the Arduino Pro Micro (Same Chip As Leonardo, 32U4)- it would read one Frame, and then timeout, I can raise that as a separate Issue if you'd like me to) Hot Tip: the Windows Built-In Game Controller Observer halts UI Updates when it's lost-focus, but Pointy's Joystick Test does not, so you can watch your results in real time |
Great job! I'm glad you got it working. About the pro micro - I don't know what that could be. You can test with different software to see if the data looks ok. Like : #3 (comment) (except you need 115200 8-n-1) |
btw vJoy comes with its own vJoy monitor (look in the program group) that also works in background. It shows the continuous pov as dot moving on a circle. |
It looks like the version with Lua-side POV hat support is good to go. |
Hi after a long time this has been added in a release. Thanks for the help! |
I was not able to find any mention, and I think it would be very useful to be able to map inputs in vJoySF to vJoy hat switch inputs. it seems to be the one thing substantially missing in the features of the main program, unless I've overlooked some functionality
The text was updated successfully, but these errors were encountered: