Controller Xbox360

Post any examples or modules that you want to share here
Almeida
Posts: 10
Joined: Wed Jun 12, 2013 12:43 pm

Controller Xbox360

Post by Almeida »

Hi,

I would like programming xbox controller with code like AHK (AutohotKey)
but i'm not used to code with Ruby. Can u help me to assign Button A to F1 function ?

If you have any documentation about programming controller, i will appreciate it !

Many thx !
Attachments
xbox360.fsm
(25.21 KiB) Downloaded 1820 times
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Controller Xbox360

Post by MyCo »

Here are two modules that send key status messages to the current active window. It uses win32Api, which is a little bit hard to read. Check the FS user guide (page 198-201)
Attachments
key strokes (MyCo).fsm
(26.64 KiB) Downloaded 1928 times
Almeida
Posts: 10
Joined: Wed Jun 12, 2013 12:43 pm

Re: Controller Xbox360

Post by Almeida »

working great. Thanks.
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Controller Xbox360

Post by MyCo »

0x70 is just hexadecimal, you can use the windows calculator to convert it into decimal, or just use an online converter like this:
http://www.rapidtables.com/convert/numb ... ecimal.htm

Or you can use FS "hex to dec" primitive

Edit: Looks like you found your answer already ;)
Almeida
Posts: 10
Joined: Wed Jun 12, 2013 12:43 pm

Re: Controller Xbox360

Post by Almeida »

yes i found it finally but can help other ! thx
Almeida
Posts: 10
Joined: Wed Jun 12, 2013 12:43 pm

Re: Controller Xbox360

Post by Almeida »

i have some code in AHK which move window at some position X,Y on the screen when i push Right on my keyboard

Right::
WinGetActiveTitle, Title1
WinMove, %Title1%,, 938, 10

then do you think it' s possible to do the same with Flowstone?

Cause have already link Right of 360xbox to send "Right" but its not read by AHK when both are open ( AHK & Flowstone)
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Controller Xbox360

Post by MyCo »

It can be done with 2 other WinApi functions (GetActiveWindow and SetWindowPos). I'll have a look at this tomorrow, or maybe someone else is faster than me ;)
User avatar
digitalwhitebyte
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Controller Xbox360

Post by digitalwhitebyte »

this is an example of code to define the size and position of the window.

Code: Select all

require 'Win32API'

def event i

# winapi GetSystemMetrics
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx
# get current windows size
screen_width = Win32API.new("User32.dll","GetSystemMetrics",["L"],"L").call(0)
screen_height = Win32API.new("User32.dll","GetSystemMetrics",["L"],"L").call(1)

# winapi FindWindow
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx
findWindow = Win32API.new('user32', 'FindWindow', ['P','P'], 'L')
# define your windows name here
windows_name =  'FlowStone - [Schematic1*]'
hWnd = findWindow.call(0, windows_name)

# winapi SetWindowPos
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
setWindowPos = Win32API.new("user32.dll", "SetWindowPos", ['I','I','I','I','I','I','I'], 'I')

# Struct SetWindowPos
# set windows size when moved (this is one of many options)
cx = 1024
cy = 768
posX = (screen_width/2)-(cx/2)
posY = (screen_height/2)-(cy/2)
# see uFlag option
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx
uFlags = 16384

#Call SetWindowPos
return_SetWindowPos = setWindowPos.call(hWnd, -2, posX, posY, cx, cy, uFlags)

watch 'hWnd', hWnd
watch 'returned value from SetWindowPos  call (If the function succeeds, the return value is nonzero.)', return_SetWindowPos
end
Almeida
Posts: 10
Joined: Wed Jun 12, 2013 12:43 pm

Re: Controller Xbox360

Post by Almeida »

This code works fine when i use it in Flowstone but i would like to do this in the current window. I saw someone talk about enumwindows function (http://msdn.microsoft.com/en-us/library ... 85%29.aspx). I didn't find the way to implement it. Can u help me to do this?
User avatar
digitalwhitebyte
Posts: 106
Joined: Sat Jul 31, 2010 10:20 am

Re: Controller Xbox360

Post by digitalwhitebyte »

# define your windows name here
windows_name = 'FlowStone - [Schematic1*]'

in my code you have modify the red contents of this variable to match your app name windows

P.S.
EnumWindows work in conbination of EnumWindowsProc, the current Win32API not support callback.
Post Reply