geekhack

geekhack Community => Keyboards => Topic started by: Popkeymon on Sat, 09 April 2011, 08:24:06

Title: Autohotkey + 12 buttons Joystick = a Chording Keyboard!!
Post by: Popkeymon on Sat, 09 April 2011, 08:24:06
I am totally new to Autohotkey scripting. As I am always looking for alternative way of human-computer interaction, I bought a really cheap PS3 like USB joystick (it is cheaper than my optical mouse actually) just for exploring the possibility to turn it into a chorded keyboard.  

(http://media.uxcell.com/uxcell/images/item/catalog/ux_a07122600ux0096_ux_c.jpg)

Here is my idea on joystick keyboarding:

Where left index button Joy5, Joy7 are for chording shift key

Joy1::A
Joy2::E
Joy3::I
Joy4::O
Joy7 & Joy1::U

AxisUp::N
AxisDown::H
AxisLeft:: D
AxisRight:: T

Joy12 :: Space
Joy11 :: Enter

Right Index
Joy8::S
Joy6::R

The other keys and symbols are then combination of chord shift plus buttons or axis.

I have tested the chord shift plus a for u with the autohotkey script. It takes time to work out the whole script and I believe it could work on all kind of gamepad and arcade stick for complete text input.
Title: Autohotkey + 12 buttons Joystick = a Chording Keyboard!!
Post by: Popkeymon on Sat, 09 April 2011, 08:29:01
The code to get the chording shift work in autohotkey

Joy1::  
Loop
{
   GetKeyState, JoyTrigger, %A_ThisHotkey%
   if JoyTrigger = U  ; Main button released before the others were pressed.
        {
   Send a
   return
   }  

; End this thread to start waiting again for a new triggering.

   GetKeyState, JoyState2, Joy7  ; Replace these digits with your chosen buttons.

   JoyStates = %JoyState2%
   if JoyStates = D  ; The Shift key is down now, so send letter and break out of the loop.
      {
   Send u
   return
   }
   else  ; Keep waiting, but do a Sleep to prevent heavy load on CPU:
      sleep,10

   GetKeyState, JoyState3, Joy5
   JoyStates2 = %JoyState3%
   if JoyStates2 = D  ; The Shift key is down now, so send letter and break out of the loop.
      {
   Send y
   return
   }
   else  ; Keep waiting, but do a Sleep to prevent heavy load on CPU:
      sleep,10
}
return