How do I show the pointer after touch interaction in Windows 8 - touch

When you touch the screen in Windows 8, the mouse pointer is hidden until you move the mouse (or other pointing device). This happens in both desktop and Metro interfaces.
We have a program that allows people to move the mouse pointer using other input methods (such as a joystick), so I need to ensure the mouse pointer is visible.
How can I force the mouse pointer to be displayed?

you can set the flag of touch feedback.
[setting] ->[control panel]->[pen and touch]->[touch feekback] item,there is a checkbox that is [show visual feedback when touch the screen].If you cann't select the checkbox, you can show the mouse pointer without coding anything when touching the screen.

You can inject mouse movement before you start joystick control, using Windows API:
POINT p;
GetCursorPos(&p);
MOUSEINPUT mi;
mi.dx = (LONG) ((p.x * 65535) / screen_width);
mi.dy = (LONG) ((p.y * 65535) / screen_height);
mi.mouseData = 0;
mi.dwFlags = type | MOUSEEVENTF_ABSOLUTE;
mi.time = 0;
mi.dwExtraInfo = NULL;
INPUT input;
input.type = INPUT_MOUSE;
input.mi = mi;
SendInput(1, &input, sizeof(INPUT));

Related

When releasing two buttons in the new Input System it detects the differences

I've been creating a game that uses the input system for moving the player
_playerInput.actions["Move"].performed += x =>
{
// We're moving
_walking = true;
// Set the movement input to the value passed by the player
_movementInput = x.ReadValue<Vector2>();
// The angle that we need the player to rotate towards so the player look where he's moving and we change it to be in degree
_targetAngle = Mathf.Atan2(_movementInput.x, _movementInput.y) * Mathf.Rad2Deg + cam.eulerAngles.y;
};
Here is my code but when I use the Arrows to move like the right and up Arrow and I want to release them it detects the smallest difference between the release of the two buttons which is near impossible to avoid (difference between release)
before releasing "_movementInput" contains (0.71, 0.71) but after release it becomes (0, 1) or (1, 0).
I want it to stay (0.71, 0.71) as it was before releasing the two buttons

Simultaneous double left click with two mouse pointers on GlovePie

I am new to GlovePie.
I created a second mouse that moves simultaneously with the first pointer while staying at a fixed distance. My intent is to get a left click from both pointers simultaneously, because my aim is to click on two buttons simultaneously.
Is it possible to do this?
The code I wrote, following the developer's wiki, is this:
Cursor2.PosX = Mouse.CursorPosX + 80
Cursor2.PosY = Mouse.CursorPosY + 0
Cursor2.LeftButton = Mouse.LeftButton
Cursor2.RightButton = Mouse.RightButton
Very simply. Moving works but simultaneous clicks don't. Any suggestions?
A friend of mine found online the solution to my request, which I share here even if I cannot fully understand its code. For example: why there are two mouse (mouse and mouse1) and two cursor (Cursor and Cursor2)? So if any of you are able to comments the lines of code, I would be grateful to understand them!
mouse.Swallow = true
fakemouse.DirectInputX = mouse1.DirectInputX
fakemouse.DirectInputY = mouse1.DirectInputY
var.x1 = mouse1.cursorPosX
var.x2 = 350
mouse.LeftButton = mouse1.LeftButton
if !mouse1.LeftButton then
Cursor2.PosX = var.x1 - var.x2
Cursor2.PosY = mouse1.cursorPosY
endif
if mouse1.LeftButton then
press mouse1.LeftButton
wait 20ms
release mouse1.LeftButton
Cursor2.PosX = var.x1
Cursor.PosX = var.x1 - var.x2
press mouse1.LeftButton
wait 20ms
release mouse1.LeftButton
Cursor2.PosX = var.x1
Cursor.PosX = var.x1 + var.x2
endif

Execute code continuously in framer

I have a little question about framer. Currently I have a little privat project in which I need to run different actions when the mouse is pressed or not.
To make it easier to talk about, I set up a simple scene with a rectangle. Now I want that the rectangle rotates to the right when the mouse is pressed and rotates to the left when the mouse isn't pressed.
layer = new Layer
x: Align.center
y: Align.center
layer.onMouseDown ->
layer.rotation += 1
layer.onMouseUp ->
layer.rotation -= 1
The problem is that the code only checks once if the mouse is pressed or not. I don't know how I let the program check continuously if the button is pressed or not.
Could anyone help me please?
If you want something to happen repeatedly without events being fired (because mouseUp and mouseDown only get fired once per mouseclick), you can use intervals. Here's an example that does what you describe:
intervalDown = null
intervalUp = null
layer.onMouseDown ->
window.clearInterval(intervalUp)
intervalDown = Utils.interval 0.1, ->
layer.rotation += 1
layer.onMouseUp ->
window.clearInterval(intervalDown)
intervalUp = Utils.interval 0.1, ->
layer.rotation -= 1
You need to create an interval on every event and clear it again using window.clearInterval when the other event fires.
Here's the full example: https://framer.cloud/SEYHy

sneakyinput not reading button when joystick is held down

I have a problem with SneakyJoystick and SneakyButton. SneakyButton is not being read as pressed when the joystick is held down and I was wondering how to get around that. I assume multitouch allows that both input be read simultaneously. In my current project, whenever the joystick is held down the character moves in that direction, but i can't seem to press a sneakyinput button while the joystick is held down.
heres my update method for the InputLayer:
GameLayer *game = [GameLayer sharedGameLayer];
Hero* hero =[game getHeroFromLayer];
if (attackButton.active)
{
[hero attack];
}
CGPoint velocity = ccpMult(dPad.velocity, 6500 * dt);
hero.position = ccp(hero.position.x + velocity.x * dt,
hero.position.y + velocity.y * dt);
Sup dude? You should try changing
if (attackButton.active)
to
if (attackButton.value == 1)
Thanks, Gnoob.
After many days struggling with how to concurrently touch on both joystick and attack/jump button but totally failed. Until now I touch this comment, just turn multitouch on, everything works!!!
Change Here:
RootViewController.mm => [eaglView setMultipleTouchEnabled:YES]

Pygame check for collisions with the top most foreground rect

I have 10 sprites which I objects of the main sprite I wrote with different images and starting positions etc. But they all behave the same way. They are sub sprites of the main sprite.
I want to be able to hold mouse click on one's rect and move it round the screen which works perfectly fine. But the problem is they all have the same controls click and drag to move them. So if I am clicking on one of the sprite rects and I drag it over another one it picks it up as well. And I don't want that to happen.
Is there a way to only check for collisions with the top most foreground rect or if someone could explain a way of doing this that would achieve similar results. I have had a look at the rect documentation but I can't find a solution.
def update(self,):
self.move(self.rect)
def move(self,rect):
if pygame.mouse.get_pressed() == (1, 0, 0) and the_rect.collidepoint(pygame.mouse.get_pos()):
self.state = 1
elif pygame.mouse.get_pressed() == (0, 0, 0) and the_rect.collidepoint(pygame.mouse.get_pos()):
self.state = 0
if self.state == 0:
the_rect.centerx = the_rect.centerx
the_rect.centery = the_rect.centery
elif self.state == 1:
(the_rect.centerx, the_rect.centery) = pygame.mouse.get_pos()
Rather than using the pygame.mouse.get_pressed() function, use the event queue and check for a pygame.MOUSEBUTTONDOWN event. It will only get fired once when the button is first pressed.