Search Unity

How to check if BB device has physical keyboard?

Discussion in 'BlackBerry' started by JaredM, Sep 22, 2013.

  1. JaredM

    JaredM

    Joined:
    Sep 22, 2013
    Posts:
    2
    Hi All,

    I'm relatively new to Unity and I am working on a multi-platform project and Blackberry is one of the target platforms. Currently in my code when checking for input I am using the mobile preprocessor defines to return input from the touch screens and accelerometer, instead of the mouse and keyboard for PC. My question is, is there an easy way to determine if the Blackberry device had a physical keyboard? I would like to use keyboard buttons on the Q10 and Q5 to make things easier on the smaller screen.

    Sorry if this has been asked somewhere already, I looked and didn't see anything.

    Thanks,

    Jared
     
  2. AlexThibodeau

    AlexThibodeau

    Unity Technologies

    Joined:
    Jul 23, 2013
    Posts:
    309
    I'll take a look at the code but I think we might have missed that! Please submit a bug so it can be addressed asap!

    Thanks,
    Alex
     
  3. JaredM

    JaredM

    Joined:
    Sep 22, 2013
    Posts:
    2
    Hi,

    Thanks for your answer. It's been a few days since I checked this thread. I will submit a big but I'm not sure where I go to do that?

    Thanks,

    Jared
     
  4. AlexThibodeau

    AlexThibodeau

    Unity Technologies

    Joined:
    Jul 23, 2013
    Posts:
    309
  5. pgarcia

    pgarcia

    Joined:
    Sep 21, 2013
    Posts:
    7
    As a workaround, couldn't you assume that there is always a keyboard? If the device is touchscreen it won't matter, and if the device has a keyboard, you could use specific keys to do what you want.

    I did a quick test on a Q5, moving a cube around using the following code:

    Code (csharp):
    1.         if (Input.GetKeyDown(KeyCode.A))
    2.         {
    3.             Vector3 position = this.transform.position;
    4.             position.x--;
    5.             this.transform.position = position;
    6.         }
    7.          if (Input.GetKeyDown(KeyCode.D))
    8.         {
    9.             Vector3 position = this.transform.position;
    10.             position.x++;
    11.             this.transform.position = position;
    12.         }
    13.         if (Input.GetKeyDown(KeyCode.W))
    14.         {
    15.             Vector3 position = this.transform.position;
    16.             position.y++;
    17.             this.transform.position = position;
    18.         }
    19.         if (Input.GetKeyDown(KeyCode.S))
    20.         {
    21.             Vector3 position = this.transform.position;
    22.             position.y--;
    23.             this.transform.position = position;
    24.         }
    25.  
    and it worked just fine pressing the WADS keys on the phone keyboard.

    Cheers

    Paulo
     
  6. eelstork

    eelstork

    Joined:
    Jun 15, 2014
    Posts:
    180
    Will this ever be addressed? More generally, it would be nice to have a cross platform way to detect whether a physical keyboard is attached. Many touch devices can use a physical keyboard.
     
    Last edited: Mar 26, 2016
  7. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    The answer is probably no, do you not know they dont support BB anymore, if this is generic maybe a new thread needs to be made in other section of forum.
     
  8. eelstork

    eelstork

    Joined:
    Jun 15, 2014
    Posts:
    180
    No, somehow I didn't pay attention to this and thanks for pointing it out.
    Not sure if I'd bother creating a separate section for this but, with respect to suggested workarounds I display text in my apps to explain how to use the keyboard. If there is no keyboard it becomes irrelevant : )
     
  9. AlexThibodeau

    AlexThibodeau

    Unity Technologies

    Joined:
    Jul 23, 2013
    Posts:
    309
  10. eelstork

    eelstork

    Joined:
    Jun 15, 2014
    Posts:
    180
    Thanks Alex but that only would tell me whether there is an integrated keyboard.

    What would be useful to know to take a typical example is whether there is a(n external) physical keyboard currently attached to an iOS or Android tablet. Though I do not know whether having a keyboard attached to an iPad or Galaxy tab etc... gives access to keydown/up events? If not this may be irrelevant from my point of view.

    Normally for cross platform functionality I test whether the wanted feature/hardware (keyboard, mouse, accelerometer, ...) exists instead of checking the device model. This tends to make apps more future proof.
     
  11. Jonny-Roy

    Jonny-Roy

    Joined:
    May 29, 2013
    Posts:
    660
    Your best option is to have the code re-act regardless of whether they have one, but in general you'd be best querying this per platform, for BlackBerry all square devices have keyboards, so you just check if screen height == screen width, for iOS and Android you might find some of the keyboards lack support for simultaneous keypresses which will really limit there use.