Jump to content


Photo

Device Input Commands


  • Please log in to reply
3 replies to this topic

#1 SpaceAce

SpaceAce

    GMC Member

  • GMC Member
  • 193 posts
  • Version:GM:Studio

Posted 10 June 2013 - 04:14 PM

Okay, this is a really stupid question, but i don't get what the numbers 0-4 mean on all the device input commands, such as device_mouse_raw_x(device)... What does device mean, or do? Can i replace it with os_android, or os_windows and get the same effect? id device_mouse_raw_x(os_android) or does the device need to be 1 for android, 0 for windows... i just don't get it


Edited by SpaceAce, 10 June 2013 - 04:15 PM.

  • 0

#2 TheMagician

TheMagician

    GMC Member

  • GMC Member
  • 599 posts

Posted 10 June 2013 - 07:28 PM

In GM:S' manual the introduction to the topic "Device Input" states that these devices (0-4) act like there are multiple mice attached to a computer. This is useful in a multi-touch environment.

There device 0 would be the first finger, device 1 becomes active if a second finger is placed on the screen and so on. With these functions it is possible to react to up to 5 fingers which are

on the screen at the same time. 

 

You could in theory code a normal PC game using the device functions (using only device 0) but in a multi-touch environment is where they really come into play.


  • 0

#3 SpaceAce

SpaceAce

    GMC Member

  • GMC Member
  • 193 posts
  • Version:GM:Studio

Posted 10 June 2013 - 07:31 PM

Can you help me with this code then? Why doesn't it work on my Android Phone? I can't figure it out. I've tried many different things, and still no luck.

if (OS == 1)    //Android
    {if (Scroll && instance_exists(obj_AchieveItem))    //To make sure the user has touched the screen and the Achievements Tab is open
        {if (AchieveObj[0].y > 64)  //If it has been scrolled to the top of the list of Achievements
            {var Ab; Ab = AchieveObj[0].y-64;
             Max = true;
             for (i = 0; i <= MaxAchieves; i += 1)  //Cycle through all of the Achievement objects and move them to the right position.
                {AchieveObj[i].y -= (Ab);}
            }
         if (AchieveObj[MaxAchieves].y < view_hview)    //If it has been scrolled to the bottom of the list of Achievements
            {var Ab; Ab = view_hview-AchieveObj[MaxAchieves].y;
             Max = true;
             for (i = 0; i <= MaxAchieves; i += 1)  //Cycle through all of the Achievement objects and move them to the right position.
                {AchieveObj[i].y += (Ab);}
            }
         if (device_mouse_check_button(0,mb_left) && !Max) //Check if the user is still touching the screen and the list isn't near the bottom or the top.
            {for (i = 0; i <= MaxAchieves; i += 1)
                {AchieveObj[i].y -= (DownY-device_mouse_raw_y(0)); //Move each object according to where the user has dragged the list.
                 MoveY = (DownY-device_mouse_raw_y(0));}
            }
         else
            {Scroll = false;}   //If the user isn't touching the screen
         if (UseMomentum && !Max)  //If momentum is on and the list ins't near the top nor bottom
            {Momentum = abs(round(MoveY/2));}
         Max = false;
         DownY = device_mouse_raw_y(0);
        }
    else if (Achieve)
        {if (device_mouse_check_button(0,mb_left)) //If the user has touched the screen
            {Scroll = true;
             DownY = device_mouse_raw_y(0);}
         if (UseMomentum && Momentum > 0 && MoveY > 0 && AchieveObj[0].y < 64)  //If momentum is on, and momentum left is greater than 0, and the user dragged up, and the list isn't at the top
            {for (i = 0; i <= MaxAchieves; i += 1)
                {AchieveObj[i].y -= (Momentum);}
             Momentum -= 2; 
            }
         if (UseMomentum && Momentum > 0 && MoveY < 0 && AchieveObj[MaxAchieves].y > view_hview)    //If momentum is on, and momentum left is greater than 0, and the user dragged down, and the list isn't at the bottom
            {for (i = 0; i <= MaxAchieves; i += 1)
                {AchieveObj[i].y += (Momentum);}
             Momentum -= 2; //Decreases momentum so list won't continue to scroll forever
            }
         if (AchieveObj[0].y > 64)  //If the list is scrolled past the first Achievement, move everything to the proper position.
            {var Ab; Ab = AchieveObj[0].y-64;
             for (i = 0; i <= MaxAchieves; i += 1)
                {AchieveObj[i].y -= (Ab);}
            }
         if (AchieveObj[MaxAchieves].y < view_hview)    //If the list is scrolled past the last Achievement, move everything to the proper position
            {var Ab; Ab = view_hview-AchieveObj[MaxAchieves].y;
             for (i = 0; i <= MaxAchieves; i += 1)
                {AchieveObj[i].y += (Ab);}
            }
        }
    }

  • 0

#4 TheMagician

TheMagician

    GMC Member

  • GMC Member
  • 599 posts

Posted 11 June 2013 - 06:51 PM

I'm sorry, I don't have the time to look into it.


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users