I'm not sure what language you're coding the game in... Normally, [ javascript ] , [ jquery ], and [ Webkit ] support touch events. But if that doesn't help, then you could try this script and alter it as per your convenience:
Quote from the creator of the script: [ link ]
I have an MID (Mobile Internet Device) called Viliv S5. It has
resolution of 1024 x 768 for 4.8 inch screen. That means icons are to
small to click with fingers. So I developed a script to convert
touchscreen (absolute coordinate) to touchpad (relative coordinate).
This script hooks mouse down, hiding real cursors and showing fake
cursors. When the finger is released, the mouse pointer is moved to
the intended position and reveal the cursor.
Usage:
Decompress the zip file in the relevant folder.
Open Touchpad.ini and set cursor "speed" (0 ~ 1).
Drag the screen and the cursor moves.
Tap anywhere on the screen and click is sent.
Double tapping is double click.
"Ctrl + u" pause/restart the script.
Click the tray icon and exit the script.
To do:
Implement dragging.
Sometimes cursors jump to my finger position.
Sometimes cursors are hidden.
Download the zip file here:
http://cafe.naver.com/flowpad/34
(I updated the above link.)
SCRIPT:
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: Seung-Young Noh <noh@socoop.net>
#SingleInstance force
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, NoStandard
Menu, Tray, Tip, Touchpad V0.7
Menu, Tray, Icon, 1.ico, , 1
Menu, Tray, add, Exit, MenuQuit
Menu, Tray, Default, Exit
Menu, Tray, Click, 1
#Persistent
CoordMode, Mouse, Screen
IniRead, Cursor_speed, Touchpad.ini, main, Cursor_speed
if not Cursor_speed
Cursor_speed := 0.7
SystemCursor("I")
SetTimer, WatchCursor, 50
return
MenuQuit:
ExitApp
return
LWin & u::
Suspend
SetTimer, WatchCursor, Off
SetTimer, MovePointer, Off
SystemCursor(1)
if (A_IsSuspended = 1) {
Menu, Tray, Icon, 2.ico
} else {
Menu, Tray, Icon, 1.ico
}
return
WatchCursor:
MouseGetPos, x, y
GetKeyState, state, LButton
FromX := FromX1
FromY := FromY1
FromX1 := x
FromY1 := y
return
StartWatchCursor:
SetTimer, WatchCursor, On
return
LButton::
SystemCursor(0)
SetTimer, WatchCursor, Off
ToX := FromX
ToY := FromY
SplashImage, C:\Windows\Cursors\arrow_r.cur, x%ToX% y%ToY% B
MouseGetPos, thisX, thisY
SetTimer, MovePointer, 100
return
LButton Up::
SetTimer, MovePointer, Off
MouseMove, %ToX%, %ToY%, 0
SplashImage, Off
if ((A_TimeSincePriorHotkey < 100) and (abs((ToX - FromY) * (ToY - FromY)) < 200)) {
Click
}
FromX := ToX
FromY := ToY
SystemCursor(1)
SetTimer, StartWatchCursor, -1000
return
MovePointer:
MouseGetPos, x, y
ToX := ToX + Round(Cursor_speed * (x - thisX))
ToY := ToY + Round(Cursor_speed * (y - thisY))
if (ToX <= 0) {
ToX = 0
} else if (ToX >= A_ScreenWidth) {
ToX := A_ScreenWidth
}
if (ToY <= 0) {
ToY = 0
} else if (ToY >= A_ScreenHeight) {
ToY := A_ScreenHeight
}
if (((x - thisX) != 0) or ((y - thisY) !=0)) {
SplashImage, C:\Windows\Cursors\arrow_r.cur, x%ToX% y%ToY% B
}
thisX := x
thisY := y
return
;; The script below is another's. I can't remember whose it is.
SystemCursor(OnOff=1) ; INIT = "I","Init"; OFF = 0,"Off"; TOGGLE = -1,"T","Toggle"; ON = others
{
static AndMask, XorMask, $, h_cursor
,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13 ; system cursors
, b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13 ; blank cursors
, h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,h12,h13 ; handles of default cursors
if (OnOff = "Init" or OnOff = "I" or $ = "") ; init when requested or at first call
{
$ = h ; active default cursors
VarSetCapacity( h_cursor,4444, 1 )
VarSetCapacity( AndMask, 32*4, 0xFF )
VarSetCapacity( XorMask, 32*4, 0 )
system_cursors = 32512,32513,32514,32515,32516,32642,32643,32644,32645,32646,32648,32649,32650
StringSplit c, system_cursors, `,
Loop %c0%
{
h_cursor := DllCall( "LoadCursor", "uint",0, "uint",c%A_Index% )
h%A_Index% := DllCall( "CopyImage", "uint",h_cursor, "uint",2, "int",0, "int",0, "uint",0 )
b%A_Index% := DllCall("CreateCursor","uint",0, "int",0, "int",0
, "int",32, "int",32, "uint",&AndMask, "uint",&XorMask )
}
}
if (OnOff = 0 or OnOff = "Off" or $ = "h" and (OnOff < 0 or OnOff = "Toggle" or OnOff = "T"))
$ = b ; use blank cursors
else
$ = h ; use the saved cursors
Loop %c0%
{
h_cursor := DllCall( "CopyImage", "uint",%$%%A_Index%, "uint",2, "int",0, "int",0, "uint",0 )
DllCall( "SetSystemCursor", "uint",h_cursor, "uint",c%A_Index% )
}
}
Hope this helps... I haven't tested the script.
Best Answer
Microsoft provides a tool,
devcon.exe
, that they claim can enable/disable devices from the command line (or a batch script, or a shortcut, etc.). This may allow you to do what you want (without a registry key).